Posted via Mobile Device Script

Go down

Solved Posted via Mobile Device Script

Post by Najerj on 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

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 September 1st 2015, 6:10 am

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

Male Posts : 13202
Reputation : 2918
Language : EN10, FR5, JA5
Location : Macungie, PA

https://github.com/SethClydesdale

Back to top Go down

Solved Re: Posted via Mobile Device Script

Post by Najerj on 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/



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

Male Posts : 13202
Reputation : 2918
Language : EN10, FR5, JA5
Location : Macungie, PA

https://github.com/SethClydesdale

Back to top Go down

Solved Re: Posted via Mobile Device Script

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

@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 September 1st 2015, 2:21 pm

You're welcome ^^

Topic archived

Have a good day. Smile
avatar
Ange Tuteur
Forumaster

Male Posts : 13202
Reputation : 2918
Language : EN10, FR5, JA5
Location : Macungie, PA

https://github.com/SethClydesdale

Back to top Go down

Back to top


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