uicore.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * Core UI functions are initialized in this file. This prevents
  3. * unexpected errors from breaking the core features. Specifically,
  4. * actions in this file should not require the usage of any internal
  5. * modules, excluding dependencies.
  6. */
  7. const $ = require('jquery');
  8. const {remote, shell} = require('electron')
  9. /* jQuery Example
  10. $(function(){
  11. console.log('UICore Initialized');
  12. })*/
  13. document.addEventListener('readystatechange', function () {
  14. if (document.readyState === 'interactive'){
  15. console.log('UICore Initializing..');
  16. // Bind close button.
  17. document.getElementById("frame_btn_close").addEventListener("click", function (e) {
  18. const window = remote.getCurrentWindow()
  19. window.close()
  20. })
  21. // Bind restore down button.
  22. document.getElementById("frame_btn_restoredown").addEventListener("click", function (e) {
  23. const window = remote.getCurrentWindow()
  24. if(window.isMaximized()){
  25. window.unmaximize();
  26. } else {
  27. window.maximize()
  28. }
  29. })
  30. // Bind minimize button.
  31. document.getElementById("frame_btn_minimize").addEventListener("click", function (e) {
  32. const window = remote.getCurrentWindow()
  33. window.minimize()
  34. })
  35. } else if(document.readyState === 'complete'){
  36. // Bind progress bar length to length of bot wrapper
  37. const targetWidth = document.getElementById("launch_content").getBoundingClientRect().width
  38. const targetWidth2 = document.getElementById("server_selection").getBoundingClientRect().width
  39. const targetWidth3 = document.getElementById("launch_button").getBoundingClientRect().width
  40. document.getElementById("launch_details").style.maxWidth = targetWidth
  41. document.getElementById("launch_progress").style.width = targetWidth2
  42. document.getElementById("launch_details_right").style.maxWidth = targetWidth2
  43. document.getElementById("launch_progress_label").style.width = targetWidth3
  44. }
  45. }, false)
  46. /**
  47. * Open web links in the user's default browser.
  48. */
  49. $(document).on('click', 'a[href^="http"]', function(event) {
  50. event.preventDefault();
  51. //console.log(os.homedir())
  52. shell.openExternal(this.href)
  53. })
  54. /**
  55. * Opens DevTools window if you hold (ctrl + shift + i).
  56. * This will crash the program if you are using multiple
  57. * DevTools, for example the chrome debugger in VS Code.
  58. */
  59. document.addEventListener('keydown', function (e) {
  60. if(e.keyCode == 73 && e.ctrlKey && e.shiftKey){
  61. let window = remote.getCurrentWindow()
  62. window.toggleDevTools()
  63. }
  64. })