()
| 116 | },false); |
| 117 | |
| 118 | function highlight(){ |
| 119 | if(customInput){ |
| 120 | selStr=prompt("Input code here",""); |
| 121 | if(!selStr)return; |
| 122 | codes=selStr.replace(/&/g, "&").replace(/\</g,"<").replace(/\>/g,">"); |
| 123 | } |
| 124 | let html='<title>Code Snippet</title>'+ |
| 125 | '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.css"/>'+ |
| 126 | '<script>var code,codeStr;window.onload=function(){code=document.querySelector("#code");codeStr=code.innerHTML.replace(/ /g, " ").replace(/&/g, "&").replace(/&(nbsp;|amp;|#39;|quot;)/g, "&$1");prettyPrint();'+ |
| 127 | 'document.querySelector("#js").onclick=function(){'+ |
| 128 | 'code.innerHTML=js_beautify('+ |
| 129 | 'codeStr.replace(/>/g, \'>\').replace(/</g, \'<\').replace(/\'(\\\\\'|[^\'])*?\'/g, function(word){'+ |
| 130 | 'return word.replace(/>/g, \'>\').replace(/</g, \'<\');}'+ |
| 131 | ').replace(/\"(\\\\\"|[^\"])*?\"/g, function(word){'+ |
| 132 | 'return word.replace(/>/g, \'>\').replace(/</g, \'<\');}'+ |
| 133 | '));code.className=\'prettyprint linenums\';prettyPrint();return false;'+ |
| 134 | '};}</script>'+ |
| 135 | '<script src="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.js?skin=sons-of-obsidian"></script>'+ |
| 136 | '<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.6.4/beautify.min.js"></script>'+ |
| 137 | '<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.6.4/beautify-html.min.js"></script>'+ |
| 138 | '<script src="https://cdnjs.cloudflare.com/ajax/libs/js-beautify/1.6.4/beautify-css.min.js"></script>'+ |
| 139 | 'Code formatting: <a id="js" href="#">Javaspcript</a> '+ |
| 140 | '<a href="#" onclick="code.innerHTML=html_beautify(codeStr);code.className=\'prettyprint linenums\';prettyPrint();return false;">Html</a> '+ |
| 141 | '<a href="#" onclick="code.innerHTML=css_beautify(codeStr);code.className=\'prettyprint linenums\';prettyPrint();return false;">Css</a> '+ |
| 142 | '<a href="#" onclick="code.innerHTML=codeStr;code.className=\'prettyprint linenums\';prettyPrint();return false;">Raw</a> <b style="color:red">('+selStr.replace(/\s/g,"").length+' words)</b>'+ |
| 143 | '<pre id="code" class="prettyprint linenums" style="word-wrap: break-word; white-space: pre-wrap;border: 1px solid rgb(136, 136, 204);border-radius: 8px;">' + codes + "</pre>"; |
| 144 | |
| 145 | let c = _unsafeWindow.open("", "_blank", "width=750, height=400, location=0, resizable=1, menubar=0, scrollbars=0"); |
| 146 | c.document.write(html); |
| 147 | c.document.close(); |
| 148 | } |
| 149 | function hideIcon(){ |
| 150 | codeIcon.style.opacity=0; |
| 151 | customInput=false; |
no test coverage detected