Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Preliminary support for bold/italic text

  • Loading branch information...
commit f7c6abf823c6d849c344b52cc8fcedf1df58eb5e 1 parent 38cc23a
@dfabulich authored
Showing with 21 additions and 6 deletions.
  1. +15 −2 web/ui.js
  2. +6 −4 xmltranslator.js
View
17 web/ui.js
@@ -22,8 +22,21 @@ function printx(msg, parent) {
if (msg == null) return;
if (msg === "") return;
if (!parent) parent = document.getElementById('text');
- var text = window.document.createTextNode(msg);
- parent.appendChild(text);
+ msg = (msg+"").replace(/&/g, '&')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/"/g, '&quot;')
+ .replace(/\[b\]/g, '<b>')
+ .replace(/\[\/b\]/g, '</b>')
+ .replace(/\[i\]/g, '<i>')
+ .replace(/\[\/i\]/g, '</i>')
+ var frag = document.createDocumentFragment();
+ temp = document.createElement('div');
+ temp.innerHTML = msg;
+ while (temp.firstChild) {
+ frag.appendChild(temp.firstChild);
+ }
+ parent.appendChild(frag);
}
function println(msg, parent) {
View
10 xmltranslator.js
@@ -38,11 +38,13 @@ function xmlEscape(str, attribute) {
var result = "" + str;
result = result.replace(/&/g, "&amp;");
if (attribute) {
- result = result.replace(/'/g, "&apos;");
- result = result.replace(/"/g, "&quot;");
+ result = result.replace(/'/g, "&apos;").replace(/"/g, "&quot;");
} else {
- result = result.replace(/</g, "&lt;");
- result = result.replace(/>/g, "&gt;");
+ result = result.replace(/</g, "&lt;").replace(/>/g, "&gt;")
+ .replace(/\[b\]/g, '<b>')
+ .replace(/\[\/b\]/g, '</b>')
+ .replace(/\[i\]/g, '<i>')
+ .replace(/\[\/i\]/g, '</i>');
}
return result;
}
Please sign in to comment.
Something went wrong with that request. Please try again.