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