Commit 7c18b025 authored by Ad Schellevis's avatar Ad Schellevis

switch to local webstorage, https://github.com/opnsense/core/issues/840 thanks @fabianfrz

parent 306b80c7
......@@ -218,31 +218,6 @@ function ajaxGet(url,sendData,callback) {
});
}
/**
* set cookie value by key
* @param key cookie key
* @param value cookie value
* @param expire time to live
*/
function setCookie(key, value, expire) {
var expires = new Date();
if (expire == undefined) {
expire = 3600000 ; // expire in 1 hour
}
expires.setTime(expires.getTime() + expire); // 1 hour
document.cookie = key + '=' + value + ';expires=' + expires.toUTCString();
}
/**
* get cookie value
* @param key cookie key
* @return cookie value (or null if not found)
*/
function getCookie(key) {
var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
return keyValue ? keyValue[2] : null;
}
/**
* watch scroll position and set to last known on page load
*/
......@@ -254,12 +229,12 @@ function watchScrollPosition() {
// link on scroll event handler
$(window).scroll(function(){
setCookie('scrollpos',current_location()+"|"+$(window).scrollTop());
localStorage.setItem('scrollpos', current_location()+"|"+$(window).scrollTop());
});
// move to last known position on page load
$( document ).ready(function() {
var scrollpos = getCookie('scrollpos');
var scrollpos = localStorage.getItem('scrollpos');
if (scrollpos != null) {
if (scrollpos.split('|')[0] == current_location()) {
$(window).scrollTop(scrollpos.split('|')[1]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment