uicore.js 3.1 KB

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