19 function setCookie(cookieName, cookieValue, exdays) {
20 exdays = typeof exdays !==
'undefined' ? exdays : 1;
21 var date =
new Date();
22 date.setTime(date.getTime() + (exdays * 24 * 60 * 60 * 1000));
23 var expires =
"expires=" + date.toUTCString();
24 document.cookie = cookieName +
"=" + cookieValue +
"; " + expires;
27 function getCookie(cookieName) {
28 var name = cookieName +
"=";
29 var allCookies = document.cookie.split(
';');
30 for (var i = 0; i < allCookies.length; i++) {
31 var theCookie = allCookies[i];
32 while (theCookie.charAt(0) ==
' ') {
33 theCookie = theCookie.substring(1);
35 if (theCookie.indexOf(name) != -1) {
36 return theCookie.substring(name.length, theCookie.length);
42 function setOption(name, value) {
43 setCookie(
"option." + name, value, 1);
46 function getOption(name) {
47 return getCookie(
"option." + name);
50 function getOptionDefaultTrue(name) {
51 var theCookie = getCookie(
"option." + name);
52 if (theCookie ===
"") {
56 return theCookie ===
"true";
60 function failed(jqXHR, textStatus, error) {
61 var err = textStatus +
", " + error;
62 console.log(
"Request Failed: " + err);
63 respondTxt = jqXHR.responseText;
64 if (respondTxt.indexOf(
'Module unavailable or your login session timed out.') != 0) {
65 $(
'#dmessage').append(respondTxt);
66 $(
'#dmessage').css(
'display',
'block');
68 else if (confirm(
"You are not logged in. Go to login page?")) {
69 window.location.href =
"?mod=auth";
73 function rmDefaultText(caller, dflt) {
74 if ($(caller).val() == dflt) {
79 function sortList(selector)
81 var options = $(selector);
82 var arr = options.map(
function(_, o) {
return { t: $(o).text(), v: o.value }; }).
get();
83 arr.sort(
function(o1, o2) {
return o1.t.toLowerCase() > o2.t.toLowerCase() ? 1 : o1.t.toLowerCase() < o2.t.toLowerCase() ? -1 : 0; });
84 options.each(
function(i, o) {