-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
91 lines (79 loc) · 2.74 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled</title>
<link href="lib/editor/codemirror.css" rel="stylesheet">
<script src="lib/editor/codemirror.js"></script>
<script src="lib/editor/mode/javascript/javascript.js"></script>
<script src="app/index.js"></script>
<style>
.CodeMirror {
height: 100% !important;
}
body {
margin: 0;
height: 100% !important;
padding: 0;
overflow: auto;
}
html {
margin: 0;
height: 100%;
width: 100%;
overflow: hidden;
}
</style>
</head>
<body>
<iframe id="iframe_0" src="about:blank" width="0" height="0" border="0" tabindex="-1" title="" style="display:none"></iframe>
<iframe id="iframe_1" src="about:blank" width="0" height="0" border="0" tabindex="-1" title="" style="display:none"></iframe>
<script>
var nextFrame = 0,
currentFrame = 0,
eval_delay = 1000,
timeout = 0,
plugins = [],
library = [],
iframe_0 = document.getElementById('iframe_0'),
iframe_1 = document.getElementById('iframe_1'),
iframeArr = [iframe_0,iframe_1];
//insert all the theme CSS
insertCSS();
//load the the plugins and cache them
plugins=loadPlugins();
//load the library js
library=loadLibrary();
var crackedEditor = CodeMirror(document.body, {
mode: "javascript",
autofocus:true,
theme:"rubyblue"
});
window.onfocus = function() {
crackedEditor.focus();
};
crackedEditor.on("changes",function(){
clearTimeout(timeout);
timeout = setTimeout(evalEditor,eval_delay);
});
function evalEditor() {
try {
currentFrame = nextFrame;
nextFrame = !nextFrame ? 1 : 0;
setTimeout(function(){
//reload the currently running iframe
iframeArr[currentFrame].src ="about:blank";
iframeArr[nextFrame].contentWindow.eval(library.join(" ; ")+" ; "+plugins.join(" ; ")+" ; "+crackedEditor.getDoc().getValue());
},0);
} catch(e) {
//console.log(e);
}
if(!crackedEditor.getDoc().isClean()) {
document.title=(document.title.match(/ \[Edited\]/)) ? document.title : document.title + " [Edited]";
} else {
document.title=(document.title.match(/ \[Edited\]/)) ? document.title.replace(/ \[Edited\]/,"") : document.title;
}
}
</script>
</body>
</html>