converter.js 774 B

12345678910111213141516171819202122232425
  1. let plugin = plugin_create();
  2. let h1 = ui_handle_create();
  3. plugin_notify_on_ui(plugin, function() {
  4. if (ui_panel(h1, "Converter")) {
  5. ui_row([1 / 2, 1 / 2]);
  6. if (ui_button(".arm to .json")) {
  7. ui_files_show("arm", false, true, function(path) {
  8. let b = data_get_blob(path);
  9. let parsed = armpack_decode(b);
  10. let out = string_to_buffer(JSON.stringify(parsed, null, " "));
  11. iron_file_save_bytes(path.substr(0, path.length - 3) + "json", out);
  12. });
  13. }
  14. if (ui_button(".json to .arm")) {
  15. ui_files_show("json", false, true, function(path) {
  16. let b = data_get_blob(path);
  17. let parsed = JSON.parse(buffer_to_string(b));
  18. let out = armpack_encode(parsed);
  19. iron_file_save_bytes(path.substr(0, path.length - 4) + "arm", out);
  20. });
  21. }
  22. }
  23. });