forked from rsms/webkit-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
147 lines (134 loc) · 4.72 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Editor</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"
></script>
<link rel="stylesheet" href="index.less" type="text/less" media="screen">
<script src="less.js"></script>
<script>
if (document.location.search.indexOf('without-prettify') === -1) {
document.write('<'+'script src="prettify.js">'+'<'+'/script>');
}
</script>
<script src="main.js"></script>
</head>
<body>
<div id="compat-disclaimer">
<h2>Euhm</h2>
<p>
I'm sorry, but this little experiment only functions properly in
Safari 4 or Chrome.
</p>
<p><small>
<a href="?no-client-check">Try it anyway</a>
</small></p>
</div>
<block id="header">
<buffer-name>*Example*</buffer-name>
</block>
<window id="main">
<gutter class="left">
<line-numbers>1</line-numbers>
</gutter>
<pre contenteditable="true" tabindex="0" class="prettyprint lang-js">var sys = require('sys');
var events = require("events"),
Buffer = require('buffer').Buffer;
// execute fn (in the local process), finalized by invocation of callback
function execute(ctx, fn, callback) {
var result;
try {
result = fn(ctx, callback);
} catch (err) {
// fn caused some trouble
return callback(err);
}
if (result === callback || result === exports.LATER) {
// fn is async and will invoke callback when done
return callback;
} else if (result === undefined) {
// undefined (no) return value means the context is to be returned
result = ctx;
}
callback(null, result);
}
exports.LATER = 1;
if (!Array.prototype.map) {
Array.prototype.map = function(fun /*, thisp*/) {
var len = this.length >>> 0;
var res = new Array(len);
var thisp = arguments[1];
for (var i = 0; i < len; i++) {
if (i in this) {
res[i] = fun.call(thisp, this[i], i, this);
}
}
return res;
};
}
if (!Array.prototype.filter) {
Array.prototype.filter = function (block /*, thisp */) {
var values = [];
var thisp = arguments[1];
for (var i = 0; i < this.length; i++) {
if (block.call(thisp, this[i])) {
values.push(this[i]);
}
}
return values;
};
}
</pre>
</window>
<block id="minibuffer">
→ <input type="text" value="">
<a href="http://github.com/rsms/webkit-editor">webkit-editor</a>
</block>
<x id="help-buffer" style="display:none">webkit-editor
<hr>
This is a very simple and experimental text editor which runs in >=Safari 4.
<b>Editing</b>
The editor works almost like other rich text editors in OS X, except that
undo/redo will be unavailable when Google Prettify is enabled, since it messes
up undo/redo.
<em>Special key bindings</em>
<samp>TAB</samp> Inserts two spaces to the left of the cursor
<samp>ESC</samp> Escape from command line (restore focus to buffer)
<samp>CTRL c</samp> Jump to command line (press <samp>ESC</samp> to leave)
<b>Command line</b>
At the bottom of the editor is an interactive command line which can be used
to issue commands and modify the editor.
The command line keeps a history which can be navigated in by pressing the up
and down arrow keys. You can clear the history using the <samp>clear-history</samp>
command.
<em>Commands</em>
<samp>help</samp> Display this help buffer
<samp>mode [{mode}]</samp> Read or set-and-read buffer mode (e.g. "js" or "cc")
<samp>eval {javascript}</samp> Evaluate JavaScript
<samp>clear-buffer</samp> Clear the buffer
<samp>new-buffer</samp> New, empty buffer
<samp>prettify disable|enable</samp><imark>↩</imark>
Disable or enable Google Prettify (syntax highlighting)
<samp>load-url {url}</samp> Load {url} into a new buffer
<samp>clear-history</samp> Clear command line history
<b>JavaScript API</b>
-- TODO: work in progress --
<samp>editor.commands</samp> -> {name: function}
<b>This is free, experimental software</b>
You can find the latest source at <a href="http://github.com/rsms/webkit-editor">http://github.com/rsms/webkit-editor</a>
Released under MIT, Copyright (c) 2010 Rasmus Andersson <<a href="http://hunch.se/">http://hunch.se/</a>>
</x>
<script>
if (document.location.search.indexOf('no-client-check') === -1) {
$(function(){
if (navigator.userAgent.indexOf('Safari') === -1) {
var e = $('#compat-disclaimer').clone().css('display', 'block');
$('body').empty().append(e);
}
//editor.commands['load-url']('http://hunch.se/');
});
}
</script>
</body>
</html>