corrade-nucleus-nucleons – Blame information for rev 20

Subversion Repositories:
Rev:
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">
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 -->
20 office 25 <link href="/script-kiddie/node_modules/bootstrap-toggle/css/bootstrap-toggle.min.css" rel="stylesheet" type="text/css">
2 office 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">&times;</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>&copy; 2017 Wizardry and Steamworks</p>
127 </footer>
128  
129 <!-- jQuery -->
20 office 130 <script src="/node_modules/jquery/dist/jquery.min.js" type="text/javascript"></script>
2 office 131 <!-- Bootstrap Javascript -->
20 office 132 <script src="/node_modules/bootstrap/dist/js/bootstrap.min.js" type="text/javascript"></script>
2 office 133 <!-- Bootstrap Validator -->
20 office 134 <script src="/node_modules/bootstrap-validator/dist/validator.min.js" type="text/javascript"></script>
2 office 135 <!-- Bootstrap Toggle -->
20 office 136 <script src="/script-kiddie/node_modules/bootstrap-toggle/js/bootstrap-toggle.min.js" type="text/javascript"></script>
2 office 137 <!-- ACE -->
20 office 138 <script src="/script-kiddie/node_modules/ace-builds/src-min-noconflict/ace.js" type="text/javascript"></script>
139 <script src="/script-kiddie/node_modules/ace-builds/src-min-noconflict/ext-language_tools.js" type="text/javascript"></script>
2 office 140 <!-- Beautify.JS -->
20 office 141 <script src="/script-kiddie/node_modules/js-beautify/js/lib/beautify.js" type="text/javascript"></script>
2 office 142 <!-- Velocity -->
20 office 143 <script src="/script-kiddie/node_modules/velocity-animate/velocity.min.js" type="text/javascript"></script>
2 office 144 <!-- Interact JS -->
20 office 145 <script src="/script-kiddie/node_modules/interactjs/dist/interact.min.js" type="text/javascript"></script>
2 office 146 <!-- Wizardry and Steamworks JavaScript Includes -->
20 office 147 <script src="/node_modules/was/dist/was.min.js" type="text/javascript"></script>
2 office 148 <script>
149 $(document).ready(() => {
150 // Auto-complete.
151 ace.require("ace/ext/language_tools");
152  
153 // Create the editor.
154 var editor = ace.edit("editor");
155 editor.setTheme("ace/theme/twilight");
156 editor.getSession().setMode("ace/mode/lsl");
157 editor.setOptions({
158 enableBasicAutocompletion: true,
159 enableSnippets: false,
160 enableLiveAutocompletion: true
161 });
162  
163 // Get the script from the storage.
6 office 164 var storeScriptText = localStorage.getItem('nucleus-script-kiddie-script-body');
165 if (typeof storeScriptText == "string")
2 office 166 editor.getSession().setValue(storeScriptText);
167  
6 office 168 function compile(lsl, callback) {
2 office 169 // Set the editor to read-only.
170 editor.setReadOnly(true);
171  
172 // Set the button image.
173 $('#compile-script').removeClass("check-image");
174 $('#compile-script').removeClass("checkButton");
175  
176 $('#compile-script').removeClass("cross-image");
177 $('#compile-script').removeClass("crossButton");
178  
179 $('#compile-script').addClass("activity-image");
180 $('#compile-script').addClass("activityButton");
181  
182 $.ajax({
183 type: 'POST',
184 url: '/',
185 data: {
186 command: 'compilescript',
187 data: lsl
188 },
189 dataType: 'json'
190 }).done(function(response) {
6 office 191 var success = response.success === "True";
2 office 192 // Set the editor to read-enabled.
193 editor.setReadOnly(false);
194  
6 office 195 if(success) {
2 office 196 // Set the button image.
197 $('#compile-script').removeClass("activity-image");
198 $('#compile-script').removeClass("activityButton");
199  
200 $('#compile-script').addClass("check-image");
201 $('#compile-script').addClass("checkButton");
202  
203 $("#message").velocity("slideUp", {
204 duration: 1000
205 });
6 office 206 callback(success);
2 office 207 return;
208 }
209  
210 // Move panel to top.
211 $('#error-panel').css('z-index', getTopWindowIndex() + 1);
212 $('#error-panel').css('position', 'relative');
213  
214 // Set the button image.
215 $('#compile-script').removeClass("activity-image");
216 $('#compile-script').removeClass("activityButton");
217  
218 $('#compile-script').addClass("cross-image");
219 $('#compile-script').addClass("crossButton");
220  
221 $("#message").velocity("slideDown", {
222 duration: 1000
223 });
224  
225 $('#message').val(wasCSVToArray(response.data).join(''));
6 office 226 callback(success);
2 office 227 });
228 }
229  
6 office 230 function store(lsl, callback) {
2 office 231 $.ajax({
232 type: 'POST',
233 url: '/',
234 data: {
6 office 235 command: 'updatescript',
236 create: true,
237 type: 'agent',
238 entity: 'text',
2 office 239 item: $('#script-UUID').val(),
6 office 240 target: $('#script-name').val(),
241 data: lsl
2 office 242 },
243 dataType: 'json'
244 }).done(function(response) {
6 office 245 var success = response.success === "True";
246 if(success) {
247 // Get the response data and item UUID.
2 office 248 var data = wasCSVToArray(response.data);
249 var UUID = data[data.indexOf('item') + 1];
250  
251 // Set the inventory UUID of the saved script.
252 $('#script-UUID').val(UUID);
253  
254 localStorage.setItem('nucleus-script-kiddie-script-UUID', UUID);
255 }
6 office 256 callback(success);
2 office 257 });
258 }
259  
260 // Add compiling with Ctrl-S
261 editor.commands.addCommand({
262 name: 'Compile',
263 bindKey: {
264 win: 'Ctrl-S',
265 mac: 'Command-S'
266 },
267 exec: editor => {
268 var data = editor.getSession().getValue();
6 office 269 // Store locally on save.
270 localStorage.setItem('nucleus-script-kiddie-script-body', data);
271  
272 compile(data, (success) => {
273 // Script did not compile so do not store.
274 if(!success)
275 return;
276  
277 // Storing is not enabled so return.
278 if($('#store-script').prop('checked') !== true)
279 return;
280  
281 store(data, (success) => {
282 // Script was stored successfully.
283 //alert("Script stored succssfully.");
284 });
285 });
286  
2 office 287 },
288 readOnly: false // false if this command should not apply in readOnly mode
289 });
290  
291 // Add click listener for compile button.
292 $('#compile-script').on('click', function (e) {
293 if($('#compile-script').hasClass("activity-image"))
294 return;
295  
296 var data = editor.getSession().getValue();
20 office 297 compile(data, (success) => {});
2 office 298 if($('#store-script').prop('checked') === true)
299 store(data);
300 });
301  
302 // Add click listener for tidy button.
303 $('#tidy-script').on('click', function (e) {
304 if($('#compile-script').hasClass("activity-image"))
305 return;
306  
307 // Code cleanup parameters.
308 editor.setValue(
309 js_beautify(
310 editor.getSession().getValue(),
311 {
312 "indent_size": 4,
313 "indent_char": " ",
314 "indent_with_tabs": false,
315 "eol": "\n",
316 "end_with_newline": true,
317 "indent_level": 0,
318 "preserve_newlines": true,
319 "max_preserve_newlines": 10,
320 "space_in_paren": false,
321 "space_in_empty_paren": false,
322 "jslint_happy": false,
323 "space_after_anon_function": false,
324 "brace_style": "expand",
325 "break_chained_methods": false,
326 "keep_array_indentation": false,
327 "unescape_strings": false,
328 "wrap_line_length": 0,
329 "e4x": false,
330 "comma_first": false,
331 "operator_position": "before-newline"
332 }
333 )
334 );
335 });
336  
6 office 337 function give(firstname, lastname, callback) {
338 $.ajax({
339 type: 'POST',
340 url: '/',
341 data: {
342 command: 'give',
343 entity: 'avatar',
344 item: $('#script-UUID').val(),
345 firstname: firstname,
346 lastname: lastname,
347 permissions: 'c--mvt------------c--mvtc--mvt'
348 },
349 dataType: 'json'
350 }).done(function(response) {
351 callback(response);
352 });
353 }
354  
355 // Add click listener for give button.
356 $('#give-script').on('click', function (e) {
357 if($('#compile-script').hasClass("activity-image"))
358 return;
359  
360 // Show the popup.
361 $('#avatar-select').modal('show');
362 });
363  
364 // Add click listener to modal confirmation.
365 $('#send-script').on('click', function(e) {
366 // Hide the popup.
367 $('#avatar-select').modal('hide');
368  
369 // Disable give button.
370 $('#give-script').attr('disabled', true);
371 give($('#avatar-firstname').val(), $('#avatar-lastname').val(), (response) => {
372 // Enable give button.
373 $('#give-script').attr('disabled', false);
374 });
375 })
376  
2 office 377 // Save script on change.
378 editor.getSession().on('change', function(e) {
6 office 379 localStorage.setItem('nucleus-script-kiddie-script-body', editor.getSession().getValue());
2 office 380 });
381  
382 // Move windows to top on click.
383 $('.draggable').click(function() {
384 $(this).css('z-index', getTopWindowIndex() + 1);
385 });
386  
387 // target elements with the "draggable" class
388 interact('.draggable')
389 .draggable({
390 // enable inertial throwing
391 inertia: true,
392 // keep the element within the area of it's parent
6 office 393 /*restrict: {
2 office 394 // Let the user move the windows freely.
6 office 395 restriction: "self",
396 endOnly: true//,
397 //elementRect: { top: 0, left: 0, bottom: 1, right: 1 }
398 },*/
2 office 399  
400 // enable autoScroll
401 autoScroll: true,
402  
403 onmove: dragMoveListener,
404 onend: function (event) {
405 event.target.style.opacity = 1;
406 },
407 onstart: function(event) {
408 // Move windows to top on drag.
409 event.target.style.zIndex = getTopWindowIndex() + 1;
410 event.target.style.opacity = 0.5;
411 }
412 })
6 office 413 .allowFrom('.panel-heading')
414 .ignoreFrom('a, input, button, textarea');
2 office 415  
416 function getTopWindowIndex() {
417 return Math.max.apply(null,
418 $.map($('.draggable'), function(e, n) {
419 if ($(e).css('position') != 'static')
420 return parseInt($(e).css('z-index')) || 1;
421 })
422 );
423 }
424  
425 function dragMoveListener (event) {
426 var target = event.target,
427 // keep the dragged position in the data-x/data-y attributes
428 x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx,
429 y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy;
430  
431 // translate the element
432 target.style.webkitTransform =
433 target.style.transform =
434 'translate(' + x + 'px, ' + y + 'px)';
435  
436 // update the posiion attributes
437 target.setAttribute('data-x', x);
438 target.setAttribute('data-y', y);
439 }
440  
441 // this is used later in the resizing and gesture demos
442 window.dragMoveListener = dragMoveListener;
443  
444 // Get the item name from the storage.
445 var storeScriptUUID = localStorage.getItem('nucleus-script-kiddie-script-UUID');
446 if (typeof storeScriptUUID == "string")
447 $('#script-UUID').val(storeScriptUUID);
448  
449 // Get the item name from the storage.
450 var storeScriptName = localStorage.getItem('nucleus-script-kiddie-script-name');
451 if (typeof storeScriptName == "string")
452 $('#script-name').val(storeScriptName);
453  
454 // Store script name on modification.
455 var scriptNameTimerID;
456 $('#script-name').on('input',function(e){
457 var value = $(this).val();
458 if($(this).data('lastval')!= value){
459  
6 office 460 $(this).data('lastval',value);
2 office 461 clearTimeout(scriptNameTimerID);
462  
463 scriptNameTimerID = setTimeout(function() {
464 localStorage.setItem('nucleus-script-kiddie-script-name', value);
465 },500);
466 };
467 });
468  
469 // Enable storing of script only if the form validates.
470 $('#script-tools').on('validated.bs.validator', function (e) {
471 if($('#script-tools').has('.has-error').length !== 0) {
472 $('#store-script').bootstrapToggle('off');
473 $('#store-script').bootstrapToggle('disable');
474 return;
475 }
476 $('#store-script').bootstrapToggle('enable');
477 });
478  
6 office 479 $('#store-script').change(function() {
480 switch($('#store-script').prop('checked'))
481 {
482 case true:
483 // Disable script name and UUID.
484 $('#script-name').attr('disabled', true);
485 $('#script-UUID').attr('disabled', true);
486  
487 var data = editor.getSession().getValue();
488 // Store locally on save.
489 localStorage.setItem('nucleus-script-kiddie-script-body', data);
490  
491 $('#give-script').attr('disabled', true);
492 compile(data, (success) => {
493 store(data, (success) => {
494 // Script was stored successfully.
495 // Enable the give button.
496 $('#give-script').attr('disabled', false);
497 });
498 });
499 break;
500 default:
501 // Enable script name and UUID.
502 $('#script-name').attr('disabled', false);
503 $('#script-UUID').attr('disabled', false);
504  
505 // Disable the give button.
506 $('#give-script').attr('disabled', true);
507 break;
508 }
509 });
2 office 510  
511 });
512 </script>
513 </body>
514 </html>