corrade-nucleus-nucleons – Blame information for rev 2
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
2 | office | 1 | <!DOCTYPE html> |
2 | |||
3 | <html lang="en"> |
||
4 | <head> |
||
5 | <meta charset="utf-8"> |
||
6 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
||
7 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
||
8 | <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> |
||
9 | <meta name="description" content="Corrade Nucleon"> |
||
10 | <meta name="author" content="Wizardry and Steamworks"> |
||
11 | <link rel="icon" href="favicon.ico"> |
||
12 | |||
13 | <title>Corrade Nucleus - LSL Scripting Environment</title> |
||
14 | |||
15 | <!-- Bootstrap core CSS --> |
||
16 | <link href="/bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" type="text/css"> |
||
17 | <!-- Corrade Nucleus Fonts --> |
||
18 | <link href="/css/nucleus/fonts.css" rel="stylesheet" type="text/css"> |
||
19 | <!-- Customized Nucleus style. --> |
||
20 | <link href="/css/nucleus/nucleus.css" rel="stylesheet" type="text/css"> |
||
21 | <!-- Script Kiddie style. --> |
||
22 | <link href="/script-kiddie/css/style.css" rel="stylesheet" type="text/css"> |
||
23 | |||
24 | <!-- Bootstrap Toggle --> |
||
25 | <link href="/script-kiddie/bower_components/bootstrap-toggle/css/bootstrap-toggle.min.css" rel="stylesheet" type="text/css"> |
||
26 | |||
27 | </script> |
||
28 | </head> |
||
29 | |||
30 | <body> |
||
31 | <!-- Dialog Modal --> |
||
32 | <div id="popup" class="modal fade bs-example-modal-lg" role="dialog"> |
||
33 | <div class="modal-dialog modal-lg"> |
||
34 | <!-- Modal content--> |
||
35 | |||
36 | <div class="modal-content"> |
||
37 | <div class="modal-header"> |
||
38 | <button type="button" class="close" data-dismiss="modal">×</button> |
||
39 | |||
40 | <h1 id="title" class="modal-title"></h1> |
||
41 | </div> |
||
42 | |||
43 | <div id="content" class="modal-body"> |
||
44 | <div class="progress"> |
||
45 | <div id="progressbar" class="progress-bar" role="progressbar" aria-valuenow="2" aria-valuemin="0" aria-valuemax="100" style="min-width: 2em; width: 2%;"> |
||
46 | 0% |
||
47 | </div> |
||
48 | </div> |
||
49 | |||
50 | <div class="modal-footer"> |
||
51 | <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> |
||
52 | </div> |
||
53 | </div> |
||
54 | </div> |
||
55 | </div> |
||
56 | </div> |
||
57 | |||
58 | <div class="container"> |
||
59 | <div class="jumbotron"> |
||
60 | <h1>Corrade Script Kiddie</h1> |
||
61 | <p class="lead">Script Kiddie is an LSL editor using Corrade as a backend for developing scripts.</p> |
||
62 | <img src="script-kiddie/img/script-kiddie.png"></div> |
||
63 | |||
64 | <!-- <div id="drag-1" class="draggable"> |
||
65 | <p> You can drag one element </p> |
||
66 | </div> --> |
||
67 | |||
68 | <div id="editor-panel" class="panel panel-default draggable movable"> |
||
69 | <div class="panel-heading"> |
||
70 | <form id="script-tools" class="form-inline" data-toggle="validator" onSubmit="event.preventDefault();"> |
||
71 | <div class="input-group"> |
||
72 | <span class="input-group-btn"> |
||
73 | <button id="compile-script" class="btn btn-default check-image checkButton" type="button" title="Compile script.">Compile</button> |
||
74 | <button id="tidy-script" class="btn btn-default" type="button" title="Tidy source-code.">Cleanup</button> |
||
75 | </span> |
||
76 | </div> |
||
77 | <div class="form-group has-feedback"> |
||
78 | <div class="input-group"> |
||
79 | <span class="input-group-btn"> |
||
80 | <input id="store-script" type="checkbox" data-toggle="toggle" data-on="Store" data-off="No Store" data-onstyle="success" disabled="disabled"> |
||
81 | </span> |
||
82 | <input id="script-name" type="text" class="form-control" placeholder="Script Name" aria-describedby="basic-addon1" required> |
||
83 | <span class="input-group-addon">-</span> |
||
84 | <input id="script-UUID" type="text" class="form-control" aria-describedby="basic-addon2" size="36" readonly> |
||
85 | </div> |
||
86 | </div> |
||
87 | </form> |
||
88 | </div> |
||
89 | <div class="panel-body" id="editorpanel"> |
||
90 | <div id="editor" style="height: 500px;">default |
||
91 | { |
||
92 | state_entry() |
||
93 | { |
||
94 | llSay(0, "Hello, Avatar!"); |
||
95 | } |
||
96 | |||
97 | touch_start(integer total_number) |
||
98 | { |
||
99 | llSay(0, "Touched."); |
||
100 | } |
||
101 | } |
||
102 | </div> |
||
103 | </div> |
||
104 | </div> |
||
105 | |||
106 | <div id="error-panel" class="panel panel-default draggable movable"> |
||
107 | <div class="panel-heading"> |
||
108 | <p>Compilation Errors</p> |
||
109 | </div> |
||
110 | <div class="panel-body" id="errorpanel"> |
||
111 | <div id="errors"> |
||
112 | <textarea id="message" class="form-control" rows="5" style="min-width: 100%; max-width: 100%; font-family: monospace; display: none;" readonly></textarea> |
||
113 | </div> |
||
114 | </div> |
||
115 | </div> |
||
116 | |||
117 | </div> <!-- /container --> |
||
118 | |||
119 | <footer class="footer"> |
||
120 | <p>© 2017 Wizardry and Steamworks</p> |
||
121 | </footer> |
||
122 | |||
123 | <!-- jQuery --> |
||
124 | <script src="/bower_components/jquery/dist/jquery.min.js" type="text/javascript"></script> |
||
125 | <!-- Bootstrap Javascript --> |
||
126 | <script src="/bower_components/bootstrap/dist/js/bootstrap.min.js" type="text/javascript"></script> |
||
127 | <!-- Bootstrap Validator --> |
||
128 | <script src="/script-kiddie/bower_components/bootstrap-validator/dist/validator.min.js" type="text/javascript"></script> |
||
129 | <!-- Bootstrap Toggle --> |
||
130 | <script src="/script-kiddie/bower_components/bootstrap-toggle/js/bootstrap-toggle.min.js" type="text/javascript"></script> |
||
131 | <!-- ACE --> |
||
132 | <script type="text/javascript" src="/script-kiddie/bower_components/ace-builds/src-min-noconflict/ace.js"></script> |
||
133 | <script type="text/javascript" src="/script-kiddie/bower_components/ace-builds/src-min-noconflict/ext-language_tools.js"></script> |
||
134 | <!-- Beautify.JS --> |
||
135 | <script type="text/javascript" src="/script-kiddie/bower_components/js-beautify/js/lib/beautify.js"></script> |
||
136 | <!-- Velocity --> |
||
137 | <script type="text/javascript" src="/script-kiddie/bower_components/velocity/velocity.min.js"></script> |
||
138 | <!-- Interact JS --> |
||
139 | <script type="text/javascript" src="/script-kiddie/bower_components/interactjs/dist/interact.min.js"></script> |
||
140 | <!-- CryptoJS --> |
||
141 | <script src="/bower_components/cryptojslib/components/core.js" type="text/javascript"></script> |
||
142 | <script src="/bower_components/cryptojslib/components/enc-base64-min.js" type="text/javascript"></script> |
||
143 | <!-- Wizardry and Steamworks JavaScript Includes --> |
||
144 | <script src="/js/was/csv.js" type="text/javascript"></script> |
||
145 | <script src="/js/was/jquery/arrays.js" type="text/javascript"></script> |
||
146 | <script> |
||
147 | $(document).ready(() => { |
||
148 | // Auto-complete. |
||
149 | ace.require("ace/ext/language_tools"); |
||
150 | |||
151 | // Create the editor. |
||
152 | var editor = ace.edit("editor"); |
||
153 | editor.setTheme("ace/theme/twilight"); |
||
154 | editor.getSession().setMode("ace/mode/lsl"); |
||
155 | editor.setOptions({ |
||
156 | enableBasicAutocompletion: true, |
||
157 | enableSnippets: false, |
||
158 | enableLiveAutocompletion: true |
||
159 | }); |
||
160 | |||
161 | // Get the script from the storage. |
||
162 | var storeScriptText = localStorage.getItem("nucleus-script-kiddie.lsl"); |
||
163 | if (typeof value == "string") |
||
164 | editor.getSession().setValue(storeScriptText); |
||
165 | |||
166 | function compile(lsl) { |
||
167 | // Set the editor to read-only. |
||
168 | editor.setReadOnly(true); |
||
169 | |||
170 | // Set the button image. |
||
171 | $('#compile-script').removeClass("check-image"); |
||
172 | $('#compile-script').removeClass("checkButton"); |
||
173 | |||
174 | $('#compile-script').removeClass("cross-image"); |
||
175 | $('#compile-script').removeClass("crossButton"); |
||
176 | |||
177 | $('#compile-script').addClass("activity-image"); |
||
178 | $('#compile-script').addClass("activityButton"); |
||
179 | |||
180 | $.ajax({ |
||
181 | type: 'POST', |
||
182 | url: '/', |
||
183 | data: { |
||
184 | command: 'compilescript', |
||
185 | data: lsl |
||
186 | }, |
||
187 | dataType: 'json' |
||
188 | }).done(function(response) { |
||
189 | // Set the editor to read-enabled. |
||
190 | editor.setReadOnly(false); |
||
191 | |||
192 | if(response.success === "True") { |
||
193 | // Set the button image. |
||
194 | $('#compile-script').removeClass("activity-image"); |
||
195 | $('#compile-script').removeClass("activityButton"); |
||
196 | |||
197 | $('#compile-script').addClass("check-image"); |
||
198 | $('#compile-script').addClass("checkButton"); |
||
199 | |||
200 | $("#message").velocity("slideUp", { |
||
201 | duration: 1000 |
||
202 | }); |
||
203 | return; |
||
204 | } |
||
205 | |||
206 | // Move panel to top. |
||
207 | $('#error-panel').css('z-index', getTopWindowIndex() + 1); |
||
208 | $('#error-panel').css('position', 'relative'); |
||
209 | |||
210 | // Set the button image. |
||
211 | $('#compile-script').removeClass("activity-image"); |
||
212 | $('#compile-script').removeClass("activityButton"); |
||
213 | |||
214 | $('#compile-script').addClass("cross-image"); |
||
215 | $('#compile-script').addClass("crossButton"); |
||
216 | |||
217 | $("#message").velocity("slideDown", { |
||
218 | duration: 1000 |
||
219 | }); |
||
220 | |||
221 | $('#message').val(wasCSVToArray(response.data).join('')); |
||
222 | }); |
||
223 | } |
||
224 | |||
225 | function store(lsl) { |
||
226 | $.ajax({ |
||
227 | type: 'POST', |
||
228 | url: '/', |
||
229 | data: { |
||
230 | command: 'upload', |
||
231 | type: 'LSLText', |
||
232 | item: $('#script-UUID').val(), |
||
233 | name: $('#script-name').val(), |
||
234 | data: CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(lsl)) |
||
235 | }, |
||
236 | dataType: 'json' |
||
237 | }).done(function(response) { |
||
238 | if(response.success === "True") { |
||
239 | var data = wasCSVToArray(response.data); |
||
240 | var UUID = data[data.indexOf('item') + 1]; |
||
241 | |||
242 | // Set the inventory UUID of the saved script. |
||
243 | $('#script-UUID').val(UUID); |
||
244 | |||
245 | localStorage.setItem('nucleus-script-kiddie-script-UUID', UUID); |
||
246 | } |
||
247 | }); |
||
248 | } |
||
249 | |||
250 | // Add compiling with Ctrl-S |
||
251 | editor.commands.addCommand({ |
||
252 | name: 'Compile', |
||
253 | bindKey: { |
||
254 | win: 'Ctrl-S', |
||
255 | mac: 'Command-S' |
||
256 | }, |
||
257 | exec: editor => { |
||
258 | var data = editor.getSession().getValue(); |
||
259 | compile(data); |
||
260 | if($('#store-script').prop('checked') === true) |
||
261 | store(data); |
||
262 | }, |
||
263 | readOnly: false // false if this command should not apply in readOnly mode |
||
264 | }); |
||
265 | |||
266 | // Add click listener for compile button. |
||
267 | $('#compile-script').on('click', function (e) { |
||
268 | if($('#compile-script').hasClass("activity-image")) |
||
269 | return; |
||
270 | |||
271 | var data = editor.getSession().getValue(); |
||
272 | compile(data); |
||
273 | if($('#store-script').prop('checked') === true) |
||
274 | store(data); |
||
275 | }); |
||
276 | |||
277 | // Add click listener for tidy button. |
||
278 | $('#tidy-script').on('click', function (e) { |
||
279 | if($('#compile-script').hasClass("activity-image")) |
||
280 | return; |
||
281 | |||
282 | // Code cleanup parameters. |
||
283 | editor.setValue( |
||
284 | js_beautify( |
||
285 | editor.getSession().getValue(), |
||
286 | { |
||
287 | "indent_size": 4, |
||
288 | "indent_char": " ", |
||
289 | "indent_with_tabs": false, |
||
290 | "eol": "\n", |
||
291 | "end_with_newline": true, |
||
292 | "indent_level": 0, |
||
293 | "preserve_newlines": true, |
||
294 | "max_preserve_newlines": 10, |
||
295 | "space_in_paren": false, |
||
296 | "space_in_empty_paren": false, |
||
297 | "jslint_happy": false, |
||
298 | "space_after_anon_function": false, |
||
299 | "brace_style": "expand", |
||
300 | "break_chained_methods": false, |
||
301 | "keep_array_indentation": false, |
||
302 | "unescape_strings": false, |
||
303 | "wrap_line_length": 0, |
||
304 | "e4x": false, |
||
305 | "comma_first": false, |
||
306 | "operator_position": "before-newline" |
||
307 | } |
||
308 | ) |
||
309 | ); |
||
310 | }); |
||
311 | |||
312 | // Save script on change. |
||
313 | editor.getSession().on('change', function(e) { |
||
314 | localStorage.setItem("nucleus-script-kiddie.lsl", editor.getValue()); |
||
315 | }); |
||
316 | |||
317 | // Move windows to top on click. |
||
318 | $('.draggable').click(function() { |
||
319 | $(this).css('z-index', getTopWindowIndex() + 1); |
||
320 | }); |
||
321 | |||
322 | // target elements with the "draggable" class |
||
323 | interact('.draggable') |
||
324 | .draggable({ |
||
325 | // enable inertial throwing |
||
326 | inertia: true, |
||
327 | // keep the element within the area of it's parent |
||
328 | restrict: { |
||
329 | // Let the user move the windows freely. |
||
330 | //restriction: "parent", |
||
331 | endOnly: true, |
||
332 | elementRect: { top: 0, left: 0, bottom: 1, right: 1 } |
||
333 | }, |
||
334 | |||
335 | // enable autoScroll |
||
336 | autoScroll: true, |
||
337 | |||
338 | onmove: dragMoveListener, |
||
339 | onend: function (event) { |
||
340 | event.target.style.opacity = 1; |
||
341 | }, |
||
342 | onstart: function(event) { |
||
343 | // Move windows to top on drag. |
||
344 | event.target.style.zIndex = getTopWindowIndex() + 1; |
||
345 | event.target.style.opacity = 0.5; |
||
346 | } |
||
347 | }) |
||
348 | .allowFrom('.panel-heading'); |
||
349 | |||
350 | function getTopWindowIndex() { |
||
351 | return Math.max.apply(null, |
||
352 | $.map($('.draggable'), function(e, n) { |
||
353 | if ($(e).css('position') != 'static') |
||
354 | return parseInt($(e).css('z-index')) || 1; |
||
355 | }) |
||
356 | ); |
||
357 | } |
||
358 | |||
359 | function dragMoveListener (event) { |
||
360 | var target = event.target, |
||
361 | // keep the dragged position in the data-x/data-y attributes |
||
362 | x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx, |
||
363 | y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy; |
||
364 | |||
365 | // translate the element |
||
366 | target.style.webkitTransform = |
||
367 | target.style.transform = |
||
368 | 'translate(' + x + 'px, ' + y + 'px)'; |
||
369 | |||
370 | // update the posiion attributes |
||
371 | target.setAttribute('data-x', x); |
||
372 | target.setAttribute('data-y', y); |
||
373 | } |
||
374 | |||
375 | // this is used later in the resizing and gesture demos |
||
376 | window.dragMoveListener = dragMoveListener; |
||
377 | |||
378 | // Get the item name from the storage. |
||
379 | var storeScriptUUID = localStorage.getItem('nucleus-script-kiddie-script-UUID'); |
||
380 | if (typeof storeScriptUUID == "string") |
||
381 | $('#script-UUID').val(storeScriptUUID); |
||
382 | |||
383 | // Get the item name from the storage. |
||
384 | var storeScriptName = localStorage.getItem('nucleus-script-kiddie-script-name'); |
||
385 | if (typeof storeScriptName == "string") |
||
386 | $('#script-name').val(storeScriptName); |
||
387 | |||
388 | // Store script name on modification. |
||
389 | var scriptNameTimerID; |
||
390 | $('#script-name').on('input',function(e){ |
||
391 | var value = $(this).val(); |
||
392 | if($(this).data('lastval')!= value){ |
||
393 | |||
394 | $(this).data('lastval',value); |
||
395 | clearTimeout(scriptNameTimerID); |
||
396 | |||
397 | scriptNameTimerID = setTimeout(function() { |
||
398 | localStorage.setItem('nucleus-script-kiddie-script-name', value); |
||
399 | },500); |
||
400 | }; |
||
401 | }); |
||
402 | |||
403 | // Enable storing of script only if the form validates. |
||
404 | $('#script-tools').on('validated.bs.validator', function (e) { |
||
405 | if($('#script-tools').has('.has-error').length !== 0) { |
||
406 | $('#store-script').bootstrapToggle('off'); |
||
407 | $('#store-script').bootstrapToggle('disable'); |
||
408 | return; |
||
409 | } |
||
410 | $('#store-script').bootstrapToggle('enable'); |
||
411 | }); |
||
412 | |||
413 | |||
414 | }); |
||
415 | </script> |
||
416 | </body> |
||
417 | </html> |