暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. function ui_save_file() {
  30. var str = JSON.stringify(card_data, null, " ");
  31. var parts = [str];
  32. var blob = new Blob(parts, { type: 'application/json' });
  33. var url = URL.createObjectURL(blob);
  34. var a = $("#file-save-link")[0];
  35. a.href = url;
  36. a.download = "rpg_cards.json";
  37. a.click();
  38. URL.revokeObjectURL(url);
  39. }
  40. $(document).ready(function () {
  41. $("#button-generate").click(ui_generate);
  42. $("#button-load").click(function () { $("#file-load").click(); });
  43. $("#file-load").change(ui_load_files);
  44. $("#button-load-sample").click(ui_load_sample);
  45. $("#button-save").click(ui_save_file);
  46. });