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