remove unused functions from render/main.js

better comments
pull/1/head
ansuz 9 years ago
parent 317abf36f3
commit 3cffdc982f

@ -31,13 +31,9 @@ define([
var $textarea = $('textarea'), var $textarea = $('textarea'),
$target = $('#target'); $target = $('#target');
var stripScripts = function (md) {
return md.replace(/<[\s\S]*?script[\s\S]*?>[\s\S]*?<\/script[\s\S]*?>/ig, "");
};
window.$textarea = $textarea; window.$textarea = $textarea;
// set markdwon rendering options // set markdown rendering options :: strip html to prevent XSS
Marked.setOptions({ Marked.setOptions({
sanitize: true sanitize: true
}); });
@ -50,8 +46,7 @@ define([
var Previous = Convert.dom.to.vdom(inner); var Previous = Convert.dom.to.vdom(inner);
return function (md) { return function (md) {
// strip scripts or people get xss var rendered = Marked(md||"");
var rendered = stripScripts(Marked(md||""));
// make a dom // make a dom
var R = $('<div id="inner">'+rendered+'</div>')[0]; var R = $('<div id="inner">'+rendered+'</div>')[0];
var New = Convert.dom.to.vdom(R); var New = Convert.dom.to.vdom(R);
@ -90,8 +85,6 @@ define([
}; };
}()); }());
var redrawTimeout;
var $inner = $('#inner'); var $inner = $('#inner');
window.makeRainbow = false window.makeRainbow = false
@ -105,6 +98,7 @@ define([
.addClass('untouched'); .addClass('untouched');
}; };
var redrawTimeout;
var lazyDraw = function (md) { var lazyDraw = function (md) {
redrawTimeout && clearTimeout(redrawTimeout); redrawTimeout && clearTimeout(redrawTimeout);
redrawTimeout = setTimeout(function () { redrawTimeout = setTimeout(function () {
@ -118,15 +112,14 @@ define([
Config.websocketURL, // websocketUrl Config.websocketURL, // websocketUrl
Crypto.rand64(8), // userName Crypto.rand64(8), // userName
key.channel, // channel key.channel, // channel
key.cryptKey, key.cryptKey, // cryptkey
null, null, // docBody
function (){ function (){ // onChange received
lazyDraw($textarea.val()); lazyDraw($textarea.val());
}); // cryptKey });
return rt; return rt;
})[0]; })[0];
//rts.onEvent
window.rts = rts; window.rts = rts;
$textarea.on('change keyup keydown', function () { $textarea.on('change keyup keydown', function () {

Loading…
Cancel
Save