UNPKG

1.71 kBJavaScriptView Raw
1/*!
2 * OpenUI5
3 * (c) Copyright 2009-2022 SAP SE or an SAP affiliate company.
4 * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5 */
6
7jQuery.sap.declare('sap-ui-debug');
8
9(function(aScriptIncludes) {
10
11 "use strict";
12
13 //extract base URL from script tag
14 var aScripts, i, sSrc, mMatch, sBaseUrl, oScriptTag,
15 bCoreRequired = false;
16
17 oScriptTag = document.getElementById("sap-ui-bootstrap");
18 if (oScriptTag) {
19 sSrc = oScriptTag.getAttribute("src");
20 mMatch = sSrc.match(/^(?:.*\/)?resources\//i);
21 if (mMatch) {
22 sBaseUrl = mMatch[1];
23 }
24 }
25
26 if (sBaseUrl == null) {
27 aScripts = document.getElementsByTagName("script");
28
29 for (i = 0; i < aScripts.length; i++) {
30 sSrc = aScripts[i].getAttribute("src");
31 if (sSrc) {
32 mMatch = sSrc.match(/(.*\/)sap-ui-core.*\.js$/i);
33 if (mMatch) {
34 sBaseUrl = mMatch[1];
35 break;
36 }
37 }
38 }
39 }
40
41 if (sBaseUrl == null) {
42 throw new Error("sap-ui-debug.js: could not identify script tag!");
43 }
44
45 for (i = 0; i < aScriptIncludes.length; i++) {
46 sSrc = aScriptIncludes[i];
47 if ( sSrc.indexOf("raw:") === 0 ) {
48 sSrc = sBaseUrl + sSrc.slice(4);
49 document.write("<script src=\"" + sSrc + "\"></script>");
50 } else if ( sSrc.indexOf("require:") === 0 ) {
51 sSrc = sSrc.slice(8);
52 bCoreRequired = bCoreRequired || sSrc === "sap.ui.core.Core";
53 document.write("<script>jQuery.sap.require(\"" + sSrc + "\");</script>");
54 }
55 }
56 if ( bCoreRequired ) {
57 document.write("<script>sap.ui.getCore().boot && sap.ui.getCore().boot();</script>");
58 }
59}([
60 "raw:sap/ui/debug/ControlTree.js",
61 "raw:sap/ui/debug/Highlighter.js",
62 "raw:sap/ui/debug/LogViewer.js",
63 "raw:sap/ui/debug/PropertyList.js",
64 "raw:sap/ui/debug/DebugEnv.js"
65]));