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