function startsWith(l,r) { return l.lastIndexOf(r, 0) === 0; } function _bind(o) { return app.service.JSInvoker.wrap(o); } function htmlForTextWithEmbeddedNewlines(text) { var htmls = []; var lines = text.split(/\n/); // The temporary
is to perform HTML entity encoding reliably. // // document.createElement() is *much* faster than jQuery('
') // http://stackoverflow.com/questions/268490/ // // You don't need jQuery but then you need to struggle with browser // differences in innerText/textContent yourself var tmpDiv = jQuery(document.createElement('div')); for (var i = 0 ; i < lines.length ; i++) { htmls.push(tmpDiv.text(lines[i]).html()); } return htmls.join("
"); } function htmlBalance(value) { return $('
').html(value).html(); } function htmlEncode(value){ return $('
').text(value).html(); } function htmlDecode(value){ return $('
').html(value).text(); } function stripNotNiceHTML(html) { // remove the tag html = html.replace(/[\s\S]*<\s*html[\s>]+[\s\S]*?>/gi, ""); // try to remove the head block html = html.replace(/[\s\S]*<\s*\/head[\s>]+[\s\S]*?>/gi, ""); // remove scripting if possible html = html.replace(/<\s*script[\s>]+[\s\S]*?<\s\/script\[\s\S]*?>/gi,""); // remove before the body html = html.replace(/[\s\S]*<\s*body>/gi,"
"); html = html.replace(/[\s\S]*<\s*body\s/gi,"
]+[\s\S]*/gi,"
"); // remove the html tag ender and everyhting aftewards html = html.replace(/<\s*\/html[\s>]+[\s\S]*/gi,""); return html; } function trimQuotes(s) { if (s == null) return null; return s.replace(/^\"*|\"*$/g, ""); } function NOHREF(x) { var result = "" + x; result = result.replace(/__HREF/g, 'href="javascript:void(0)"'); return result; } function log() {} function logFormatDate () { var d = new Date(); return "" + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + "." + d.getMilliseconds(); } function log_() { var out = [ logFormatDate() + ":" ]; for (var i=0; i