天天看点

从丁哥那里学到的两个 SAP UI5 技能

/**
            * Determine whether to use debug sources depending on URL parameter and local storage
            * and load debug library if necessary
            */
      
(function() {
                                //Check URI param
                                var bDebugSources = /sap-ui-debug=(true|x|X)/.test(location.search),
                                                bIsOptimized = window["sap-ui-optimized"];
 
                                //Check local storage
                                try { //Necessary for FF when Cookies are deactivated
                                                bDebugSources = bDebugSources || (window.localStorage.getItem("sap-ui-debug") == "X");
                                } catch (e) {}
 
                                window["sap-ui-debug"] = bDebugSources;
 
                                // if bootstap URL already contains -dbg URL, just set sap-ui-loaddbg
                                if (/-dbg\.js([?#]|$)/.test(_oBootstrap.url)) {
                                                window["sap-ui-loaddbg"] = true;
                                                window["sap-ui-debug"] = true;
                                }
 
                                // if current sources are optimized and debug sources are wanted, restart with debug URL
                                if (bIsOptimized && bDebugSources) {
                                                var sDebugUrl = _oBootstrap.url.replace(/\/(?:sap-ui-cachebuster\/)?([^\/]+)\.js/, "/$1-dbg.js");
                                                window["sap-ui-optimized"] = false;
                                                window["sap-ui-loaddbg"] = true;
                                                document.write("<script type=\"text/javascript\" src=\"" + sDebugUrl + "\"></script>");
                                                var oRestart = new Error("Aborting UI5 bootstrap and restarting from: " + sDebugUrl);
                                                oRestart.name = "Restart";
                                                throw oRestart;
                                }
                })();
 
Sap-ui-core.js is merged from sapui5.runtime\src\framework\_core\target\classes\META-INF\maven\com.sap.openui5\sap.ui.core\pom.xml  
<echo>Merging module: sap-ui-core.js</echo>
                concat destfile="${project.build.outputDirectory}/META-INF/resources/sap-ui-core.js" overwrite="true" encoding="UTF-8" eol="lf" fixlastline="true">
                                                                                                                                                <filelist dir="${project.build.outputDirectory}/META-INF/resources/">
                                                                                                                                                                <file name="sap/ui/thirdparty/jquery/jquery-1.11.1.js"/>
                                                                                                                                                                <file name="sap/ui/thirdparty/jqueryui/jquery-ui-position.js"/>
                                                                                                                                                                <file name="sap/ui/Device.js"/>
                                                                                                                                                                <file name="sap/ui/thirdparty/URI.js"/>
                                                                                                                                                                <file name="jquery.sap.promise.js"/>
                                                                                                                                                                <file name="jquery.sap.global.js"/>
                                                                                                                                                </filelist>
                                                                                                                                </concat>
      

继续阅读