Mercurial > hg > batmud > chester
comparison index.php @ 13:1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 10 Jan 2011 08:49:45 +0200 |
parents | 774db3b4bedc |
children | 11f9c6fc4e6e |
comparison
equal
deleted
inserted
replaced
12:774db3b4bedc | 13:1edbabcbcdbd |
---|---|
241 <p id="create_buttons"> | 241 <p id="create_buttons"> |
242 <input type="button" value=" Create BatMUD Commands " onclick="createInit('batmud');" /> | 242 <input type="button" value=" Create BatMUD Commands " onclick="createInit('batmud');" /> |
243 <!-- <input type="button" value=" Create TinyFugue Macros " onclick="createInit('tf');" /> | 243 <!-- <input type="button" value=" Create TinyFugue Macros " onclick="createInit('tf');" /> |
244 --> | 244 --> |
245 <input type="button" value=" Create SAVEBLOB " onclick="createInit('save');" /> | 245 <input type="button" value=" Create SAVEBLOB " onclick="createInit('save');" /> |
246 <input type="button" value=" Reset " onclick="resetAll();" /> | 246 <input type="button" value=" Reset All " onclick="resetAll();" /> |
247 <input type="button" value=" Clear Containers " onclick="clearContainers();" /> | |
247 </p> | 248 </p> |
248 | 249 |
249 | 250 |
250 <table> | 251 <table> |
251 <tr> | 252 <tr> |
256 <table class="buttons"> | 257 <table class="buttons"> |
257 <tr> | 258 <tr> |
258 <td><input type="button" value=" Delete " onclick="deleteItems(this.form);" /></td> | 259 <td><input type="button" value=" Delete " onclick="deleteItems(this.form);" /></td> |
259 <td><input type="button" value=" Add new " onclick="addItems(this.form);" disabled="disabled" /></td> | 260 <td><input type="button" value=" Add new " onclick="addItems(this.form);" disabled="disabled" /></td> |
260 <td><b><span id="curr_nitems"></span> items</b></td> | 261 <td><b><span id="curr_nitems"></span> items</b></td> |
261 <td style="width: 60%; text-align: right;"><input id="move_button" type="button" value=" Move to container " onclick="moveItems(this.form);" /></td> | 262 <td><input type="button" value=" AutoMove " onclick="autoMoveItems(this.form);" /></td> |
263 <td style="width: 60%; text-align: right;"><input type="button" value=" Move to container " onclick="moveItems(this.form);" /></td> | |
262 </tr> | 264 </tr> |
263 </table> | 265 </table> |
264 </td> | 266 </td> |
265 | 267 |
266 <td id="container_editor"> | 268 <td id="container_editor"> |
281 <? | 283 <? |
282 printInputField("container_name", "Identifier/name", 15); | 284 printInputField("container_name", "Identifier/name", 15); |
283 printInputField("container_slots", "Number of slots", 5); | 285 printInputField("container_slots", "Number of slots", 5); |
284 ?> | 286 ?> |
285 <input type="button" value=" Create new " onclick="containerCreate(this.form);" id="create_button" /> | 287 <input type="button" value=" Create new " onclick="containerCreate(this.form);" id="create_button" /> |
286 <input type="button" value=" Change " onclick="containerChange(this.form);" id="change_button" /> | 288 <input type="button" value=" Modify " onclick="containerModify(this.form);" id="modify_button" /> |
287 </td> | 289 </td> |
288 | 290 |
289 <td id="container_list_editor"> | 291 <td id="container_list_editor"> |
290 <h2>Defined containers</h2> | 292 <h2>Defined containers</h2> |
291 <? printOptionSelect("container_list", 5, FALSE); ?> | 293 <? printOptionSelect("container_list", 5, FALSE); ?> |
411 | 413 |
412 echo " | 414 echo " |
413 var list_containers; | 415 var list_containers; |
414 var list_items; | 416 var list_items; |
415 | 417 |
416 function initAll() | 418 function initContainers() |
417 { | 419 { |
418 list_containers = [".$str."]; | 420 list_containers = [".$str."]; |
421 } | |
422 | |
423 function initItems() | |
424 { | |
419 list_items = ".(isset($data["items"]) ? getContainerObject("items", 10000, $data["items"]) : "null")."; | 425 list_items = ".(isset($data["items"]) ? getContainerObject("items", 10000, $data["items"]) : "null")."; |
426 } | |
427 | |
428 function initSettings() | |
429 { | |
420 ".$jsData." | 430 ".$jsData." |
421 curr_container = null; | 431 curr_container = null; |
422 updatePage(); | |
423 statusMsg('Welcome to the editor. <b>(c) Copyright 2011 Matti Hämäläinen aka Ggr Pupunen.</b>'); | |
424 } | 432 } |
425 "; | 433 "; |
426 ?> | 434 ?> |
427 <!-- kludge --><!-- | 435 <!-- kludge --><!-- |
428 | 436 |
429 | 437 |
430 function resetAll() | 438 function resetAll() |
431 { | 439 { |
432 var answer = confirm("Really delete all defined containers and reset item pool to original state?"); | 440 var answer = confirm("Really delete all defined containers and reset item pool to original state? You will have to re-define containers from scratch."); |
433 if (!answer) { | 441 if (!answer) { |
434 statusMsg("Reset operation cancelled."); | 442 statusMsg("Reset operation cancelled."); |
435 return; | 443 return; |
436 } | 444 } |
437 initAll(); | 445 initContainers(); |
446 initItems(); | |
447 initSettings(); | |
448 updatePage(); | |
449 statusMsg('Welcome to the editor. <b>(c) Copyright 2011 Matti Hämäläinen aka Ggr Pupunen.</b>'); | |
450 } | |
451 | |
452 function clearContainers() | |
453 { | |
454 var answer = confirm("Really clear (empty) all defined containers and reset item pool to original state?"); | |
455 if (!answer) { | |
456 statusMsg("Clear operation cancelled."); | |
457 return; | |
458 } | |
459 initItems(); | |
460 for (var i = 0; i < list_containers.length; i++) { | |
461 list_containers[i].items = []; | |
462 } | |
463 updatePage(); | |
438 } | 464 } |
439 | 465 |
440 | 466 |
441 function setHTML(id, str) | 467 function setHTML(id, str) |
442 { | 468 { |
561 updatePage(); | 587 updatePage(); |
562 } | 588 } |
563 | 589 |
564 | 590 |
565 // Change current container | 591 // Change current container |
566 function containerChange(f) | 592 function containerModify(f) |
567 { | 593 { |
568 if (curr_container == null) { | 594 if (curr_container == null) { |
569 statusMsg("No current container, create or select one."); | 595 statusMsg("No current container, create or select one."); |
570 return; | 596 return; |
571 } | 597 } |
735 list_items.flush(); | 761 list_items.flush(); |
736 updatePage(); | 762 updatePage(); |
737 statusMsg("Moved " + selected.length + " items to current container."); | 763 statusMsg("Moved " + selected.length + " items to current container."); |
738 } | 764 } |
739 } | 765 } |
766 | |
767 function autoMoveItems(f) | |
768 { | |
769 var selected = getSelectedItems(f.elements['curr_items']); | |
770 | |
771 if (selected.length == 0) { | |
772 statusMsg("No items selected for AutoMove(tm)."); | |
773 return; | |
774 } | |
775 | |
776 if (list_containers.length == 0) { | |
777 statusMsg("No containers available for AutoMove(tm)."); | |
778 return; | |
779 } | |
780 | |
781 var remaining = selected.length; | |
782 var n = 0; | |
783 while (remaining > 0 && n < list_containers.length) { | |
784 curr = list_containers[n]; | |
785 | |
786 for (var q = curr.getSpace(); q > 0 && remaining > 0; q--) { | |
787 remaining--; | |
788 if (!list_items.moveItemById(curr, selected[remaining])) { | |
789 statusMsg("Internal error moving item #"+remaining+": '"+selected[remaining]+"'."); | |
790 return; | |
791 } | |
792 } | |
793 | |
794 n++; | |
795 } | |
796 | |
797 list_items.flush(); | |
798 updatePage(); | |
799 | |
800 if (remaining > 0) { | |
801 statusMsg("Not enough space! <b>"+ remaining +" of "+ selected.length +"</b> items left without slots!"); | |
802 return; | |
803 } | |
804 | |
805 statusMsg("AutoMoved " + selected.length + " items to containers."); | |
806 } | |
807 | |
808 | |
740 | 809 |
741 | 810 |
742 var edit_modes = ['batmud', 'tf', 'save']; | 811 var edit_modes = ['batmud', 'tf', 'save']; |
743 | 812 |
744 function createInit(mode) | 813 function createInit(mode) |
827 o.style.display = state ? "block" : "none"; | 896 o.style.display = state ? "block" : "none"; |
828 var o = document.getElementById("command_data"); | 897 var o = document.getElementById("command_data"); |
829 o.innerHTML = str; | 898 o.innerHTML = str; |
830 } | 899 } |
831 | 900 |
832 initAll(); | 901 |
902 initContainers(); | |
903 initItems(); | |
904 initSettings(); | |
905 updatePage(); | |
833 --> | 906 --> |
834 </script> | 907 </script> |
835 <? | 908 <? |
836 } | 909 } |
837 | 910 |