add url parsing to sortt function
This commit is contained in:
parent
fe10eabff8
commit
7833ab0dcf
22
sortt.js
22
sortt.js
@ -7,15 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//safe url sort param global
|
//safe url sort param global
|
||||||
window.sortt_url=window.location.search;
|
|
||||||
if (window.sortt_url.indexOf("sort=") < 0) {
|
|
||||||
//no sort url argument found
|
|
||||||
window.sortt_url="";
|
|
||||||
|
|
||||||
} else {
|
|
||||||
window.sortt_url=window.sortt_url.substr(window.sortt_url.indexOf("sort=")+5);
|
|
||||||
window.sortt_url=window.sortt_url.substr(0,window.sortt_url.indexOf("&"));
|
|
||||||
}
|
|
||||||
//creat global function with main routine
|
//creat global function with main routine
|
||||||
window.sortt=function(normsort,revsort,isdefault){
|
window.sortt=function(normsort,revsort,isdefault){
|
||||||
//sortTable [normsort] (revsort) (isdefault)
|
//sortTable [normsort] (revsort) (isdefault)
|
||||||
@ -26,8 +18,22 @@ window.sortt=function(normsort,revsort,isdefault){
|
|||||||
//default values of optinal parameters
|
//default values of optinal parameters
|
||||||
if (typeof revsort === 'undefined') revsort = "";
|
if (typeof revsort === 'undefined') revsort = "";
|
||||||
if (typeof isdefault === 'undefined') isdefault = false;
|
if (typeof isdefault === 'undefined') isdefault = false;
|
||||||
|
if (!(typeof isdefault === 'boolean')) isdefault = false;
|
||||||
|
|
||||||
// look at ReadMe
|
// look at ReadMe
|
||||||
console.log("sortTable() normsort:\"" + normsort + "\" revsort:\"" + revsort + "\" sortdefault:\"" + sortdefault + "\"");
|
console.log("sortTable() normsort:\"" + normsort + "\" revsort:\"" + revsort + "\" sortdefault:\"" + sortdefault + "\"");
|
||||||
|
|
||||||
|
// parse URL
|
||||||
|
url_sort="";
|
||||||
|
if (window.location.search.indexOf("sort=") < 0) {
|
||||||
|
if ( isdefault ) url_sort = normsort;
|
||||||
|
} else {
|
||||||
|
url_sort=window.location.search.substr(window.location.search.indexOf("sort=")+5);
|
||||||
|
url_sort=url_sort.substr(0,url_sort.indexOf("&"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user