rtwreport_utils.js 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // Copyright 2011-2013 The MathWorks, Inc.
  2. function local_onload() {
  3. if (typeof top.rtwreport_document_frame !== "undefined") {
  4. var docObj = window.document;
  5. var alink = docObj.getElementById("linkToText_plain");
  6. if (alink) {
  7. alink.href = "matlab:coder.internal.editUrlTextFile('" + alink.href + "')";
  8. }
  9. alink = docObj.getElementById("linkToCS");
  10. if (alink) {
  11. alink.href = "matlab:coder.internal.viewCodeConfigsetFromReport('" + alink.href + "');";
  12. }
  13. }
  14. }
  15. var utils = (function() {
  16. // Load via Microsoft.XMLDOM--for older versions of IE
  17. function loadXML_MSXMLDOM(filename, callback, async) {
  18. if (navigator.appName == "Microsoft Internet Explorer") {
  19. // Internet Explorer 5/6
  20. try {
  21. var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  22. xmlDoc.async = async;
  23. xmlDoc.onreadystatechange = function() {
  24. if (xmlDoc.readyState == 4) {
  25. callback(xmlDoc);
  26. }
  27. }
  28. xmlDoc.load(filename);
  29. return true;
  30. } catch(e) {
  31. }
  32. }
  33. return false;
  34. }
  35. // Load via XMLHttpRequest
  36. function loadXML_XHR(filename, callback, async) {
  37. if (window.XMLHttpRequest) {
  38. try {
  39. var xhr = new XMLHttpRequest();
  40. xhr.onreadystatechange = function() {
  41. if (this.readyState == 4) {
  42. callback(this.responseXML);
  43. }
  44. }
  45. xhr.open("GET", filename, async);
  46. xhr.send("");
  47. return true;
  48. } catch(e) {
  49. if (navigator.appName === "Netscape" && e.code === 1012) {
  50. // file not found: ignore
  51. return true;
  52. }
  53. }
  54. }
  55. return false;
  56. }
  57. return {
  58. trimText: function(s) {
  59. // In IE9, String.trim not present
  60. if (s && s.trim) {
  61. return s.trim();
  62. }
  63. else {
  64. return s;
  65. }
  66. },
  67. getText: function(elt) {
  68. // In IE9, use 'text' property rather than 'textContent'
  69. return elt.textContent ? elt.textContent : elt.text;
  70. },
  71. loadXML: function(filename, callback, options) {
  72. var async = !!options && typeof(options["async"]) !== "undefined" ? options.async : true;
  73. if (!loadXML_XHR(filename, callback, async)) {
  74. if (!loadXML_MSXMLDOM(filename, callback, async)) {
  75. return false;
  76. }
  77. }
  78. return true;
  79. }
  80. };
  81. })();
  82. function code2model(sid) {
  83. utils.loadXML("http://localhost:31415/matlab/feval/coder.internal.code2model?arguments=[\"" + sid + "\"]", function() {});
  84. //window.location.href = "matlab:coder.internal.code2model('" + sid + "')";
  85. }