uicore.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. //266.01
  37. //170.8
  38. //53.21
  39. // Bind progress bar length to length of bot wrapper
  40. //const targetWidth = document.getElementById("launch_content").getBoundingClientRect().width
  41. //const targetWidth2 = document.getElementById("server_selection").getBoundingClientRect().width
  42. //const targetWidth3 = document.getElementById("launch_button").getBoundingClientRect().width
  43. document.getElementById("launch_details").style.maxWidth = 266.01
  44. document.getElementById("launch_progress").style.width = 170.8
  45. document.getElementById("launch_details_right").style.maxWidth = 170.8
  46. document.getElementById("launch_progress_label").style.width = 53.21
  47. }
  48. }, false)
  49. /**
  50. * Open web links in the user's default browser.
  51. */
  52. $(document).on('click', 'a[href^="http"]', function(event) {
  53. event.preventDefault();
  54. //console.log(os.homedir())
  55. shell.openExternal(this.href)
  56. })
  57. /**
  58. * Opens DevTools window if you hold (ctrl + shift + i).
  59. * This will crash the program if you are using multiple
  60. * DevTools, for example the chrome debugger in VS Code.
  61. */
  62. document.addEventListener('keydown', function (e) {
  63. if(e.keyCode == 73 && e.ctrlKey && e.shiftKey){
  64. let window = remote.getCurrentWindow()
  65. window.toggleDevTools()
  66. }
  67. })