From d1da6ed6b0a6911c3b24e012ea051c9253ce8479 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 10 Dec 2018 22:43:10 +0100 Subject: pull in dulldream celery server --- server/app/static/js/util.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 server/app/static/js/util.js (limited to 'server/app/static/js/util.js') diff --git a/server/app/static/js/util.js b/server/app/static/js/util.js new file mode 100644 index 00000000..851f634a --- /dev/null +++ b/server/app/static/js/util.js @@ -0,0 +1,32 @@ +var is_iphone = (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) +var is_ipad = (navigator.userAgent.match(/iPad/i)) +var is_android = (navigator.userAgent.match(/Android/i)) +var is_mobile = is_iphone || is_ipad || is_android +var is_desktop = ! is_mobile; + +document.body.parentNode.classList.add(is_desktop ? 'desktop' : 'mobile') + +function preventDefault(e){ + e.preventDefault() + e.stopPropagation() +} + +var decodeEntities = (function() { + // this prevents any overhead from creating the object each time + var element = document.createElement('div'); + + function decodeHTMLEntities (str) { + if(str && typeof str === 'string') { + // strip script/html tags + str = str.replace(/]*>([\S\s]*?)<\/script>/gmi, ''); + str = str.replace(/<\/?\w(?:[^"'>]|"[^"]*"|'[^']*')*>/gmi, ''); + element.innerHTML = str; + str = element.textContent; + element.textContent = ''; + } + + return str; + } + + return decodeHTMLEntities; +})(); \ No newline at end of file -- cgit v1.2.3-70-g09d2