summaryrefslogtreecommitdiff
path: root/js/common.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2018-12-08 09:32:14 +0300
committerAndrew Dolgov <[email protected]>2018-12-08 09:32:14 +0300
commitbd66a9ef28ddf25e014e852e5ee770868f619aaa (patch)
tree1e101b88ff13c1aaeaaa743a1c582a828327a90c /js/common.js
parent41e967136f6391ff6d7a7c20af47dc434d853099 (diff)
render article on the client using headlines data
Diffstat (limited to 'js/common.js')
-rwxr-xr-xjs/common.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/js/common.js b/js/common.js
index 00bac636b..788c159fe 100755
--- a/js/common.js
+++ b/js/common.js
@@ -331,3 +331,16 @@ function popupOpenArticle(id) {
w.location = "backend.php?op=article&method=view&mode=raw&html=1&zoom=1&id=" + id + "&csrf_token=" + App.getInitParam("csrf_token");
}
}
+
+// htmlspecialchars()-alike for headlines data-content attribute
+function escapeHtml(text) {
+ const map = {
+ '&': '&amp;',
+ '<': '&lt;',
+ '>': '&gt;',
+ '"': '&quot;',
+ "'": '&#039;'
+ };
+
+ return text.replace(/[&<>"']/g, function(m) { return map[m]; });
+} \ No newline at end of file