Printable Version of Topic
Click here to view this topic in its original format
Jcink.com Forums > General Support > autosave sent PMs doesn't work in mobile [SOLVED]


Posted by: thenoisyflower May 10 2018, 09:54 AM
Hi there,

I found this post on the support forums from a while ago with some helpful code in it so that the 'save a copy of this PM' box is always checked when you compose a new message.

http://forums.jcink.com/index.php?showtopic=18320

It appears to be working in desktop mode, but PMs sent from my phone/using the mobile mode are not being saved! Does anybody know of a fix for this?

roaringdandelion.jcink.net

Posted by: Dusty May 10 2018, 12:30 PM
That's because mobile mode changes the URL, which that script is dependent on. With respect to John and the time that script was written, you can do this a number of more succinct ways nowadays, with the introduction of querySelector:

For several checkboxes
CODE
var li = document.querySelectorAll('input[name=add_sent], input[name=add_tracking]')
for(i=0;i<li.length;i++)
 {li[i].checked=true}

you could also skip the for loop and just jump straight to li.item(0) and li.item(1), which would look like:

CODE
var li = document.querySelectorAll('input[name=add_sent], input[name=add_tracking]')
li[0].checked=true
li[1].checked=true


For one checkbox
CODE
document.querySelectorAll('input[name=add_sent]')[0].checked=true

Posted by: John May 12 2018, 11:36 AM
QUOTE (Dusty @ May 10 2018, 01:30 PM)
That's because mobile mode changes the URL, which that script is dependent on. With respect to John and the time that script was written, you can do this a number of more succinct ways nowadays


You could do it better even back then, I'm pretty sure I just googled for that one and copied it from a post previously. Thanks for the shorter code. http://files.b1.jcink.com/html/emoticons/smile.gif

Posted by: thenoisyflower May 23 2018, 04:17 PM
Thank you so much! Does this go in the Style Sheet, or the HTML templates?

Posted by: Dusty May 25 2018, 02:23 AM
Neither! Wrap it in script tags and throw it in your wrappers near the </body> tag.

Posted by: thenoisyflower May 26 2018, 04:01 PM
Inside it, or just after? I tried all of them, but they don't seem to be working. Hmmm....

Posted by: Dusty May 26 2018, 06:32 PM
Just inside the closing body tag. Open your web console (usually F12) and check the console tab for errors. It may just be that it needs to wait for a state change.

Posted by: thenoisyflower May 30 2018, 01:08 PM
Silly question...I assume I have to have code in place that would make the checkboxes appear in mobile mode at all in order for this to work? Also code that would allow you to access sent mail in mobile mode?

If not, I'm stumped. None of the error messages were related to this - the console tab only showed errors related to insecure font scripts.

Posted by: Dusty May 30 2018, 02:10 PM
Oh dear, I completely forgot that those inputs don't appear in mobile mode. Luckily, all they do is append an extra parameter to POST, so that'll be a reasonably simple fix, if a bit.. weird.

On a plus note, recently found out JQuery is loaded in mobile mode still. <3
CODE
$(function() {
 if ($('#mobile') && ($('input[name="CODE"]').val() === '04')) {
   $('<input name="add_sent" value="yes" type="checkbox"><b>Add a copy of this message to my sent items folder</b><br><input name="add_tracking" value="1" type="checkbox"><b>Track this message?</b>').insertAfter($('.textinput + div'))
 }
})


You can use that to append the checkboxes to the mobile messenger. By default, they're unchecked, though you can add the boolean attribute inside the input and they'll then default to checked - otherwise, you'll need to follow it with the script from before.

Posted by: thenoisyflower Jun 8 2018, 10:06 AM
So, just to make sure I've got it right, just inside the closing body tag on my board wrappers, I should have either:

<script>
$(function() {
if ($('#mobile') && ($('input[name="CODE"]').val() === '04')) {
$('<input name="add_sent" value="yes" type="checkbox"><b>Add a copy of this message to my sent items folder</b><br><input name="add_tracking" value="1" type="checkbox"><b>Track this message?</b>').insertAfter($('.textinput + div'))
}
})

var li = document.querySelectorAll('input[name=add_sent], input[name=add_tracking]')
li[0].checked=true
li[1].checked=true
</script>

OR

<script>
$(function() {
if ($('#mobile') && ($('input[name="CODE"]').val() === '04')) {
$('<input name="add_sent" value="yes" type="checkbox"><b>Add a copy of this message to my sent items folder</b><br><input name="add_tracking" value="1" type="checkbox"><b>Track this message?</b>').insertAfter($('.textinput + div'))
}
})

var li = document.querySelectorAll('input[name=add_sent], input[name=add_tracking]')
for(i=0;i<li.length;i++)
{li[i].checked=true}
</script>

I'm wondering if I did something wrong, as neither of those appears to make a change in mobile mode.

Thanks for your patience on this one.

Posted by: John Jun 8 2018, 10:38 AM
Ok, so the mobile template can be a little complicated to insert JavaScript. Not only that, I checked the post form and the tracked nor sent options were even hidden fields. When I wrote the mobile mode system I just didn’t include them. I have now added them AND storing sent PMs on mobile is default checked, so no one has to use js on mobile to enable it and can avoid the struggle you've been having here thenoisyflower

Posted by: thenoisyflower Jun 13 2018, 11:24 AM
You're a marvel, John. Thank you SO much for everything you do!

Posted by: John Jun 13 2018, 04:20 PM
This topic has been solved. If you need anymore help please post a new thread. Thanks for choosing Jcink services.

'
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)