uicore.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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, webFrame} = require('electron')
  9. // Disable zoom, needed for darwin.
  10. webFrame.setVisualZoomLevelLimits(1, 1)
  11. webFrame.setLayoutZoomLevelLimits(0, 0)
  12. /* jQuery Example
  13. $(function(){
  14. console.log('UICore Initialized');
  15. })*/
  16. document.addEventListener('readystatechange', function () {
  17. if (document.readyState === 'interactive'){
  18. console.log('UICore Initializing..');
  19. // Bind close button.
  20. document.getElementById("frame_btn_close").addEventListener("click", function (e) {
  21. const window = remote.getCurrentWindow()
  22. window.close()
  23. })
  24. // Bind restore down button.
  25. document.getElementById("frame_btn_restoredown").addEventListener("click", function (e) {
  26. const window = remote.getCurrentWindow()
  27. if(window.isMaximized()){
  28. window.unmaximize();
  29. } else {
  30. window.maximize()
  31. }
  32. })
  33. // Bind minimize button.
  34. document.getElementById("frame_btn_minimize").addEventListener("click", function (e) {
  35. const window = remote.getCurrentWindow()
  36. window.minimize()
  37. })
  38. } else if(document.readyState === 'complete'){
  39. //266.01
  40. //170.8
  41. //53.21
  42. // Bind progress bar length to length of bot wrapper
  43. //const targetWidth = document.getElementById("launch_content").getBoundingClientRect().width
  44. //const targetWidth2 = document.getElementById("server_selection").getBoundingClientRect().width
  45. //const targetWidth3 = document.getElementById("launch_button").getBoundingClientRect().width
  46. document.getElementById("launch_details").style.maxWidth = 266.01
  47. document.getElementById("launch_progress").style.width = 170.8
  48. document.getElementById("launch_details_right").style.maxWidth = 170.8
  49. document.getElementById("launch_progress_label").style.width = 53.21
  50. }
  51. }, false)
  52. /**
  53. * Open web links in the user's default browser.
  54. */
  55. $(document).on('click', 'a[href^="http"]', function(event) {
  56. event.preventDefault();
  57. //console.log(os.homedir())
  58. shell.openExternal(this.href)
  59. })
  60. /**
  61. * Opens DevTools window if you hold (ctrl + shift + i).
  62. * This will crash the program if you are using multiple
  63. * DevTools, for example the chrome debugger in VS Code.
  64. */
  65. document.addEventListener('keydown', function (e) {
  66. if(e.keyCode == 73 && e.ctrlKey && e.shiftKey){
  67. let window = remote.getCurrentWindow()
  68. window.toggleDevTools()
  69. }
  70. })