The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Posted via Mobile Device Script

View previous topic View next topic Go down

Solved Posted via Mobile Device Script

Post by Najerj on Mon 31 Aug 2015, 06: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 01 Sep 2015, 14:16; edited 3 times in total

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 on Tue 01 Sep 2015, 06:10

Bump

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 on Tue 01 Sep 2015, 10: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]';
      };
    }
  }
});

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Posted via Mobile Device Script

Post by Najerj on Tue 01 Sep 2015, 12:57

@Ange Tuteur Thank you! You always amaze me.

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

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



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 on Tue 01 Sep 2015, 13: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.

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Posted via Mobile Device Script

Post by Najerj on Tue 01 Sep 2015, 14:18

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

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 on Tue 01 Sep 2015, 14:21

You're welcome ^^

Topic archived

Have a good day. Smile

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

View previous topic View next topic Back to top


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