corrade-nucleus-nucleons – Blame information for rev 13

Subversion Repositories:
Rev:
Rev Author Line No. Line
10 office 1 <!DOCTYPE html>
2  
3 <html lang="en">
4 <head>
5 <meta charset="utf-8">
6 <meta http-equiv="X-UA-Compatible" content="IE=edge">
7 <meta name="viewport" content="width=device-width, initial-scale=1">
8 <meta name="description" content="Corrade Nucleon">
9 <meta name="author" content="Wizardry and Steamworks">
10 <link rel="icon" href="favicon.ico">
11  
12 <title>Corrade Nucleus - Pack Rat Inventory Manager</title>
13  
14 <!-- Bootstrap core CSS -->
15 <link href="/bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" type="text/css">
16 <!-- Corrade Nucleus Fonts -->
17 <link href="/css/nucleus/fonts.css" rel="stylesheet" type="text/css">
18 <!-- Customized bootstrap style. -->
19 <link href="/css/nucleus/nucleus.css" rel="stylesheet" type="text/css">
20  
21 <!-- jsTree style -->
22 <link href="/pack-rat/bower_components/jstree/dist/themes/default/style.min.css" rel="stylesheet" type="text/css">
23 </script>
24 </head>
25  
26 <body>
27 <!-- Bootstrap Modal -->
28 <div id="popup" class="modal fade bs-example-modal-lg" role="dialog">
29 <div class="modal-dialog modal-lg">
30 <!-- Modal content-->
31  
32 <div class="modal-content">
33 <div class="modal-header">
34 <button type="button" class="close" data-dismiss="modal">&times;</button>
35  
36 <h1 id="title" class="modal-title"></h1>
37 </div>
38  
39 <div id="content" class="modal-body">
40 <div class="progress">
41 <div id="progressbar" class="progress-bar" role="progressbar" aria-valuenow="2" aria-valuemin="0" aria-valuemax="100" style="min-width: 2em; width: 2%;">
42 0%
43 </div>
44 </div>
45  
46 <div class="modal-footer">
47 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
48 </div>
49 </div>
50 </div>
51 </div>
52 </div>
53  
54 <div class="container">
55 <div class="jumbotron">
56 <h1>Corrade Pack Rat</h1>
57 <p class="lead">Pack Rat is an inventory manager for Corrade Nucleus that allows you to sort your inventory and perform other management operations.</p>
58 <img src="/pack-rat/img/pack-rat.png"></div>
59  
60 <!-- Will hold the inventory tree (completed dynamically). -->
61 <div id="tree">
62 </div>
63  
64 <footer class="footer">
65 <p>&copy; 2017 Wizardry and Steamworks</p>
66 </footer>
67 </div>
68 <!-- jQuery -->
69 <script src="/bower_components/jquery/dist/jquery.min.js" type="text/javascript"></script>
70 <!-- Wizardry and Steamworks JavaScript Includes -->
71 <script src="/bower_components/was/dist/was.min.js" type="text/javascript"></script>
72 <!-- Bootstrap Javascript -->
73 <script type="text/javascript" src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
74 <!-- Bootstrap Form Validator -->
75 <script src="/pack-rat/bower_components/bootstrap-validator/dist/validator.min.js" type="text/javascript"></script>
76 <!-- XML <-> JSON -->
77 <!-- <script src="/bootstrap/bower_components/x2js/xml2json.min.js" type="text/javascript"></script> -->
78 <!-- CryptoJS -->
79 <script src="/bower_components/cryptojslib/components/core.js" type="text/javascript"></script>
80 <script src="/bower_components/cryptojslib/rollups/md5.js" type="text/javascript"></script>
81 <!-- Form To Object -->
82 <!-- <script src="/bootstrap/node_modules/form_to_object/dist/formToObject.min.js" type="text/javascript"></script> -->
83 <!-- Load form processor. -->
84 <!-- <script src="/bootstrap/js/corrade-bootstrap-processor.js" type="text/javascript"></script> -->
85 <!-- Moment JS -->
86 <script src="/pack-rat/bower_components/moment/min/moment.min.js" type="text/javascript"></script>
87 <!-- JsTree -->
88 <script src="/pack-rat/bower_components/jstree/dist/jstree.min.js" type="text/javascript"></script>
89 <!-- JSON to Table -->
90 <script src="/pack-rat/bower_components/json-to-table/json-to-table.js" type="text/javascript"></script>
91 <!-- Main script -->
92 <script type="text/javascript">
93 $(function() {
94 function customMenu(node) {
95 // The default set of menu items for all types
96 var items = {
97 // Grab information about the item.
98 infoItem: {
99 label: "Get Info",
100 action: function(obj) {
101 $('#popup').dialog({
102 width: 800,
103 height: 600,
104 modal: true,
105 resizable: false,
106 dialogClass: 'no-close texture-dialog'
107 }).on('dialogclose', function(event) {
108 $('#content').html('');
109 });
110 $.ajax({
111 type: 'POST',
112 url: '/',
113 dataType: 'json',
114 data: {
115 command: 'getinventorydata',
116 item: node.id.split(/[\/]+/).pop(),
117 data: [
118 'AssetUUID',
119 'CreationDate',
120 'Description',
121 'Permissions',
122 'UUID' // part of InventoryBase
123 ]
124 }
125 }).done(function(data) {
126 $('#content').html(ConvertJsonToTable(data, null, null, null));
127 });
128 }
129 }
130 };
131  
132 // Give inventory items menu for anything but folders.
133 // They could be supported too but would require first
134 // counting the number of items inside the folder and
135 // only accepting to send if the number is below max.
136 if (node.data.type != "folder") {
137 $.extend(items, {
138 giveItem: {
139 label: "Give",
140 action: function(obj) {
141 $("#content").html('<form><fieldset class="ui-helper-reset"><label for="firstname">Firstname</label><input type="text" name="firstname" id="firstname" value="" class="ui-widget-content ui-corner-all"><br/><label for="lastname">Lastname</label><input type="text" name="lastname" id="lastname" value="" class="ui-widget-content ui-corner-all"></fieldset></form>');
142 $("#popup").dialog({
143 width: 320,
144 height: 180,
145 modal: true,
146 resizable: false,
147 buttons: {
148 Select: function() {
149 if ($.trim($("#firstname").val()) == '' ||
150 $.trim($("#lastname").val()) == '')
151 return;
152 var firstName = $("#firstname").val();
153 var lastName = $("#lastname").val();
154 $.ajax({
155 type: 'POST',
156 url: "giveInventoryItem.php?t=" + Math.random(),
157 data: {
158 uuid: node.id.split(/[\/]+/).pop(),
159 firstname: firstName,
160 lastname: lastName
161 }
162 }).done(function(data) {
163 $("#popup").dialog("close");
164 if ($.trim(data) != '')
165 alert(data);
166 });
167 },
168 Cancel: function() {
169 $("#popup").dialog("close");
170 }
171 }
172 }).on('dialogclose', function(event) {
173 $('#content').html('');
174 $('#popup').dialog('option', 'buttons', {});
175 });
176 }
177 }
178 });
179 }
180  
181 // The "download" menu item for textures.
182 if (node.data.type == "texture" || node.data.type == "snapshot") {
183 $.extend(items, {
184 downloadItem: {
185 label: "Download",
186 "action": function(obj) {
187 $('#texture').attr('src', 'images/loader.gif');
188 $('#popup').dialog({
189 width: 800,
190 height: 600,
191 modal: true,
192 resizable: false,
193 dialogClass: 'no-close texture-dialog'
194 }).on('dialogclose', function(event) {
195 $('#content').html('');
196 });
197 $.ajax({
198 type: 'POST',
199 url: "downloadTexture.php?t=" + Math.random(),
200 data: {
201 uuid: node.id.split(/[\/]+/).pop()
202 }
203 }).done(function(data) {
204 $('#content').html('<img src="" align="middle" id="texture">');
205 $('#texture').attr('src', "data:image/png;base64," + data);
206 });
207 }
208 }
209 });
210 }
211  
212 // The "download" menu item for notecards.
213 if (node.data.type == "notecard") {
214 $.extend(items, {
215 downloadItem: {
216 label: "Download",
217 "action": function(obj) {
218 $('#texture').attr('src', 'images/loader.gif');
219 $('#popup').dialog({
220 width: 800,
221 height: 600,
222 modal: true,
223 resizable: false,
224 dialogClass: 'no-close texture-dialog'
225 }).on('dialogclose', function(event) {
226 $('#content').html('');
227 });
228 $.ajax({
229 type: 'POST',
230 url: "downloadNotecard.php?t=" + Math.random(),
231 data: {
232 uuid: node.id.split(/[\/]+/).pop()
233 }
234 }).done(function(data) {
235 $.base64.utf8decode = true;
236 $('#content').html('<pre>' + $.base64.atob(data) + '</pre>');
237 });
238 }
239 }
240 });
241 }
242  
243 // The "download" menu item for sounds.
244 if (node.data.type == "sound") {
245 $.extend(items, {
246 downloadItem: {
247 label: "Download",
248 "action": function(obj) {
249 $('#texture').attr('src', 'images/loader.gif');
250 $('#popup').dialog({
251 width: 800,
252 height: 600,
253 modal: true,
254 resizable: false,
255 dialogClass: 'no-close texture-dialog'
256 }).on('dialogclose', function(event) {
257 $('#content').html('');
258 });
259 $.ajax({
260 type: 'POST',
261 url: "downloadSound.php?t=" + Math.random(),
262 data: {
263 uuid: node.id.split(/[\/]+/).pop()
264 }
265 }).done(function(data) {
266 $('#content').html('<audio controls="controls"><source id="source" src="" type="audio/mp3"></source></audio>');
267 $('#source').attr('src', "data:audio/mp3;base64," + data);
268 });
269 }
270 }
271 });
272 }
273  
274 return items;
275 }
276  
277 $("#tree").jstree({
278 // - sort will sort items by date
279 // - state will store the open / closed state of the jstree
280 'plugins': ["themes", "json_data", "ui", "contextmenu", "sort", "dnd", "state"],
281 /*'contextmenu': {
282 "items": function(node) {
283 return customMenu(node);
284 }
285 },*/
286 'dnd': {
287 // Do not copy items.
288 'copy': false,
289 // Do not execute the check callback whilst dragging.
290 'check_while_dragging': false
291 },
292 'sort': function(a, b) {
293 return Date.parse(this.get_node(a).data.time) <
294 Date.parse(this.get_node(b).data.time) ? 1 : -1;
295 },
296 'core': {
297 /*'check_callback': function(operation, node, parent, position, more) {
298 // Do not allow moves above the root node.
299 if (parent.id == "#")
300 return false;
301  
302 var moved = false;
303 $.ajax({
304 // A synchronous reply is needed so we know what to tell the tree.
305 async: false,
306 type: 'POST',
307 url: "moveInventoryItem.php?t=" + Math.random(),
308 data: {
309 source: node.id,
310 target: parent.id
311 }
312 }).done(function(data) {
313 if ($.trim(data) != 'success') {
314 if ($.trim(data) != '')
315 alert(data);
316 return;
317 }
318 moved = true;
319 });
320 return moved;
321 },*/
322 data: function(node, callback) {
323 if(node.id === '#') {
324 callback.call(this, [
325 {
326 "id" : "/My Inventory",
327 "parent" : "#",
328 "text" : "My Inventory",
329 "data" : {
330 "type" :
331 "folder"
332 },
333 "children" : true,
334 "opened" : false
335 },
336 {
337 "id" : "/Library",
338 "parent" : "#",
339 "text" : "Library",
340 "data" : {
341 "type" :
342 "folder"
343 },
344 "children" : true,
345 "opened" : false
346 }
347 ]);
348 return;
349 }
350 $.ajax({
351 //async: false,
352 type: 'POST',
353 url: '/',
354 dataType: 'json',
355 data: {
356 command: 'inventory',
357 action: 'ls',
358 path: node.id
359 }
360 }).done(function(response) {
361 var data = wasCSVToArray(response.data);
362 alert(JSON.stringify(data.chunk(10), 4, null));
13 office 363 $.each(data.chunk(10), function(i, e) {
364 alert(wasKeyValueObjectify(e));
365 /*data.push({
10 office 366 x: time + ++j * updateInterval,
367 y: parseInt(e)
13 office 368 });*/
369 });
10 office 370 });
371 }
372 }
373 }).bind('move_node.jstree', function(e, data) {
374 // Once the node is moved, update the node ID to reflect the path change.
375 var parentPath = data.parent != '/' ? data.parent : "";
376 var item = data.node.id.split(/[\/]+/).pop();
377 data.instance.set_id(data.node, parentPath + '/' + item);
378 });
379 });
380 </script>
381 </body>
382 </html>