User:Emma/common.js: Difference between revisions
Jump to navigation
Jump to search
Want an adless experience? Log in or Create an account.
m (Worked) |
m (Script Testing) |
||
Line 1: | Line 1: | ||
addOnloadHook( function() { | |||
jQuery('.sortable').each( function() { | |||
var id = jQuery(this).attr('id'); | |||
document.shCookie = getCookie('sortheader-'+id); | |||
document.sortheaderId = 0; | |||
jQuery('#'+id+' a.sortheader').each( function() { | |||
var id = jQuery(this).parent().parent().parent().parent().attr('id'); | |||
var sh = document.sortheaderId++; | |||
if( sh+100 == document.shCookie ) { ts_resortTable(this); ts_resortTable(this); } | |||
if( sh == document.shCookie ) { ts_resortTable(this); sh += 100; } | |||
jQuery(this).bind('click', {id: id, sh: sh}, function(e) { | |||
setCookie('sortheader-'+e.data.id, e.data.sh, 1); | |||
e.data.sh += e.data.sh < 100 ? 100 : -100; | |||
}); | |||
}); | |||
}); | |||
}); | |||
function setCookie(c_name,value,exdays) { | |||
var exdate=new Date(); | |||
exdate.setDate(exdate.getDate() + exdays); | |||
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()); | |||
document.cookie=c_name + "=" + c_value; | |||
} | |||
function getCookie(c_name) { | |||
var i,x,y,ARRcookies=document.cookie.split(";"); | |||
for (i=0;i<ARRcookies.length;i++) { | |||
x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); | |||
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); | |||
x=x.replace(/^\s+|\s+$/g,""); | |||
if (x==c_name) return unescape(y); | |||
} | |||
} |
Revision as of 06:34, October 8, 2012
addOnloadHook( function() { jQuery('.sortable').each( function() { var id = jQuery(this).attr('id'); document.shCookie = getCookie('sortheader-'+id); document.sortheaderId = 0; jQuery('#'+id+' a.sortheader').each( function() { var id = jQuery(this).parent().parent().parent().parent().attr('id'); var sh = document.sortheaderId++; if( sh+100 == document.shCookie ) { ts_resortTable(this); ts_resortTable(this); } if( sh == document.shCookie ) { ts_resortTable(this); sh += 100; } jQuery(this).bind('click', {id: id, sh: sh}, function(e) { setCookie('sortheader-'+e.data.id, e.data.sh, 1); e.data.sh += e.data.sh < 100 ? 100 : -100; }); }); }); }); function setCookie(c_name,value,exdays) { var exdate=new Date(); exdate.setDate(exdate.getDate() + exdays); var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()); document.cookie=c_name + "=" + c_value; } function getCookie(c_name) { var i,x,y,ARRcookies=document.cookie.split(";"); for (i=0;i<ARRcookies.length;i++) { x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); x=x.replace(/^\s+|\s+$/g,""); if (x==c_name) return unescape(y); } }