LocalStorage Coding help
3 posters
Page 1 of 1
LocalStorage Coding help
So, I was having trouble with a status update widget the other day. I did manage to get it fixed thanks to Twisted. However, I am having a small problem editing the LocalStorage script to work with the widget. The widget isn't showing the current status, which leads me to believe that it's due to not setting up the LocalStorage script correctly due to my lack of knowledge in Java. Below are the current codes I have for the widget and widget's Java page.
Any assistance in setting up the LocalStorage script would be amazing. I'm so lost with Java x.x
Widget Code
Widget Java Code
Any assistance in setting up the LocalStorage script would be amazing. I'm so lost with Java x.x
Widget Code
- Code:
<div align="center">
<span id="tm_currstat">Current Status:</span><br /><br />
<div class="form-group row p-2">
<label for="input-text-help" id="tmst_stnotice" class="control-label"></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><em class="fa fa-paypal"></em></span>
</div>
<input maxlength="150" type="text" class="form-control" id="tstatus" value="" />
</div>
</div>
<div class="form-group row p-2">
<button class="btn btn-light px-5" type="button" onclick="updstatus()">
<em class="fa fa-floppy-o mr-1" id="tmst_stnotice"> </em> Save Status
</button>
</div>
</div>
Widget Java Code
- Code:
jQuery(function()
{
var id = 'field_id1';
dataStore.set('Stat', '', 60*1000);
if(dataStore.get('Stat').value =="")
{
jQuery.get('/u'+_userdata.user_id, function (data)
{
var cstat= jQuery('#'+id+' .field_uneditable', data).eq(0).text();
jQuery('#tm_currstat').text('Current Status: '+cstat);
jQuery('#tstatus').val(cstat);
dataStore.set('Stat', cstat, 60*1000);
})
}else{
jQuery('#tstatus').val(cstat);
jQuery('#tm_currstat').text('Current Status: '+dataStore.get('Stat').value);
}
});
function updstatus()
{
var id = 'field_id1';
var name = 'profile_field_13_8';
jQuery.getScript('https://illiweb.com/rs3/86/frm/jquery/json/jquery.json-1.3.min.js', function()
{
jQuery('#tmst_stnotice').text('Updating.');
var content = new Array();
var newstat = jQuery('#tstatus').val();
content.push(new Array(name, newstat));
jQuery.post('/ajax_profile.forum?jsoncallback=?', {
id: id.substring(8, id.length),
user: _userdata.user_id,
active: '1',
content: jQuery.toJSON(content),
tid: document.getElementById('logout').href.replace(/.*tid=(.*?)&.*/,'$1')
},function(data)
{
jQuery.get('/u'+_userdata.user_id, function (data)
{
var cstat= jQuery('dl:contains(Status) .field_uneditable', data).eq(0).text();
if (jQuery('#tstatus').val()==cstat)
{
jQuery('#tm_currstat').text('Current Status: '+cstat);
dataStore.set('Stat', cstat, 60*1000);
jQuery('#tmst_stnotice').text('Done...');
}else{
jQuery('#tmst_stnotice').text('Error Try Again.');
}
})
}, 'json');
});
};
Last edited by Astariel on March 6th 2019, 12:01 am; edited 2 times in total
Re: LocalStorage Coding help
the local storage code from that page you just copy the first code box and create a new javascript and run it on the pages you need it on no changes are needed
Re: LocalStorage Coding help
@_Twisted_Mods_
I don't need to set up any of the set or get functions? If not, does the status widget just not keep track of the current status like the widget shows?
I don't need to set up any of the set or get functions? If not, does the status widget just not keep track of the current status like the widget shows?
Re: LocalStorage Coding help
the get and set functions are already setup in the code for the status widget .. all it does is prevent the widget from making the request to get the status every time the page loads. it saves it for a hour then it will make the request again when the page is loaded. this will prevent a large load on your website if you had a lot of users opening pages with the widget on it
Re: LocalStorage Coding help
@_Twisted_Mods_
So, the widget itself should only show the status when they update it? And it'll only stay on the until they reload the page?
So, the widget itself should only show the status when they update it? And it'll only stay on the until they reload the page?
Re: LocalStorage Coding help
the status will load each time the page is loaded but it does not grab the status each time it only grabs it once every hour no matter how many times its loaded unless the user changes the status then it will grab the new status
Re: LocalStorage Coding help
@_Twisted_Mods_
Oh, well that's my problem with it then. It's not grabbing the status. Like, once you add your status, it shows until you leave the page. Then it just says 'Current Status: '. It never grabs the current status. That's why I thought I set the LocalStorage up wrong x.x
Oh, well that's my problem with it then. It's not grabbing the status. Like, once you add your status, it shows until you leave the page. Then it just says 'Current Status: '. It never grabs the current status. That's why I thought I set the LocalStorage up wrong x.x
Re: LocalStorage Coding help
you might have because that's where it saves the status and keeps it from updating every time the page loads. pm me a test account and ill check it out
Re: LocalStorage Coding help
i missed a part of the code when i was changing stuff
in the first script
had to be changed to
can you confirm its working now?
in the first script
- Code:
var cstat= jQuery('#'+id+' .field_uneditable', data).eq(0).text();
had to be changed to
- Code:
var cstat= jQuery('dl:contains(Status) .field_uneditable', data).eq(0).text();
can you confirm its working now?
Re: LocalStorage Coding help
@_Twisted_Mods_
You are literally a coding genius, Twisted. It's grabbing the current status perfectly now! Thank you so much! <3
You are literally a coding genius, Twisted. It's grabbing the current status perfectly now! Thank you so much! <3
Re: LocalStorage Coding help
Thank you so much for your help @_Twisted_Mods_
Problem solved & topic archived.
|
Similar topics
» How to prevent the request limit in this javascript via the localstorage?
» dataStore : localStorage expiration made easy
» Coding Spot (FM-Coding Support)
» table coding
» coding
» dataStore : localStorage expiration made easy
» Coding Spot (FM-Coding Support)
» table coding
» coding
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum