broadcastActivateEvent.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/env node
  2. // This Plugin-Hook sets ToastCapable on true to allow windows-platform
  3. // cordova apps displaing local-notifications
  4. var fs = require('fs'),
  5. rootdir = process.argv[2];
  6. if (!rootdir)
  7. return;
  8. function replace_string_in_file (filename, to_replace, replace_with) {
  9. var data = fs.readFileSync(filename, 'utf8'),
  10. result;
  11. // if (data.indexOf(replace_with) > -1)
  12. // return;
  13. result = data.replace(new RegExp(to_replace, 'g'), replace_with);
  14. fs.writeFileSync(filename, result, 'utf8');
  15. }
  16. var snippet =
  17. "var activatedHandler = function (args) {" +
  18. "channel.deviceready.subscribe(function () {" +
  19. "WinJS.Application.queueEvent(args);" +
  20. "});" +
  21. "};" +
  22. "WinJS.Application.addEventListener('activated', activatedHandler, false);" +
  23. "document.addEventListener('deviceready', function () {" +
  24. "WinJS.Application.removeEventListener('activated', activatedHandler);" +
  25. "}, false);" +
  26. "app.start();";
  27. var files = [
  28. 'platforms/windows/www/cordova.js',
  29. 'platforms/windows/platform_www/cordova.js'
  30. ];
  31. setTimeout(function () {
  32. for (var i = 0; i < files.length; i++) {
  33. replace_string_in_file(files[i], 'app.start();', '123app.start();');
  34. }
  35. }, 1000);
  36. console.log(123);