dojoCheck.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Licensed Materials - Property of IBM
  2. //
  3. // IBM Cognos Products: cpscrn
  4. //
  5. // (C) Copyright IBM Corp. 2005, 2011
  6. //
  7. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  8. //
  9. //
  10. // only load Dojo if it is not already loaded.
  11. if (typeof dojo == "undefined") {
  12. var nodes = document.getElementsByTagName("SCRIPT");
  13. var l = nodes.length;
  14. // Find the $WEB$ environment variable
  15. foundweb: for (var i = 0; i < l; i++) {
  16. var attrs = nodes[i].attributes;
  17. for (var j = 0; j < attrs.length; j++) {
  18. if (attrs[j].nodeName == "src") {
  19. if (attrs[j].nodeValue.indexOf("?web=") > 0) {
  20. var web = attrs[j].nodeValue.substring(attrs[j].nodeValue.indexOf("?web=")+5, attrs[j].nodeValue.length);
  21. break foundweb;
  22. }
  23. break;
  24. }
  25. }
  26. }
  27. // If the value of web is not passed into dojoCheck then get from _F_Config.
  28. if (typeof web == "undefined") {
  29. if (typeof _F_Config != "undefined") {
  30. var web = _F_Config.webContent;
  31. }
  32. else if (typeof console != "undefined") {
  33. console.error("Unable to find web content directory. Dojo not loaded.");
  34. }
  35. }
  36. // Make sure the web variable has been set before trying to load Dojo
  37. if (typeof web != "undefined") {
  38. // Set the djConfig once
  39. djConfig = {
  40. parseOnLoad: true,
  41. baseUrl: web + "/dojo16/dojo/"
  42. }
  43. // Inject the Dojo script tag into the head of the webpage.
  44. if (document.getElementsByTagName("head")[0] != null) {
  45. var head = document.getElementsByTagName("head")[0];
  46. var newscript= document.createElement('script');
  47. newscript.type = 'text/javascript';
  48. newscript.setAttribute("src", djConfig.baseUrl+"dojo.js");
  49. head.appendChild(newscript);
  50. }
  51. }
  52. }