corrade-nucleus-nucleons – Diff between revs 38 and 39

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 38 Rev 39
1 <div id="pack-rat"> 1 <div id="pack-rat">
2 <!-- jsTree style --> 2 <!-- jsTree style -->
3 <link href="/pack-rat/node_modules/jstree/dist/themes/default/style.min.css" rel="stylesheet" type="text/css"> 3 <link href="/pack-rat/node_modules/jstree/dist/themes/default/style.min.css" rel="stylesheet" type="text/css">
4 <!-- Bootstrap table --> 4 <!-- Bootstrap table -->
5 <link href="/pack-rat/node_modules/bootstrap-table/dist/bootstrap-table.min.css" rel="stylesheet" type="text/css"> 5 <link href="/pack-rat/node_modules/bootstrap-table/dist/bootstrap-table.min.css" rel="stylesheet" type="text/css">
6 6
7 <!-- Bootstrap Modal --> 7 <!-- Bootstrap Modal -->
8 <div id="pack-rat-item-info-modal" class="modal fade bs-example-modal-lg" role="dialog"> 8 <div id="pack-rat-item-info-modal" class="modal fade bs-example-modal-lg" role="dialog">
9 <div class="modal-dialog modal-lg"> 9 <div class="modal-dialog modal-lg">
10 <!-- Modal content--> 10 <!-- Modal content-->
11   11  
12 <div class="modal-content"> 12 <div class="modal-content">
13 <div class="modal-header"> 13 <div class="modal-header">
14 <button type="button" class="close" data-dismiss="modal">&times;</button> 14 <button type="button" class="close" data-dismiss="modal">&times;</button>
15   15  
16 <h1 class="modal-title">Item Information</h1> 16 <h1 class="modal-title">Item Information</h1>
17 </div> 17 </div>
18   18  
19 <div class="modal-body"> 19 <div class="modal-body">
20 <table id="pack-rat-item-info" data-height="460"> 20 <table id="pack-rat-item-info" data-height="460">
21 <thead> 21 <thead>
22 <tr> 22 <tr>
23 <th data-field="AssetUUID">Asset UUID</th> 23 <th data-field="AssetUUID">Asset UUID</th>
24 <th data-field="CreationDate">Creation Date</th> 24 <th data-field="CreationDate">Creation Date</th>
25 <th data-field="Description">Description</th> 25 <th data-field="Description">Description</th>
26 <th data-field="Permissions">Permissions</th> 26 <th data-field="Permissions">Permissions</th>
27 <th data-field="UUID">Inventory UUID</th> 27 <th data-field="UUID">Inventory UUID</th>
28 </tr> 28 </tr>
29 </thead> 29 </thead>
30 </table> 30 </table>
31 </div> 31 </div>
32 <div class="modal-footer"> 32 <div class="modal-footer">
33 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 33 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
34 </div> 34 </div>
35 </div> 35 </div>
36 </div> 36 </div>
37 </div> 37 </div>
38   38  
39 <!-- Give Inventory Item Destination Dialog --> 39 <!-- Give Inventory Item Destination Dialog -->
40 <div id="pack-rat-avatar-select-modal" class="modal fade bs-example-modal-lg" role="dialog"> 40 <div id="pack-rat-avatar-select-modal" class="modal fade bs-example-modal-lg" role="dialog">
41 <div class="modal-dialog modal-lg"> 41 <div class="modal-dialog modal-lg">
42 <!-- Modal content--> 42 <!-- Modal content-->
43   43  
44 <div class="modal-content"> 44 <div class="modal-content">
45 <div class="modal-header"> 45 <div class="modal-header">
46 <button type="button" class="close" data-dismiss="modal">&times;</button> 46 <button type="button" class="close" data-dismiss="modal">&times;</button>
47   47  
48 <h1 class="modal-title">Avatar Selection</h1> 48 <h1 class="modal-title">Avatar Selection</h1>
49 </div> 49 </div>
50   50  
51 <form class="form-inline" data-toggle="validator" onSubmit="event.preventDefault();"> 51 <form class="form-inline" data-toggle="validator" onSubmit="event.preventDefault();">
52 <div class="modal-body"> 52 <div class="modal-body">
53 <p>Please enter the avatar firstname and lastname to send the script to.</p> 53 <p>Please enter the avatar firstname and lastname to send the script to.</p>
54 <div class="form-group has-feedback"> 54 <div class="form-group has-feedback">
55 <label for="pack-rat-avatar-firstname">First Name</label> 55 <label for="pack-rat-avatar-firstname">First Name</label>
56 <input id="pack-rat-avatar-firstname" type="text" class="form-control" aria-describedby="basic-addon1" required> 56 <input id="pack-rat-avatar-firstname" type="text" class="form-control" aria-describedby="basic-addon1" required>
57 <label for="pack-rat-avatar-lastname">Last Name</label> 57 <label for="pack-rat-avatar-lastname">Last Name</label>
58 <input id="pack-rat-avatar-lastname" type="text" class="form-control" aria-describedby="basic-addon1" required> 58 <input id="pack-rat-avatar-lastname" type="text" class="form-control" aria-describedby="basic-addon1" required>
59 </div> 59 </div>
60 </div> 60 </div>
61 <div class="modal-footer"> 61 <div class="modal-footer">
62 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 62 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
63 <button id="pack-rat-send-item" type="button" class="btn btn-primary">Confirm</button> 63 <button id="pack-rat-send-item" type="button" class="btn btn-primary">Confirm</button>
64 </div> 64 </div>
65 </form> 65 </form>
66 </div> 66 </div>
67 </div> 67 </div>
68 </div> 68 </div>
69   69  
70 <!-- Inventory Item Download Dialog --> 70 <!-- Inventory Item Download Dialog -->
71 <div id="pack-rat-item-download-modal" class="modal fade bs-example-modal-lg" role="dialog"> 71 <div id="pack-rat-item-download-modal" class="modal fade bs-example-modal-lg" role="dialog">
72 <div class="modal-dialog modal-lg"> 72 <div class="modal-dialog modal-lg">
73 <!-- Modal content--> 73 <!-- Modal content-->
74   74  
75 <div class="modal-content"> 75 <div class="modal-content">
76 <div class="modal-header"> 76 <div class="modal-header">
77 <button type="button" class="close" data-dismiss="modal">&times;</button> 77 <button type="button" class="close" data-dismiss="modal">&times;</button>
78   78  
79 <h1 class="modal-title">Download</h1> 79 <h1 class="modal-title">Download</h1>
80 </div> 80 </div>
81 81
82 <div id="pack-rat-item-download-content" class="modal-body"> 82 <div id="pack-rat-item-download-content" class="modal-body">
83 </div> 83 </div>
84 84
85 <div class="modal-footer"> 85 <div class="modal-footer">
86 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 86 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
87 </div> 87 </div>
88 </div> 88 </div>
89 </div> 89 </div>
90 </div> 90 </div>
91   91  
92 <!-- Main nucleon panel. --> 92 <!-- Main nucleon panel. -->
93 <div class="panel panel-default window-manager-window"> 93 <div class="panel panel-default window-manager-window" data-target="pack-rat">
94 <div class="panel-heading"> 94 <div class="panel-heading">
95 Pack-Rat 95 Pack-Rat
96 <button type="button" class="close window-manager-close-button" data-target="pack-rat"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button> 96 <button type="button" class="close window-manager-close-button" data-target="pack-rat"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
97 </div> 97 </div>
98 <div class="panel-body"> 98 <div class="panel-body">
99 <!-- Will hold the inventory tree (completed dynamically). --> 99 <!-- Will hold the inventory tree (completed dynamically). -->
100 <div id="pack-rat-tree"> 100 <div id="pack-rat-tree">
101 </div> 101 </div>
102 </div> 102 </div>
103 <!-- Bootstrap Table --> 103 <!-- Bootstrap Table -->
104 <script src="/pack-rat/node_modules/bootstrap-table/dist/bootstrap-table.min.js" type="text/javascript"></script> 104 <script src="/pack-rat/node_modules/bootstrap-table/dist/bootstrap-table.min.js" type="text/javascript"></script>
105 <!-- Bootstrap Form Validator --> 105 <!-- Bootstrap Form Validator -->
106 <script src="/node_modules/bootstrap-validator/dist/validator.min.js" type="text/javascript"></script> 106 <script src="/node_modules/bootstrap-validator/dist/validator.min.js" type="text/javascript"></script>
107 <!-- Forge --> 107 <!-- Forge -->
108 <script src="/node_modules/node-forge/dist/forge.all.min.js" type="text/javascript"></script> 108 <script src="/node_modules/node-forge/dist/forge.all.min.js" type="text/javascript"></script>
109 <!-- Moment JS --> 109 <!-- Moment JS -->
110 <script src="/pack-rat/node_modules/moment/min/moment.min.js" type="text/javascript"></script> 110 <script src="/pack-rat/node_modules/moment/min/moment.min.js" type="text/javascript"></script>
111 <!-- JsTree --> 111 <!-- JsTree -->
112 <script src="/pack-rat/node_modules/jstree/dist/jstree.min.js" type="text/javascript"></script> 112 <script src="/pack-rat/node_modules/jstree/dist/jstree.min.js" type="text/javascript"></script>
113 <!-- Main script --> 113 <!-- Main script -->
114 <script type="text/javascript"> 114 <script type="text/javascript">
115 $(function() { 115 $(function() {
116 function customMenu(node) { 116 function customMenu(node) {
117 // The default set of menu items for all types 117 // The default set of menu items for all types
118 var items = { 118 var items = {
119 // Grab information about the item. 119 // Grab information about the item.
120 infoItem: { 120 infoItem: {
121 label: "Get Info", 121 label: "Get Info",
122 action: function(obj) { 122 action: function(obj) {
123 $.ajax({ 123 $.ajax({
124 //async: false, 124 //async: false,
125 type: 'POST', 125 type: 'POST',
126 url: '/', 126 url: '/',
127 dataType: 'json', 127 dataType: 'json',
128 data: { 128 data: {
129 command: 'getinventorydata', 129 command: 'getinventorydata',
130 item: node.id, 130 item: node.id,
131 data: wasArrayToCSV([ 131 data: wasArrayToCSV([
132 'AssetUUID', 132 'AssetUUID',
133 'CreationDate', 133 'CreationDate',
134 'Description', 134 'Description',
135 'Permissions', 135 'Permissions',
136 'UUID' // part of InventoryBase 136 'UUID' // part of InventoryBase
137 ]) 137 ])
138 } 138 }
139 }).done(function(response) { 139 }).done(function(response) {
140 if(response.success !== 'True') { 140 if(response.success !== 'True') {
141 alert('Error moving item: ' + response.error); 141 alert('Error moving item: ' + response.error);
142 return; 142 return;
143 } 143 }
144 $('#pack-rat-item-info').bootstrapTable({ 144 $('#pack-rat-item-info').bootstrapTable({
145 data: [ wasKeyValueObjectify(wasCSVToArray(response.data)) ] 145 data: [ wasKeyValueObjectify(wasCSVToArray(response.data)) ]
146 }); 146 });
147 $('#pack-rat-item-info-modal').modal('show'); 147 $('#pack-rat-item-info-modal').modal('show');
148 }); 148 });
149 } 149 }
150 } 150 }
151 }; 151 };
152   152  
153 // Give inventory items menu for anything but folders. 153 // Give inventory items menu for anything but folders.
154 // They could be supported too but would require first 154 // They could be supported too but would require first
155 // counting the number of items inside the folder and 155 // counting the number of items inside the folder and
156 // only accepting to send if the number is below max. 156 // only accepting to send if the number is below max.
157 if (node.data.type != "folder") { 157 if (node.data.type != "folder") {
158 $.extend(items, { 158 $.extend(items, {
159 giveItem: { 159 giveItem: {
160 label: "Give", 160 label: "Give",
161 action: function(obj) { 161 action: function(obj) {
162 $('#pack-rat-avatar-select-modal') 162 $('#pack-rat-avatar-select-modal')
163 .modal('show') 163 .modal('show')
164 .on('click', '#pack-rat-send-item', function(e) { 164 .on('click', '#pack-rat-send-item', function(e) {
165 $('#pack-rat-avatar-select-modal').modal('hide').unbind('click'); 165 $('#pack-rat-avatar-select-modal').modal('hide').unbind('click');
166 $.ajax({ 166 $.ajax({
167 type: 'POST', 167 type: 'POST',
168 url: '/', 168 url: '/',
169 data: { 169 data: {
170 command: 'give', 170 command: 'give',
171 entity: 'avatar', 171 entity: 'avatar',
172 item: node.id, 172 item: node.id,
173 firstname: $('#pack-rat-avatar-firstname').val(), 173 firstname: $('#pack-rat-avatar-firstname').val(),
174 lastname: $('#pack-rat-avatar-lastname').val() 174 lastname: $('#pack-rat-avatar-lastname').val()
175 }, 175 },
176 dataType: 'json' 176 dataType: 'json'
177 }).done(function(response) { 177 }).done(function(response) {
178 if(response.success !== 'True') { 178 if(response.success !== 'True') {
179 alert('Error sending item: ' + response.error); 179 alert('Error sending item: ' + response.error);
180 return; 180 return;
181 } 181 }
182 }); 182 });
183 }); 183 });
184 } 184 }
185 } 185 }
186 }); 186 });
187 } 187 }
188   188  
189 // The "download" menu item for textures. 189 // The "download" menu item for textures.
190 if (node.data.type == "texture" || node.data.type == "snapshot") { 190 if (node.data.type == "texture" || node.data.type == "snapshot") {
191 $.extend(items, { 191 $.extend(items, {
192 downloadItem: { 192 downloadItem: {
193 label: "Download", 193 label: "Download",
194 "action": function(obj) { 194 "action": function(obj) {
195 $("<img id='pack-rat-item-download-texture' width='100%' height='100%'>") 195 $("<img id='pack-rat-item-download-texture' width='100%' height='100%'>")
196 .attr('src', '/pack-rat/img/loader.svg') 196 .attr('src', '/img/loader.gif')
197 .appendTo('#pack-rat-item-download-content'); 197 .appendTo('#pack-rat-item-download-content');
198 $('#pack-rat-item-download-modal') 198 $('#pack-rat-item-download-modal')
199 .modal('show') 199 .modal('show')
200 .on('hidden.bs.modal', function (e) { 200 .on('hidden.bs.modal', function (e) {
201 $('#pack-rat-item-download-content') 201 $('#pack-rat-item-download-content')
202 .html(''); 202 .html('');
203 }); 203 });
204 $.ajax({ 204 $.ajax({
205 type: 'POST', 205 type: 'POST',
206 url: '/', 206 url: '/',
207 data: { 207 data: {
208 command: 'download', 208 command: 'download',
209 item: node.id, 209 item: node.id,
210 format: 'Png', 210 format: 'Png',
211 type: 'Texture' 211 type: 'Texture'
212 }, 212 },
213 dataType: 'json' 213 dataType: 'json'
214 }).done(function(response) { 214 }).done(function(response) {
215 // Create the image tag and set the content. 215 // Create the image tag and set the content.
216 $("#pack-rat-item-download-texture") 216 $("#pack-rat-item-download-texture")
217 .attr('src', "data:image/png;base64," + response.data); 217 .attr('src', "data:image/png;base64," + response.data);
218 }); 218 });
219 } 219 }
220 } 220 }
221 }); 221 });
222 } 222 }
223   223  
224 // The "download" menu item for notecards. 224 // The "download" menu item for notecards.
225 if (node.data.type == "notecard") { 225 if (node.data.type == "notecard") {
226 $.extend(items, { 226 $.extend(items, {
227 downloadItem: { 227 downloadItem: {
228 label: "Download", 228 label: "Download",
229 "action": function(obj) { 229 "action": function(obj) {
230 $("<img id='pack-rat-item-download-texture' width='100%' height='100%'>") 230 $("<img id='pack-rat-item-download-texture' width='100%' height='100%'>")
231 .attr('src', '/pack-rat/img/loader.svg') 231 .attr('src', '/img/loader.gif')
232 .appendTo('#pack-rat-item-download-content'); 232 .appendTo('#pack-rat-item-download-content');
233 $('#pack-rat-item-download-modal') 233 $('#pack-rat-item-download-modal')
234 .modal('show') 234 .modal('show')
235 .on('hidden.bs.modal', function (e) { 235 .on('hidden.bs.modal', function (e) {
236 $('#pack-rat-item-download-content') 236 $('#pack-rat-item-download-content')
237 .html(''); 237 .html('');
238 }); 238 });
239 $.ajax({ 239 $.ajax({
240 type: 'POST', 240 type: 'POST',
241 url: '/', 241 url: '/',
242 data: { 242 data: {
243 command: 'download', 243 command: 'download',
244 item: node.id, 244 item: node.id,
245 type: 'Notecard' 245 type: 'Notecard'
246 }, 246 },
247 dataType: 'json' 247 dataType: 'json'
248 }).done(function(response) { 248 }).done(function(response) {
249 $('#pack-rat-item-download-content') 249 $('#pack-rat-item-download-content')
250 .html(''); 250 .html('');
251 251
252 // Decode notecard and display it. 252 // Decode notecard and display it.
253 $('#pack-rat-item-download-content').html( 253 $('#pack-rat-item-download-content').html(
254 '<pre>' + 254 '<pre>' +
255 forge.util.decodeUtf8( 255 forge.util.decodeUtf8(
256 forge.util.decode64(response.data) 256 forge.util.decode64(response.data)
257 ) + 257 ) +
258 '</pre>' 258 '</pre>'
259 ); 259 );
260 }); 260 });
261 } 261 }
262 } 262 }
263 }); 263 });
264 } 264 }
265   265  
266 // The "download" menu item for sounds. 266 // The "download" menu item for sounds.
267 if (node.data.type == "sound") { 267 if (node.data.type == "sound") {
268 $.extend(items, { 268 $.extend(items, {
269 downloadItem: { 269 downloadItem: {
270 label: "Download", 270 label: "Download",
271 "action": function(obj) { 271 "action": function(obj) {
272 $("<img id='pack-rat-item-download-texture' width='100%' height='100%'>") 272 $("<img id='pack-rat-item-download-texture' width='100%' height='100%'>")
273 .attr('src', '/pack-rat/img/loader.svg') 273 .attr('src', '/img/loader.gif')
274 .appendTo('#pack-rat-item-download-content'); 274 .appendTo('#pack-rat-item-download-content');
275 $('#pack-rat-item-download-modal') 275 $('#pack-rat-item-download-modal')
276 .modal('show') 276 .modal('show')
277 .on('hidden.bs.modal', function (e) { 277 .on('hidden.bs.modal', function (e) {
278 $('#pack-rat-item-download-content') 278 $('#pack-rat-item-download-content')
279 .html(''); 279 .html('');
280 }); 280 });
281 $.ajax({ 281 $.ajax({
282 type: 'POST', 282 type: 'POST',
283 url: '/', 283 url: '/',
284 data: { 284 data: {
285 command: 'download', 285 command: 'download',
286 item: node.id, 286 item: node.id,
287 type: 'Sound', 287 type: 'Sound',
288 format: 'wav' 288 format: 'wav'
289 }, 289 },
290 dataType: 'json' 290 dataType: 'json'
291 }).done(function(response) { 291 }).done(function(response) {
292 $('#pack-rat-item-download-content') 292 $('#pack-rat-item-download-content')
293 .html(''); 293 .html('');
294 294
295 // Create HTML5 audio tags and load the data. 295 // Create HTML5 audio tags and load the data.
296 $('#pack-rat-item-download-content') 296 $('#pack-rat-item-download-content')
297 .html("<audio controls='' preload='auto'><source src='" + 'data:audio/x-wav;base64,' + response.data + "' type='audio/x-wav'></audio>"); 297 .html("<audio controls='' preload='auto'><source src='" + 'data:audio/x-wav;base64,' + response.data + "' type='audio/x-wav'></audio>");
298 }); 298 });
299 } 299 }
300 } 300 }
301 }); 301 });
302 } 302 }
303   303  
304 return items; 304 return items;
305 } 305 }
306   306  
307 $("#pack-rat-tree").jstree({ 307 $("#pack-rat-tree").jstree({
308 // - sort will sort items by date 308 // - sort will sort items by date
309 // - state will store the open / closed state of the jstree 309 // - state will store the open / closed state of the jstree
310 'plugins': ["themes", "json_data", "ui", "contextmenu", "sort", "dnd", "state"], 310 'plugins': ["themes", "json_data", "ui", "contextmenu", "sort", "dnd", "state"],
311 'contextmenu': { 311 'contextmenu': {
312 "items": function(node) { 312 "items": function(node) {
313 return customMenu(node); 313 return customMenu(node);
314 } 314 }
315 }, 315 },
316 'dnd': { 316 'dnd': {
317 // Do not copy items. 317 // Do not copy items.
318 'copy': false, 318 'copy': false,
319 // Do not execute the check callback whilst dragging. 319 // Do not execute the check callback whilst dragging.
320 'check_while_dragging': true 320 'check_while_dragging': true
321 }, 321 },
322 'sort': function(a, b) { 322 'sort': function(a, b) {
323 return this.get_node(a).data.time < this.get_node(b).data.time ? 1 : -1; 323 return this.get_node(a).data.time < this.get_node(b).data.time ? 1 : -1;
324 }, 324 },
325 'core': { 325 'core': {
326 'check_callback': function(operation, node, parent, position, more) { 326 'check_callback': function(operation, node, parent, position, more) {
327 // Only allow move operations 327 // Only allow move operations
328 if (operation !== 'move_node' || 328 if (operation !== 'move_node' ||
329 // Do not move system folders. 329 // Do not move system folders.
330 node.data.system !== false || 330 node.data.system !== false ||
331 // Do not allow moves above the root node. 331 // Do not allow moves above the root node.
332 parent.id === "#" || 332 parent.id === "#" ||
333 // Do not allow moving an item over another item. 333 // Do not allow moving an item over another item.
334 (node.data.type !== 'folder' && parent.data.type !== 'folder')) 334 (node.data.type !== 'folder' && parent.data.type !== 'folder'))
335 return false; 335 return false;
336 336
337 var source = node.id; 337 var source = node.id;
338 var target = parent.id; 338 var target = parent.id;
339 339
340 // Normalize source and target. 340 // Normalize source and target.
341 if(source === '#') 341 if(source === '#')
342 source = '/'; 342 source = '/';
343 343
344 if(target === '#') 344 if(target === '#')
345 target = '/'; 345 target = '/';
346 346
347 if(source == '/' && target == '/') 347 if(source == '/' && target == '/')
348 return false; 348 return false;
349 349
350 // Check if source path is sane. 350 // Check if source path is sane.
351 if(source.split('/').some( 351 if(source.split('/').some(
352 function(part) { 352 function(part) {
353 return /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/.test(part); 353 return /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/.test(part);
354 })) { 354 })) {
355 return false; 355 return false;
356 } 356 }
357 357
358 // Check if target path is sane. 358 // Check if target path is sane.
359 if(target.split('/').some( 359 if(target.split('/').some(
360 function(part) { 360 function(part) {
361 return /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/.test(part); 361 return /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/.test(part);
362 })) { 362 })) {
363 return false; 363 return false;
364 } 364 }
365 365
366 return true; 366 return true;
367 }, 367 },
368 data: function(node, callback) { 368 data: function(node, callback) {
369 if(node.id === '#') { 369 if(node.id === '#') {
370 callback.call(this, [ 370 callback.call(this, [
371 { 371 {
372 "id" : "/My Inventory", 372 "id" : "/My Inventory",
373 "parent" : "#", 373 "parent" : "#",
374 "text" : "My Inventory", 374 "text" : "My Inventory",
375 "data" : { 375 "data" : {
376 "type" : "folder", 376 "type" : "folder",
377 'time' : Date.now(), 377 'time' : Date.now(),
378 'system' : true 378 'system' : true
379 }, 379 },
380 "children" : true, 380 "children" : true,
381 "opened" : false 381 "opened" : false
382 }, 382 },
383 { 383 {
384 "id" : "/Library", 384 "id" : "/Library",
385 "parent" : "#", 385 "parent" : "#",
386 "text" : "Library", 386 "text" : "Library",
387 "data" : { 387 "data" : {
388 "type" : "folder", 388 "type" : "folder",
389 'time' : Date.now(), 389 'time' : Date.now(),
390 'system' : true 390 'system' : true
391 }, 391 },
392 "children" : true, 392 "children" : true,
393 "opened" : false 393 "opened" : false
394 } 394 }
395 ]); 395 ]);
396 return; 396 return;
397 } 397 }
398 $.ajax({ 398 $.ajax({
399 //async: false, 399 //async: false,
400 type: 'POST', 400 type: 'POST',
401 url: '/', 401 url: '/',
402 dataType: 'json', 402 dataType: 'json',
403 data: { 403 data: {
404 command: 'inventory', 404 command: 'inventory',
405 action: 'ls', 405 action: 'ls',
406 path: node.id 406 path: node.id
407 } 407 }
408 }).done(function(response) { 408 }).done(function(response) {
409 var list = []; 409 var list = [];
410 $.each(wasCSVToArray(response.data) 410 $.each(wasCSVToArray(response.data)
411 .chunk(10), 411 .chunk(10),
412 function(i, e) { 412 function(i, e) {
413 e = wasKeyValueObjectify(e); 413 e = wasKeyValueObjectify(e);
414 //alert(node.id + " to " + JSON.stringify(e, 4, null)); 414 //alert(node.id + " to " + JSON.stringify(e, 4, null));
415 list.push({ 415 list.push({
416 'id' : node.id === '/' ? '/' + e['item'] : node.id + '/' + e['item'], 416 'id' : node.id === '/' ? '/' + e['item'] : node.id + '/' + e['item'],
417 'parent' : node.id, 417 'parent' : node.id,
418 'data' : { 418 'data' : {
419 'type' : e['type'], 419 'type' : e['type'],
420 'time' : Date.parse(e['time']), 420 'time' : Date.parse(e['time']),
421 // Check if this folder is a system folder. 421 // Check if this folder is a system folder.
422 'system' : node.id === '/My Inventory' && ( 422 'system' : node.id === '/My Inventory' && (
423 e['name'] === 'Trash' || 423 e['name'] === 'Trash' ||
424 e['name'] === 'Notecards' || 424 e['name'] === 'Notecards' ||
425 e['name'] === 'Scripts' || 425 e['name'] === 'Scripts' ||
426 e['name'] === 'Lost And Found' || 426 e['name'] === 'Lost And Found' ||
427 e['name'] === 'Landmarks' || 427 e['name'] === 'Landmarks' ||
428 e['name'] === 'Current Outfit' || 428 e['name'] === 'Current Outfit' ||
429 e['name'] === 'Calling Cards' || 429 e['name'] === 'Calling Cards' ||
430 e['name'] === 'Textures' || 430 e['name'] === 'Textures' ||
431 e['name'] === 'Objects' || 431 e['name'] === 'Objects' ||
432 e['name'] === 'My Outfits' || 432 e['name'] === 'My Outfits' ||
433 e['name'] === 'Clothing' || 433 e['name'] === 'Clothing' ||
434 e['name'] === 'Body Parts' || 434 e['name'] === 'Body Parts' ||
435 e['name'] === 'Photo Album' || 435 e['name'] === 'Photo Album' ||
436 e['name'] === 'Favorites' || 436 e['name'] === 'Favorites' ||
437 e['name'] === 'Gestures' || 437 e['name'] === 'Gestures' ||
438 e['name'] === 'Animations' 438 e['name'] === 'Animations'
439 ) 439 )
440 }, 440 },
441 'text' : e['name'], 441 'text' : e['name'],
442 'children' : e['type'] === 'folder', 442 'children' : e['type'] === 'folder',
443 'icon' : '/pack-rat/img/icons/' + e['type'] + '.gif', 443 'icon' : '/pack-rat/img/icons/' + e['type'] + '.gif',
444 'opened' : 'false' 444 'opened' : 'false'
445 }); 445 });
446 }); 446 });
447 callback.call(this, list); 447 callback.call(this, list);
448 }); 448 });
449 } 449 }
450 } 450 }
451 }).bind('move_node.jstree', function(e, data) { 451 }).bind('move_node.jstree', function(e, data) {
452 $.ajax({ 452 $.ajax({
453 //async: false, 453 //async: false,
454 type: 'POST', 454 type: 'POST',
455 url: '/', 455 url: '/',
456 dataType: 'json', 456 dataType: 'json',
457 data: { 457 data: {
458 command: 'inventory', 458 command: 'inventory',
459 action: 'mv', 459 action: 'mv',
460 source: data.node.id, 460 source: data.node.id,
461 target: data.parent 461 target: data.parent
462 } 462 }
463 }).done(function(response) { 463 }).done(function(response) {
464 if(response.success !== 'True') { 464 if(response.success !== 'True') {
465 alert('Error moving item: ' + response.error); 465 alert('Error moving item: ' + response.error);
466 } 466 }
467 }); 467 });
468 // Once the node is moved, update the node ID to reflect the path change. 468 // Once the node is moved, update the node ID to reflect the path change.
469 var parentPath = data.parent != '/' ? data.parent : ""; 469 var parentPath = data.parent != '/' ? data.parent : "";
470 var item = data.node.id.split(/[\/]+/).pop(); 470 var item = data.node.id.split(/[\/]+/).pop();
471 data.instance.set_id(data.node, parentPath + '/' + item); 471 data.instance.set_id(data.node, parentPath + '/' + item);
472 }); 472 });
473 473
474 // Move context menu to top-most. 474 // Move context menu to top-most.
475 $('#pack-rat-tree').on('contextmenu', '.jstree-anchor', function (e) { 475 $('#pack-rat-tree').on('contextmenu', '.jstree-anchor', function (e) {
476 $('.vakata-context').css('z-index', getTopWindowIndex() + 1); 476 $('.vakata-context').css('z-index', getTopWindowIndex() + 1);
477 }); 477 });
478 }); 478 });
479 </script> 479 </script>
480 </div> 480 </div>
481 </div> 481 </div>
482   482  
483
Generated by GNU Enscript 1.6.5.90.
483
Generated by GNU Enscript 1.6.5.90.
484   484  
485   485  
486   486