script.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. var $ = require('jQuery');
  2. const remote = require('electron').remote
  3. const shell = require('electron').shell
  4. const path = require('path')
  5. /* Open web links in the user's default browser. */
  6. $(document).on('click', 'a[href^="http"]', function(event) {
  7. event.preventDefault();
  8. //testdownloads()
  9. shell.openExternal(this.href)
  10. });
  11. testdownloads = async function(){
  12. const ag = require(path.join(__dirname, 'assets', 'js', 'assetguard.js'))
  13. const basePath = path.join(__dirname, '..', 'mcfiles')
  14. let versionData = await ag.loadVersionData('1.11.2', basePath)
  15. await ag.validateAssets(versionData, basePath)
  16. console.log('assets done')
  17. await ag.validateLibraries(versionData, basePath)
  18. console.log('libs done')
  19. ag.runQueue()
  20. }
  21. /*Opens DevTools window if you type "wcdev" in sequence.
  22. This will crash the program if you are using multiple
  23. DevTools, for example the chrome debugger in VS Code. */
  24. const match = [87, 67, 68, 69, 86]
  25. let at = 0;
  26. document.addEventListener('keydown', function (e) {
  27. switch(e.keyCode){
  28. case match[0]:
  29. if(at === 0) ++at
  30. break
  31. case match[1]:
  32. if(at === 1) ++at
  33. break
  34. case match[2]:
  35. if(at === 2) ++at
  36. break
  37. case match[3]:
  38. if(at === 3) ++at
  39. case match[4]:
  40. if(at === 4) ++at
  41. break
  42. default:
  43. at = 0
  44. }
  45. if(at === 5) {
  46. var window = remote.getCurrentWindow()
  47. window.toggleDevTools()
  48. at = 0
  49. }
  50. })