Skip to content

Instantly share code, notes, and snippets.

@Kreijstal
Last active August 29, 2015 14:04
Show Gist options
  • Save Kreijstal/78d5dd67b4acfa402418 to your computer and use it in GitHub Desktop.
Save Kreijstal/78d5dd67b4acfa402418 to your computer and use it in GitHub Desktop.
Continues to send requests, to see when cebollachan is up again.
HTTP=(function(url,callback,method,post,headers){//headers is an object like this {Connection:"keep-alive"}
function createXMLHttpRequest() {
if (typeof XMLHttpRequest != "undefined") {
return new XMLHttpRequest();
} else if (typeof window.ActiveXObject != "undefined") {
try {
return new ActiveXObject("Msxml2.XMLHTTP.4.0");
} catch (e) {
try {
return new ActiveXObject("MSXML2.XMLHTTP");
} catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
return null;
}
}
}
}
}
function looProp(object,callback){
var a;
for(a in object){
if(object.hasOwnProperty(a))callback.call(object,a,object[a]);
}
}
method=method||"GET";
var xhr=createXMLHttpRequest(),callbackcall=true;
if(xhr){
xhr.open(method,url,true);
looProp(headers,function(a,b){xhr.setRequestHeader(a,b)})
xhr.onreadystatechange=function(){if(xhr.readyState==xhr.DONE&&callbackcall){callbackcall=false;callback(xhr)}};
xhr.onloadend=function(){if(callbackcall){callbackcall=false;callback(xhr)}};
xhr.send(post);
return xhr;}else{return null;}
});
function tryTor(web){
var d;
function callback(a){
console.log("DELTA TIME",Date.now()-d)
if(a.status){alert("Yay")}else{console.log("Didn't work, trying again");setTimeout(function(){d=Date.now();HTTP(web,callback);},5000)}
}
window.xhr=HTTP(web,callback);
};tryTor("http://www.s6cco2jylmxqcdeh.onion/index.php")
function getForm(asdf){
var div=document.createElement('div');
div.innerHTML=asdf;
return div.getElementsByTagName("form")[0];
}
function removeElement(element){
element&&element.parentNode.removeChild(element);
}
function HTTPRequestRetry(link,success,requesttype,post,headers,attemptsleft,failure){
attemptsleft=attemptsleft|0;
function callback(xhr){
if(xhr.status){success(xhr)}else{
if(failure)failure(xhr);
if(--attemptsleft){
console.log("Didn't work, trying again");
HTTP(link,callback,requesttype,post,headers);
}
}
}
return function(){HTTP(link,callback,requesttype,post,headers);}
}
function CebollaChanPost(reply,text){
var lik="http://www.s6cco2jylmxqcdeh.onion/new_reply/"+reply;
var c=HTTPRequestRetry(lik,function(a){
var form=getForm(a.responseText);
if(!form){
console.log("ERROR: form not found");
}else{
console.log(form)
removeElement(form.querySelector("[name=\"body\"]"));
removeElement(form.querySelector("[name=\"image\"]"));
removeElement(form.querySelector("[name=\"start_time\"]"));
var formdata=new FormData(form);
formdata.append("start_time",(Date.now()/1000)-500|0)
formdata.append("body",text);
formdata.append("post","Post");
//setTimeout(
HTTPRequestRetry(lik,function(a){console.log("Data has been sent! I guess")},"POST",formdata)();
//,0);
}})()
}
CebollaChanPost(26139,"Ohhh kye.");
// ==UserScript==
// @name PonyCebollaChan
// @version 0.1.0
// @namespace CebollaChan
// @description Extension de ponies en cebollachan.
// @match *://s6cco2jylmxqcdeh.onion//*
// @run-at document-start
// ==/UserScript==
function CssStyle(css,perm){
this.source=css;
this.element=null;
this.perm=Boolean(perm);
}
CssStyle.prototype.appendToDocument=function(){
this.element=$Rainb.el("style",null,[this.source])
$Rainb.add(document.head,this.element);
}
CssStyle.prototype.show=function(){
if(!this.element)this.appendToDocument();
this.element.sheet.disabled=false;
}
CssStyle.prototype.hide=function(){
if(!this.element)this.appendToDocument();
this.element.sheet.disabled=true;
}
var styles={def:new CssStyle("body {\
background: none repeat-x fixed right top #555;\
color: #111111;\
font-family: verdana,sans-serif;\
font-size: 13px;\
margin: 0;\
padding-bottom: 0 !important;\
padding-left: 2em;\
padding-right: 2em;\
padding-top: 3em;\
}\
body a {\
color: #373737;\
}\
.body {\
background-color: #999999;\
border-bottom-left-radius: 8px;\
border-bottom-right-radius: 8px;\
box-shadow: 0 1px 3px #CAE6C1;\
color: #111111;\
line-height: 1.5em;\
margin-bottom: 1em;\
margin-top: 0;\
/* opacity: 0.8; */\
min-width: 50%;\
display: inline-block;\
overflow: hidden;\
padding: 0.5em 0.7em 0.5em 0.5em;\
white-space: normal;\
word-wrap: break-word;\
}\
.body a {\
color: #000000 !important;\
}\
.body img {\
border: medium none;\
float: left;\
margin-bottom: 6px;\
margin-right: 7px;\
}\
.body ul.menu {\
clear: both;\
margin: 0.5em 0 0;\
text-align: right;\
}\
.body ul.menu li {\
margin: 0 0 0 0.5em;\
}\
h1 {\
font-size: 17px;\
text-align: center;\
}\
h1 a {\
color: #1E1E1E;\
display: none;\
text-decoration: none;\
}\
h1#logo {\
\tbackground: none repeat scroll 0 0 transparent !important;\
\tmargin-top: -26px !important;\
}\
#logo {\
/*background-image: url(\"http://s6cco2jylmxqcdeh.onion/img/onioncebo.png\");*/\
background-repeat:no-repeat;\
background-position:center top;\
\
cursor: pointer;\
display: block !important;\
\
/* height: 455px !important; */\
margin: 0;\
position: relative;\
text-indent: -9999px;\
font-size: 21px;\
font-style: bold;\
\
}\
h2 {\
color: #222222;\
font-size: 16px;\
margin-bottom: 0.6em;\
margin-top: 1em;\
position: relative;\
text-shadow: 0 1px #778B6D !important;\
}\
h2 a:hover {\
text-decoration: underline;\
}\
h3 {\
background-image: -moz-linear-gradient(center top , #DAEDF8, #C4DDEC);\
border-top-left-radius: 8px;\
border-top-right-radius: 8px;\
color: #222621;\
font-size: 12px;\
font-weight: 400;\
margin-bottom: 0;\
overflow: auto;\
padding: 0.5em;\
text-align: left;\
text-shadow: 0 1px #E7BDDF !important;\
}\
h3 a {\
color: #222621 !important;\
}\
h4.section {\
font-size: 15px;\
margin-bottom: 7px;\
}\
h4.user {\
font-size: 14px;\
margin: 0 0 0.5em;\
}\
.codebox {\
color: #393939;\
display: block;\
font: 0.9em/1.3em monaco,\"andale mono\",\"courier new\",courier,mono;\
height: auto;\
margin: 3px 0;\
max-height: 250px;\
overflow: auto;\
padding-top: 5px;\
white-space: normal;\
}\
span.quote {\
color: #5B8860;\
}\
.highlighted {\
background: none repeat scroll 0 0 #ABD69E;\
}\
.spoiler {\
background-color: #000000;\
color: #000000;\
text-shadow: none;\
}\
.spoiler:hover {\
color: #FFFFFF;\
cursor: default;\
}\
.border {\
background-color: #DAEDF8;\
border: 1px solid #DAEDF8;\
border-radius: 8px 8px 8px 8px;\
margin: 1em;\
padding: 0.5em;\
}\
.highlight {\
background-color: #FFFF99;\
color: #1D1D1D;\
font-style: normal;\
font-weight: 700;\
}\
#notice {\
background: none repeat scroll 0 0 #171717;\
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);\
color: #FFFFFF;\
cursor: pointer;\
font-size: 13px;\
margin-bottom: -1em;\
margin-left: -2em !important;\
margin-right: -2em !important;\
margin-top: -4em !important;\
opacity: 0.7;\
padding: 2.3em 1.5em 1em;\
position: fixed;\
text-shadow: 1px 1px 1px #111111;\
width: 100%;\
}\
.reply_id {\
float: right;\
text-align: right;\
vertical-align: middle;\
}\
label.common {\
float: left;\
padding-right: 0.5em;\
text-align: right;\
width: 15em;\
}\
input, textarea {\
display: block;\
}\
textarea {\
font-family: monospace;\
}\
fieldset {\
margin: 1em 0;\
}\
ul.body, ul.error_message {\
list-style-type: none;\
}\
ul.error_message {\
margin: 0;\
padding: 0;\
}\
ul.error_message li {\
font-style: italic;\
padding: 0.2em;\
}\
ul.menu {\
margin: 1em;\
text-align: center;\
}\
ul.menu li {\
display: inline;\
font-weight: 700;\
margin: 0 1em;\
}\
ul#main_menu {\
background-image: -moz-linear-gradient(center top , #94B8CD, #94B8CD);\
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);\
height: 18px;\
margin-bottom: 0;\
margin-left: -2em !important;\
margin-right: -2em !important;\
/* margin-top: -3em !important; */\
overflow: hidden;\
padding-bottom: 1em !important;\
padding-right: 1em;\
padding-top: 1.3em;\
}\
ul#main_menu a {\
color: #000000;\
font-size: 15px;\
font-weight: normal;\
margin-left: -8px;\
margin-right: 0;\
overflow: hidden !important;\
text-decoration: none;\
text-shadow: 0 1px #997B8D;\
}\
ul#main_menu li a[href=\"http://www.tinychan.org/hot_topics\"] {\
display: none;\
}\
ul#main_menu a:hover {\
border-bottom: 2px solid #000000;\
color: #353535;\
font-weight: normal;\
text-decoration: none;\
text-shadow: 0 1px #4B84A5;\
}\
ul.stuff {\
margin-bottom: 2em;\
}\
ul.stuff li {\
margin-bottom: 0.5em;\
}\
table {\
background: repeat-x scroll 50% 0 #DAEDF8;\
border-collapse: collapse;\
border-radius: 8px 8px 8px 8px;\
box-shadow: 0 1px 3px #CAE6C1;\
margin-bottom: 1em;\
margin-left: 0;\
margin-right: 0;\
width: 100%;\
}\
table a {\
color: #222621;\
font-weight: normal !important;\
text-decoration: none;\
}\
table th {\
background-image: -moz-linear-gradient(center top , #DAEDF8, #94B8CD);\
border-bottom: 1px solid #8EC98B;\
border-top-left-radius: 8px;\
border-top-right-radius: 8px;\
color: #222621;\
font-size: 12px !important;\
font-weight: normal;\
padding-bottom: 0.5em;\
padding-left: 0.7em !important;\
padding-right: 0.5em;\
padding-top: 0.5em;\
text-align: left;\
text-shadow: 0 1px #94B8CD;\
}\
table td {\
background: repeat-x scroll 50% 0 -moz-linear-gradient(center top, #D4EBF7, #D4EBF7);\
border-bottom: 1px solid #DAEDF8;\
color: #000000;\
padding: 0.5em 0.5em 0.5em 0.7em;\
text-shadow: 0 1px #DAEDF8;\
vertical-align: middle;\
}\
table tr.odd td {\
background: -moz-linear-gradient(center top, #DAEDF8, #DAEDF8);\
color: #000000;\
text-shadow: 0 1px #DAEDF8;\
}\
table tr:hover td {\
background-image: -moz-linear-gradient(center top , #FFFFFF, #FFFFFF);\
border-top: 1px solid #9DCA93;\
}\
table .minimal {\
font-size: 11px;\
white-space: nowrap;\
width: 1%;\
}\
.profile_fix {\
overflow: hidden;\
white-space: normal;\
word-wrap: break-word;\
}\
.reply_body_snippet, .snippet {\
font-style: italic;\
}\
.topic_headline a:visited {\
font-weight: 400;\
}\
.topic_info {\
color: #BC0707;\
cursor: default;\
float: right;\
}\
em.marked {\
background-color: #FFFF99;\
font-style: normal;\
font-weight: 700;\
}\
p.caption {\
font-size: 11px;\
margin-top: 2px;\
}\
.inline {\
display: inline;\
}\
#last_seen_marker {\
border-top: 2px solid #8FC88C;\
}\
#snapback_link {\
left: 2px;\
position: fixed;\
top: 50%;\
}\
.video, video, a.video {\
margin: 0 auto 1em;\
width: 500px;\
}\
.standalone, .row {\
margin-bottom: 1em;\
}\
.body ul.menu li, .unimportant {\
font-size: 10px;\
padding-left: 2em;\
}\
a:hover, h2 a, #snapback_link a {\
text-decoration: none;\
}\
a.youtube_alternate, .noscreen {\
display: none;\
}\
h3#preview, h3#error, h3#replying_to, label, legend, .topic_headline a, .reply_body_snippet a, .snippet a {\
font-weight: 700;\
}\
.help, .help_cursor {\
cursor: help;\
}\
input[type=\"text\"] {\
background: none repeat scroll 0 0 #FFFFFF;\
border: 1px solid #B1B1B1;\
border-radius: 4px 4px 4px 4px;\
box-shadow: 0 0 5px #99C398;\
color: #333333;\
display: block;\
font-size: 12px;\
margin: 5px 0;\
padding: 5px;\
}\
input[type=\"text\"]:focus {\
border: 1px solid #8BC88F;\
box-shadow: 0 0 5px #999999;\
}\
input[type=\"password\"] {\
background: none repeat scroll 0 0 #FFFFFF;\
border: 1px solid #B1B1B1;\
border-radius: 4px 4px 4px 4px;\
box-shadow: 0 0 5px #99C398;\
color: #333333;\
display: block;\
font-size: 12px;\
margin: 5px 0;\
padding: 5px;\
}\
input[type=\"password\"]:focus {\
border: 1px solid #8BC88F;\
box-shadow: 0 0 5px #999999;\
}\
textarea {\
background: none repeat scroll 0 0 #FFFFFF;\
border: 1px solid #B1B1B1;\
border-radius: 4px 4px 4px 4px;\
box-shadow: 0 0 5px #99C398;\
color: #333333;\
display: block;\
font-family: arial,sans-serif;\
font-size: 12px;\
margin: 4px 0;\
padding: 5px;\
width: 99%;\
}\
textarea:focus {\
border: 1px solid #8BC88F;\
box-shadow: 0 0 5px #999999;\
}\
input, textarea, keygen, select, button, isindex, datagrid {\
display: inline-block;\
letter-spacing: normal;\
line-height: normal;\
margin: 0;\
text-indent: 0;\
text-shadow: none;\
text-transform: none;\
word-spacing: normal;\
}\
input[name^=\"post\"] {\
margin-bottom: 1em;\
margin-top: 5px;\
}\
input[name^=\"preview\"] {\
margin-bottom: 1em;\
margin-top: 5px;\
}\
input[name^=\"image\"] {\
color: #333333 !important;\
display: inline-block;\
margin-top: 5px;\
}\
textarea[id^=\"qr_text\"] {\
height: 120px !important;\
}\
input[type=\"text\"]:focus, input[type=\"password\"]:focus, textarea:focus {\
outline: 0 solid #FFFFFF;\
}\
input[name^=\"name\"] {\
width: 220px;\
}\
input[name^=\"form[custom_style]\"] {\
width: 250px !important;\
}\
input[name^=\"form[memorable_name]\"] {\
width: 200px !important;\
}\
input[name^=\"form[memorable_password]\"] {\
width: 200px !important;\
}\
input[type^=\"radio\"] {\
margin-right: 3px !important;\
}\
input[id^=\"phrase\"] {\
width: 700px !important;\
}\
#main_menu li.watchlist {\
display: none !important;\
}\
#main_menu li.shuffle {\
display: none !important;\
}\
#main_menu li.hot_topics {\
display: none !important;\
}\
#main_menu li.events {\
display: none !important;\
}\
:active, *:focus {\
outline: medium none;\
}\
:focus {\
outline: medium none;\
}\
a:focus {\
outline-style: none;\
}\
.bar_container {\
border-color: #666666 !important;\
}\
.bar {\
background-color: #9AC234 !important;\
height: 1em !important;\
}\
a[onclick=\"document.getElementById('quick_reply').style.display = 'none'; return false;\"] {\
display: none;\
}\
.split {\
float: left;\
width: 50%;\
}\
p#advertisement {\
text-align: center;\
font-size: 10px;\
}\
\
.floatingform{background: wheat;padding: 1em 1em 1em 1em;}\
.corner{position: fixed; bottom: 0px; right: 0px;text-align: right;\
max-width: 12em;}\
.pagstyle{float:right}\
.topictools{float:right;}\
.topictools>button{border:none;background:none;cursor:pointer;}\
.topictools>button:hover{text-decoration:underline}\
.divappear>div{display:none;background:#aaa;}\
.divappear:hover>div{display:block;}\
.switcharrow{float:right;margin-left: 2px;\n\
background-image: -webkit-linear-gradient(top, #FFFFFF 0%,#A9CEFC 25%,#53A5F0 100%);\
background-image: -moz-linear-gradient(top, #FFFFFF 0%,#A9CEFC 25%,#53A5F0 100%);}\
.thmbimg{float:right}\
.thmbimg:hover{opacity:0.4;}",true),
//RAINBOW DASH STYLE
//RAINBOW DASH STYLE
//RAINBOW DASH STYLE
//RAINBOW DASH STYLE
//RAINBOW DASH STYLE
//RAINBOW DASH STYLE
RainbowDash:new CssStyle("body {\n\
background-color: #94DDEC;\n\
}\n\
.body {\n\
background-color: #DAEDF8;\n\
color: #111111;\n\
line-height: 1.5em;\n\
margin-bottom: 1em;\n\
opacity: 1;\n\
/* overflow: hidden; */\n\
padding: 0.5em 0.7em 0.5em 0.5em;\n\
white-space: normal;\n\
word-wrap: break-word;\n\
display: inline-block;\n\
}\n\
.body a {\n\
color: #000000 !important;\n\
}\n\
\
tr.odd {\n\
background-color: rgb(120, 200, 205);\n\
}\n\
h1#logo {\n\
\tbackground: none repeat scroll 0 0 transparent !important;\n\
\tmargin-top: -26px !important;\n\
}\n\
#logo {\n\
background-image: null;\n\
margin: 0;\n\
}\n\
h2 {\n\
color: #222222;\n\
text-shadow: 0 1px #79BAC7 !important;\n\
}\n\
h3 {\n\
background-image: -moz-linear-gradient(center top , #DAEDF8, #C4DDEC);\n\
color: #222621;\n\
font-weight: 400;\n\
overflow: auto;\n\
padding: 0.5em;\n\
text-align: left;\n\
text-shadow: 0 1px #C0E7BD !important;\n\
}\n\
h3 a {\n\
color: #222621 !important;\n\
}\n\
\
span.quote {\n\
color: #5B8860;\n\
}\n\
.highlighted {\n\
background: none repeat scroll 0 0 #D3A6E0;\n\
}\n\
.spoiler {\n\
background-color: #000000;\n\
color: #000000;\n\
text-shadow: none;\n\
}\n\
.spoiler:hover {\n\
color: #FFFFFF;\n\
cursor: default;\n\
}\n\
.border {\n\
background-color: #DAEDF8;\n\
}\n\
.highlight {\n\
background-color: #FFFF99;\n\
color: #1D1D1D;\n\
}\n\
\
.floatingform{\n\
background-color: #DAEDF8;\n\
border: 2px solid #2DC6CC;\n\
}\n\
ul#main_menu{\n\
background-image:-webkit-linear-gradient(top, rgba(255, 0, 0, 0.5) 0%,rgba(255, 255, 0, 0.63),rgba(0, 255, 0, 0.41),rgba(0, 255, 255, 0.53),rgba(0, 0, 255, 0.34),rgba(255, 0, 255, 0.58),rgba(255, 0, 0, 0.46) 100%);\
background-image:-moz-linear-gradient(top, rgba(255, 0, 0, 0.5) 0%,rgba(255, 255, 0, 0.63),rgba(0, 255, 0, 0.41),rgba(0, 255, 255, 0.53),rgba(0, 0, 255, 0.34),rgba(255, 0, 255, 0.58),rgba(255, 0, 0, 0.46) 100%);\
}"),Fluttershy:new CssStyle("body {\n\
background-color: #ffa;\n\
background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+DQo8c3ZnDQogICB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iDQogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIg0KICAgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIg0KICAgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyINCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyINCiAgIHhtbG5zOnNvZGlwb2RpPSJodHRwOi8vc29kaXBvZGkuc291cmNlZm9yZ2UubmV0L0RURC9zb2RpcG9kaS0wLmR0ZCINCiAgIHhtbG5zOmlua3NjYXBlPSJodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy9uYW1lc3BhY2VzL2lua3NjYXBlIg0KICAgdmlld0JveD0iLTM0NCAtMzYzIDcxOCA3MzIiDQogICB3aWR0aD0iNTAwIg0KICAgaGVpZ2h0PSI1MTAiDQogICBpZD0ic3ZnMiINCiAgIHZlcnNpb249IjEuMSINCiAgIGlua3NjYXBlOn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Y1IDM4LC0xMDQgNjAsLTEyOSBsIC0xLC0xIDE0LC00NiBxIDEwLC0zNiAyLC00OCBsIC0yLC0zIC0xMSwtMSBxIC04LDggMCwxNyBsIDEsMSAtNSw2IC0yLC0yIHEgLTYsLTcgLTUsLTE1IDEsLTggNiwtMTMgbCAxMCwtNCINCiAgICAgaWQ9InBhdGgyNyIgLz4NCjwvc3ZnPg0K );\n\
background-repeat: no-repeat;\n\
}\n\
.body {\n\
background-color: rgb(255, 197, 197);\n\
color: #111111;\n\
line-height: 1.5em;\n\
margin-bottom: 1em;\n\
opacity: 1;\n\
/* overflow: hidden; */\n\
padding: 0.5em 0.7em 0.5em 0.5em;\n\
white-space: normal;\n\
word-wrap: break-word;\n\
display: inline-block;\n\
}\n\
.body a {\n\
color: #000000 !important;\n\
}\n\
tr.odd {\n\
background-color: rgb(120, 200, 205);\n\
}\n\
h1#logo {\n\
\tbackground: none repeat scroll 0 0 transparent !important;\n\
\tmargin-top: -26px !important;\n\
}\n\
#logo {\n\
background-image: null;\n\
margin: 0;\n\
}\n\
h2 {\n\
color: #222222;\n\
text-shadow: 0 1px #79BAC7 !important;\n\
}\n\
h3 {\n\
background-image: -moz-linear-gradient(center top , #DAEDF8, #C4DDEC);\n\
color: #222621;\n\
font-weight: 400;\n\
overflow: auto;\n\
padding: 0.5em;\n\
text-align: left;\n\
text-shadow: 0 1px #C0E7BD !important;\n\
}\n\
h3 a {\n\
color: #6AD6D6 !important;\n\
}\n\
span.quote {\n\
color: #5B8860;\n\
}\n\
.highlighted {\n\
background: none repeat scroll 0 0 #D3A6E0;\n\
}\n\
.spoiler {\n\
background-color: #000000;\n\
color: #000000;\n\
text-shadow: none;\n\
}\n\
.spoiler:hover {\n\
color: #FFFFFF;\n\
cursor: default;\n\
}\n\
.border {\n\
background-color: #DAEDF8;\n\
}\n\
.highlight {\n\
background-color: #00D1B0;\n\
color: #1D1D1D;\n\
}\n\
.floatingform{\n\
background-color: rgb(255, 197, 197);\n\
border: 2px solid #2DC6CC;\n\
}\n\
ul#main_menu{\n\
background-color:#6AD6D6")}
function styleSwitchto(style){
for(var i in styles){
if(i==style||styles[i].perm){
styles[i].show();
} else
styles[i].hide();
}
}
//This probably proves I've gotten better at programming.
//DOM helper functions.
//This probably proves I've gotten better at programming.
//DOM helper functions.
var CssSelectorParser = (function () {
var source, index;
var treeRewrite = {
unknown: function (a) {
return this[a.name](a)
},
selectorArray: function (a) {
var b = {
name: "selector group",
list: []
};
for (var i = 0, l = a.content.length; i < l; i++) b.list.push(this.unknown(a.content[i]))
return b
},
selector: function (a) {
return this.unknown(a.content)
},
"simple selector": function (a) {
var b = {},att,c;
for (var i = 0, l = a.content.length, d; i < l; i++) {
d = a.content[i];
b.class=[];b.attributes=[];b.pseudoClass=[]
switch (d.name) {
case "type selector":
if(!b.tagName){b.tagname=this.unescape(d.content);}
break;
case "class selector":
b.class.push(this.unescape(d.content[1].content))
break;
case "ID selector":
if(!b.ID){b.ID=this.unescape(d.content[1].content);}
break;
case "attribute selector":att={attributeName:this.unescape(d.content[1][1].content)}
if(c=d.content[1][2]){att.operator=c.content;att.attributeValue=this.unescape(d.content[1][3].content)}
break;
case "pseudo-class":
b.pseudoClass.push(this.unescape(d.content))
break;
}
}
return b;
},
operator: function (a) {
var b=this.unknown(a.arguments[1]);
b.parent=this.unknown(a.arguments[0]);
b.parentRelationship=a.op;
return b;
},
unescape: function (string) {
var replacement, string2 = string,
func;
if ((string[0] == '"' || string[0] == "'") && (string[0] === string[string.length - 1])) {
string2 = string.substring(1, string.length - 1)
}
for (var i = 0; i < unescape.length; i++) {
if ((func = unescape[i].replace.f) === undefined) {
replacement = "$" + unescape[i].replace.for
} else {
if (func == "hexadecimal") replacement = function (s) {
return String.fromCharCode(parseInt(arguments[unescape[i].replace.for], 16))
}
}
string2 = string2.replace(unescape[i].search, replacement)
}
return string2;
}
},
unescape = [{
search: /\\([0-9A-fa-f]{1,6} ?)/g,
replace: {
f: "hexadecimal",
for: 1
}
}, {
search: /\\(.)/g,
replace: {
for: 1
}
}]
//Apparently, you don't tokenize and then parse, you do it on the go, but with more specific techniques which people call grammars, oh well, how was I suppesd to know that anyway.
//reference {type:"type",is:"type"} "hue"
//repetition {type:"repeat",optional:false,from:1,to:Infinity,contains:{},delimiting:null,multipleDelimeters:null} optional to and from are defaulted, delimiters can be used for lists like a,b,c and stuff
//array {type:"tyArray",contains:[]}
//alternate {type:"alternate",contains:[]}
//Expression {type:"expression",contains:{},operators:[{precedence:1,rightAssociative:false,tokens:[]}}],delimeters=[["(",")"]],whiteSpaceIgnore:null}
var tys = { //tys, meaning types
"type selector": /\*|(?:[\w_]|\\x?[a-f0-9]{2,6}\s?|\\[\S\s])(?:[^\\\s#.>&+~:,="'[\]]|\\x?[a-f0-9]{2,6}\s?|\\[\S\s])*/i, //regex for tagname
attributeValue: { //the vaue of an attibute, it can be
type: "alternate",
contains: [/"(?:[^"\\]|\\[\s\S])*"|'(?:[^'\\]|\\[\s\S])*'/i, {
type: "type",
is: "type selector"
}]
},
"pseudo-class": /::?(?:[\w_]|\\x?[a-f0-9]{2,6}\s?|\\[\S\s])(?:[^\\\s#.>&+~:,(]|\\x?[a-f0-9]{2,6}\s?|\\[\S\s])*(?:\((?:[^)\\]|\\[\S\s])*\))?/, //is for this I was thinking of implementing my own regex, this is beyond ridiculous
operator: /\s*(?:\$=|\^=|~=|\|=|\*=|=)\s*/, //you know the thing at [attr=value]
"attribute selector": {
type: "tyArray",
contains: ['[', {
type: "tyArray",
contains: [{
type: "type",
is: "type selector"
}, {
type: "type",
is: "operator"
}, {
type: "type",
is: "attributeValue"
}],
optional: [1, 2]
}, ']']
},
"ID selector": {
type: "tyArray",
contains: ['#', { //an id starts with an #
type: "type",
is: "type selector"
}]
},
"class selector": { //a classname starts with a dot
type: "tyArray",
contains: ['.', {
type: "type",
is: "type selector"
}]
},
"simple selector": { //a element selector is composed from tagname, clasname,attributesm, and pseudoclasses
//this is a sequence of simple selectors
type: "repeat",
contains: {
type: "alternate",
contains: [{
type: "type",
is: "type selector"
}, {
type: "type",
is: "class selector"
}, {
type: "type",
is: "ID selector"
}, {
type: "type",
is: "attribute selector"
}, {
type: "type",
is: "pseudo-class"
}]
}
},
selector:
/* {OLD LOL
type: "repeat",
delimiting: {
type: "type",
is: "relationship"
},
contains: {
type: "type",
is: "element"
}*/
{
type: "expression",
contains: {
type: "type",
is: "simple selector"
},
whiteSpaceIgnore: true,
rightAssociative: true,
operators: [{
precedence: 1,
tokens: ['>', '&', '+', '~', /\s/] //these are not actually operators this are combinators
}]
},
selectorArray: { //this is a selector group
type: "repeat",
delimiting: /\s*,\s*/, //it is separated by a comma, and optionally whitespace
contains: {
type: "type",
is: "selector"
}
}
}
var mains = { //START PARSE
type: "type",
is: "selectorArray"
}
//yay extendibility
var funcs = { //funcions/types used, hue
expression: function (o) { //parse it like an expression
//this is probably a little bit hard to understand
var r = {
type: "alternate",
contains: [o.contains]
}, //is it a token, an operator, or a parenthesis?
opers = {
type: "alternate",
contains: []
},
delims = {
type: "alternate",
contains: []
},
i, I, l, L, props, t, n, ret = {},
_ind = index,
EXPRS = [],
OPERATORS = [],
O, precedence, rightAssociative, arg1, arg2, k; //I use and reuse most variables I can, damn
if (O = o.operators) {
for (i = 0, l = O.length; i < l; i++) {
for (I = 0, L = O[i].tokens.length; I < L; I++) {
t = O[i].tokens[I];
if (o.whiteSpaceIgnore) {
if (typeof t === "string") {
opers.contains.push(new RegExp("\\s*(?:" + t.replace(/([-+\\?.!$^&*(){}[\]])/g, "\\$1") + ")\\s*"));
} else if (t instanceof RegExp) {
opers.contains.push(new RegExp("\\s*(?:" + t.source + ")\\s*", (t.multiline ? "m" : "") + (t.ignoreCase ? "i" : "")))
} else {
opers.contains.push({
type: "tyArray",
contains: [/\s*/, t, /\s*/]
}); /*Ahh I HATE THIS! D:*/
}
} else {
opers.contains.push(t);
}
}
}
r.contains[1] = opers; //ADD THEM TO THE LIST
}
if (O = o.delimeters) { //this is like a carbon copy of the previous if, should I try to make it a function? Don't repeat yourself
for (i = 0, l = O.length; i < l; i++) {
for (I = 0, L = O[i].length; I < L; I++) {
t = O[i][I];
if (o.whiteSpaceIgnore) {
if (typeof t === "string") {
delims.contains.push(new RegExp("\s*(?:" + t + ")\s*"));
} else if (t instanceof RegExp) {
delims.contains.push(new RegExp("\s*(?:" + t.source + ")\s*", (t.multiline ? "m" : "") + (t.ignoreCase ? "i" : "")))
} else {
delims.contains.push({
type: "tyArray",
contains: [/\s*/, t, /\s*/]
}); /*Ahh I HATE THIS! D:*/
}
} else {
delims.contains.push(t);
}
}
}
r.contains[2] = delims;
}
/*Shunting Yard Algorithm*/
while (n = isIndexItem(r, props = {})) { //While there are tokens to be read
//read a token
if (props._matched === r.contains[0]) { //If the token is a number, then add it to the output queue.
EXPRS.push(n);
} else
if (props._matched === opers) { //If the token is an operator, o1, then
if ((I = opers.contains.indexOf(props.props._matched)) !== -1) {
for (i = 0, l = (O = o.operators).length, k = 0; i < l; i++) { //
if ((k += O[i].tokens.length) > I) {
precedence = O[i].precedence;
rightAssociative = O[i].rightAssociative;
break;
}
}
} else {
throw new Error("props.props._matched not found at oper.contains, This is impossible.. or is it?");
}
while ((L = OPERATORS.length) && (((!rightAssociative) && precedence === OPERATORS[L - 1][1]) || precedence < OPERATORS[L - 1][1])) { //while there is an operator token, o2, at the top of the stack, and
//either o1 is left-associative and its precedence is equal to that of o2,
//or o1 has precedence less than that of o2,
/*POPPINGG!!*/
//pop o2 off the stack, onto the output queue;
//This popping is also a bit of PRN execution, basically it is shunting yard and prn, or something weird
arg2 = EXPRS.pop();
arg1 = EXPRS.pop();
if (!(EXPRS.length || arg1)) {
console.warn("NOT ENOUGH TERMS");
}
t = OPERATORS.pop();
for (i = 0, l = (O = o.operators).length, k = 0; i < l; i++) {
if ((k += O[i].tokens.length) > t[2]) {
EXPRS.push({
operation: O[i].tokens[t[2] - (k - O[i].tokens.length)],
op: t[0],
arguments: [arg1, arg2],
name: "operator"
});
break;
}
}
}
OPERATORS.push([n, precedence, I]);
} else
if (props._match === delims) {} else {
throw Error("This is impossible! It has matched an unknown value..???");
}
}
//When there are no more tokens to read
while (L = OPERATORS.length) { //While there are still operator tokens in the stack
//Pop the operator onto the output queue.
arg2 = EXPRS.pop();
arg1 = EXPRS.pop();
if (!(EXPRS.length || arg1)) {
console.warn("NOT ENOUGH TERMS");
}
t = OPERATORS.pop();
for (i = 0, l = (O = o.operators).length, k = 0; i < l; i++) {
if ((k += O[i].tokens.length) > t[2]) {
EXPRS.push({
operation: O[i].tokens[t[2] - (k - O[i].tokens.length)],
op: t[0],
arguments: [arg1, arg2],
name: "operator"
});
break;
}
}
}
if (EXPRS.length < 1) {
return null;
}
if (EXPRS.length !== 1) {
throw new Error("Operators and expressions mismatch!!");
}
return EXPRS[0];
},
type: function (o) { //get type and parse it
var props = {},
a = isIndexItem(tys[o.is], props),
t, ret; //this is where props originally started, in short words, it is used to pass properties from other functions to here
if (a === null) return null;
//console.log()
ret = {
type: (t = tys[o.is]) && (t.delimiting ? "list" : t.type || ((typeof t === "string" || t instanceof RegExp) ? "String" : undefined)),
name: o.is,
content: a
}
for (var k in props) {
if (props.hasOwnProperty(k) && (!ret[k])) {
ret[k] = props[k];
}
}
return ret;
},
repeat: function (o, props) { //repeat
var reto = [],
e, d, _ind = index,
l, p, D = o.delimiting,
i = 0,
p = D && o.multipleDelimeters, //say, if the delimeter is just once, there is no point in putting it each time it appears.. right? so an CSV like "abc,dfe,ege" will appear as ["abc","dfe","ege"] instead of ["abc",',',"dfe",',',"ege"]
props2;
d = o.contains;
props.props = [];
do {
e = isIndexItem(D ? i & 1 ? D : d : d, props2 = {});
if ((!p) && D && i & 1) {
i++;
if (e !== null) {
continue;
} else {
break;
}
}
i++;
if (e !== null) {
reto.push(e)
props.props.push(props2)
}
} while (e !== null && i !== o.to);
l = reto.length;
if (((!o.optional) && l == 0) || ((!isNaN(p = o.from)) && l < p)) {
index = _ind;
return null;
}
if (D && !p) {
props.delimeter = D
}
return reto;
},
tyArray: function (o, props) { //tokens are in some order
var reto = [],
e, _ind = index,
opt = o.optional || [],
props2;
props.props = [];
for (var i = 0, l = o.contains.length, d; i < l; i++) {
d = o.contains[i];
e = isIndexItem(d, props2 = {});
if (e === null && (opt.indexOf(i) < 0)) {
index = _ind;
return null;
}
if (e !== null)
props.props.push(props2);
reto.push(e);
}
return reto;
},
alternate: function (o, props) { //It alternates
var reto = null,
e, props2 = {};
for (var i = 0, l = o.contains.length, d; i < l; i++) {
d = o.contains[i];
e = isIndexItem(d, props2);
if (e !== null) {
reto = e;
props.props = props2;
props._matched = d;
break;
}
}
return reto;
}
}
function isIndexItem(item, props) { //recursive
//returns item or null
var s, t, r,
f;
if (!item) {
return null
} else
if (item instanceof RegExp) {
r = new RegExp
r.compile("^(?:" + item.source + ")", (item.multiline ? "m" : "") + (item.eturnignoreCase ? "i" : ""))
//r.lastIndex = index;
s = r.exec(source.substr(index)); //RAAAWR damn it
t = s && s[0];
if (t === null) return null;
index += t.length;
return t;
} else if (typeof item == "string") { //literal match
//console.log("DOES "+item+" and"+source.substr(index,item.length)+" MATCHES??");
if (item === source.substr(index, item.length))
return (index += item.length), item;
return null;
} else {
t = item.type;
f = funcs[t];
s = f(item, props);
if (f) return s;
else return null;
}
}
function selectorParser(arg) {
source = arg,
index = 0; //index is 0!!!
return treeRewrite.unknown(isIndexItem(mains)); //wasn't that just pretty understandable?
}
return selectorParser;
})();
$Rainb={d:document.documentElement}
$Rainb.id = function(id) {
return document.getElementById(id);
};
$Rainb.ready = function(fc) {
var cb;
if (document.readyState !== 'loading') {
fc();
return;
}
cb = function() {
$Rainb.off(document, 'DOMContentLoaded', cb);
return fc();
};
return $Rainb.on(document, 'DOMContentLoaded', cb);
};
$Rainb.formData = function(form) {
var fd, key, val;
if (form instanceof HTMLFormElement) {
return new FormData(form);
}
fd = new FormData();
for (key in form) {
val = form[key];
if (val) {
if (typeof val === 'object' && 'newName' in val) {
fd.append(key, val, val.newName);
} else {
fd.append(key, val);
}
}
}
return fd;
};
$Rainb.extend = function(object, properties) {
var key, val;
for (key in properties) {
val = properties[key];
object[key] = val;
}
};
$Rainb.on = function(el, events, handler) {
var event, _i, _len, _ref;
_ref = events.split(' ');
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
event = _ref[_i];
el.addEventListener(event, handler, false);
}
};
$Rainb.off = function(el, events, handler) {
var event, _i, _len, _ref;
_ref = events.split(' ');
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
event = _ref[_i];
el.removeEventListener(event, handler, false);
}
};
$Rainb.el=function (elem, attributes, childnodes, listeners) {
//listener format: {lstng:"click",cb:callback}
var e = document.createElement(elem),l;
for (var a in attributes) {
if (a == "style") {
for (var d in attributes[a]) {
e.style[d] = attributes[a][d];
}
continue;
}
if (a == "__properties") {
for (d in attributes[a]) {
e[d] = attributes[a][d];
}
continue;
}
e.setAttribute(a, attributes[a])
}
if (childnodes && (l=childnodes.length)) {
for (var i = 0, c; i < l; i++) {
c = childnodes[i];
if (c.length && typeof c == "string") {
e.appendChild(document.createTextNode(c));
continue;
}
e.appendChild(c)
}
}
if (listeners && (l=listeners.length)) {
for (var i = 0, c; i < l; i++) {
c = listeners[i];
$Rainb.on(e,c.lstng,c.cb);
}
}
return e;
}
$Rainb.HTTP=function(){var lastModified={};return(function(url,extra,callback,headers){
//headers is an object like this {Connection:"keep-alive"}
extra=extra||{};
function createXMLHttpRequest() {
if (typeof XMLHttpRequest != "undefined") {
return new XMLHttpRequest();
} else if (typeof window.ActiveXObject != "undefined") {
try {
return new ActiveXObject("Msxml2.XMLHTTP.4.0");
} catch (e) {
try {
return new ActiveXObject("MSXML2.XMLHTTP");
} catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
return null;
}
}
}
}
}
function looProp(object,callback){
var a;
for(a in object){
if(object.hasOwnProperty(a))callback.call(object,a,object[a]);
}
}
extra.method=extra.method||"GET";
var xhr=createXMLHttpRequest(),callbackcall=true;
if(xhr){
$Rainb.extend(xhr,extra.opts);
$Rainb.extend(xhr.upload, extra.upCallbacks);
xhr.open(extra.method,url,!extra.sync);
if (extra.whenModified) {
if (url in lastModified) {
xhr.setRequestHeader('If-Modified-Since', lastModified[url]);
}
$Rainb.on(r, 'load', function() {
return lastModified[url] = r.getResponseHeader('Last-Modified');
});
}
looProp(headers,function(a,b){xhr.setRequestHeader(a,b)})
xhr.onreadystatechange=function(){if(xhr.readyState==xhr.DONE&&callbackcall){callbackcall=false;callback(xhr)}};
xhr.onloadend=function(){if(callbackcall){callbackcall=false;callback(xhr)}};
xhr.send(extra.post);
return xhr;}else{return null;}
});}()
$Rainb.hasClass = function(el, className) {
return el.classList&&el.classList.contains(className);
};
$Rainb.rm = function(el) {
return el&&el.parentNode.removeChild(el);
}
$Rainb.tn = function(s) {
return document.createTextNode(s);
};
$Rainb.add = function(parent, el) {
return parent.appendChild($Rainb.nodes(el));
};
$Rainb.nodes = function(nodes) {
var frag, node, _i, _len;
if (!(nodes instanceof Array)) {
return nodes;
}
frag = d.createDocumentFragment();
for (_i = 0, _len = nodes.length; _i < _len; _i++) {
node = nodes[_i];
frag.appendChild(node);
}
return frag;
};
$Rainb.prepend = function(parent, el) {
return parent.insertBefore($Rainb.nodes(el), parent.firstChild);
};
$Rainb.bubbleFind=function(element,elementSelector){
while(element!==null){
if($Rainb.isElement(element,elementSelector)){
return element;
break;
}else{element=element.parentNode}
}
}
$Rainb.nodes = function(nodes) {
var frag, node, _i, _len;
if (!(nodes instanceof Array)) {
return nodes;
}
frag = document.createDocumentFragment();
for (_i = 0, _len = nodes.length; _i < _len; _i++) {
node = nodes[_i];
frag.appendChild(node);
}
return frag;
};
$Rainb.after = function(root, el) {
return root.parentNode.insertBefore($Rainb.nodes(el), root.nextSibling);
};
$Rainb.before = function(root, el) {
return root.parentNode.insertBefore($Rainb.nodes(el), root);
};
$Rainb.replace = function(root, el) {
return root.parentNode.replaceChild($Rainb.nodes(el), root);
};
$Rainb.ins=function (txtarea,text,textEnd) {
var scrollPos = txtarea.scrollTop;
var strPos = 0;
textEnd=textEnd||"";
var br = ((txtarea.selectionStart || txtarea.selectionStart == '0') ?
"ff" : (document.selection ? "ie" : false ) );
if (br == "ie") {
txtarea.focus();
var range = document.selection.createRange();
range.moveStart ('character', -txtarea.value.length);
strPos = range.text.length;
}
else if (br == "ff") strPos = txtarea.selectionStart;
var front = (txtarea.value).substring(0,strPos);
var selectedText=(txtarea.value).substring(strPos,txtarea.selectionEnd);
var back = (txtarea.value).substring(txtarea.selectionEnd,txtarea.value.length);
txtarea.value=front+text+selectedText+textEnd+back;
strPos = strPos + text.length+selectedText.length+textEnd.length;
if (br == "ie") {
txtarea.focus();
var range = document.selection.createRange();
range.moveStart ('character', -txtarea.value.length);
range.moveStart ('character', strPos);
range.moveEnd ('character', 0);
range.select();
}
else if (br == "ff") {
txtarea.selectionStart = strPos;
txtarea.selectionEnd = strPos;
txtarea.focus();
}
txtarea.scrollTop = scrollPos;
};
$Rainb.alast=function(arr){
return arr[arr.length-1];
}
$Rainb.till=function(){
var selects=[],listening=false;
function nodeInserted(event){if(!selects.length){$Rainb.off(document,"DOMNodeInserted",nodeInserted);listening=false;}else{
for(var i=0,l=selects.length;i<l;i++){if($Rainb.isElement(selects[i].selector,event.target)){selects[i].cb(event.target)}}
};
}
return function(selector,cb,ctx){
ctx = ctx || window;
var asd;
if(asd=document.querySelector(selector)){cb(asd);}else{
selects.push({selector:selector,cb:cb});
if(!listening){$Rainb.on(document,"DOMNodeInserted",nodeInserted);listening=true;}}
}
}();
$Rainb.addStyle = function(css,cb) {
var style=[];
for(var i=0,l=css.length;i<l;i++){
style[i] = $Rainb.el('style',null,[css[i]]);}
$Rainb.till("head",function(a) {
for(var i=0,l=style.length;i<l;i++){
$Rainb.add(document.head, style[i]);
}
return cb(style);
});
return style;
};
$Rainb.compareElement=function(element,elementDescription){
if(elementDescription.tagname&&(elementDescription.tagname.toUpperCase()!==element.tagName))return false;
for(var i2=0,item,l2=(item=elementDescription.class).length;i2<l2;i2++){
if(!$Rainb.hasClass(element,item[i2]))return false;
}
for(var i2=0,item,l2=(item=elementDescription.pseudoClass).length;i2<l2;i2++){}
for(var i2=0,item,l2=(item=elementDescription.attributes).length;i2<l2;i2++){}
return true;
};
$Rainb.isElement=function(element,elementSelector){
var abstractparsetree=CssSelectorParser(elementSelector);
for(var i=0,l=abstractparsetree.list.length;i<l;i++){
if($Rainb.compareElement(element,abstractparsetree.list[i])){return true;};
}
};
$Rainb.setEventListener=function (listener,listening,callback,elementSelector,ignoreElementSelector){
$Rainb.on(listener,listening,function(event){
var element=event.target;
while(element!==null){
if(ignoreElementSelector&&$Rainb.isElement(element,ignoreElementSelector)){
break;
}else if($Rainb.isElement(element,elementSelector)){
callback.call(element,event);
break;
}else{element=element.parentNode}
}
});
}
$Rainb.HTTPRequestsRetry=function(requests,success,done,extra,headers,timeout,attemptsleft,failure){//Same shit when basically the caller function is the same
var queue=requests;function DoOne(){
return $Rainb.HTTPRequestRetry(queue.pop(),function(afg){
success(afg);
if(queue.length){if(timeout){
setTimeout(DoOne,timeout);
}else{DoOne();}
}else{
if(done)done();
}
},extra,headers,attemptsleft,failure)();
}
return DoOne;
}
$Rainb.HTTPRequestRetry=function(link,success,extra,headers,attemptsleft,failure){
attemptsleft=attemptsleft|0;
var f,abort=false,req;
function callback(xhr){
if(xhr.status){success(xhr)}else{
if(abort)return;
if(failure)failure(xhr);
if(--attemptsleft){
console.log("Didn't work, trying again");
f();
}
}
}
f=function(arg){if(arg=="abort"){abort=true;req.abort();attemptsleft=1;return;};req=$Rainb.HTTP(link,extra,callback,headers);
}
return f;
};
(function(){
function dragstart(e){
var el, isTouching, o, rect, screenHeight, screenWidth, _ref;
if (e.type === 'mousedown' && e.button !== 0) {
return;
}
e.preventDefault();
if (isTouching = e.type === 'touchstart') {
_ref = e.changedTouches, e = _ref[_ref.length - 1];
}
el = this;
rect = el.getBoundingClientRect();
screenHeight = $Rainb.d.clientHeight;
screenWidth = $Rainb.d.clientWidth;
o = {
id: el.id,
style: el.style,
dx: e.clientX - rect.left,
dy: e.clientY - rect.top,
height: screenHeight - rect.height,
width: screenWidth - rect.width,
screenHeight: screenHeight,
screenWidth: screenWidth,
isTouching: isTouching
};
if (isTouching) {
o.identifier = e.identifier;
o.move = touchmove.bind(o);
o.up = touchend.bind(o);
$Rainb.on(document, 'touchmove', o.move);
return $Rainb.on(d, 'touchend touchcancel', o.up);
} else {
o.move = drag.bind(o);
o.up = dragend.bind(o);
$Rainb.on(document, 'mousemove', o.move);
return $Rainb.on(document, 'mouseup', o.up);
}
};
touchmove = function(e) {
var touch, _i, _len, _ref;
_ref = e.changedTouches;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
touch = _ref[_i];
if (touch.identifier === this.identifier) {
drag.call(this, touch);
return;
}
}
};
drag = function(e) {
var bottom, clientX, clientY, left, right, style, top;
clientX = e.clientX, clientY = e.clientY;
left = clientX - this.dx;
left = left < 10 ? 0 : this.width - left < 10 ? null : left / this.screenWidth * 100 + '%';
top = clientY - this.dy;
top = top < 10 ? 0 : this.height - top < 10 ? null : top / this.screenHeight * 100 + '%';
right = left === null ? 0 : null;
bottom = top === null ? 0 : null;
style = this.style;
style.left = left;
style.right = right;
style.top = top;
return style.bottom = bottom;
};
touchend = function(e) {
var touch, _i, _len, _ref;
_ref = e.changedTouches;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
touch = _ref[_i];
if (touch.identifier === this.identifier) {
dragend.call(this);
return;
}
}
};
dragend = function() {
if (this.isTouching) {
$Rainb.off(document, 'touchmove', this.move);
$Rainb.off(document, 'touchend touchcancel', this.up);
} else {
$Rainb.off(document, 'mousemove', this.move);
$Rainb.off(document, 'mouseup', this.up);
}
//return $.set("" + this.id + ".position", this.style.cssText);
};
$Rainb.enableDrag=function(){$Rainb.setEventListener(document,"touchstart mousedown",dragstart,".draggable","textarea,button,input,a")}
})();
//(function(){ //UNCOMMENT WHEN READY
function Notice(notice){
var elem=document.getElementById('notice');
if(!elem){
$Rainb.prepend(document.body,$Rainb.el('div',{id:"notice",onclick:"this.parentNode.removeChild(this);"},[$Rainb.el("strong",null,"Notice"),": "+notice]))
}else{
elem.innerHTML="<strong>Notice</strong>: "+notice;
}
}
var topic=null;
$Rainb.rm(document.getElementById('logo').getElementsByTagName('img')[0])
var fold=location.pathname.split('/')[1],body=document.getElementsByTagName('body')[0];
var topic;
$Rainb.till("head",function(){
for(var i=0,l=document.styleSheets.length;i<l;i++){
document.styleSheets[i].disabled=true;
}
for(var i in styles){
styles[i].hide();
}
styles.def.show();
styles.RainbowDash.show();
})
function renod(nodes){for(var i=0,el;i<nodes.length;i++){
if(nodes[i].tagName==="H3"){
el=nodes[i];
$Rainb.rm(el);
$Rainb.prepend(nodes[i],el);
}
}};
function addReply(posts){
for(var i=0,l=posts.length;i<l;i++){
var menu=posts[i].getElementsByClassName('menu')[0];
$Rainb.prepend(menu,$Rainb.el('li',null,[$Rainb.el('a',{href:"#",class:"reply","data-replyto":topic},["Reply"])]))
}};
function ifTopic(){
topic=location.pathname.split('/')[2];
nodes=body.children;
renod(nodes);
var posts=body.querySelectorAll('body>.body');
function refresh(a){
var bod,chil,div=$Rainb.el("div",{__properties:{innerHTML:a.responseText}});
renod((bod=div.getElementsByTagName('body')[0]||div).children);
chil=bod.getElementsByClassName('body')
var i2=posts.length;
pony:while(i2--){
for(var i=0;i<chil.length;i++){
if(chil[i].id==posts[i2].id){
chil=Array.prototype.slice.call(chil,i+1);
addReply(chil);
chil=$Rainb.nodes(chil);
$Rainb.after(posts[i2],chil);
posts=body.querySelectorAll('body>.body');
break pony;
}
}
}
}
window.pagerefresh=refresh;
var timer=240,time=240,interval;
var hue;
$Rainb.add(corner,$Rainb.el("div",{class:"divappear"},[(hue=$Rainb.el("span")),$Rainb.el("div",null,["Segundos que faltan para refrescar la p\xe1gina.",$Rainb.el('button',null,["¡Refrescar ahora!"],[{lstng:"click",cb:function(e){e.preventDefault();$Rainb.HTTP(location.href,{},refresh);timer=time;}}])])]));
function tick(){
hue.innerHTML="-"+timer--;
if(timer<0){
$Rainb.HTTPRequestRetry(location.href,function(){refresh.apply(this,arguments);interval=setInterval(tick,1000);},{},null,0,function(){hue.innerHTML="Error receiving requests, from server, retrying"});timer=time;
clearInterval(interval)
}
}
interval=setInterval(tick,1000);
addReply(posts);
}
var corner;
$Rainb.ready(function(){$Rainb.setEventListener(body,"click",PopUpForm,"a.reply");
corner=$Rainb.el("div",{class:"corner"});
var styleElem;
$Rainb.add(body,$Rainb.el("div",{class:"pagstyle"},["Estilo de p\xe1gina",styleElem=$Rainb.el('select',null,(function(){
var d=[];
for(var i in styles){
if(i!=='def')d.push($Rainb.el("option",null,[i]))
}
return d;
})(),[{lstng:"change",cb:function(e){
styleSwitchto(e.target.value);
}}])]));
$Rainb.add(body,corner);
if(fold=="topic"){
ifTopic();
}else if(fold=="index.php"||fold=="topics"){
var headlines=document.getElementsByTagName('table')[0].getElementsByClassName('topic_headline');
for(var i=0;i<headlines.length;i++){
$Rainb.add(headlines[i],$Rainb.el('span',{class:"topictools"},[$Rainb.el('button',null,["Expandir"]),$Rainb.el('button',{class:"reply","data-replyto":$Rainb.alast(headlines[i].children[0].href.split('/'))},["Responder"])]));
}
};
});
function getForm(asdf){
var div=document.createElement('div');
div.innerHTML=asdf;
return div.getElementsByTagName("form")[0];
}
function CebollaChanPost(reply,text,image,filename){
var lik="http://"+location.hostname+"/new_reply/"+reply,attempts=0;
theForm.sai("Getting form values..");
var c=$Rainb.HTTPRequestRetry(lik,function(a){
var form=getForm(a.responseText);
if(!form){
theForm.sai("ERROR: form not found");
}else{
$Rainb.rm(form.querySelector("[name=\"body\"]"));
$Rainb.rm(form.querySelector("[name=\"image\"]"));
$Rainb.rm(form.querySelector("[name=\"start_time\"]"));
var formdata=new FormData(form);
formdata.append("start_time",(Date.now()/1000)-500|0)
formdata.append("body",text);
formdata.append("post","Post");
if(filename)
formdata.append("image",image,filename);
else formdata.append("image",image);
//setTimeout(
(c=$Rainb.HTTPRequestRetry(lik,function(a){
theForm.posting=false;
var div=$Rainb.el("div",{__properties:{innerHTML:a.responseText}}),error=div.querySelector('#error');
if(error){
theForm.sai("Post error:"+error.outerHTML+error.nextSibling.outerHTML,"red");
return;
}
if(/^New/i.test(div.getElementsByTagName('title')[0].textContent)){
theForm.sai("Error inesperado.. ","red");
};
theForm.sai("Data has been sent! I guess");if(pagerefresh)pagerefresh(a);theForm.replies.shift();theForm.form.reset();theForm.loadForm();},{method:"POST",post:formdata,opts:{onerror:function(){theForm.sai("ERROR, retyring....","organge")}},upCallbacks:{onprogress:function(e){
theForm.sai(e.loaded+"/"+e.total+" ("+((e.loaded*100/e.total))+"%)");
}}
}
))();
//,0);
}},{opts:{onerror:function(){}}},null,0,function(){
theForm.sai("Hmmm, el request no fue respondido, al parecer Cebollachan esta caida (otra vez -.-), no importa. Se seguira intentando :D<br>Numero de intentos: "+(++attempts),"orange");
});
c();
function abort(){c("abort")};
return abort;
};
var theForm={replies:[],postingIn:topic,posting:false,abort:null,poppedup:false,next:function(){
this.currentReply|=0;
this.saveReply();
this.form.reset();
this.currentReply++;
this.loadForm();
this.saveReply();
this.sai((this.currentReply+1)+"/"+this.replies.length);
},previous:function(){
this.currentReply|=0;
if(this.currentReply<=0){this.currentReply=0;return}
this.saveReply();
this.form.reset();
this.currentReply--;
this.sai((this.currentReply+1)+"/"+this.replies.length);
this.loadForm();
},loadForm:function(){
if(this.replies.length<=this.currentReply){
this.imgs.innerHTML='';
return;}
var reply=this.replies[this.currentReply];
this.currentReply|=0;
this.textarea.value=reply.text;
this.textarea.focus();
this.imgs.innerHTML='';
if(reply.image){
var reader=new FileReader();
$Rainb.on(reader,'loadend',function(ev){
$Rainb.add(theForm.imgs,$Rainb.el('img',{src:reader.result,height:90}));
theForm.sai("Los ponies han sido cargados y estan listos para ser posteados :D","rgb(217, 201, 231)")
});
reader.readAsDataURL(reply.image);
}
},replyingTo:null,sai:function(asd,color){if(color){this.say.style.background=color}else{this.say.style.background="yellow"}this.say.innerHTML=asd},currentReply:null,textarea:null,input:null,saveReply:function(){
this.currentReply|=0;
if(!this.replies[this.currentReply]){
this.replies[this.currentReply]=({});
}
this.replies[this.currentReply].text=this.textarea.value;
},postReply:function(){
if(this.posting){
this.abort();
this.posting=false;
this.sai("Has abortado tu post!! ¿Te has equivocado?.. Bien. corrígelo","red");
}else{
var r=this.replies[0];
this.posting=true
if(!this.replyingTo){this.replyingTo=topic}
this.abort=CebollaChanPost(this.replyingTo,r.text,r.image,r.filename);
}
}};
function PopUpForm(e){
//console.log('form has been POPPED out');
e.preventDefault();
if(!theForm.poppedup){
theForm.poppedup=true;
theForm.form=$Rainb.el('form',{class:"floatingform draggable",style:{position:"fixed",bottom:0}},[$Rainb.el("div",null,["Reply here:",$Rainb.el('button',{class:"switcharrow"},['\u25BA'],[{lstng:"click",cb:function(e){e.preventDefault();theForm.next();}}]),$Rainb.el('button',{class:"switcharrow"},['\u25C4'],[{lstng:"click",cb:function(e){e.preventDefault();theForm.previous();}}])]),(theForm.textarea=$Rainb.el("textarea",{name:"body",rows:10,cols:70})),$Rainb.el('br'),(theForm.imgs=$Rainb.el('div',{class:"thmbimg"},null,[{lstng:"click",cb:function(){
theForm.replies[theForm.currentReply].image=null;
theForm.loadForm();
}}])),(theForm.say=$Rainb.el('span',{style:{background:"yellow"}})),$Rainb.el('br'),(theForm.input=$Rainb.el("input",{type:"file",name:"image",multiple:''},null,[{lstng:"change",cb:function(){
theForm.currentReply=theForm.currentReply|0;
for(var i=theForm.currentReply,files=theForm.input.files;i<files.length;i++){
theForm.replies[i]={text:theForm.replies[i]&&theForm.replies[i].text,image:files[i]}
}
theForm.saveReply();
theForm.loadForm();
}}])),$Rainb.el('br'),$Rainb.el("button",null,["Postear Ponis :D"],[{lstng:"click",cb:function(e)
{
e.preventDefault();
//POST MESSAGE
theForm.saveReply();
theForm.postReply();
}}])]);
$Rainb.add(body,theForm.form);
}
theForm.replyingTo=this.dataset.replyto;
var ppar=$Rainb.bubbleFind(this,".body");
if(ppar.id){
$Rainb.ins(theForm.textarea,'@'+ppar.getElementsByTagName('a')[0].textContent.substr(1)+'\n');
}
theForm.textarea.focus();
}
$Rainb.enableDrag();
//}()) //UNCOMMENT WHEN READY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment