설명 없음
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ui.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. function ui_generate() {
  2. // Generate output HTML
  3. var card_html = card_pages_generate_html(card_data);
  4. // Open a new window for the output
  5. // Use a separate window to avoid CSS conflicts
  6. var tab = window.open("output.html", 'rpg-cards-output');
  7. // Send the generated HTML to the new window
  8. // Use a delay to give the new window time to set up a message listener
  9. setTimeout(function () { tab.postMessage(card_html, '*') }, 100);
  10. }
  11. function ui_load_sample() {
  12. card_data = card_data_example;
  13. }
  14. function ui_clear_all() {
  15. card_data = [];
  16. }
  17. function ui_load_files(evt) {
  18. ui_clear_all();
  19. var files = evt.target.files;
  20. for (var i = 0, f; f = files[i]; i++) {
  21. var reader = new FileReader();
  22. reader.onload = function (reader) {
  23. var data = JSON.parse(this.result);
  24. card_data = card_data.concat(data);
  25. };
  26. reader.readAsText(f);
  27. }
  28. }
  29. $(document).ready(function () {
  30. $("#button-generate").click(ui_generate);
  31. $("#button-load").click(function () { $("#file-load").click(); });
  32. $("#file-load").change(ui_load_files);
  33. $("#button-load-sample").click(ui_load_sample);
  34. });