corrade-nucleus-nucleons – Blame information for rev 6
?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 --> |
||
6 | office | 32 | <div id="avatar-select" class="modal fade bs-example-modal-lg" role="dialog"> |
2 | office | 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 | |||
6 | office | 40 | <h1 id="title" class="modal-title">Avatar Selection</h1> |
2 | office | 41 | </div> |
42 | |||
6 | office | 43 | <form id="avatar-select-form" class="form-inline" data-toggle="validator" onSubmit="event.preventDefault();"> |
44 | <div id="content" class="modal-body"> |
||
45 | <p>Please enter the avatar firstname and lastname to send the script to.</p> |
||
46 | <div class="form-group has-feedback"> |
||
47 | <label for="avatar-firstname">First Name</label> |
||
48 | <input id="avatar-firstname" type="text" class="form-control" aria-describedby="basic-addon1" required> |
||
49 | <label for="avatar-lastname">Last Name</label> |
||
50 | <input id="avatar-lastname" type="text" class="form-control" aria-describedby="basic-addon1" required> |
||
2 | office | 51 | </div> |
52 | </div> |
||
53 | <div class="modal-footer"> |
||
54 | <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> |
||
6 | office | 55 | <button id="send-script" type="submit" class="btn btn-primary">Confirm</button> |
2 | office | 56 | </div> |
6 | office | 57 | </form> |
2 | office | 58 | </div> |
59 | </div> |
||
60 | </div> |
||
61 | |||
62 | <div class="container"> |
||
63 | <div class="jumbotron"> |
||
64 | <h1>Corrade Script Kiddie</h1> |
||
65 | <p class="lead">Script Kiddie is an LSL editor using Corrade as a backend for developing scripts.</p> |
||
66 | <img src="script-kiddie/img/script-kiddie.png"></div> |
||
67 | |||
68 | <!-- <div id="drag-1" class="draggable"> |
||
69 | <p> You can drag one element </p> |
||
70 | </div> --> |
||
71 | |||
72 | <div id="editor-panel" class="panel panel-default draggable movable"> |
||
73 | <div class="panel-heading"> |
||
6 | office | 74 | <form id="script-tools" data-toggle="validator" onSubmit="event.preventDefault();"> |
75 | <div class="form-group"> |
||
2 | office | 76 | <button id="compile-script" class="btn btn-default check-image checkButton" type="button" title="Compile script.">Compile</button> |
77 | <button id="tidy-script" class="btn btn-default" type="button" title="Tidy source-code.">Cleanup</button> |
||
6 | office | 78 | |
2 | office | 79 | </div> |
80 | <div class="form-group has-feedback"> |
||
81 | <div class="input-group"> |
||
82 | <span class="input-group-btn"> |
||
83 | <input id="store-script" type="checkbox" data-toggle="toggle" data-on="Store" data-off="No Store" data-onstyle="success" disabled="disabled"> |
||
84 | </span> |
||
85 | <input id="script-name" type="text" class="form-control" placeholder="Script Name" aria-describedby="basic-addon1" required> |
||
86 | <span class="input-group-addon">-</span> |
||
6 | office | 87 | <input id="script-UUID" type="text" class="form-control" aria-describedby="basic-addon2" size="36"> |
88 | <span class="input-group-btn"> |
||
89 | <button id="give-script" class="btn btn-default" type="button" title="Give script." disabled="disabled">Give</button> |
||
90 | </span> |
||
2 | office | 91 | </div> |
92 | </div> |
||
93 | </form> |
||
94 | </div> |
||
95 | <div class="panel-body" id="editorpanel"> |
||
96 | <div id="editor" style="height: 500px;">default |
||
97 | { |
||
98 | state_entry() |
||
99 | { |
||
100 | llSay(0, "Hello, Avatar!"); |
||
101 | } |
||
102 | |||
103 | touch_start(integer total_number) |
||
104 | { |
||
105 | llSay(0, "Touched."); |
||
106 | } |
||
107 | } |
||
108 | </div> |
||
109 | </div> |
||
110 | </div> |
||
111 | |||
112 | <div id="error-panel" class="panel panel-default draggable movable"> |
||
113 | <div class="panel-heading"> |
||
114 | <p>Compilation Errors</p> |
||
115 | </div> |
||
116 | <div class="panel-body" id="errorpanel"> |
||
117 | <div id="errors"> |
||
118 | <textarea id="message" class="form-control" rows="5" style="min-width: 100%; max-width: 100%; font-family: monospace; display: none;" readonly></textarea> |
||
119 | </div> |
||
120 | </div> |
||
121 | </div> |
||
122 | |||
123 | </div> <!-- /container --> |
||
124 | |||
125 | <footer class="footer"> |
||
126 | <p>© 2017 Wizardry and Steamworks</p> |
||
127 | </footer> |
||
128 | |||
129 | <!-- jQuery --> |
||
130 | <script src="/bower_components/jquery/dist/jquery.min.js" type="text/javascript"></script> |
||
131 | <!-- Bootstrap Javascript --> |
||
132 | <script src="/bower_components/bootstrap/dist/js/bootstrap.min.js" type="text/javascript"></script> |
||
133 | <!-- Bootstrap Validator --> |
||
134 | <script src="/script-kiddie/bower_components/bootstrap-validator/dist/validator.min.js" type="text/javascript"></script> |
||
135 | <!-- Bootstrap Toggle --> |
||
136 | <script src="/script-kiddie/bower_components/bootstrap-toggle/js/bootstrap-toggle.min.js" type="text/javascript"></script> |
||
137 | <!-- ACE --> |
||
138 | <script type="text/javascript" src="/script-kiddie/bower_components/ace-builds/src-min-noconflict/ace.js"></script> |
||
139 | <script type="text/javascript" src="/script-kiddie/bower_components/ace-builds/src-min-noconflict/ext-language_tools.js"></script> |
||
140 | <!-- Beautify.JS --> |
||
141 | <script type="text/javascript" src="/script-kiddie/bower_components/js-beautify/js/lib/beautify.js"></script> |
||
142 | <!-- Velocity --> |
||
143 | <script type="text/javascript" src="/script-kiddie/bower_components/velocity/velocity.min.js"></script> |
||
144 | <!-- Interact JS --> |
||
145 | <script type="text/javascript" src="/script-kiddie/bower_components/interactjs/dist/interact.min.js"></script> |
||
146 | <!-- Wizardry and Steamworks JavaScript Includes --> |
||
147 | <script src="/js/was/csv.js" type="text/javascript"></script> |
||
148 | <script src="/js/was/jquery/arrays.js" type="text/javascript"></script> |
||
149 | <script> |
||
150 | $(document).ready(() => { |
||
151 | // Auto-complete. |
||
152 | ace.require("ace/ext/language_tools"); |
||
153 | |||
154 | // Create the editor. |
||
155 | var editor = ace.edit("editor"); |
||
156 | editor.setTheme("ace/theme/twilight"); |
||
157 | editor.getSession().setMode("ace/mode/lsl"); |
||
158 | editor.setOptions({ |
||
159 | enableBasicAutocompletion: true, |
||
160 | enableSnippets: false, |
||
161 | enableLiveAutocompletion: true |
||
162 | }); |
||
163 | |||
164 | // Get the script from the storage. |
||
6 | office | 165 | var storeScriptText = localStorage.getItem('nucleus-script-kiddie-script-body'); |
166 | if (typeof storeScriptText == "string") |
||
2 | office | 167 | editor.getSession().setValue(storeScriptText); |
168 | |||
6 | office | 169 | function compile(lsl, callback) { |
2 | office | 170 | // Set the editor to read-only. |
171 | editor.setReadOnly(true); |
||
172 | |||
173 | // Set the button image. |
||
174 | $('#compile-script').removeClass("check-image"); |
||
175 | $('#compile-script').removeClass("checkButton"); |
||
176 | |||
177 | $('#compile-script').removeClass("cross-image"); |
||
178 | $('#compile-script').removeClass("crossButton"); |
||
179 | |||
180 | $('#compile-script').addClass("activity-image"); |
||
181 | $('#compile-script').addClass("activityButton"); |
||
182 | |||
183 | $.ajax({ |
||
184 | type: 'POST', |
||
185 | url: '/', |
||
186 | data: { |
||
187 | command: 'compilescript', |
||
188 | data: lsl |
||
189 | }, |
||
190 | dataType: 'json' |
||
191 | }).done(function(response) { |
||
6 | office | 192 | var success = response.success === "True"; |
2 | office | 193 | // Set the editor to read-enabled. |
194 | editor.setReadOnly(false); |
||
195 | |||
6 | office | 196 | if(success) { |
2 | office | 197 | // Set the button image. |
198 | $('#compile-script').removeClass("activity-image"); |
||
199 | $('#compile-script').removeClass("activityButton"); |
||
200 | |||
201 | $('#compile-script').addClass("check-image"); |
||
202 | $('#compile-script').addClass("checkButton"); |
||
203 | |||
204 | $("#message").velocity("slideUp", { |
||
205 | duration: 1000 |
||
206 | }); |
||
6 | office | 207 | callback(success); |
2 | office | 208 | return; |
209 | } |
||
210 | |||
211 | // Move panel to top. |
||
212 | $('#error-panel').css('z-index', getTopWindowIndex() + 1); |
||
213 | $('#error-panel').css('position', 'relative'); |
||
214 | |||
215 | // Set the button image. |
||
216 | $('#compile-script').removeClass("activity-image"); |
||
217 | $('#compile-script').removeClass("activityButton"); |
||
218 | |||
219 | $('#compile-script').addClass("cross-image"); |
||
220 | $('#compile-script').addClass("crossButton"); |
||
221 | |||
222 | $("#message").velocity("slideDown", { |
||
223 | duration: 1000 |
||
224 | }); |
||
225 | |||
226 | $('#message').val(wasCSVToArray(response.data).join('')); |
||
6 | office | 227 | callback(success); |
2 | office | 228 | }); |
229 | } |
||
230 | |||
6 | office | 231 | function store(lsl, callback) { |
2 | office | 232 | $.ajax({ |
233 | type: 'POST', |
||
234 | url: '/', |
||
235 | data: { |
||
6 | office | 236 | command: 'updatescript', |
237 | create: true, |
||
238 | type: 'agent', |
||
239 | entity: 'text', |
||
2 | office | 240 | item: $('#script-UUID').val(), |
6 | office | 241 | target: $('#script-name').val(), |
242 | data: lsl |
||
2 | office | 243 | }, |
244 | dataType: 'json' |
||
245 | }).done(function(response) { |
||
6 | office | 246 | var success = response.success === "True"; |
247 | if(success) { |
||
248 | // Get the response data and item UUID. |
||
2 | office | 249 | var data = wasCSVToArray(response.data); |
250 | var UUID = data[data.indexOf('item') + 1]; |
||
251 | |||
252 | // Set the inventory UUID of the saved script. |
||
253 | $('#script-UUID').val(UUID); |
||
254 | |||
255 | localStorage.setItem('nucleus-script-kiddie-script-UUID', UUID); |
||
256 | } |
||
6 | office | 257 | callback(success); |
2 | office | 258 | }); |
259 | } |
||
260 | |||
261 | // Add compiling with Ctrl-S |
||
262 | editor.commands.addCommand({ |
||
263 | name: 'Compile', |
||
264 | bindKey: { |
||
265 | win: 'Ctrl-S', |
||
266 | mac: 'Command-S' |
||
267 | }, |
||
268 | exec: editor => { |
||
269 | var data = editor.getSession().getValue(); |
||
6 | office | 270 | // Store locally on save. |
271 | localStorage.setItem('nucleus-script-kiddie-script-body', data); |
||
272 | |||
273 | compile(data, (success) => { |
||
274 | // Script did not compile so do not store. |
||
275 | if(!success) |
||
276 | return; |
||
277 | |||
278 | // Storing is not enabled so return. |
||
279 | if($('#store-script').prop('checked') !== true) |
||
280 | return; |
||
281 | |||
282 | store(data, (success) => { |
||
283 | // Script was stored successfully. |
||
284 | //alert("Script stored succssfully."); |
||
285 | }); |
||
286 | }); |
||
287 | |||
2 | office | 288 | }, |
289 | readOnly: false // false if this command should not apply in readOnly mode |
||
290 | }); |
||
291 | |||
292 | // Add click listener for compile button. |
||
293 | $('#compile-script').on('click', function (e) { |
||
294 | if($('#compile-script').hasClass("activity-image")) |
||
295 | return; |
||
296 | |||
297 | var data = editor.getSession().getValue(); |
||
298 | compile(data); |
||
299 | if($('#store-script').prop('checked') === true) |
||
300 | store(data); |
||
301 | }); |
||
302 | |||
303 | // Add click listener for tidy button. |
||
304 | $('#tidy-script').on('click', function (e) { |
||
305 | if($('#compile-script').hasClass("activity-image")) |
||
306 | return; |
||
307 | |||
308 | // Code cleanup parameters. |
||
309 | editor.setValue( |
||
310 | js_beautify( |
||
311 | editor.getSession().getValue(), |
||
312 | { |
||
313 | "indent_size": 4, |
||
314 | "indent_char": " ", |
||
315 | "indent_with_tabs": false, |
||
316 | "eol": "\n", |
||
317 | "end_with_newline": true, |
||
318 | "indent_level": 0, |
||
319 | "preserve_newlines": true, |
||
320 | "max_preserve_newlines": 10, |
||
321 | "space_in_paren": false, |
||
322 | "space_in_empty_paren": false, |
||
323 | "jslint_happy": false, |
||
324 | "space_after_anon_function": false, |
||
325 | "brace_style": "expand", |
||
326 | "break_chained_methods": false, |
||
327 | "keep_array_indentation": false, |
||
328 | "unescape_strings": false, |
||
329 | "wrap_line_length": 0, |
||
330 | "e4x": false, |
||
331 | "comma_first": false, |
||
332 | "operator_position": "before-newline" |
||
333 | } |
||
334 | ) |
||
335 | ); |
||
336 | }); |
||
337 | |||
6 | office | 338 | function give(firstname, lastname, callback) { |
339 | $.ajax({ |
||
340 | type: 'POST', |
||
341 | url: '/', |
||
342 | data: { |
||
343 | command: 'give', |
||
344 | entity: 'avatar', |
||
345 | item: $('#script-UUID').val(), |
||
346 | firstname: firstname, |
||
347 | lastname: lastname, |
||
348 | permissions: 'c--mvt------------c--mvtc--mvt' |
||
349 | }, |
||
350 | dataType: 'json' |
||
351 | }).done(function(response) { |
||
352 | callback(response); |
||
353 | }); |
||
354 | } |
||
355 | |||
356 | // Add click listener for give button. |
||
357 | $('#give-script').on('click', function (e) { |
||
358 | if($('#compile-script').hasClass("activity-image")) |
||
359 | return; |
||
360 | |||
361 | // Show the popup. |
||
362 | $('#avatar-select').modal('show'); |
||
363 | }); |
||
364 | |||
365 | // Add click listener to modal confirmation. |
||
366 | $('#send-script').on('click', function(e) { |
||
367 | // Hide the popup. |
||
368 | $('#avatar-select').modal('hide'); |
||
369 | |||
370 | // Disable give button. |
||
371 | $('#give-script').attr('disabled', true); |
||
372 | give($('#avatar-firstname').val(), $('#avatar-lastname').val(), (response) => { |
||
373 | // Enable give button. |
||
374 | $('#give-script').attr('disabled', false); |
||
375 | }); |
||
376 | }) |
||
377 | |||
2 | office | 378 | // Save script on change. |
379 | editor.getSession().on('change', function(e) { |
||
6 | office | 380 | localStorage.setItem('nucleus-script-kiddie-script-body', editor.getSession().getValue()); |
2 | office | 381 | }); |
382 | |||
383 | // Move windows to top on click. |
||
384 | $('.draggable').click(function() { |
||
385 | $(this).css('z-index', getTopWindowIndex() + 1); |
||
386 | }); |
||
387 | |||
388 | // target elements with the "draggable" class |
||
389 | interact('.draggable') |
||
390 | .draggable({ |
||
391 | // enable inertial throwing |
||
392 | inertia: true, |
||
393 | // keep the element within the area of it's parent |
||
6 | office | 394 | /*restrict: { |
2 | office | 395 | // Let the user move the windows freely. |
6 | office | 396 | restriction: "self", |
397 | endOnly: true//, |
||
398 | //elementRect: { top: 0, left: 0, bottom: 1, right: 1 } |
||
399 | },*/ |
||
2 | office | 400 | |
401 | // enable autoScroll |
||
402 | autoScroll: true, |
||
403 | |||
404 | onmove: dragMoveListener, |
||
405 | onend: function (event) { |
||
406 | event.target.style.opacity = 1; |
||
407 | }, |
||
408 | onstart: function(event) { |
||
409 | // Move windows to top on drag. |
||
410 | event.target.style.zIndex = getTopWindowIndex() + 1; |
||
411 | event.target.style.opacity = 0.5; |
||
412 | } |
||
413 | }) |
||
6 | office | 414 | .allowFrom('.panel-heading') |
415 | .ignoreFrom('a, input, button, textarea'); |
||
2 | office | 416 | |
417 | function getTopWindowIndex() { |
||
418 | return Math.max.apply(null, |
||
419 | $.map($('.draggable'), function(e, n) { |
||
420 | if ($(e).css('position') != 'static') |
||
421 | return parseInt($(e).css('z-index')) || 1; |
||
422 | }) |
||
423 | ); |
||
424 | } |
||
425 | |||
426 | function dragMoveListener (event) { |
||
427 | var target = event.target, |
||
428 | // keep the dragged position in the data-x/data-y attributes |
||
429 | x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx, |
||
430 | y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy; |
||
431 | |||
432 | // translate the element |
||
433 | target.style.webkitTransform = |
||
434 | target.style.transform = |
||
435 | 'translate(' + x + 'px, ' + y + 'px)'; |
||
436 | |||
437 | // update the posiion attributes |
||
438 | target.setAttribute('data-x', x); |
||
439 | target.setAttribute('data-y', y); |
||
440 | } |
||
441 | |||
442 | // this is used later in the resizing and gesture demos |
||
443 | window.dragMoveListener = dragMoveListener; |
||
444 | |||
445 | // Get the item name from the storage. |
||
446 | var storeScriptUUID = localStorage.getItem('nucleus-script-kiddie-script-UUID'); |
||
447 | if (typeof storeScriptUUID == "string") |
||
448 | $('#script-UUID').val(storeScriptUUID); |
||
449 | |||
450 | // Get the item name from the storage. |
||
451 | var storeScriptName = localStorage.getItem('nucleus-script-kiddie-script-name'); |
||
452 | if (typeof storeScriptName == "string") |
||
453 | $('#script-name').val(storeScriptName); |
||
454 | |||
455 | // Store script name on modification. |
||
456 | var scriptNameTimerID; |
||
457 | $('#script-name').on('input',function(e){ |
||
458 | var value = $(this).val(); |
||
459 | if($(this).data('lastval')!= value){ |
||
460 | |||
6 | office | 461 | $(this).data('lastval',value); |
2 | office | 462 | clearTimeout(scriptNameTimerID); |
463 | |||
464 | scriptNameTimerID = setTimeout(function() { |
||
465 | localStorage.setItem('nucleus-script-kiddie-script-name', value); |
||
466 | },500); |
||
467 | }; |
||
468 | }); |
||
469 | |||
470 | // Enable storing of script only if the form validates. |
||
471 | $('#script-tools').on('validated.bs.validator', function (e) { |
||
472 | if($('#script-tools').has('.has-error').length !== 0) { |
||
473 | $('#store-script').bootstrapToggle('off'); |
||
474 | $('#store-script').bootstrapToggle('disable'); |
||
475 | return; |
||
476 | } |
||
477 | $('#store-script').bootstrapToggle('enable'); |
||
478 | }); |
||
479 | |||
6 | office | 480 | $('#store-script').change(function() { |
481 | switch($('#store-script').prop('checked')) |
||
482 | { |
||
483 | case true: |
||
484 | // Disable script name and UUID. |
||
485 | $('#script-name').attr('disabled', true); |
||
486 | $('#script-UUID').attr('disabled', true); |
||
487 | |||
488 | var data = editor.getSession().getValue(); |
||
489 | // Store locally on save. |
||
490 | localStorage.setItem('nucleus-script-kiddie-script-body', data); |
||
491 | |||
492 | $('#give-script').attr('disabled', true); |
||
493 | compile(data, (success) => { |
||
494 | store(data, (success) => { |
||
495 | // Script was stored successfully. |
||
496 | // Enable the give button. |
||
497 | $('#give-script').attr('disabled', false); |
||
498 | }); |
||
499 | }); |
||
500 | break; |
||
501 | default: |
||
502 | // Enable script name and UUID. |
||
503 | $('#script-name').attr('disabled', false); |
||
504 | $('#script-UUID').attr('disabled', false); |
||
505 | |||
506 | // Disable the give button. |
||
507 | $('#give-script').attr('disabled', true); |
||
508 | break; |
||
509 | } |
||
510 | }); |
||
2 | office | 511 | |
512 | }); |
||
513 | </script> |
||
514 | </body> |
||
515 | </html> |