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.

Posted via Mobile Device Script

2 posters

Go down

Solved Posted via Mobile Device Script

Post by Najerj August 31st 2015, 6:47 am

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 September 1st 2015, 2:16 pm; edited 3 times in total
avatar
Najerj
Forumember

Posts : 25
Reputation : 2
Language : English

http://royalflyff.forumtl.com/

Back to top Go down

Solved Re: Posted via Mobile Device Script

Post by Najerj September 1st 2015, 6:10 am

Bump
avatar
Najerj
Forumember

Posts : 25
Reputation : 2
Language : English

http://royalflyff.forumtl.com/

Back to top Go down

Solved Re: Posted via Mobile Device Script

Post by Ange Tuteur September 1st 2015, 10:23 am

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]';
      };
    }
  }
});
Ange Tuteur
Ange Tuteur
Forumaster

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

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Posted via Mobile Device Script

Post by Najerj September 1st 2015, 12:57 pm

@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
avatar
Najerj
Forumember

Posts : 25
Reputation : 2
Language : English

http://royalflyff.forumtl.com/

Back to top Go down

Solved Re: Posted via Mobile Device Script

Post by Ange Tuteur September 1st 2015, 1:20 pm

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.
Ange Tuteur
Ange Tuteur
Forumaster

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

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Posted via Mobile Device Script

Post by Najerj September 1st 2015, 2:18 pm

@Ange Tuteur Thank you so much!!!! It is now fixed.
avatar
Najerj
Forumember

Posts : 25
Reputation : 2
Language : English

http://royalflyff.forumtl.com/

Back to top Go down

Solved Re: Posted via Mobile Device Script

Post by Ange Tuteur September 1st 2015, 2:21 pm

You're welcome ^^

Topic archived

Have a good day. Smile
Ange Tuteur
Ange Tuteur
Forumaster

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

https://fmdesign.forumotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum