From 8733f95d481d341a74d95cd97ecbef39a1f0609f Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Tue, 12 Mar 2013 06:12:24 +0100 Subject: World day against cyber censorship --- public/css/sublab-2012-09-16.css | 444 ------------------------------------- public/css/sublab-2013-03-12.css | 464 +++++++++++++++++++++++++++++++++++++++ public/inc/zensur.js | 169 ++++++++++++++ 3 files changed, 633 insertions(+), 444 deletions(-) delete mode 100644 public/css/sublab-2012-09-16.css create mode 100644 public/css/sublab-2013-03-12.css create mode 100644 public/inc/zensur.js (limited to 'public') diff --git a/public/css/sublab-2012-09-16.css b/public/css/sublab-2012-09-16.css deleted file mode 100644 index 9ad8eda..0000000 --- a/public/css/sublab-2012-09-16.css +++ /dev/null @@ -1,444 +0,0 @@ -* { - font-family: Verdana, Helvetica, sans-serif; - font-size: 12px; - color: #ddd; - } - -iframe.youtube { - margin: 5px 15px 0px 15px; - width: 300px; - height: 235px; - border: 1px solid #444; - } - -iframe.osm { - margin: 5px 15px 0px 15px; - width: 500px; - height: 325px; - border: 1px solid #444; - scroll: no; - } - -body { - background: #000 url(../img/background.jpg) no-repeat fixed center center; - } - -div.frame { - border: 1px solid #aaa; - background-color: rgba(0, 0, 0, 0.75); - margin-left: auto; - margin-right: auto; - min-width: 700px; - max-width: 1500px; - position: relative; - } - -div.hiddenframe { - margin: 50px; - } - -div.logo { - float: left; - height: 150px; - width: 110px; - margin: 5px 5px 5px 5px; - border: 0px solid #222; - background: #000 url(../img/logo.png) no-repeat center center; - } - -div.image { - margin-top: 0px; - margin: 5px; - margin-left: 125px; - border: 1px solid #444; - height: 150px; - background: #000 url(../img/topimage.jpg) no-repeat left bottom; - } - -div.menu { - clear: both; - color: #fff; - border: 1px solid #444; - padding: 5px; - background-color: rgba(16, 16, 16, 0.5); - margin-left: 5px; - position: absolute; - top: 160px; - width: 100px; - min-height: 150px; - } - -div.content { - color: #fff; - border: 1px solid #444; - padding: 5px; - background-color: rgba(16, 16, 16, 0.5); - position: static; - margin: 0px 225px 5px 125px; - top: 160px; - min-height: 120px; - height: 100%; - } - -div.info { - color: #fff; - background-color: rgba(16, 16, 16, 0.5); - border: 1px solid #444; - padding: 5px; - margin-right: 5px; - margin-bottom: 5px; - width: 200px; - position: absolute; - right: 0px; - min-height: 200px; - } - -div.status { - width: 180px; - margin-left: 10px; - margin-right: 10px; - } - -div.footer { - clear: both; - background-color: rgba(16, 16, 16, 0.5); - color: #fff; - border: 1px solid #444; - padding: 5px; - margin: 5px; - text-align: center; - } - -.imagecontent { - clear: both; - float: right; - margin: 5px 10px 5px 10px; - width: 35%; - min-width: 150px; - } - -img { - border: 1px solid #444; - } - -img.webcam { - border: 1px solid #444; - width: 400px; - margin: 5px 5px 0px 15px; - } - -img.logo { - height: 140px; - width: auto; - border: 0px; - } - -img.webcamthumb { - margin: 10px; - border: 1px solid #444; - width: 180px; - height: auto; - } - -.contentimage { - width: 95%; - height: auto; - margin: 0px 5px 0px 5px; - border: 2px solid #444; - } - -img.bigimage { - width: 100%; - max-width: 640px; - margin-left: auto; - margin-right: auto; - display: block; - } - -.floatright { - float: right; - } - -.floatleft { - float: left; - } - -table { - width: 200px; - margin: auto; - } - -hr { - margin: 10px; - color: #ddd; - clear: both; - } - -#menu { - list-style: none; - margin: 5px; - padding: 0px; - } - -#menu a { - text-decoration: none; - font-weight: bold; - line-height: 15px; - border: 0px; - color: #ddd; - } - -#menu a:hover { - text-decoration: none; - font-weight: bold; - color: #fff; - } - -#menu a:active { - text-decoration: none; - font-weight: bold; - color: #bbb; - } - -h1 { - text-align: center; - visibility: hidden; - } - -h3 { - /*clear: both;*/ - font-size: 14px; - text-align: left; - color: #ddd; - line-height: 20px; - margin: 15px 10px 5px 10px; - } - -h4 { - line-height: 25px; - text-align: center; - color: #ddd; - margin-top: 5px; - } - -h2 { - font-size: 18px; - line-height: 40px; - margin-left: 10px; - color: #ddd; - } - -p { - margin: 5px 15px 5px 15px; - color: #ddd; - line-height: 20px; - } - -p.subtext { - color: #ddd; - line-height: 12px; - margin: 2px 5px 5px 15px; - } - -p.header { - text-align: right; - margin: 10px; - } - -span.header { - background-color: rgba(16, 16, 16, 0.75); - padding: 5px 10px 5px 10px; - } - -.statusinfo { - line-height: 20px; - } - -.status { - line-height: 20px; - margin-left: 10px; - margin-right: 10px; - } - -.member { - line-height: 20px; - font-weight: bold; - margin-left: 10px; - margin-right: 10px; - text-align: center; - } - -a { - text-decoration: none; - border-bottom: 1px dotted; - color: #ddd; - } - -a:hover { - text-decoration: none; - color: #fff; - } - -a:active { - text-decoration: none; - color: #bbb; - } - -a.img { - text-decoration: none; - border: 0px; - color: #ddd; - } - -a.img:hover { - text-decoration: none; - color: #bbb; - } - -a.img:active { - text-decoration: none; - color: #999; - } - -span.box { - border: 1px solid #222; - padding: 2px; - } - -.olFramedCloudPopupContent h2 { - color: #000000; - font-size: 14px; - } - -.olFramedCloudPopupContent p { - color: #000000; - font-size: 12px; - } - -.olFramedCloudPopupContent a { - color: #3333FF; - font-size: 14px; - } - -#mapdiv img { - border: 0px; - } - -/* These are for the wiki */ -div.page { - border: none; - margin: 0px; - margin-right: 1em; -} - -.actions ul { - text-align: right; - margin-top: -3px; -} -.actions li { - display: inline; - padding: 2px; - border-style: solid; - border-width: 1px; - border-top-width: 0px; - border-color: #444; - background-color: rgba(16,16,16,0.5); -} - -.actions a { - border-bottom: 0px; -} - -div.pageheader { - margin-left: 10px; -} - -div.pagedate { - text-align: right; -} - -span.title, span.parentlinks, .parentlinks a { - font-size: 18px; - font-weight: bold; - line-height: 40px; -} - -span.title:after { - content: " ]"; -} - -span.parentlinks:before { - content: "[ "; -} - -textarea, input, select { - background-color: #101010; -} - -div.recentchanges { - border-style: solid; - border-width: 1px; - overflow: auto; - width: auto; - clear: none; - background: #404040; -} -.recentchanges .metadata { - padding: 0px 0.5em; -} -.recentchanges .changelog { - font-style: italic; - clear: both; - display: block; - padding: 1px 2px; -} -.recentchanges .desc { - display: none; -} -.recentchanges .diff { - display: none; -} -.recentchanges .committer { - float: left; - margin: 0; - width: 40%; -} -.recentchanges .committype { - float: left; - margin: 0; - width: 5%; - font-size: small; -} -.recentchanges .changedate { - float: left; - margin: 0; - width: 35%; - font-size: small; -} -.recentchanges .pagelinks, -.recentchanges .revert { - float: right; - margin: 0; - width: 60%; -} - -li.menu { - padding: 0px; -} - -li { - padding: 5px; -} - -img.img { - clear: both; - float: right; - margin: 5px 10px 5px 10px; - width: 35%; - height: auto; - min-width: 150px; - } - -.pagefooter { - clear: both; -} diff --git a/public/css/sublab-2013-03-12.css b/public/css/sublab-2013-03-12.css new file mode 100644 index 0000000..68a1a97 --- /dev/null +++ b/public/css/sublab-2013-03-12.css @@ -0,0 +1,464 @@ +* { + font-family: Verdana, Helvetica, sans-serif; + font-size: 12px; + color: #ddd; + } + +.censored { + color: #ddd; + background-color: #ddd; +} + +#zensurinfo { + padding: 0.5em; + position: absolute; + left: 0px; + top: 0px; + right: 0px; + font-size: 1.5em; + font-weight: bold; + color: white; + background-color: red; +} +#zensurinfo * { color: white } +#zensurinfo .censored { color: white; background-color: grey; } +#zensurinfo a, #zensurinfo a:hover, #zensurinfo a:visited { color: yellow } + +iframe.youtube { + margin: 5px 15px 0px 15px; + width: 300px; + height: 235px; + border: 1px solid #444; + } + +iframe.osm { + margin: 5px 15px 0px 15px; + width: 500px; + height: 325px; + border: 1px solid #444; + scroll: no; + } + +body { + background: #000 url(../img/background.jpg) no-repeat fixed center center; + } + +div.frame { + border: 1px solid #aaa; + background-color: rgba(0, 0, 0, 0.75); + margin-left: auto; + margin-right: auto; + min-width: 700px; + max-width: 1500px; + position: relative; + } + +div.hiddenframe { + margin: 50px; + } + +div.logo { + float: left; + height: 150px; + width: 110px; + margin: 5px 5px 5px 5px; + border: 0px solid #222; + background: #000 url(../img/logo.png) no-repeat center center; + } + +div.image { + margin-top: 0px; + margin: 5px; + margin-left: 125px; + border: 1px solid #444; + height: 150px; + background: #000 url(../img/topimage.jpg) no-repeat left bottom; + } + +div.menu { + clear: both; + color: #fff; + border: 1px solid #444; + padding: 5px; + background-color: rgba(16, 16, 16, 0.5); + margin-left: 5px; + position: absolute; + top: 160px; + width: 100px; + min-height: 150px; + } + +div.content { + color: #fff; + border: 1px solid #444; + padding: 5px; + background-color: rgba(16, 16, 16, 0.5); + position: static; + margin: 0px 225px 5px 125px; + top: 160px; + min-height: 120px; + height: 100%; + } + +div.info { + color: #fff; + background-color: rgba(16, 16, 16, 0.5); + border: 1px solid #444; + padding: 5px; + margin-right: 5px; + margin-bottom: 5px; + width: 200px; + position: absolute; + right: 0px; + min-height: 200px; + } + +div.status { + width: 180px; + margin-left: 10px; + margin-right: 10px; + } + +div.footer { + clear: both; + background-color: rgba(16, 16, 16, 0.5); + color: #fff; + border: 1px solid #444; + padding: 5px; + margin: 5px; + text-align: center; + } + +.imagecontent { + clear: both; + float: right; + margin: 5px 10px 5px 10px; + width: 35%; + min-width: 150px; + } + +img { + border: 1px solid #444; + } + +img.webcam { + border: 1px solid #444; + width: 400px; + margin: 5px 5px 0px 15px; + } + +img.logo { + height: 140px; + width: auto; + border: 0px; + } + +img.webcamthumb { + margin: 10px; + border: 1px solid #444; + width: 180px; + height: auto; + } + +.contentimage { + width: 95%; + height: auto; + margin: 0px 5px 0px 5px; + border: 2px solid #444; + } + +img.bigimage { + width: 100%; + max-width: 640px; + margin-left: auto; + margin-right: auto; + display: block; + } + +.floatright { + float: right; + } + +.floatleft { + float: left; + } + +table { + width: 200px; + margin: auto; + } + +hr { + margin: 10px; + color: #ddd; + clear: both; + } + +#menu { + list-style: none; + margin: 5px; + padding: 0px; + } + +#menu a { + text-decoration: none; + font-weight: bold; + line-height: 15px; + border: 0px; + color: #ddd; + } + +#menu a:hover { + text-decoration: none; + font-weight: bold; + color: #fff; + } + +#menu a:active { + text-decoration: none; + font-weight: bold; + color: #bbb; + } + +h1 { + text-align: center; + visibility: hidden; + } + +h3 { + /*clear: both;*/ + font-size: 14px; + text-align: left; + color: #ddd; + line-height: 20px; + margin: 15px 10px 5px 10px; + } + +h4 { + line-height: 25px; + text-align: center; + color: #ddd; + margin-top: 5px; + } + +h2 { + font-size: 18px; + line-height: 40px; + margin-left: 10px; + color: #ddd; + } + +p { + margin: 5px 15px 5px 15px; + color: #ddd; + line-height: 20px; + } + +p.subtext { + color: #ddd; + line-height: 12px; + margin: 2px 5px 5px 15px; + } + +p.header { + text-align: right; + margin: 10px; + } + +span.header { + background-color: rgba(16, 16, 16, 0.75); + padding: 5px 10px 5px 10px; + } + +.statusinfo { + line-height: 20px; + } + +.status { + line-height: 20px; + margin-left: 10px; + margin-right: 10px; + } + +.member { + line-height: 20px; + font-weight: bold; + margin-left: 10px; + margin-right: 10px; + text-align: center; + } + +a { + text-decoration: none; + border-bottom: 1px dotted; + color: #ddd; + } + +a:hover { + text-decoration: none; + color: #fff; + } + +a:active { + text-decoration: none; + color: #bbb; + } + +a.img { + text-decoration: none; + border: 0px; + color: #ddd; + } + +a.img:hover { + text-decoration: none; + color: #bbb; + } + +a.img:active { + text-decoration: none; + color: #999; + } + +span.box { + border: 1px solid #222; + padding: 2px; + } + +.olFramedCloudPopupContent h2 { + color: #000000; + font-size: 14px; + } + +.olFramedCloudPopupContent p { + color: #000000; + font-size: 12px; + } + +.olFramedCloudPopupContent a { + color: #3333FF; + font-size: 14px; + } + +#mapdiv img { + border: 0px; + } + +/* These are for the wiki */ +div.page { + border: none; + margin: 0px; + margin-right: 1em; +} + +.actions ul { + text-align: right; + margin-top: -3px; +} +.actions li { + display: inline; + padding: 2px; + border-style: solid; + border-width: 1px; + border-top-width: 0px; + border-color: #444; + background-color: rgba(16,16,16,0.5); +} + +.actions a { + border-bottom: 0px; +} + +div.pageheader { + margin-left: 10px; +} + +div.pagedate { + text-align: right; +} + +span.title, span.parentlinks, .parentlinks a { + font-size: 18px; + font-weight: bold; + line-height: 40px; +} + +span.title:after { + content: " ]"; +} + +span.parentlinks:before { + content: "[ "; +} + +textarea, input, select { + background-color: #101010; +} + +div.recentchanges { + border-style: solid; + border-width: 1px; + overflow: auto; + width: auto; + clear: none; + background: #404040; +} +.recentchanges .metadata { + padding: 0px 0.5em; +} +.recentchanges .changelog { + font-style: italic; + clear: both; + display: block; + padding: 1px 2px; +} +.recentchanges .desc { + display: none; +} +.recentchanges .diff { + display: none; +} +.recentchanges .committer { + float: left; + margin: 0; + width: 40%; +} +.recentchanges .committype { + float: left; + margin: 0; + width: 5%; + font-size: small; +} +.recentchanges .changedate { + float: left; + margin: 0; + width: 35%; + font-size: small; +} +.recentchanges .pagelinks, +.recentchanges .revert { + float: right; + margin: 0; + width: 60%; +} + +li.menu { + padding: 0px; +} + +li { + padding: 5px; +} + +img.img { + clear: both; + float: right; + margin: 5px 10px 5px 10px; + width: 35%; + height: auto; + min-width: 150px; + } + +.pagefooter { + clear: both; +} diff --git a/public/inc/zensur.js b/public/inc/zensur.js new file mode 100644 index 0000000..d6b4d29 --- /dev/null +++ b/public/inc/zensur.js @@ -0,0 +1,169 @@ +(function() { + // states + // 0: uncensored + // 1: start_censor + // 2: censored + // state transition probabilities: + var p_trans = [ + // x uncensored -> uncensored + 0.08, // uncensored -> start_censor + // 0 uncensored -> censored + // 0 start_censor -> uncensored + // 0 start_censor -> start_censor + // 1 start_censor -> censored + 0.55, // censored -> uncensored + // 0 censored -> start_censor + // x censored -> censored + ]; + var censored_tag = "span"; + var censored_class = "censored"; + var start_censor = "<" + censored_tag + " class=\"" + censored_class + "\">"; + var stop_censor = ""; + var re_censor = /[0-9A-Za-z]/; + var isCensored = true; + var censoredElements = []; + + function splitWords(text) { + // some older IEs don't suppport capturing parentheses + // return text.split(/([\t\n\r ])/); + if (text.length === 0) { + return [""]; + } + var words = []; + var last_i = 0; + for (var i = 0; i < text.length; i++) { + switch(text[i]) { + case '\t': + case '\n': + case '\r': + case ' ': + if (last_i !== i) { + words.push(text.slice(last_i, i)); + } + words.push(text[i]); + last_i = i + 1; + } + } + if (last_i !== text.length) { + words.push(text.slice(last_i)); + } + return words; + } + + function censorWord(state, word) { + // ignore words not containing letters (may be spaces only) + if (!word.match(re_censor)) { + return word; + } + + var r = Math.random(); + var prefix = ""; + var suffix = ""; + + if (state.s === 1) { + // start_censor -> censored + state.s = 2; + prefix = start_censor; + } + + if (state.s === 0 && r < p_trans[0]) { + // uncensored -> start_censor + state.s = 1; + } + else if (state.s === 2 && r < p_trans[1]) { + // censored -> uncensored + state.s = 0; + suffix = stop_censor; + } + + return prefix + word + suffix; + } + + function censorTextNode(node) { + var state = { s: 0 }; + if (Math.random() < p_trans[0]) { + // start_censor + state.s = 1; + } + var words = splitWords(node.nodeValue); + for (var i in words) { + words[i] = censorWord(state, words[i]); + } + if (state.s === 2) { + words[words.length-1] = words[words.length-1] + stop_censor; + } + var newnode = document.createElement(censored_tag); + newnode.innerHTML = words.join(""); + return newnode; + } + + function censorElement(element, on) { + var childs = element.childNodes; + var uncensored = false; + for (var i in childs) { + + if (childs[i].nodeType === 1 && + childs[i].nodeName !== "OPTION" && + childs[i].nodeName !== "SCRIPT" && + childs[i].nodeName !== "SELECT" && + childs[i].nodeName !== "STYLE" && + childs[i].nodeName !== "TEXTAREA" && + childs[i].nodeName !== "TITLE") + { + if (!on && + childs[i].nodeName === censored_tag.toUpperCase() && + childs[i].className === censored_class && + childs[i].childNodes.length === 1) + { + uncensored = true; + element.replaceChild(childs[i].childNodes[0], childs[i]); + } + + var childUncensored = censorElement(childs[i], on); + if (!on && childUncensored) + { + var newnode = document.createTextNode(""); + for (var j in childs[i].childNodes) { + if (!childs[i].childNodes[j].nodeType === 3) { + return; + } + if (childs[i].childNodes[j].nodeValue) { + newnode.nodeValue += childs[i].childNodes[j].nodeValue; + } + } + element.replaceChild(newnode, childs[i]); + } + } + + else if (on && + childs[i].nodeType === 3 && + childs[i].nodeValue.match(re_censor)) + { + element.replaceChild(censorTextNode(childs[i]), childs[i]); + } + + } + + return uncensored; + } + + function doCensor(on) { + for (var i in censoredElements) { + censorElement(censoredElements[i], on); + } + } + + window.zensurjs = function(arg) { + if (arg === undefined) { + isCensored = !isCensored; + doCensor(isCensored); + } + else { + censoredElements.push(arg); + if (isCensored) { + censorElement(arg, true); + } + } + return isCensored; + }; +})(); -- cgit v1.2.1