52 lines
1.8 KiB
JavaScript
52 lines
1.8 KiB
JavaScript
/*
|
|
* Solo - A small and beautiful blogging system written in Java.
|
|
* Copyright (c) 2010-2019, b3log.org & hacpai.com
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
// *** Cookies ***
|
|
function writeCookie(name, value) {
|
|
exp = new Date();
|
|
exp.setTime(exp.getTime() + (86400 * 1000 * 30));
|
|
document.cookie = name + "=" + escape(value) + "; expires=" + exp.toGMTString() + "; path=/";
|
|
document.cookie.replace("stylesheet=css0","stylesheet="+value);
|
|
}
|
|
function readCookie(name) {
|
|
var search;
|
|
search = name + "=";
|
|
offset = document.cookie.indexOf(search);
|
|
if (offset != -1) {
|
|
offset += search.length;
|
|
end = document.cookie.indexOf(";", offset);
|
|
if (end == -1){
|
|
end = document.cookie.length;
|
|
}
|
|
return unescape(document.cookie.substring(offset, end));
|
|
}else{
|
|
return "";
|
|
}
|
|
}
|
|
|
|
function setStyleSheet(strCSS){
|
|
var objs=document.getElementsByTagName("link");
|
|
var intFound=0;
|
|
for(var i=0;i<objs.length;i++){
|
|
if(objs[i].type.indexOf("css")>-1&&objs[i].title){
|
|
objs[i].disabled = true;
|
|
if(objs[i].title==strCSS) intFound=i;
|
|
}
|
|
}
|
|
objs[intFound].disabled = false;
|
|
writeCookie("stylesheet",objs[intFound].title);
|
|
} |