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.
The forum of the forums
2 posters

    Posted via Mobile Device Script

    avatar
    Najerj
    Forumember


    Posts : 25
    Reputation : 2
    Language : English

    Solved Posted via Mobile Device Script

    Post by Najerj Mon 31 Aug - 4:47

    Hi guys! I am just wondering if it's possible to include "Posted via Mobile Device" at the end part of the post once a user posted/replied a topic using their mobile (in mobile version). I wan't this feature to monitor the activity of mobile users (how often they're using it to browse the forum) as I am planning to create a mobile application of my forum for android users.


    Where is my cookie?

    Posted via Mobile Device.


    Thank you in advance!


    Last edited by Najerj on Tue 1 Sep - 12:16; edited 3 times in total
    avatar
    Najerj
    Forumember


    Posts : 25
    Reputation : 2
    Language : English

    Solved Re: Posted via Mobile Device Script

    Post by Najerj Tue 1 Sep - 4:10

    Bump
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Posted via Mobile Device Script

    Post by Ange Tuteur Tue 1 Sep - 8:23

    Hi @Najerj,

    Sorry for the delay, I wrote up a small snippet for you to try. Go to Modules > JavaScript codes management and create a new script

    Placement : In the topics ( or all pages depending on your preferences )
    Code:
    $(function() {
      if (_userdata.page_desktop) {
        var form = $('.postbody form')[0];
        if (form) {
          form.onsubmit = function() {
            if (this.message) this.message.value += '\n\n[size=10][i]Posted via Mobile Device.[/i][/size]';
          };
        }
      }
    });
    avatar
    Najerj
    Forumember


    Posts : 25
    Reputation : 2
    Language : English

    Solved Re: Posted via Mobile Device Script

    Post by Najerj Tue 1 Sep - 10:57

    @Ange Tuteur Thank you! You always amaze me.

    However, the code only works when the user replied in a post. Posted via Mobile Device message doesn't appear when posting a New Post even the javascript was tick to all pages.

    Forum URL: http://royalflyff.forumtl.com/


    Posted via Mobile Device Script C8zhboA
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Posted via Mobile Device Script

    Post by Ange Tuteur Tue 1 Sep - 11:20

    Here, try replacing it with this :
    Code:
    $(function() {
      if (_userdata.page_desktop) {
        var form = $('form[action="/post"]')[0];
        if (form) {
          form.onsubmit = function() {
            if (this.message) this.message.value += '\n\n[size=10][i]Posted via Mobile Device.[/i][/size]';
          };
        }
      }
    });

    I adjusted the query so it looks for all forms that match the message form.
    avatar
    Najerj
    Forumember


    Posts : 25
    Reputation : 2
    Language : English

    Solved Re: Posted via Mobile Device Script

    Post by Najerj Tue 1 Sep - 12:18

    @Ange Tuteur Thank you so much!!!! It is now fixed.
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Posted via Mobile Device Script

    Post by Ange Tuteur Tue 1 Sep - 12:21

    You're welcome ^^

    Topic archived

    Have a good day. Smile

      Current date/time is Wed 13 Nov - 17:38