additional_networks.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. function addnet_switch_to_txt2img(){
  2. switch_to_txt2img();
  3. setTimeout(function() { gradioApp().getElementById("additional_networks_txt2img").scrollIntoView(); }, 100);
  4. return args_to_array(arguments);
  5. }
  6. function addnet_switch_to_img2img(){
  7. switch_to_img2img();
  8. setTimeout(function() { gradioApp().getElementById("additional_networks_img2img").scrollIntoView(); }, 100);
  9. return args_to_array(arguments);
  10. }
  11. function addnet_switch_to_metadata_editor(){
  12. Array.from(gradioApp().querySelector('#tabs').querySelectorAll('button')).filter(e => e.textContent.trim() === "Additional Networks")[0].click();
  13. return args_to_array(arguments);
  14. }
  15. function addnet_send_to_metadata_editor() {
  16. var module = arguments[0];
  17. var model_path = arguments[1];
  18. if (model_path == "None") {
  19. return args_to_array(arguments);
  20. }
  21. console.log(arguments);
  22. console.log(model_path);
  23. var select = gradioApp().querySelector("#additional_networks_metadata_editor_model > label > select");
  24. var opt = [...select.options].filter(o => o.text == model_path)[0];
  25. if (opt == null) {
  26. return;
  27. }
  28. addnet_switch_to_metadata_editor();
  29. select.selectedIndex = opt.index;
  30. select.dispatchEvent(new Event("change", { bubbles: true }));
  31. return args_to_array(arguments);
  32. }