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

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 30 Rev 38
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">
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 <!-- JSON to Table --> -  
114 <script src="/pack-rat/node_modules/json-to-table/json-to-table.js" type="text/javascript"></script> -  
115 <!-- Main script --> 113 <!-- Main script -->
116 <script type="text/javascript"> 114 <script type="text/javascript">
117 $(function() { 115 $(function() {
118 function customMenu(node) { 116 function customMenu(node) {
119 // The default set of menu items for all types 117 // The default set of menu items for all types
120 var items = { 118 var items = {
121 // Grab information about the item. 119 // Grab information about the item.
122 infoItem: { 120 infoItem: {
123 label: "Get Info", 121 label: "Get Info",
124 action: function(obj) { 122 action: function(obj) {
125 $.ajax({ 123 $.ajax({
126 //async: false, 124 //async: false,
127 type: 'POST', 125 type: 'POST',
128 url: '/', 126 url: '/',
129 dataType: 'json', 127 dataType: 'json',
130 data: { 128 data: {
131 command: 'getinventorydata', 129 command: 'getinventorydata',
132 item: node.id, 130 item: node.id,
133 data: wasArrayToCSV([ 131 data: wasArrayToCSV([
134 'AssetUUID', 132 'AssetUUID',
135 'CreationDate', 133 'CreationDate',
136 'Description', 134 'Description',
137 'Permissions', 135 'Permissions',
138 'UUID' // part of InventoryBase 136 'UUID' // part of InventoryBase
139 ]) 137 ])
140 } 138 }
141 }).done(function(response) { 139 }).done(function(response) {
142 if(response.success !== 'True') { 140 if(response.success !== 'True') {
143 alert('Error moving item: ' + response.error); 141 alert('Error moving item: ' + response.error);
144 return; 142 return;
145 } 143 }
146 $('#pack-rat-item-info').bootstrapTable({ 144 $('#pack-rat-item-info').bootstrapTable({
147 data: [ wasKeyValueObjectify(wasCSVToArray(response.data)) ] 145 data: [ wasKeyValueObjectify(wasCSVToArray(response.data)) ]
148 }); 146 });
149 $('#pack-rat-item-info-modal').modal('show'); 147 $('#pack-rat-item-info-modal').modal('show');
150 }); 148 });
151 } 149 }
152 } 150 }
153 }; 151 };
154   152  
155 // Give inventory items menu for anything but folders. 153 // Give inventory items menu for anything but folders.
156 // They could be supported too but would require first 154 // They could be supported too but would require first
157 // counting the number of items inside the folder and 155 // counting the number of items inside the folder and
158 // only accepting to send if the number is below max. 156 // only accepting to send if the number is below max.
159 if (node.data.type != "folder") { 157 if (node.data.type != "folder") {
160 $.extend(items, { 158 $.extend(items, {
161 giveItem: { 159 giveItem: {
162 label: "Give", 160 label: "Give",
163 action: function(obj) { 161 action: function(obj) {
164 $('#pack-rat-avatar-select-modal') 162 $('#pack-rat-avatar-select-modal')
165 .modal('show') 163 .modal('show')
166 .on('click', '#pack-rat-send-item', function(e) { 164 .on('click', '#pack-rat-send-item', function(e) {
167 $('#pack-rat-avatar-select-modal').modal('hide').unbind('click'); 165 $('#pack-rat-avatar-select-modal').modal('hide').unbind('click');
168 $.ajax({ 166 $.ajax({
169 type: 'POST', 167 type: 'POST',
170 url: '/', 168 url: '/',
171 data: { 169 data: {
172 command: 'give', 170 command: 'give',
173 entity: 'avatar', 171 entity: 'avatar',
174 item: node.id, 172 item: node.id,
175 firstname: $('#pack-rat-avatar-firstname').val(), 173 firstname: $('#pack-rat-avatar-firstname').val(),
176 lastname: $('#pack-rat-avatar-lastname').val() 174 lastname: $('#pack-rat-avatar-lastname').val()
177 }, 175 },
178 dataType: 'json' 176 dataType: 'json'
179 }).done(function(response) { 177 }).done(function(response) {
180 if(response.success !== 'True') { 178 if(response.success !== 'True') {
181 alert('Error sending item: ' + response.error); 179 alert('Error sending item: ' + response.error);
182 return; 180 return;
183 } 181 }
184 }); 182 });
185 }); 183 });
186 } 184 }
187 } 185 }
188 }); 186 });
189 } 187 }
190   188  
191 // The "download" menu item for textures. 189 // The "download" menu item for textures.
192 if (node.data.type == "texture" || node.data.type == "snapshot") { 190 if (node.data.type == "texture" || node.data.type == "snapshot") {
193 $.extend(items, { 191 $.extend(items, {
194 downloadItem: { 192 downloadItem: {
195 label: "Download", 193 label: "Download",
196 "action": function(obj) { 194 "action": function(obj) {
197 $("<img id='pack-rat-item-download-texture' width='100%' height='100%'>") 195 $("<img id='pack-rat-item-download-texture' width='100%' height='100%'>")
198 .attr('src', '/pack-rat/img/loader.svg') 196 .attr('src', '/pack-rat/img/loader.svg')
199 .appendTo('#pack-rat-item-download-content'); 197 .appendTo('#pack-rat-item-download-content');
200 $('#pack-rat-item-download-modal') 198 $('#pack-rat-item-download-modal')
201 .modal('show') 199 .modal('show')
202 .on('hidden.bs.modal', function (e) { 200 .on('hidden.bs.modal', function (e) {
203 $('#pack-rat-item-download-content') 201 $('#pack-rat-item-download-content')
204 .html(''); 202 .html('');
205 }); 203 });
206 $.ajax({ 204 $.ajax({
207 type: 'POST', 205 type: 'POST',
208 url: '/', 206 url: '/',
209 data: { 207 data: {
210 command: 'download', 208 command: 'download',
211 item: node.id, 209 item: node.id,
212 format: 'Png', 210 format: 'Png',
213 type: 'Texture' 211 type: 'Texture'
214 }, 212 },
215 dataType: 'json' 213 dataType: 'json'
216 }).done(function(response) { 214 }).done(function(response) {
217 // Create the image tag and set the content. 215 // Create the image tag and set the content.
218 $("#pack-rat-item-download-texture") 216 $("#pack-rat-item-download-texture")
219 .attr('src', "data:image/png;base64," + response.data); 217 .attr('src', "data:image/png;base64," + response.data);
220 }); 218 });
221 } 219 }
222 } 220 }
223 }); 221 });
224 } 222 }
225   223  
226 // The "download" menu item for notecards. 224 // The "download" menu item for notecards.
227 if (node.data.type == "notecard") { 225 if (node.data.type == "notecard") {
228 $.extend(items, { 226 $.extend(items, {
229 downloadItem: { 227 downloadItem: {
230 label: "Download", 228 label: "Download",
231 "action": function(obj) { 229 "action": function(obj) {
232 $("<img id='pack-rat-item-download-texture' width='100%' height='100%'>") 230 $("<img id='pack-rat-item-download-texture' width='100%' height='100%'>")
233 .attr('src', '/pack-rat/img/loader.svg') 231 .attr('src', '/pack-rat/img/loader.svg')
234 .appendTo('#pack-rat-item-download-content'); 232 .appendTo('#pack-rat-item-download-content');
235 $('#pack-rat-item-download-modal') 233 $('#pack-rat-item-download-modal')
236 .modal('show') 234 .modal('show')
237 .on('hidden.bs.modal', function (e) { 235 .on('hidden.bs.modal', function (e) {
238 $('#pack-rat-item-download-content') 236 $('#pack-rat-item-download-content')
239 .html(''); 237 .html('');
240 }); 238 });
241 $.ajax({ 239 $.ajax({
242 type: 'POST', 240 type: 'POST',
243 url: '/', 241 url: '/',
244 data: { 242 data: {
245 command: 'download', 243 command: 'download',
246 item: node.id, 244 item: node.id,
247 type: 'Notecard' 245 type: 'Notecard'
248 }, 246 },
249 dataType: 'json' 247 dataType: 'json'
250 }).done(function(response) { 248 }).done(function(response) {
251 $('#pack-rat-item-download-content') 249 $('#pack-rat-item-download-content')
252 .html(''); 250 .html('');
253 251
254 // Decode notecard and display it. 252 // Decode notecard and display it.
255 $('#pack-rat-item-download-content').html( 253 $('#pack-rat-item-download-content').html(
256 '<pre>' + 254 '<pre>' +
257 forge.util.decodeUtf8( 255 forge.util.decodeUtf8(
258 forge.util.decode64(response.data) 256 forge.util.decode64(response.data)
259 ) + 257 ) +
260 '</pre>' 258 '</pre>'
261 ); 259 );
262 }); 260 });
263 } 261 }
264 } 262 }
265 }); 263 });
266 } 264 }
267   265  
268 // The "download" menu item for sounds. 266 // The "download" menu item for sounds.
269 if (node.data.type == "sound") { 267 if (node.data.type == "sound") {
270 $.extend(items, { 268 $.extend(items, {
271 downloadItem: { 269 downloadItem: {
272 label: "Download", 270 label: "Download",
273 "action": function(obj) { 271 "action": function(obj) {
274 $("<img id='pack-rat-item-download-texture' width='100%' height='100%'>") 272 $("<img id='pack-rat-item-download-texture' width='100%' height='100%'>")
275 .attr('src', '/pack-rat/img/loader.svg') 273 .attr('src', '/pack-rat/img/loader.svg')
276 .appendTo('#pack-rat-item-download-content'); 274 .appendTo('#pack-rat-item-download-content');
277 $('#pack-rat-item-download-modal') 275 $('#pack-rat-item-download-modal')
278 .modal('show') 276 .modal('show')
279 .on('hidden.bs.modal', function (e) { 277 .on('hidden.bs.modal', function (e) {
280 $('#pack-rat-item-download-content') 278 $('#pack-rat-item-download-content')
281 .html(''); 279 .html('');
282 }); 280 });
283 $.ajax({ 281 $.ajax({
284 type: 'POST', 282 type: 'POST',
285 url: '/', 283 url: '/',
286 data: { 284 data: {
287 command: 'download', 285 command: 'download',
288 item: node.id, 286 item: node.id,
289 type: 'Sound', 287 type: 'Sound',
290 format: 'wav' 288 format: 'wav'
291 }, 289 },
292 dataType: 'json' 290 dataType: 'json'
293 }).done(function(response) { 291 }).done(function(response) {
294 $('#pack-rat-item-download-content') 292 $('#pack-rat-item-download-content')
295 .html(''); 293 .html('');
296 294
297 // Create HTML5 audio tags and load the data. 295 // Create HTML5 audio tags and load the data.
298 $('#pack-rat-item-download-content') 296 $('#pack-rat-item-download-content')
299 .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>");
300 }); 298 });
301 } 299 }
302 } 300 }
303 }); 301 });
304 } 302 }
305   303  
306 return items; 304 return items;
307 } 305 }
308   306  
309 $("#pack-rat-tree").jstree({ 307 $("#pack-rat-tree").jstree({
310 // - sort will sort items by date 308 // - sort will sort items by date
311 // - state will store the open / closed state of the jstree 309 // - state will store the open / closed state of the jstree
312 'plugins': ["themes", "json_data", "ui", "contextmenu", "sort", "dnd", "state"], 310 'plugins': ["themes", "json_data", "ui", "contextmenu", "sort", "dnd", "state"],
313 'contextmenu': { 311 'contextmenu': {
314 "items": function(node) { 312 "items": function(node) {
315 return customMenu(node); 313 return customMenu(node);
316 } 314 }
317 }, 315 },
318 'dnd': { 316 'dnd': {
319 // Do not copy items. 317 // Do not copy items.
320 'copy': false, 318 'copy': false,
321 // Do not execute the check callback whilst dragging. 319 // Do not execute the check callback whilst dragging.
322 'check_while_dragging': true 320 'check_while_dragging': true
323 }, 321 },
324 'sort': function(a, b) { 322 'sort': function(a, b) {
325 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;
326 }, 324 },
327 'core': { 325 'core': {
328 'check_callback': function(operation, node, parent, position, more) { 326 'check_callback': function(operation, node, parent, position, more) {
329 // Only allow move operations 327 // Only allow move operations
330 if (operation !== 'move_node' || 328 if (operation !== 'move_node' ||
331 // Do not move system folders. 329 // Do not move system folders.
332 node.data.system !== false || 330 node.data.system !== false ||
333 // Do not allow moves above the root node. 331 // Do not allow moves above the root node.
334 parent.id === "#" || 332 parent.id === "#" ||
335 // Do not allow moving an item over another item. 333 // Do not allow moving an item over another item.
336 (node.data.type !== 'folder' && parent.data.type !== 'folder')) 334 (node.data.type !== 'folder' && parent.data.type !== 'folder'))
337 return false; 335 return false;
338 336
339 var source = node.id; 337 var source = node.id;
340 var target = parent.id; 338 var target = parent.id;
341 339
342 // Normalize source and target. 340 // Normalize source and target.
343 if(source === '#') 341 if(source === '#')
344 source = '/'; 342 source = '/';
345 343
346 if(target === '#') 344 if(target === '#')
347 target = '/'; 345 target = '/';
348 346
349 if(source == '/' && target == '/') 347 if(source == '/' && target == '/')
350 return false; 348 return false;
351 349
352 // Check if source path is sane. 350 // Check if source path is sane.
353 if(source.split('/').some( 351 if(source.split('/').some(
354 function(part) { 352 function(part) {
355 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);
356 })) { 354 })) {
357 return false; 355 return false;
358 } 356 }
359 357
360 // Check if target path is sane. 358 // Check if target path is sane.
361 if(target.split('/').some( 359 if(target.split('/').some(
362 function(part) { 360 function(part) {
363 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);
364 })) { 362 })) {
365 return false; 363 return false;
366 } 364 }
367 365
368 return true; 366 return true;
369 }, 367 },
370 data: function(node, callback) { 368 data: function(node, callback) {
371 if(node.id === '#') { 369 if(node.id === '#') {
372 callback.call(this, [ 370 callback.call(this, [
373 { 371 {
374 "id" : "/My Inventory", 372 "id" : "/My Inventory",
375 "parent" : "#", 373 "parent" : "#",
376 "text" : "My Inventory", 374 "text" : "My Inventory",
377 "data" : { 375 "data" : {
378 "type" : "folder", 376 "type" : "folder",
379 'time' : Date.now(), 377 'time' : Date.now(),
380 'system' : true 378 'system' : true
381 }, 379 },
382 "children" : true, 380 "children" : true,
383 "opened" : false 381 "opened" : false
384 }, 382 },
385 { 383 {
386 "id" : "/Library", 384 "id" : "/Library",
387 "parent" : "#", 385 "parent" : "#",
388 "text" : "Library", 386 "text" : "Library",
389 "data" : { 387 "data" : {
390 "type" : "folder", 388 "type" : "folder",
391 'time' : Date.now(), 389 'time' : Date.now(),
392 'system' : true 390 'system' : true
393 }, 391 },
394 "children" : true, 392 "children" : true,
395 "opened" : false 393 "opened" : false
396 } 394 }
397 ]); 395 ]);
398 return; 396 return;
399 } 397 }
400 $.ajax({ 398 $.ajax({
401 //async: false, 399 //async: false,
402 type: 'POST', 400 type: 'POST',
403 url: '/', 401 url: '/',
404 dataType: 'json', 402 dataType: 'json',
405 data: { 403 data: {
406 command: 'inventory', 404 command: 'inventory',
407 action: 'ls', 405 action: 'ls',
408 path: node.id 406 path: node.id
409 } 407 }
410 }).done(function(response) { 408 }).done(function(response) {
411 var list = []; 409 var list = [];
412 $.each(wasCSVToArray(response.data) 410 $.each(wasCSVToArray(response.data)
413 .chunk(10), 411 .chunk(10),
414 function(i, e) { 412 function(i, e) {
415 e = wasKeyValueObjectify(e); 413 e = wasKeyValueObjectify(e);
416 //alert(node.id + " to " + JSON.stringify(e, 4, null)); 414 //alert(node.id + " to " + JSON.stringify(e, 4, null));
417 list.push({ 415 list.push({
418 'id' : node.id === '/' ? '/' + e['item'] : node.id + '/' + e['item'], 416 'id' : node.id === '/' ? '/' + e['item'] : node.id + '/' + e['item'],
419 'parent' : node.id, 417 'parent' : node.id,
420 'data' : { 418 'data' : {
421 'type' : e['type'], 419 'type' : e['type'],
422 'time' : Date.parse(e['time']), 420 'time' : Date.parse(e['time']),
423 // Check if this folder is a system folder. 421 // Check if this folder is a system folder.
424 'system' : node.id === '/My Inventory' && ( 422 'system' : node.id === '/My Inventory' && (
425 e['name'] === 'Trash' || 423 e['name'] === 'Trash' ||
426 e['name'] === 'Notecards' || 424 e['name'] === 'Notecards' ||
427 e['name'] === 'Scripts' || 425 e['name'] === 'Scripts' ||
428 e['name'] === 'Lost And Found' || 426 e['name'] === 'Lost And Found' ||
429 e['name'] === 'Landmarks' || 427 e['name'] === 'Landmarks' ||
430 e['name'] === 'Current Outfit' || 428 e['name'] === 'Current Outfit' ||
431 e['name'] === 'Calling Cards' || 429 e['name'] === 'Calling Cards' ||
432 e['name'] === 'Textures' || 430 e['name'] === 'Textures' ||
433 e['name'] === 'Objects' || 431 e['name'] === 'Objects' ||
434 e['name'] === 'My Outfits' || 432 e['name'] === 'My Outfits' ||
435 e['name'] === 'Clothing' || 433 e['name'] === 'Clothing' ||
436 e['name'] === 'Body Parts' || 434 e['name'] === 'Body Parts' ||
437 e['name'] === 'Photo Album' || 435 e['name'] === 'Photo Album' ||
438 e['name'] === 'Favorites' || 436 e['name'] === 'Favorites' ||
439 e['name'] === 'Gestures' || 437 e['name'] === 'Gestures' ||
440 e['name'] === 'Animations' 438 e['name'] === 'Animations'
441 ) 439 )
442 }, 440 },
443 'text' : e['name'], 441 'text' : e['name'],
444 'children' : e['type'] === 'folder', 442 'children' : e['type'] === 'folder',
445 'icon' : '/pack-rat/img/icons/' + e['type'] + '.gif', 443 'icon' : '/pack-rat/img/icons/' + e['type'] + '.gif',
446 'opened' : 'false' 444 'opened' : 'false'
447 }); 445 });
448 }); 446 });
449 callback.call(this, list); 447 callback.call(this, list);
450 }); 448 });
451 } 449 }
452 } 450 }
453 }).bind('move_node.jstree', function(e, data) { 451 }).bind('move_node.jstree', function(e, data) {
454 $.ajax({ 452 $.ajax({
455 //async: false, 453 //async: false,
456 type: 'POST', 454 type: 'POST',
457 url: '/', 455 url: '/',
458 dataType: 'json', 456 dataType: 'json',
459 data: { 457 data: {
460 command: 'inventory', 458 command: 'inventory',
461 action: 'mv', 459 action: 'mv',
462 source: data.node.id, 460 source: data.node.id,
463 target: data.parent 461 target: data.parent
464 } 462 }
465 }).done(function(response) { 463 }).done(function(response) {
466 if(response.success !== 'True') { 464 if(response.success !== 'True') {
467 alert('Error moving item: ' + response.error); 465 alert('Error moving item: ' + response.error);
468 } 466 }
469 }); 467 });
470 // 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.
471 var parentPath = data.parent != '/' ? data.parent : ""; 469 var parentPath = data.parent != '/' ? data.parent : "";
472 var item = data.node.id.split(/[\/]+/).pop(); 470 var item = data.node.id.split(/[\/]+/).pop();
473 data.instance.set_id(data.node, parentPath + '/' + item); 471 data.instance.set_id(data.node, parentPath + '/' + item);
474 }); 472 });
475 473
476 // Move context menu to top-most. 474 // Move context menu to top-most.
477 $('#pack-rat-tree').on('contextmenu', '.jstree-anchor', function (e) { 475 $('#pack-rat-tree').on('contextmenu', '.jstree-anchor', function (e) {
478 $('.vakata-context').css('z-index', getTopWindowIndex() + 1); 476 $('.vakata-context').css('z-index', getTopWindowIndex() + 1);
479 }); 477 });
480 }); 478 });
481 </script> 479 </script>
482 </div> 480 </div>
483 </div> 481 </div>
484   482  
485
Generated by GNU Enscript 1.6.5.90.
483
Generated by GNU Enscript 1.6.5.90.
486   484  
487   485  
488   486