Can you make a JS that will be triggered by a new post? Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.
2 posters

    Can you make a JS that will be triggered by a new post?

    blaca
    blaca
    New Member


    Posts : 11
    Reputation : 1
    Language : Thai, maybe English

    Can you make a JS that will be triggered by a new post? Empty Can you make a JS that will be triggered by a new post?

    Post by blaca December 13th 2018, 1:21 pm

    If there's a new post in specific forum, it will be triggered this JavaScript.

    FYI, I'm not a founder, I'm just an administrator. So, I can't access to some authorization that founder can.

    Thanks ahead of time!
    skouliki
    skouliki
    Manager
    Manager


    Female Posts : 15310
    Reputation : 1705
    Language : English,Greek
    Location : Greece

    Can you make a JS that will be triggered by a new post? Empty Re: Can you make a JS that will be triggered by a new post?

    Post by skouliki December 13th 2018, 1:31 pm

    hello

    i cannot fully understand what you are asking for can you please be more specific or put a screenshot
    also please provide us with your forum url

    thank you

    blaca
    blaca
    New Member


    Posts : 11
    Reputation : 1
    Language : Thai, maybe English

    Can you make a JS that will be triggered by a new post? Empty Re: Can you make a JS that will be triggered by a new post?

    Post by blaca December 13th 2018, 2:06 pm

    I already have Javascript(JS) that will get topic titles for POSTing to another platform, like Discord.
    But, I want to make it's triggered automatically by new posts.

    So, I tried to make a Webhook by using the specific forum as base. It's like notification to platform which it will update automatically by new posts.
    For now, I can make it POST by refreshing manually in specific page for now.

    Forum url: http://thaistickman.thai-forum.net/
    avatar
    Guest
    Guest


    Can you make a JS that will be triggered by a new post? Empty Re: Can you make a JS that will be triggered by a new post?

    Post by Guest December 13th 2018, 6:42 pm

    I am not sure how Discord works but I suppose they have an API which you can access. After you post a topic on the forum, it redirects you to a /post page with a message life "Topic was posted". You basically need a javascript that gets executed on that page, looks for the Topic was posted message, then makes a call to the Discord API. I can help you if you need.
    blaca
    blaca
    New Member


    Posts : 11
    Reputation : 1
    Language : Thai, maybe English

    Can you make a JS that will be triggered by a new post? Empty Re: Can you make a JS that will be triggered by a new post?

    Post by blaca December 14th 2018, 10:21 am

    Menim wrote:I am not sure how Discord works but I suppose they have an API which you can access. After you post a topic on the forum, it redirects you to a /post page with a message life "Topic was posted". You basically need a javascript that gets executed on that page, looks for the Topic was posted message, then makes a call to the Discord API. I can help you if you need.

    I can't to find that redirect page in Admin panel, though. At least, It's not in what I can access to.
    But, I'm already done with Discord part. Smile

    Also, Won't that trigger JS whenever the users post a new topic?
    I might use the wrong word? By the forum, I mean one of row of forums like this.
    (in red square.)

    Spoiler:


    I want to make them to trigger after new topic in One of those forums.
    Just like when Icon changed into 'New' when new topics came up.

    Spoiler:

    I hope this specifies better.
    avatar
    Guest
    Guest


    Can you make a JS that will be triggered by a new post? Empty Re: Can you make a JS that will be triggered by a new post?

    Post by Guest December 14th 2018, 11:43 am

    You want the js to run when a topic is posted or what?
    blaca
    blaca
    New Member


    Posts : 11
    Reputation : 1
    Language : Thai, maybe English

    Can you make a JS that will be triggered by a new post? Empty Re: Can you make a JS that will be triggered by a new post?

    Post by blaca December 14th 2018, 2:00 pm

    Menim wrote:You want the js to run when a topic is posted or what?

    Yes, but only on one of forum.
    avatar
    Guest
    Guest


    Can you make a JS that will be triggered by a new post? Empty Re: Can you make a JS that will be triggered by a new post?

    Post by Guest December 14th 2018, 4:37 pm

    That's going to be a little bit harder. Your code has to detect the /post?f=ID&mode=newtopic page, where ID is the ID of the forum whose topics you need. Than listen the the submit event on the form there and send a call to the api when the user submits.
    blaca
    blaca
    New Member


    Posts : 11
    Reputation : 1
    Language : Thai, maybe English

    Can you make a JS that will be triggered by a new post? Empty Re: Can you make a JS that will be triggered by a new post?

    Post by blaca December 16th 2018, 7:38 pm

    Come to update a bit. I already make my code to detect that page.

    But, I'm not sure how to make it listen the submit form, because I don't know what is the id for the form.
    I tried to check with view page source and such. I still stumble anyhow. Any idea?

    Code:

    if(!(window.location.href.indexOf("/post?f=") > -1))
    {    return;
    }

    $(document).ready(function() {
      /*$(document).addEventListener('submit',function()
        {        alert("sended submission!2");
                //webHook('{ "content": "1 founda new post :>" }');
                return false;
               
        });*/
    });

    }
    avatar
    Guest
    Guest


    Can you make a JS that will be triggered by a new post? Empty Re: Can you make a JS that will be triggered by a new post?

    Post by Guest December 17th 2018, 2:09 pm

    The form has no id here on the support forum. Not sure about your forum. You can use
    Code:
    form[action="/post"]
    or even simply
    Code:
    form
    if you don't have any other forms on the page.