-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstoryeditor.htm
More file actions
37 lines (34 loc) · 1.32 KB
/
Copy pathstoryeditor.htm
File metadata and controls
37 lines (34 loc) · 1.32 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<script src="ckeditor/ckeditor.js"></script>
</head>
<body onload="init()">
<textarea class="ckeditor" id="editor1" name="editor1"></textarea>
<script>
function init() // WHEN PAGE LOADED
{
if (window.addEventListener) // If supported this way
window.addEventListener("message",shivaEventHandler,false); // Add event handler
else // Use other method
window.attachEvent("message",shivaEventHandler); // Add handler
CKEDITOR.on('instanceLoaded', function(e) { // When loaded
e.editor.resize("100%", window.innerHeight-34); // Resize editor
CKEDITOR.instances.editor1.on('change', function(e) { window.parent.postMessage("StoryEdit=changed","*"); }); // Send change message
});
}
function shivaEventHandler(e) // ON EVENT
{
if (e.data && e.data.match(/INS:/)) { // Insert macro
CKEDITOR.instances.editor1.insertText(e.data.substring(4)); // Insert text
}
else if (e.data && e.data.match(/PUT:/)) // Put
CKEDITOR.instances.editor1.setData(e.data.substring(4)); // Set html
else if (e.data && e.data.match(/GET:/)) { // Get
e.source.postMessage("StoryEdit="+CKEDITOR.instances.editor1.getData(e.data.substring(4)),"*");
}
}
</script>
</body>
</html>