uicore.js 2.8 KB

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