Repository navigation
Expand file tree
/
Copy path1.min.html
More file actions
1 lines (1 loc) · 4.52 KB
/
Copy path1.min.html
File metadata and controls
1 lines (1 loc) · 4.52 KB
1
<!DOCTYPE html><html><head><title>Total.js Code Editor</title><meta charset="utf-8" /><meta http-equiv="X-UA-Compatible" content="IE=11" /><meta name="format-detection" content="telephone=no" /><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /><meta name="robots" content="all,follow" /><link href="1.min.css" rel="stylesheet" type="text/css" /><script src="1.min.js"></script></head><body><div id="TOTALEDITOR"></div><script>common.version=1;common.callbackid=1;common.callbacks={};common.init=false;function PROCESS(msg){if(!msg)return;if(msg.TYPE==='init'){if(common.init){var history=EDITOR.doc.history;history.done.pop();history.done.pop()}EDITOR.Total.realtime=!!msg.realtime;EDITOR.Total.upload=msg.upload||'';EDITOR.Total.readonly(!!msg.readonly);EDITOR.Total.keywords_search=msg.keywords?new RegExp('.('+msg.keywords.replace(/\,/g,'|')+').'):null;EDITOR.Total.keywords=msg.keywords?msg.keywords.split(/\,/g):null;EDITOR.setOption('mode',msg.mode);EDITOR.setOption('lint',msg.lint===false?false:(msg.mode==='javascript'||msg.mode==='xml'||msg.mode==='clientside'||msg.mode==='serverside'||msg.mode==='html'?{esversion:8,expr:true,evil:true,unused:true,shadow:true,node:true,browser:true}:false));EDITOR.setOption('matchBrackets',true);EDITOR.setOption('lineWrapping',msg.mode==='markdown');var tmp=msg.linenumbers;EDITOR.setOption('lineNumbers',tmp!==false&&tmp!==0);EDITOR.setOption('highlightSelectionMatches',{annotateScrollbar:true,delay:100});EDITOR.setValue(msg.body||msg.value||'');EDITOR.refresh();EDITOR.scrollTo(0,0);EDITOR.setCursor(0);var b=document.body;if(msg.darkmode)b.classList.add('ui-dark');else b.classList.remove('ui-dark');common.init=true;common.id=msg.id;common.docid=msg.docid;return}if(msg.TYPE==='replace'){var val=EDITOR.getValue();var index=null;while(index!==-1){index=val.indexOf(msg.text||msg.value,index||0);if(index!==-1)val=val.substring(0,index)+msg.to+val.substring(index+msg.text.length)}EDITOR.keepdiff=true;EDITOR.setValue(val);return}if(msg.TYPE==='setoption'){EDITOR.setOption(msg.name||msg.key||msg.id,msg.value);return}if(msg.TYPE==='keywords'){EDITOR.Total.keywords=msg.keywords?new RegExp('.('+msg.keywords.replace(/\,/g,'|')+').'):null;EDITOR.refresh();return}if(msg.TYPE==='readonly'){EDITOR.Total.readonly(msg.value);return}if(msg.TYPE==='darkmode'){if(msg.value)b.classList.add('ui-dark');else b.classList.remove('ui-dark');return}if(msg.TYPE==='change'){var history=EDITOR.doc.history.done,arr=msg.value;if(arr instanceof Array){EDITOR.Total.realtime=false;for(var item of arr){EDITOR.replaceRange(item.text,item.from,item.to);history.pop();history.pop()}EDITOR.Total.realtime=true}return}if(msg.TYPE==='insert'){msg.value&&EDITOR.replaceSelection(msg.value);return}if(msg.TYPE==='replacerange'){msg.value&&EDITOR.replaceRange(msg.value,msg.from?CodeMirror.Pos(msg.from):undefined,msg.to?CodeMirror.Pos(msg.to):undefined);return}if(msg.TYPE==='replaceselections'){msg.value&&EDITOR.replaceSelections(msg.value);return}if(msg.TYPE==='replaceselection'){msg.value&&EDITOR.replaceSelection(msg.value);return}if(msg.TYPE==='change'){EDITOR.replaceRange(msg.value,msg.from,msg.to);var history=EDITOR.doc.history.done;history.pop();history.pop();return}if(msg.TYPE==='marker'){EDITOR.Total.marker(msg.value,msg.from,msg.to,msg.color);return}if(msg.TYPE==='focus'){W.focus();EDITOR.focus();return}if(msg.TYPE==='command'){EDITOR.focus();EDITOR.execCommand(msg.value);return}if(msg.TYPE==='exec'){document.execCommand(msg.a,msg.b,msg.c);return}if(msg.TYPE==='search'){var cursor=EDITOR.getSearchCursor(msg.value);var output=[];while(cursor.findNext())output.push({from:cursor.from(),to:cursor.to()});SEND({TYPE:'search',callbackid:msg.callbackid,value:output})}if(msg.TYPE==='select'){var cur=EDITOR.getCursor();EDITOR.setCursor(msg.from);EDITOR.centerLine(msg.from.line);EDITOR.focus();if(msg.to&&msg.to.line===cur.line)EDITOR.setSelection(EDITOR.getCursor(),msg.to);return}if(msg.TYPE==='goto'){msg.value&&EDITOR.self.gotoline(msg.value);return}if(msg.TYPE==='eval'){msg.value&&(new Function(msg.value)(EDITOR));return}if(msg.TYPE==='clear'){EDITOR.Total.self.clear();return}if(msg.TYPE==='body'){SEND({TYPE:'body',callbackid:msg.callbackid,value:EDITOR.getValue()});return}if(msg.callbackid){var callback=common.callbacks[msg.callbackid];if(callback){delete common.callbacks[msg.callbackid];setTimeout(callback,2,msg)}}}W.addEventListener('click',function(){SEND({TYPE:'click'})});W.addEventListener('message',function(e){e.data&&PROCESS(typeof(e.data)==='string'?JSON.parse(e.data):e.data)});INIT_EDITOR(TOTALEDITOR);</script></body></html>