uicore.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. Array.from(document.getElementsByClassName('fCb')).map((val) => {
  22. val.addEventListener('click', e => {
  23. const window = remote.getCurrentWindow()
  24. window.close()
  25. })
  26. })
  27. // Bind restore down button.
  28. Array.from(document.getElementsByClassName('fRb')).map((val) => {
  29. val.addEventListener('click', e => {
  30. const window = remote.getCurrentWindow()
  31. if(window.isMaximized()){
  32. window.unmaximize()
  33. } else {
  34. window.maximize()
  35. }
  36. document.activeElement.blur()
  37. })
  38. })
  39. // Bind minimize button.
  40. Array.from(document.getElementsByClassName('fMb')).map((val) => {
  41. val.addEventListener('click', e => {
  42. const window = remote.getCurrentWindow()
  43. window.minimize()
  44. document.activeElement.blur()
  45. })
  46. })
  47. } else if(document.readyState === 'complete'){
  48. //266.01
  49. //170.8
  50. //53.21
  51. // Bind progress bar length to length of bot wrapper
  52. //const targetWidth = document.getElementById("launch_content").getBoundingClientRect().width
  53. //const targetWidth2 = document.getElementById("server_selection").getBoundingClientRect().width
  54. //const targetWidth3 = document.getElementById("launch_button").getBoundingClientRect().width
  55. document.getElementById("launch_details").style.maxWidth = 266.01
  56. document.getElementById("launch_progress").style.width = 170.8
  57. document.getElementById("launch_details_right").style.maxWidth = 170.8
  58. document.getElementById("launch_progress_label").style.width = 53.21
  59. }
  60. }, false)
  61. /**
  62. * Open web links in the user's default browser.
  63. */
  64. $(document).on('click', 'a[href^="http"]', function(event) {
  65. event.preventDefault();
  66. //console.log(os.homedir())
  67. shell.openExternal(this.href)
  68. })
  69. /**
  70. * Opens DevTools window if you hold (ctrl + shift + i).
  71. * This will crash the program if you are using multiple
  72. * DevTools, for example the chrome debugger in VS Code.
  73. */
  74. document.addEventListener('keydown', function (e) {
  75. if(e.keyCode == 73 && e.ctrlKey && e.shiftKey){
  76. let window = remote.getCurrentWindow()
  77. window.toggleDevTools()
  78. }
  79. })