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