PageSourceSearch

https://marx-brothers.org/styleswitch.js

js marx-brothers.org collected 2026-10-02 05:30:29 UTC 4,512 bytes, 91 lines download raw bytes

1//Style Sheet Switcher version 1.1 Oct 10th, 2006
2//Author: Dynamic Drive: http://www.dynamicdrive.com
3//Usage terms: http://www.dynamicdrive.com/notice.htm
4
5var manual_or_random="manual" //"manual" or "random"
6var randomsetting="3 days" //"eachtime", "sessiononly", or "x days (replace x with desired integer)". Only applicable if mode is random.
7
8//////No need to edit beyond here//////////////
9
10function getCookie(Name) { 
11var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
12if (document.cookie.match(re)) //if cookie found
13return document.cookie.match(re)[0].split("=")[1] //return its value
14return null
15}
16
17function setCookie(name, value, days) {
18var expireDate = new Date()
19//set "expstring" to either future or past date, to set or delete cookie, respectively
20var expstring=(typeof days!="undefined")? expireDate.setDate(expireDate.getDate()+parseInt(days)) : expireDate.setDate(expireDate.getDate()-5)
21document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
22}
23
24function deleteCookie(name){
25setCookie(name, "moot")
26}
27
28
29function setStylesheet(title, randomize){ //Main stylesheet switcher function. Second parameter if defined causes a random alternate stylesheet (including none) to be enabled
30var i, cacheobj, altsheets=[""]
31for(i=0; (cacheobj=document.getElementsByTagName("link")[i]); i++) {
32if(cacheobj.getAttribute("rel").toLowerCase()=="alternate stylesheet" && cacheobj.getAttribute("title")) { //if this is an alternate stylesheet with title
33cacheobj.disabled = true
34altsheets.push(cacheobj) //store reference to alt stylesheets inside array
35if(cacheobj.getAttribute("title") == title) //enable alternate stylesheet with title that matches parameter
36cacheobj.disabled = false //enable chosen style sheet
37}
38}
39if (typeof randomize!="undefined"){ //if second paramter is defined, randomly enable an alt style sheet (includes non)
40var randomnumber=Math.floor(Math.random()*altsheets.length)
41altsheets[randomnumber].disabled=false
42}
43return (typeof randomize!="undefined" && altsheets[randomnumber]!="")? altsheets[randomnumber].getAttribute("title") : "" //if in "random" mode, return "title" of randomly enabled alt stylesheet
44}
45
46function chooseStyle(styletitle, days){ //Interface function to switch style sheets plus save "title" attr of selected stylesheet to cookie
47if (document.getElementById){
48setStylesheet(styletitle)
49//setCookie("mysheet", styletitle, days)
50}
51}
52
53function indicateSelected(element){ //Optional function that shows which style sheet is currently selected within group of radio buttons or select menu
54if (selectedtitle!=null && (element.type==undefined || element.type=="select-one")){ //if element is a radio button or select menu
55var element=(element.type=="select-one") ? element.options : element
56for (var i=0; i<element.length; i++){
57if (element[i].value==selectedtitle){ //if match found between form element value and cookie value
58if (element[i].tagName=="OPTION") //if this is a select menu
59element[i].selected=true
60else //else if it's a radio button
61element[i].checked=true
62break
63}
64}
65}
66}
67/*
68if (manual_or_random=="manual"){ //IF MANUAL MODE
69var selectedtitle= null//getCookie("mysheet")
70if (document.getElementById && selectedtitle!=null) //load user chosen style sheet from cookie if there is one stored
71setStylesheet(selectedtitle)
72}
73else if (manual_or_random=="random"){ //IF AUTO RANDOM MODE
74if (randomsetting=="eachtime")
75setStylesheet("", "random")
76else if (randomsetting=="sessiononly"){ //if "sessiononly" setting
77if (getCookie("mysheet_s")==null) //if "mysheet_s" session cookie is empty
78document.cookie="mysheet_s="+setStylesheet("", "random")+"; path=/" //activate random alt stylesheet while remembering its "title" value
79else
80setStylesheet(getCookie("mysheet_s")) //just activate random alt stylesheet stored in cookie
81}
82else if (randomsetting.search(/^[1-9]+ days/i)!=-1){ //if "x days" setting
83if (getCookie("mysheet_r")==null || parseInt(getCookie("mysheet_r_days"))!=parseInt(randomsetting)){ //if "mysheet_r" cookie is empty or admin has changed number of days to persist in "x days" variable
84setCookie("mysheet_r", setStylesheet("", "random"), parseInt(randomsetting)) //activate random alt stylesheet while remembering its "title" value
85setCookie("mysheet_r_days", randomsetting, parseInt(randomsetting)) //Also remember the number of days to persist per the "x days" variable
86}
87else
88setStylesheet(getCookie("mysheet_r")) //just activate random alt stylesheet stored in cookie
89} 
90}
91*/

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.