_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q19600
train
function(oEvent) { this.byId("phoneImage").setVisible(oEvent.name === "Phone"); this.byId("desktopImage").setVisible(oEvent.name !== "Phone"); this.byId("phoneImage").toggleStyleClass("phoneHeaderImageDesktop", oEvent.name === "Phone"); }
javascript
{ "resource": "" }
q19601
train
function(oIconTabBar, fnScrollEndCallback, fnScrollStartCallback) { this._oIconTabBar = oIconTabBar; this._fnScrollEndCallback = jQuery.proxy(fnScrollEndCallback, oIconTabBar); this._fnScrollStartCallback = jQuery.proxy(fnScrollStartCallback, oIconTabBar); return this; }
javascript
{ "resource": "" }
q19602
train
function(vElement) { // check if vElement is a DOM element and if yes convert it to jQuery object var $Element = vElement instanceof jQuery ? vElement : jQuery(vElement), oElementPosition = $Element.position(), $OffsetParent = $Element.offsetParent(), oAddUpPosition; while (!$OffsetParent.is(this._$Container)) { oAddUpPosition = $OffsetParent.position(); oElementPosition.top += oAddUpPosition.top; oElementPosition.left += oAddUpPosition.left; $OffsetParent = $OffsetParent.offsetParent(); } return oElementPosition; }
javascript
{ "resource": "" }
q19603
train
function(oElement, iTime, aOffset) { aOffset = aOffset || [0, 0]; // do nothing if _$Container is not a (grand)parent of oElement if (!this._$Container[0].contains(oElement) || oElement.style.display === "none" || oElement.offsetParent.nodeName.toUpperCase() === "HTML") { return this; } var $Element = jQuery(oElement), oScrollPosition = this.getChildPosition($Element), iLeftScroll = this.getScrollLeft() + oScrollPosition.left + aOffset[0], iTopScroll = this.getScrollTop() + oScrollPosition.top + aOffset[1]; if (this._bFlipX) { // in IE RTL scrollLeft goes opposite direction iLeftScroll = this.getScrollLeft() - (oScrollPosition.left - this._$Container.width()) - $Element.width(); } // scroll to destination this._scrollTo(iLeftScroll, iTopScroll , iTime); return this; }
javascript
{ "resource": "" }
q19604
Generator
train
function Generator(sOutputFolder, bPrettyPrint) { if (!(this instanceof Generator)) { return new Generator(sOutputFolder, bPrettyPrint); } this._sOutputFolder = sOutputFolder; this._bPrettyPrint = bPrettyPrint; events.EventEmitter.call(this); }
javascript
{ "resource": "" }
q19605
init
train
function init() { if (!oInitPromise) { oInitPromise = new Promise(function(resolve, reject) { oWorker = new window.Worker(WORKER.URL); // listen for confirmation from worker oWorker.addEventListener('message', function(oEvent) { var oData = oEvent.data; resolve(oData && oData[WORKER.RESPONSE_FIELDS.DONE] === true); }, false); // instruct the worker to fetch the index data oWorker.postMessage({ "cmd": WORKER.COMMANDS.INIT, "bIsMsieBrowser": !!Device.browser.msie }); }); } return oInitPromise; }
javascript
{ "resource": "" }
q19606
search
train
function search(sQuery) { return new Promise(function(resolve, reject) { init().then(function() { oWorker.addEventListener('message', function(oEvent) { var oData = oEvent.data; resolve(oData && oData[WORKER.RESPONSE_FIELDS.SEARCH_RESULT]); }, false); oWorker.postMessage({ "cmd": WORKER.COMMANDS.SEARCH, "sQuery": sQuery }); }); }); }
javascript
{ "resource": "" }
q19607
train
function () { var bLoaded = sap.ui.getCore().getLoadedLibraries()["sap.ui.support"], deferred = jQueryDOM.Deferred(); if (!bLoaded) { sap.ui.require(["sap/ui/support/Bootstrap"], function (bootstrap) { bootstrap.initSupportRules(["true", "silent"], { onReady: function () { deferred.resolve(); } }); }); } else { deferred.resolve(); } return deferred.promise(); }
javascript
{ "resource": "" }
q19608
train
function(options) { var ruleDeferred = jQueryDOM.Deferred(), options = options[0] || {}, failOnAnyRuleIssues = options["failOnAnyIssues"], failOnHighRuleIssues = options["failOnHighIssues"], rules = options.rules, preset = options.preset, metadata = options.metadata, executionScope = options.executionScope; // private API provided by jquery.sap.global RuleAnalyzer.analyze(executionScope, rules || preset, metadata).then(function () { var analysisHistory = RuleAnalyzer.getAnalysisHistory(), lastAnalysis = { issues: [] }; if (analysisHistory.length) { lastAnalysis = analysisHistory[analysisHistory.length - 1]; } var issueSummary = lastAnalysis.issues.reduce(function (summary, issue) { summary[issue.severity.toLowerCase()] += 1; return summary; }, { high: 0, medium: 0, low: 0 }); var assertionResult = lastAnalysis.issues.length === 0; if (failOnHighRuleIssues) { assertionResult = issueSummary.high === 0; } else if (failOnAnyRuleIssues === false || failOnHighRuleIssues === false) { assertionResult = true; } if (fnShouldSkipRulesIssues()) { assertionResult = true; } ruleDeferred.resolve({ result: assertionResult, message: "Support Assistant issues found: [High: " + issueSummary.high + ", Medium: " + issueSummary.medium + ", Low: " + issueSummary.low + "]", expected: "0 high 0 medium 0 low", actual: issueSummary.high + " high " + issueSummary.medium + " medium " + issueSummary.low + " low" }); }); return ruleDeferred.promise(); }
javascript
{ "resource": "" }
q19609
train
function () { var ruleDeferred = jQueryDOM.Deferred(), history = RuleAnalyzer.getFormattedAnalysisHistory(), analysisHistory = RuleAnalyzer.getAnalysisHistory(), totalIssues = analysisHistory.reduce(function (total, analysis) { return total + analysis.issues.length; }, 0), result = totalIssues === 0, message = "Support Assistant Analysis History", actual = message; if (result) { message += " - no issues found"; } else if (fnShouldSkipRulesIssues()) { result = true; message += ' - issues are found. To see them remove the "sap-skip-rules-issues=true" URI parameter'; } ruleDeferred.resolve({ result: result, message: message, actual: actual, expected: history }); return ruleDeferred.promise(); }
javascript
{ "resource": "" }
q19610
train
function (oODataModelInstance) { var iVersion; var sODataModelName; // check if the given object has metadata and a class name if (oODataModelInstance && oODataModelInstance.getMetadata) { sODataModelName = oODataModelInstance.getMetadata().getName(); } switch (sODataModelName) { case "sap.ui.model.odata.ODataModel": iVersion = this.V1; break; case "sap.ui.model.odata.v2.ODataModel": iVersion = this.V2; break; default: iVersion = this.NONE; Log.info("AnalyticalVersionInfo.getVersion(...) - The given object is no instance of ODataModel V1 or V2!"); break; } return iVersion; }
javascript
{ "resource": "" }
q19611
createOverride
train
function createOverride(sXHRMethod) { mRegistry[sXHRMethod] = Object.create(null); // backup the original function mXHRFunctions[sXHRMethod] = window.XMLHttpRequest.prototype[sXHRMethod]; window.XMLHttpRequest.prototype[sXHRMethod] = function() { var oArgs = arguments; // call the original function first mXHRFunctions[sXHRMethod].apply(this, oArgs); // call the registered callbacks in order of their registration for (var sName in mRegistry[sXHRMethod]) { mRegistry[sXHRMethod][sName].apply(this, oArgs); } }; }
javascript
{ "resource": "" }
q19612
train
function(sName, sXHRMethod, fnCallback) { Log.debug("Register '" + sName + "' for XHR function '" + sXHRMethod + "'", XHRINTERCEPTOR); // initially the override needs to be placed per XHR method if (!mRegistry[sXHRMethod]) { createOverride(sXHRMethod); } mRegistry[sXHRMethod][sName] = fnCallback; }
javascript
{ "resource": "" }
q19613
train
function(sName, sXHRMethod) { var bRemove = delete mRegistry[sXHRMethod][sName]; Log.debug("Unregister '" + sName + "' for XHR function '" + sXHRMethod + (bRemove ? "'" : "' failed"), XHRINTERCEPTOR); return bRemove; }
javascript
{ "resource": "" }
q19614
train
function (sTopicId) { var sUrl = "", sVersion = "", sFullVersion = sap.ui.getVersionInfo().version, iMajorVersion = jQuery.sap.Version(sFullVersion).getMajor(), iMinorVersion = jQuery.sap.Version(sFullVersion).getMinor(), sOrigin = window.location.origin; //This check is to make sure that version is even. Example: 1.53 will back down to 1.52 // This is used to generate the correct path to demokit if (iMinorVersion % 2 !== 0) { iMinorVersion--; } sVersion += String(iMajorVersion) + "." + String(iMinorVersion); if (sOrigin.indexOf("veui5infra") !== -1) { sUrl = sOrigin + "/sapui5-sdk-internal/#/topic/" + sTopicId; } else { sUrl = sOrigin + "/demokit-" + sVersion + "/#/topic/" + sTopicId; } this._redirectToUrlWithFallback(sUrl, sTopicId); }
javascript
{ "resource": "" }
q19615
train
function (sUrl, sTopicId) { this._pingUrl(sUrl).then(function success() { mLibrary.URLHelper.redirect(sUrl, true); }, function error() { jQuery.sap.log.info("Support Assistant tried to load documentation link in " + sUrl + "but fail"); sUrl = "https://ui5.sap.com/#/topic/" + sTopicId; mLibrary.URLHelper.redirect(sUrl, true); }); }
javascript
{ "resource": "" }
q19616
CLDR
train
function CLDR(oOptions) { if (!(this instanceof CLDR)) { return new CLDR(oOptions); } this._oOptions = oOptions; events.EventEmitter.call(this); }
javascript
{ "resource": "" }
q19617
toIslamic
train
function toIslamic(oGregorian) { var iGregorianYear = oGregorian.year, iGregorianMonth = oGregorian.month, iGregorianDay = oGregorian.day, iIslamicYear, iIslamicMonth, iIslamicDay, iMonths, iDays, iLeapAdj, iJulianDay; iLeapAdj = 0; if ((iGregorianMonth + 1) > 2) { iLeapAdj = isGregorianLeapYear(iGregorianYear) ? -1 : -2; } iJulianDay = (GREGORIAN_EPOCH_DAYS - 1) + (365 * (iGregorianYear - 1)) + Math.floor((iGregorianYear - 1) / 4) + (-Math.floor((iGregorianYear - 1) / 100)) + Math.floor((iGregorianYear - 1) / 400) + Math.floor((((367 * (iGregorianMonth + 1)) - 362) / 12) + iLeapAdj + iGregorianDay); iJulianDay = Math.floor(iJulianDay) + 0.5; iDays = iJulianDay - ISLAMIC_EPOCH_DAYS; iMonths = Math.floor(iDays / 29.530588853); // day/CalendarAstronomer.SYNODIC_MONTH if (iMonths < 0) { //negative means Islamic date before the Islamic's calendar start. So we do not apply customization. iIslamicYear = Math.floor(iMonths / 12) + 1; iIslamicMonth = iMonths % 12; if (iIslamicMonth < 0) { iIslamicMonth += 12; } iIslamicDay = iDays - monthStart(iIslamicYear, iIslamicMonth) + 1; } else { /* Guess the month start. * Always also check the next month, since customization can * differ. It can differ for not more than 3 days. so that * checking the next month is enough. */ iMonths++; /* * Check the true month start for the given month. If it is * later, check the previous month, until a suitable is found. */ while (getCustomMonthStartDays(iMonths) > iDays) { iMonths--; } iIslamicYear = Math.floor(iMonths / 12) + 1; iIslamicMonth = iMonths % 12; iIslamicDay = (iDays - getCustomMonthStartDays(12 * (iIslamicYear - 1) + iIslamicMonth)) + 1; } return { day: iIslamicDay, month: iIslamicMonth, year: iIslamicYear }; }
javascript
{ "resource": "" }
q19618
train
function(oEvent){ var oItem = oEvent.getParameter("item"); this.fireItemSelected({itemId: oItem.getId(), item: oItem}); this.firePress({itemId: oItem.getId(), item: oItem}); }
javascript
{ "resource": "" }
q19619
each
train
function each(collection, callback) { if (!collection) { return; } for (var i = 0, l = collection.length; i < l; i += 1) { callback(collection[i]); } }
javascript
{ "resource": "" }
q19620
isDigitSequence
train
function isDigitSequence(sValue, oConstraints) { return oConstraints && oConstraints.isDigitSequence && sValue && sValue.match(rDigitsOnly); }
javascript
{ "resource": "" }
q19621
_bind
train
function _bind(sAggregation, oControl, oBindingInfo) { var oBindingContext = this.getBindingContext(); if (oBindingContext) { oBindingInfo.path = oBindingContext.getPath(); oControl.bindAggregation(sAggregation, oBindingInfo); } }
javascript
{ "resource": "" }
q19622
train
function (oRun, sLibraryName, sRuleName) { var aIssues = []; if (oRun.issues[sLibraryName] && oRun.issues[sLibraryName][sRuleName]) { oRun.issues[sLibraryName][sRuleName].forEach(function (oIssue) { var oMinimizedIssue = { "context": oIssue.context, "details": oIssue.details, "name": oIssue.name, "severity": oIssue.severity }; aIssues.push(oMinimizedIssue); }); } return aIssues; }
javascript
{ "resource": "" }
q19623
train
function (oContext) { var mIssues = IssueManager.groupIssues(IssueManager.getIssuesModel()), aIssues = IssueManager.getIssues(), mRules = RuleSetLoader.getRuleSets(), mSelectedRules = oContext._oSelectedRulesIds, oSelectedRulePreset = oContext._oSelectedRulePreset; _aRuns.push({ date: new Date().toUTCString(), issues: mIssues, onlyIssues: aIssues, application: oContext._oDataCollector.getAppInfo(), technical: oContext._oDataCollector.getTechInfoJSON(), rules: IssueManager.getRulesViewModel(mRules, mSelectedRules, mIssues), rulePreset: oSelectedRulePreset, scope: { executionScope: { type: oContext._oExecutionScope.getType(), selectors: oContext._oExecutionScope._getContext().parentId || oContext._oExecutionScope._getContext().components } }, analysisDuration: oContext._oAnalyzer.getElapsedTimeString(), analysisMetadata: oContext._oAnalysisMetadata || null }); }
javascript
{ "resource": "" }
q19624
train
function () { var aOutput = []; _aRuns.forEach(function (oRun) { var oTmp = _generateRootLevelKeys(oRun); for (var sLibraryName in oRun.rules) { _generateLibraryStructure(oTmp, sLibraryName, oRun); for (var sRuleName in oRun.rules[sLibraryName]) { _generateRuleStructure(oTmp, sLibraryName, sRuleName, oRun); } } aOutput.push(oTmp); }); return aOutput; }
javascript
{ "resource": "" }
q19625
train
function (sFormat) { var oFormattedHistory, aHistory = this.getHistory(); switch (sFormat) { case library.HistoryFormats.Abap: oFormattedHistory = AbapHistoryFormatter.format(aHistory); break; default : oFormattedHistory = StringHistoryFormatter.format(aHistory); } return oFormattedHistory; }
javascript
{ "resource": "" }
q19626
_createHighLighter
train
function _createHighLighter() { var highLighter = document.createElement("div"); highLighter.style.cssText = "box-sizing: border-box;border:1px solid blue;background: rgba(20, 20, 200, 0.4);position: absolute"; var highLighterWrapper = document.createElement("div"); highLighterWrapper.id = "ui5-highlighter"; highLighterWrapper.style.cssText = "position: fixed;top:0;right:0;bottom:0;left:0;z-index: 1000;overflow: hidden;"; highLighterWrapper.appendChild(highLighter); document.body.appendChild(highLighterWrapper); // Save reference for later usage _highLighter = document.getElementById("ui5-highlighter"); // Add event handler _highLighter.onmouseover = _hideHighLighter; }
javascript
{ "resource": "" }
q19627
train
function (elementId) { var highlighter; var targetDomElement; var targetRect; if (_highLighter === null && !document.getElementById("ui5-highlighter")) { _createHighLighter(); } else { _showHighLighter(); } highlighter = _highLighter.firstElementChild; targetDomElement = document.getElementById(elementId); if (targetDomElement) { targetRect = targetDomElement.getBoundingClientRect(); highlighter.style.top = targetRect.top + "px"; highlighter.style.left = targetRect.left + "px"; highlighter.style.height = targetRect.height + "px"; highlighter.style.width = targetRect.width + "px"; } return this; }
javascript
{ "resource": "" }
q19628
train
function() { var aVisibleColumnsIds = [], aColumns = SelectionUtils.treeTable.getColumns(); aColumns.forEach(function (oColumn) { if (oColumn.getVisible()){ aVisibleColumnsIds.push(oColumn.sId); } }); storage.setVisibleColumns(aVisibleColumnsIds); }
javascript
{ "resource": "" }
q19629
fnAddHTML
train
function fnAddHTML (oBlockSection, sBlockedLayerId) { var oContainer = document.createElement("div"); oContainer.id = sBlockedLayerId; oContainer.className = "sapUiBlockLayer "; BlockLayerUtils.addAriaAttributes(oContainer); oBlockSection.appendChild(oContainer); return oContainer; }
javascript
{ "resource": "" }
q19630
suppressDefaultAndStopPropagation
train
function suppressDefaultAndStopPropagation(oEvent) { var bTargetIsBlockLayer = oEvent.target === this.$blockLayer.get(0), oTabbable; if (bTargetIsBlockLayer && oEvent.type === 'keydown' && oEvent.keyCode === 9) { // Special handling for "tab" keydown: redirect to next element before or after busy section Log.debug("Local Busy Indicator Event keydown handled: " + oEvent.type); oTabbable = oEvent.shiftKey ? this.oTabbableBefore : this.oTabbableAfter; oTabbable.setAttribute("tabindex", -1); // ignore execution of focus handler this.bIgnoreFocus = true; oTabbable.focus(); this.bIgnoreFocus = false; oTabbable.setAttribute("tabindex", 0); oEvent.stopImmediatePropagation(); } else if (bTargetIsBlockLayer && (oEvent.type === 'mousedown' || oEvent.type === 'touchstart')) { // Do not "preventDefault" to allow to focus busy indicator Log.debug("Local Busy Indicator click handled on busy area: " + oEvent.target.id); oEvent.stopImmediatePropagation(); } else { Log.debug("Local Busy Indicator Event Suppressed: " + oEvent.type); oEvent.preventDefault(); oEvent.stopImmediatePropagation(); } }
javascript
{ "resource": "" }
q19631
registerInteractionHandler
train
function registerInteractionHandler(fnHandler) { var aSuppressHandler = [], oParentDOM = this.$parent.get(0), oBlockLayerDOM = this.$blockLayer.get(0); for (var i = 0; i < aPreventedEvents.length; i++) { // Add event listeners with "useCapture" settings to suppress events before dispatching/bubbling starts oParentDOM.addEventListener(aPreventedEvents[i], fnHandler, { capture: true, passive: false }); aSuppressHandler.push(EventTriggerHook.suppress(aPreventedEvents[i], oParentDOM, oBlockLayerDOM)); } //for jQuery triggered events we also need the keydown handler this.$blockLayer.bind('keydown', fnHandler); return aSuppressHandler; }
javascript
{ "resource": "" }
q19632
deregisterInteractionHandler
train
function deregisterInteractionHandler(fnHandler) { var i, oParentDOM = this.$parent.get(0), oBlockLayerDOM = this.$blockLayer.get(0); if (oParentDOM) { for (i = 0; i < aPreventedEvents.length; i++) { // Remove event listeners with "useCapture" settings oParentDOM.removeEventListener(aPreventedEvents[i], fnHandler, { capture: true, passive: false }); } } if (this._aSuppressHandler) { for (i = 0; i < this._aSuppressHandler.length; i++) { // this part should be done even no DOMRef exists EventTriggerHook.release(this._aSuppressHandler[i]); } } if (oBlockLayerDOM) { this.$blockLayer.unbind('keydown', fnHandler); } }
javascript
{ "resource": "" }
q19633
train
function() { if (!this._aHistory) { var aHistory = this._oStorage.get(this._sHistoryId); if (typeof (aHistory) === "string") { // in case it is a string, convert it to an array aHistory = aHistory.split(","); } else if (!aHistory) { // or create a new one in case of non existence aHistory = []; } // else assume that there is the means for serializing JSON used, returning an array directly //do a final check of the entries this._aHistory = this._fCheckHistory(aHistory); } return this._aHistory; }
javascript
{ "resource": "" }
q19634
train
function(sValue) { var aHistory = this._initHistory(); var aResult = []; for (var i = 0; i < aHistory.length; i++) { if (this._fFilter(aHistory[i], sValue)) { aResult.push(aHistory[i]); } } return aResult; }
javascript
{ "resource": "" }
q19635
train
function(sValue) { var aHistory = this._initHistory(); for (var i = 0; i < aHistory.length; i++) { if (aHistory[i] == sValue) { aHistory.splice(i, 1); break; } } }
javascript
{ "resource": "" }
q19636
train
function(sValue) { var aHistory = this._initHistory(); // ensure it is not contained twice -> remove for (var i = 0; i < aHistory.length; i++) { if (aHistory[i] === sValue) { aHistory.splice(i,1); break; } } // and put it to the 'very top' aHistory.unshift(sValue); // but do not store more than specified if (aHistory.length > this._iMaxHistory) { aHistory.splice(this._iMaxHistory); } this._oStorage.put(this._sHistoryId, aHistory); }
javascript
{ "resource": "" }
q19637
each
train
function each(obj, cb) { if (!obj) return; if (!Array.isArray(obj) && typeof obj === "object") obj = Object.keys(obj); obj.forEach(cb); }
javascript
{ "resource": "" }
q19638
train
function (oEvent) { var sValue = this.getValue(); if (sValue) { that.setValue(sValue); that._selectItemByKey(); this.setValue(that._sOldInput); that.close(); } }
javascript
{ "resource": "" }
q19639
handleChange
train
function handleChange(sType, oObject, sName, fnCreateChange) { var sId = oObject.getId(), oTargetConfig = mTargets[sId]; if (oTargetConfig) { var oChange; for (var i = 0; i < oTargetConfig.listeners.length; i++) { if (isObserving(oTargetConfig.configurations[i], sType, sName)) { if (!oChange) { oChange = fnCreateChange(); oChange.name = sName; oChange.object = oObject; } var oListener = oTargetConfig.listeners[i]; oListener._fnCallback(oChange); } } } }
javascript
{ "resource": "" }
q19640
isObserving
train
function isObserving(oConfiguration, sType, sName) { // no configuration, listen to all types if (oConfiguration == null || !sType) { return false; } if (sType != "destroy" && sType != "parent" && !sName) { return false; } // either all (true) properties/aggregations/associations are relevant or a specific list or names is provided return oConfiguration[sType] === true || (Array.isArray(oConfiguration[sType]) && oConfiguration[sType].indexOf(sName) > -1); }
javascript
{ "resource": "" }
q19641
remove
train
function remove(oTarget, oListener, oConfiguration) { oConfiguration = oConfiguration || getConfiguration(oTarget, oListener); updateConfiguration(oTarget, oListener, oConfiguration, true); }
javascript
{ "resource": "" }
q19642
destroy
train
function destroy(oListener) { for (var n in mTargets) { var oTargetConfig = mTargets[n]; for (var i = 0; i < oTargetConfig.listeners.length; i++) { if (oTargetConfig.listeners[i] === oListener) { oTargetConfig.listeners.splice(i, 1); oTargetConfig.configurations.splice(i, 1); } } if (oTargetConfig.listeners && oTargetConfig.listeners.length === 0) { delete mTargets[n]; oTargetConfig.object._observer = undefined; } } }
javascript
{ "resource": "" }
q19643
updateConfiguration
train
function updateConfiguration(oTarget, oListener, oConfiguration, bRemove) { var sId = oTarget.getId(), oTargetConfig = mTargets[sId], oCurrentConfig, iIndex; if (bRemove) { if (!oTargetConfig) { // no registration so far, nothing to remove return; } iIndex = oTargetConfig.listeners.indexOf(oListener); if (iIndex >= 0) { // already registered, update the configuration oCurrentConfig = oTargetConfig.configurations[iIndex]; } } else { if (!oTargetConfig) { oTargetConfig = mTargets[sId] = { listeners: [], configurations: [], object: oTarget }; } iIndex = oTargetConfig.listeners.indexOf(oListener); if (iIndex === -1) { // not registered, push listener and configuration oTargetConfig.listeners.push(oListener); oTargetConfig.configurations.push(oConfiguration); } else { oCurrentConfig = oTargetConfig.configurations[iIndex]; } } if (oCurrentConfig) { oCurrentConfig.properties = oCurrentConfig.properties || []; updateSingleArray(oCurrentConfig.properties, oConfiguration.properties, bRemove); oCurrentConfig.aggregations = oCurrentConfig.aggregations || []; updateSingleArray(oCurrentConfig.aggregations, oConfiguration.aggregations, bRemove); oCurrentConfig.associations = oCurrentConfig.associations || []; updateSingleArray(oCurrentConfig.associations, oConfiguration.associations, bRemove); oCurrentConfig.bindings = oCurrentConfig.bindings || []; updateSingleArray(oCurrentConfig.bindings, oConfiguration.bindings, bRemove); oCurrentConfig.events = oCurrentConfig.events || []; updateSingleArray(oCurrentConfig.events, oConfiguration.events, bRemove); if (oConfiguration.destroy != null) { if (bRemove) { delete oCurrentConfig.destroy; } else { oCurrentConfig.destroy = oConfiguration.destroy; } } if (oConfiguration.parent != null) { if (bRemove) { delete oCurrentConfig.parent; } else { oCurrentConfig.parent = oConfiguration.parent; } } } var bEventsObserved = hasObserverFor(oTarget, "events"); if (oTarget._observer && bRemove) { //delete oTarget._observer; if (!bEventsObserved && EventProvider.hasListener(oTarget, "EventHandlerChange", fnHandleEventChange)) { oTarget.detachEvent("EventHandlerChange", fnHandleEventChange); } if (!bEventsObserved && !hasObserverFor(oTarget, "properties") && !hasObserverFor(oTarget, "aggregations") && !hasObserverFor(oTarget, "associations") && !hasObserverFor(oTarget, "destroy") && !hasObserverFor(oTarget, "parent") && !hasObserverFor(oTarget, "bindings")) { delete oTarget._observer; delete mTargets[sId]; } } else if (!oTarget._observer && !bRemove) { //is any config listening to events if (bEventsObserved && !EventProvider.hasListener(oTarget, "EventHandlerChange", fnHandleEventChange)) { oTarget.attachEvent("EventHandlerChange", fnHandleEventChange); } oTarget._observer = Observer; } }
javascript
{ "resource": "" }
q19644
updateSingleArray
train
function updateSingleArray(aOrig, aAdditional, bRemove) { if (!aAdditional) { return; } for (var i = 0; i < aAdditional.length; i++) { var iIndex = aOrig.indexOf(aAdditional[i]); if (iIndex > -1 && bRemove) { aOrig.splice(iIndex, 1); } else if (iIndex === -1 && !bRemove) { aOrig.push(aAdditional[i]); } } }
javascript
{ "resource": "" }
q19645
normalizeConfiguration
train
function normalizeConfiguration(oObject, oConfiguration) { var oMetadata = oObject.getMetadata(), aProperties = Object.keys(oMetadata.getAllProperties()), aAggregations = Object.keys(oMetadata.getAllAggregations()), aAssociations = Object.keys(oMetadata.getAllAssociations()), aBindings = uniqueSort(aProperties.concat(aAggregations)), aEvents = Object.keys(oMetadata.getAllEvents()); oConfiguration.properties = oConfiguration.properties === true ? aProperties : oConfiguration.properties; oConfiguration.aggregations = oConfiguration.aggregations === true ? aAggregations : oConfiguration.aggregations; oConfiguration.associations = oConfiguration.associations === true ? aAssociations : oConfiguration.associations; oConfiguration.bindings = oConfiguration.bindings === true ? aBindings : oConfiguration.bindings; oConfiguration.events = oConfiguration.events === true ? aEvents : oConfiguration.events; oConfiguration.destroy = (oConfiguration.destroy == null) ? false : oConfiguration.destroy; oConfiguration.parent = (oConfiguration.parent == null) ? false : oConfiguration.parent; }
javascript
{ "resource": "" }
q19646
getLogEntryListenerInstance
train
function getLogEntryListenerInstance(){ if (!oListener) { oListener = { listeners: [], onLogEntry: function(oLogEntry){ for (var i = 0; i < oListener.listeners.length; i++) { if (oListener.listeners[i].onLogEntry) { oListener.listeners[i].onLogEntry(oLogEntry); } } }, attach: function(oLog, oLstnr){ if (oLstnr) { oListener.listeners.push(oLstnr); if (oLstnr.onAttachToLog) { oLstnr.onAttachToLog(oLog); } } }, detach: function(oLog, oLstnr){ for (var i = 0; i < oListener.listeners.length; i++) { if (oListener.listeners[i] === oLstnr) { if (oLstnr.onDetachFromLog) { oLstnr.onDetachFromLog(oLog); } oListener.listeners.splice(i,1); return; } } } }; } return oListener; }
javascript
{ "resource": "" }
q19647
log
train
function log(iLevel, sMessage, sDetails, sComponent, fnSupportInfo) { if (!fnSupportInfo && !sComponent && typeof sDetails === "function") { fnSupportInfo = sDetails; sDetails = ""; } if (!fnSupportInfo && typeof sComponent === "function") { fnSupportInfo = sComponent; sComponent = ""; } sComponent = sComponent || sDefaultComponent; if (iLevel <= level(sComponent) ) { var fNow = now(), oNow = new Date(fNow), iMicroSeconds = Math.floor((fNow - Math.floor(fNow)) * 1000), oLogEntry = { time : pad0(oNow.getHours(),2) + ":" + pad0(oNow.getMinutes(),2) + ":" + pad0(oNow.getSeconds(),2) + "." + pad0(oNow.getMilliseconds(),3) + pad0(iMicroSeconds,3), date : pad0(oNow.getFullYear(),4) + "-" + pad0(oNow.getMonth() + 1,2) + "-" + pad0(oNow.getDate(),2), timestamp: fNow, level : iLevel, message : String(sMessage || ""), details : String(sDetails || ""), component: String(sComponent || "") }; if (bLogSupportInfo && typeof fnSupportInfo === "function") { oLogEntry.supportInfo = fnSupportInfo(); } aLog.push( oLogEntry ); if (oListener) { oListener.onLogEntry(oLogEntry); } /* * Console Log, also tries to log to the console, if available. * * Unfortunately, the support for console is quite different between the UI5 browsers. The most important differences are: * - in IE (checked until IE9), the console object does not exist in a window, until the developer tools are opened for that window. * After opening the dev tools, the console remains available even when the tools are closed again. Only using a new window (or tab) * restores the old state without console. * When the console is available, it provides most standard methods, but not debug and trace * - in FF3.6 the console is not available, until FireBug is opened. It disappears again, when fire bug is closed. * But when the settings for a web site are stored (convenience), the console remains open * When the console is available, it supports all relevant methods * - in FF9.0, the console is always available, but method assert is only available when firebug is open * - in Webkit browsers, the console object is always available and has all required methods * - Exception: in the iOS Simulator, console.info() does not exist */ /*eslint-disable no-console */ if (console) { // in IE and FF, console might not exist; in FF it might even disappear var isDetailsError = sDetails instanceof Error, logText = oLogEntry.date + " " + oLogEntry.time + " " + oLogEntry.message + " - " + oLogEntry.details + " " + oLogEntry.component; switch (iLevel) { case Log.Level.FATAL: case Log.Level.ERROR: isDetailsError ? console.error(logText, "\n", sDetails) : console.error(logText); break; case Log.Level.WARNING: isDetailsError ? console.warn(logText, "\n", sDetails) : console.warn(logText); break; case Log.Level.INFO: if (console.info) { // info not available in iOS simulator isDetailsError ? console.info(logText, "\n", sDetails) : console.info(logText); } else { isDetailsError ? console.log(logText, "\n", sDetails) : console.log(logText); } break; case Log.Level.DEBUG: if (console.debug) { // debug not available in IE, fallback to log isDetailsError ? console.debug(logText, "\n", sDetails) : console.debug(logText); } else { isDetailsError ? console.log(logText, "\n", sDetails) : console.log(logText); } break; case Log.Level.TRACE: if (console.trace) { // trace not available in IE, fallback to log (no trace) isDetailsError ? console.trace(logText, "\n", sDetails) : console.trace(logText); } else { isDetailsError ? console.log(logText, "\n", sDetails) : console.log(logText); } break; } if (console.info && oLogEntry.supportInfo) { console.info(oLogEntry.supportInfo); } } /*eslint-enable no-console */ return oLogEntry; } }
javascript
{ "resource": "" }
q19648
filter
train
function filter(mMap, fnFilter) { return Object.keys(mMap).filter(fnFilter).reduce(copyTo.bind(mMap), {}); }
javascript
{ "resource": "" }
q19649
train
function () { // 1. call overridden init (calls createContent) UIComponent.prototype.init.apply(this, arguments); // 2. nav to initial pages var router = this.getRouter(); if (!Device.system.phone) { router.myNavToWithoutHash("sap.ui.demokit.explored.view.master", "XML", true); router.myNavToWithoutHash("sap.ui.demokit.explored.view.welcome", "XML", false); } // 3. initialize the router this.routeHandler = new RouteMatchedHandler(router); router.initialize(); }
javascript
{ "resource": "" }
q19650
train
function (oModel, oBinding, sPath, iIndex, oCreatePromise) { return new Context(oModel, oBinding, sPath, iIndex, oCreatePromise); }
javascript
{ "resource": "" }
q19651
onLoadstart
train
function onLoadstart(event) { Log.info(getTstmp(event.timeStamp) + ", " + this.xidx + ": loadstart"); this.xfirstByteSent = getTstmp(event.timeStamp); }
javascript
{ "resource": "" }
q19652
train
function(oSettings) { var oMetadata = this.getMetadata(), aValidKeys = oMetadata.getJSONKeys(), // UID names required, they're part of the documented contract sKey, oValue, oKeyInfo; for (sKey in oSettings) { // get info object for the key if ( (oKeyInfo = aValidKeys[sKey]) !== undefined ) { oValue = oSettings[sKey]; switch (oKeyInfo._iKind) { case 3: // SINGLE ASSOCIATIONS // prefix the association ids with the view id if ( typeof oValue === "string" ) { oSettings[sKey] = that.createId(oValue); } break; case 5: // EVENTS if ( typeof oValue === "string" ) { oSettings[sKey] = EventHandlerResolver.resolveEventHandler(oValue, oController); } break; } } } }
javascript
{ "resource": "" }
q19653
getVersionWithoutSuffix
train
function getVersionWithoutSuffix(sVersion) { var oVersion = Version(sVersion); return oVersion.getSuffix() ? Version(oVersion.getMajor() + "." + oVersion.getMinor() + "." + oVersion.getPatch()) : oVersion; }
javascript
{ "resource": "" }
q19654
getObject
train
function getObject(oObject, sPath) { // if the incoming sPath is a path we do a nested lookup in the // manifest object and return the concrete value, e.g. "/sap.ui5/extends" if (oObject && sPath && typeof sPath === "string" && sPath[0] === "/") { var aPaths = sPath.substring(1).split("/"), sPathSegment; for (var i = 0, l = aPaths.length; i < l; i++) { sPathSegment = aPaths[i]; // Prevent access to native properties oObject = oObject.hasOwnProperty(sPathSegment) ? oObject[sPathSegment] : undefined; // Only continue with lookup if the value is an object. // Accessing properties of other types is not allowed! if (oObject === null || typeof oObject !== "object") { // Clear the value in case this is not the last segment in the path. // Otherwise e.g. "/foo/bar/baz" would return the value of "/foo/bar" // in case it is not an object. if (i + 1 < l && oObject !== undefined) { oObject = undefined; } break; } } return oObject; } // if no path starting with slash is specified we access and // return the value directly from the manifest return oObject && oObject[sPath]; }
javascript
{ "resource": "" }
q19655
deepFreeze
train
function deepFreeze(oObject) { if (oObject && typeof oObject === 'object' && !Object.isFrozen(oObject)) { Object.freeze(oObject); for (var sKey in oObject) { if (oObject.hasOwnProperty(sKey)) { deepFreeze(oObject[sKey]); } } } }
javascript
{ "resource": "" }
q19656
train
function(sPath) { if (!sPath || sPath.indexOf(".") <= 0) { Log.warning("Manifest entries with keys without namespace prefix can not be read via getEntry. Key: " + sPath + ", Component: " + this.getComponentName()); return null; } var oManifest = this.getJson(); var oEntry = getObject(oManifest, sPath); // top-level manifest section must be an object (e.g. sap.ui5) if (sPath && sPath[0] !== "/" && !isPlainObject(oEntry)) { Log.warning("Manifest entry with key '" + sPath + "' must be an object. Component: " + this.getComponentName()); return null; } return oEntry; }
javascript
{ "resource": "" }
q19657
train
function() { // version check => only if minVersion is available a warning // will be logged and the debug mode is turned on // TODO: enhance version check also for libraries and components var sMinUI5Version = this.getEntry("/sap.ui5/dependencies/minUI5Version"); if (sMinUI5Version && Log.isLoggable(Log.Level.WARNING) && sap.ui.getCore().getConfiguration().getDebug()) { sap.ui.getVersionInfo({async: true}).then(function(oVersionInfo) { var oMinVersion = getVersionWithoutSuffix(sMinUI5Version); var oVersion = getVersionWithoutSuffix(oVersionInfo && oVersionInfo.version); if (oMinVersion.compareTo(oVersion) > 0) { Log.warning("Component \"" + this.getComponentName() + "\" requires at least version \"" + oMinVersion.toString() + "\" but running on \"" + oVersion.toString() + "\"!"); } }.bind(this), function(e) { Log.warning("The validation of the version for Component \"" + this.getComponentName() + "\" failed! Reasion: " + e); }.bind(this)); } }
javascript
{ "resource": "" }
q19658
train
function() { // skip loading includes once already loaded if (this._bIncludesLoaded) { return; } var mResources = this.getEntry("/sap.ui5/resources"); if (!mResources) { return; } var sComponentName = this.getComponentName(); // load JS files var aJSResources = mResources["js"]; if (aJSResources) { for (var i = 0; i < aJSResources.length; i++) { var oJSResource = aJSResources[i]; var sFile = oJSResource.uri; if (sFile) { // load javascript file var m = sFile.match(/\.js$/i); if (m) { //var sJsUrl = this.resolveUri(sFile.slice(0, m.index)); var sJsUrl = sComponentName.replace(/\./g, '/') + (sFile.slice(0, 1) === '/' ? '' : '/') + sFile.slice(0, m.index); Log.info("Component \"" + sComponentName + "\" is loading JS: \"" + sJsUrl + "\""); // call internal sap.ui.require variant that accepts a requireJS path and loads the module synchronously sap.ui.requireSync(sJsUrl); } } } } // include CSS files var aCSSResources = mResources["css"]; if (aCSSResources) { for (var j = 0; j < aCSSResources.length; j++) { var oCSSResource = aCSSResources[j]; if (oCSSResource.uri) { var sCssUrl = this.resolveUri(oCSSResource.uri); Log.info("Component \"" + sComponentName + "\" is loading CSS: \"" + sCssUrl + "\""); includeStylesheet(sCssUrl, { id: oCSSResource.id, "data-sap-ui-manifest-uid": this._uid }); } } } this._bIncludesLoaded = true; }
javascript
{ "resource": "" }
q19659
train
function() { // skip removing includes when not loaded yet if (!this._bIncludesLoaded) { return; } var mResources = this.getEntry("/sap.ui5/resources"); if (!mResources) { return; } var sComponentName = this.getComponentName(); // remove CSS files var aCSSResources = mResources["css"]; if (aCSSResources) { // As all <link> tags have been marked with the manifest's unique id (via data-sap-ui-manifest-uid) // it is not needed to check for all individual CSS files defined in the manifest. // Checking for all "href"s again might also cause issues when they have been adopted (e.g. to add cachebuster url params). var aLinks = document.querySelectorAll("link[data-sap-ui-manifest-uid='" + this._uid + "']"); for (var i = 0; i < aLinks.length; i++) { var oLink = aLinks[i]; Log.info("Component \"" + sComponentName + "\" is removing CSS: \"" + oLink.href + "\""); oLink.parentNode.removeChild(oLink); } } this._bIncludesLoaded = false; }
javascript
{ "resource": "" }
q19660
train
function(sUri, sRelativeTo) { var oUri = this._resolveUri(new URI(sUri), sRelativeTo); return oUri && oUri.toString(); }
javascript
{ "resource": "" }
q19661
train
function(oInstance) { if (this._iInstanceCount === 0) { // version check => only if minVersion is available a warning // will be logged and the debug mode is turned on this.checkUI5Version(); // define the resource roots // => if not loaded via manifest first approach the resource roots // will be registered too late for the AMD modules of the Component // controller. This is a constraint for the resource roots config // in the manifest! this.defineResourceRoots(); // load the component dependencies (other UI5 libraries) this.loadDependencies(); // load the custom scripts and CSS files this.loadIncludes(); // activate the static customizing this.activateCustomizing(); } // activate the instance customizing if (oInstance) { this.activateCustomizing(oInstance); } this._iInstanceCount++; }
javascript
{ "resource": "" }
q19662
train
function(oInstance) { // ensure that the instance count is never negative var iInstanceCount = Math.max(this._iInstanceCount - 1, 0); // deactivate the instance customizing if (oInstance) { this.deactivateCustomizing(oInstance); } if (iInstanceCount === 0) { // deactivcate the customizing this.deactivateCustomizing(); // remove the custom scripts and CSS files this.removeIncludes(); } this._iInstanceCount = iInstanceCount; }
javascript
{ "resource": "" }
q19663
train
function(oInstance) { // activate the customizing configuration var oUI5Manifest = this.getEntry("sap.ui5", true), mExtensions = oUI5Manifest && oUI5Manifest["extends"] && oUI5Manifest["extends"].extensions; if (!jQuery.isEmptyObject(mExtensions)) { var CustomizingConfiguration = sap.ui.requireSync('sap/ui/core/CustomizingConfiguration'); if (!oInstance) { CustomizingConfiguration.activateForComponent(this.getComponentName()); } else { CustomizingConfiguration.activateForComponentInstance(oInstance); } } }
javascript
{ "resource": "" }
q19664
train
function(oInstance) { // deactivate the customizing configuration var CustomizingConfiguration = sap.ui.require('sap/ui/core/CustomizingConfiguration'); if (CustomizingConfiguration) { if (!oInstance) { CustomizingConfiguration.deactivateForComponent(this.getComponentName()); } else { CustomizingConfiguration.deactivateForComponentInstance(oInstance); } } }
javascript
{ "resource": "" }
q19665
train
function (sDateString) { var iMillis = NativeDate_parse.apply(Date, arguments); if (sDateString && typeof sDateString === "string") { // if the year is gt/eq 2034 we need to increment the // date by one additional day since this is broken in // PhantomJS => this is a workaround for the upper BUG! var m = /^(\d{4})(?:-(\d+)?-(\d+))(?:[T ](\d+):(\d+)(?::(\d+)(?:\.(\d+))?)?)?(?:Z(-?\d*))?$/.exec(sDateString); if (m && parseInt(m[1]) >= 2034) { iMillis += 24 * 60 * 60 * 1000; } } return iMillis; }
javascript
{ "resource": "" }
q19666
mapKeyCodeToKey
train
function mapKeyCodeToKey(sKeyCode) { // look up number in KeyCodes enum to get the string if (!isNaN(sKeyCode)) { sKeyCode = getKeyCodeStringFromNumber(sKeyCode); } if (!sKeyCode) { return undefined; } sKeyCode = sKeyCode.toLowerCase(); // replace underscores with dash character such as 'ARROW_LEFT' --> 'ARROW-LEFT' and then camelize it --> 'ArrowLeft' sKeyCode = camelize(sKeyCode.replace(/_/g, "-")); // capitalize key var sKey = capitalize(sKeyCode); // remove "Digit" and "Numpad" from the resulting string as this info is present within the Location property and not the key property // e.g. "Digit9" --> "9" if (sKey.startsWith("Digit")) { return sKey.substring("Digit".length); } else if (sKey.startsWith("Numpad")) { sKey = sKey.substring("Numpad".length); } // special handling where KeyCodes[sKeyCode] does not match // e.g. KeyCodes.BREAK --> 'Pause' instead of 'Break' switch (sKey) { case "Break": return "Pause"; case "Space": return " "; case "Print": return "PrintScreen"; case "Windows": return "Meta"; case "Sleep": return "Standby"; case "TurnOff": return "PowerOff"; case "Asterisk": return "*"; case "Plus": return "+"; case "Minus": return "-"; case "Comma": return ","; case "Slash": return "/"; case "OpenBracket": return ";"; case "Dot": return "."; case "Pipe": return "|"; case "Semicolon": return ";"; case "Equals": return "="; case "SingleQUote": return "="; case "Backslash": return "\\"; case "GreatAccent": return "`"; default: return sKey; } }
javascript
{ "resource": "" }
q19667
getKeyCodeStringFromNumber
train
function getKeyCodeStringFromNumber(iKeyCode) { for (var sKey in KeyCodes) { if (KeyCodes.hasOwnProperty(sKey)) { if (KeyCodes[sKey] === iKeyCode) { return sKey; } } } }
javascript
{ "resource": "" }
q19668
offset
train
function offset(a,b,va,vb) { return abOffset[a * N + b] + va * params[b].n + vb; }
javascript
{ "resource": "" }
q19669
calcCost
train
function calcCost(a, va) { var score = { va: va, pairs:0, redundant:0 }; for (var c = 0; c < N; c++) { var count; if ( c < a ) { count = occurs[offset(c,a,value_index[c],va)]; } else if ( c > a ) { var j = offset(a,c,va,0), end = j + params[c].n; for (count = occurs[j]; count > 0 && i < end; j++ ) { if ( occurs[j] < count ) { count = occurs[j]; } } } score.redundant = score.redundant + count; if ( count == 0 ) { score.pairs++; } } return score; }
javascript
{ "resource": "" }
q19670
normalize
train
function normalize(sResourceName, sBaseName) { var p = sResourceName.search(rDotSegmentAnywhere), aSegments, sSegment, i,j,l; // check whether the name needs to be resolved at all - if not, just return the sModuleName as it is. if ( p < 0 ) { return sResourceName; } // if the name starts with a relative segment then there must be a base name (a global sap.ui.require doesn't support relative names) if ( p === 0 ) { if ( sBaseName == null ) { throw new Error("relative name not supported ('" + sResourceName + "'"); } // prefix module name with the parent package sResourceName = sBaseName.slice(0, sBaseName.lastIndexOf('/') + 1) + sResourceName; } aSegments = sResourceName.split('/'); // process path segments for (i = 0, j = 0, l = aSegments.length; i < l; i++) { sSegment = aSegments[i]; if ( rDotSegment.test(sSegment) ) { if (sSegment === '.' || sSegment === '') { // ignore '.' as it's just a pointer to current package. ignore '' as it results from double slashes (ignored by browsers as well) continue; } else if (sSegment === '..') { // move to parent directory if ( j === 0 ) { throw new Error("Can't navigate to parent of root ('" + sResourceName + "')"); } j--; } else { throw new Error("Illegal path segment '" + sSegment + "' ('" + sResourceName + "')"); } } else { aSegments[j++] = sSegment; } } aSegments.length = j; return aSegments.join('/'); }
javascript
{ "resource": "" }
q19671
registerResourcePath
train
function registerResourcePath(sResourceNamePrefix, sUrlPrefix) { sResourceNamePrefix = String(sResourceNamePrefix || ""); if ( sUrlPrefix == null ) { // remove a registered URL prefix, if it wasn't for the empty resource name prefix if ( sResourceNamePrefix ) { if ( mUrlPrefixes[sResourceNamePrefix] ) { delete mUrlPrefixes[sResourceNamePrefix]; log.info("registerResourcePath ('" + sResourceNamePrefix + "') (registration removed)"); } return; } // otherwise restore the default sUrlPrefix = DEFAULT_BASE_URL; log.info("registerResourcePath ('" + sResourceNamePrefix + "') (default registration restored)"); } // cast to string and remove query parameters and/or hash sUrlPrefix = pathOnly(String(sUrlPrefix)); // ensure that the prefix ends with a '/' if ( sUrlPrefix.slice(-1) !== '/' ) { sUrlPrefix += '/'; } mUrlPrefixes[sResourceNamePrefix] = { url: sUrlPrefix, // calculate absolute URL, only to be used by 'guessResourceName' absoluteUrl: resolveURL(sUrlPrefix) }; }
javascript
{ "resource": "" }
q19672
getResourcePath
train
function getResourcePath(sResourceName, sSuffix) { var sNamePrefix = sResourceName, p = sResourceName.length, sPath; // search for a registered name prefix, starting with the full name and successively removing one segment while ( p > 0 && !mUrlPrefixes[sNamePrefix] ) { p = sNamePrefix.lastIndexOf('/'); // Note: an empty segment at p = 0 (leading slash) will be ignored sNamePrefix = p > 0 ? sNamePrefix.slice(0, p) : ''; } assert((p > 0 || sNamePrefix === '') && mUrlPrefixes[sNamePrefix], "there always must be a mapping"); sPath = mUrlPrefixes[sNamePrefix].url + sResourceName.slice(p + 1); // also skips a leading slash! //remove trailing slash if ( sPath.slice(-1) === '/' ) { sPath = sPath.slice(0, -1); } return sPath + (sSuffix || ''); }
javascript
{ "resource": "" }
q19673
findMapForContext
train
function findMapForContext(sContext) { var p, mMap; if ( sContext != null ) { // maps are defined on module IDs, reduce URN to module ID sContext = urnToIDAndType(sContext).id; p = sContext.length; mMap = mMaps[sContext]; while ( p > 0 && mMap == null ) { p = sContext.lastIndexOf('/'); if ( p > 0 ) { // Note: an empty segment at p = 0 (leading slash) will be ignored sContext = sContext.slice(0, p); mMap = mMaps[sContext]; } } } // if none is found, fallback to '*' map return mMap || mMaps['*']; }
javascript
{ "resource": "" }
q19674
loadSyncXHR
train
function loadSyncXHR(oModule) { var xhr = new XMLHttpRequest(); function enrichXHRError(error) { error = error || ensureStacktrace(new Error(xhr.status + " - " + xhr.statusText)); error.status = xhr.status; error.statusText = xhr.statusText; error.loadError = true; return error; } xhr.addEventListener('load', function(e) { // File protocol (file://) always has status code 0 if ( xhr.status === 200 || xhr.status === 0 ) { oModule.state = LOADED; oModule.data = xhr.responseText; } else { oModule.error = enrichXHRError(); } }); // Note: according to whatwg spec, error event doesn't fire for sync send(), instead an error is thrown // we register a handler, in case a browser doesn't follow the spec xhr.addEventListener('error', function(e) { oModule.error = enrichXHRError(); }); xhr.open('GET', oModule.url, false); try { xhr.send(); } catch (error) { oModule.error = enrichXHRError(error); } }
javascript
{ "resource": "" }
q19675
execModule
train
function execModule(sModuleName, bAsync) { var oModule = mModules[sModuleName], oShim = mShims[sModuleName], bLoggable = log.isLoggable(), sOldPrefix, sScript, vAMD, oMatch, bOldForceSyncDefines; if ( oModule && oModule.state === LOADED && typeof oModule.data !== "undefined" ) { // check whether the module is known to use an existing AMD loader, remember the AMD flag vAMD = (oShim === true || (oShim && oShim.amd)) && typeof __global.define === "function" && __global.define.amd; bOldForceSyncDefines = bForceSyncDefines; try { if ( vAMD ) { // temp. remove the AMD Flag from the loader delete __global.define.amd; } bForceSyncDefines = !bAsync; if ( bLoggable ) { log.debug(sLogPrefix + "executing '" + sModuleName + "'"); sOldPrefix = sLogPrefix; sLogPrefix = sLogPrefix + ": "; } // execute the script in the __global context oModule.state = EXECUTING; _execStack.push({ name: sModuleName, used: false }); if ( typeof oModule.data === "function" ) { oModule.data.call(__global); } else if ( Array.isArray(oModule.data) ) { ui5Define.apply(null, oModule.data); } else { sScript = oModule.data; // sourceURL: Firebug, Chrome, Safari and IE11 debugging help, appending the string seems to cost ZERO performance // Note: IE11 supports sourceURL even when running in IE9 or IE10 mode // Note: make URL absolute so Chrome displays the file tree correctly // Note: do not append if there is already a sourceURL / sourceMappingURL // Note: Safari fails, if sourceURL is the same as an existing XHR URL // Note: Chrome ignores debug files when the same URL has already been load via sourcemap of the bootstrap file (sap-ui-core) // Note: sourcemap annotations URLs in eval'ed sources are resolved relative to the page, not relative to the source if (sScript ) { oMatch = /\/\/[#@] source(Mapping)?URL=(.*)$/.exec(sScript); if ( oMatch && oMatch[1] && /^[^/]+\.js\.map$/.test(oMatch[2]) ) { // found a sourcemap annotation with a typical UI5 generated relative URL sScript = sScript.slice(0, oMatch.index) + oMatch[0].slice(0, -oMatch[2].length) + resolveURL(oMatch[2], oModule.url); } // @evo-todo use only sourceMappingURL, sourceURL or both? if ( !oMatch || oMatch[1] ) { // write sourceURL if no annotation was there or when it was a sourceMappingURL sScript += "\n//# sourceURL=" + resolveURL(oModule.url) + "?eval"; } } // framework internal hook to intercept the loaded script and modify // it before executing the script - e.g. useful for client side coverage if (typeof translate === "function") { sScript = translate(sScript, sModuleName); } if (__global.execScript && (!oModule.data || oModule.data.length < MAX_EXEC_SCRIPT_LENGTH) ) { try { oModule.data && __global.execScript(sScript); // execScript fails if data is empty } catch (e) { _execStack.pop(); // eval again with different approach - should fail with a more informative exception /* eslint-disable no-eval */ eval(oModule.data); /* eslint-enable no-eval */ throw e; // rethrow err in case globalEval succeeded unexpectedly } } else { __global.eval(sScript); } } _execStack.pop(); queue.process(oModule); if ( bLoggable ) { sLogPrefix = sOldPrefix; log.debug(sLogPrefix + "finished executing '" + sModuleName + "'"); } } catch (err) { if ( bLoggable ) { sLogPrefix = sOldPrefix; } oModule.data = undefined; oModule.fail(err); } finally { // restore AMD flag if ( vAMD ) { __global.define.amd = vAMD; } bForceSyncDefines = bOldForceSyncDefines; } } }
javascript
{ "resource": "" }
q19676
dumpInternals
train
function dumpInternals(iThreshold) { var states = [PRELOADED, INITIAL, LOADED, READY, FAILED, EXECUTING, LOADING]; var stateNames = {}; stateNames[PRELOADED] = 'PRELOADED'; stateNames[INITIAL] = 'INITIAL'; stateNames[LOADING] = 'LOADING'; stateNames[LOADED] = 'LOADED'; stateNames[EXECUTING] = 'EXECUTING'; stateNames[READY] = 'READY'; stateNames[FAILED] = 'FAILED'; if ( iThreshold == null ) { iThreshold = PRELOADED; } /*eslint-disable no-console */ var info = log.isLoggable('INFO') ? log.info.bind(log) : console.info.bind(console); /*eslint-enable no-console */ var aModuleNames = Object.keys(mModules).sort(); states.forEach(function(state) { if ( state < iThreshold ) { return; } var count = 0; info(stateNames[state] + ":"); aModuleNames.forEach(function(sModule, idx) { var oModule = mModules[sModule]; if ( oModule.state === state ) { var addtlInfo; if ( oModule.state === LOADING ) { var pending = oModule.pending && oModule.pending.reduce(function(acc, dep) { var oDepModule = Module.get(dep); if ( oDepModule.state !== READY ) { acc.push( dep + "(" + stateNames[oDepModule.state] + ")"); } return acc; }, []); if ( pending && pending.length > 0 ) { addtlInfo = "waiting for " + pending.join(", "); } } else if ( oModule.state === FAILED ) { addtlInfo = (oModule.error.name || "Error") + ": " + oModule.error.message; } info(" " + (idx + 1) + " " + sModule + (addtlInfo ? " (" + addtlInfo + ")" : "")); count++; } }); if ( count === 0 ) { info(" none"); } }); }
javascript
{ "resource": "" }
q19677
getUrlPrefixes
train
function getUrlPrefixes() { var mUrlPrefixesCopy = Object.create(null); forEach(mUrlPrefixes, function(sNamePrefix, oUrlInfo) { mUrlPrefixesCopy[sNamePrefix] = oUrlInfo.url; }); return mUrlPrefixesCopy; }
javascript
{ "resource": "" }
q19678
unloadResources
train
function unloadResources(sName, bPreloadGroup, bUnloadAll, bDeleteExports) { var aModules = [], sURN, oModule; if ( bPreloadGroup == null ) { bPreloadGroup = true; } if ( bPreloadGroup ) { // collect modules that belong to the given group for ( sURN in mModules ) { oModule = mModules[sURN]; if ( oModule && oModule.group === sName ) { aModules.push(sURN); } } } else { // single module if ( mModules[sName] ) { aModules.push(sName); } } aModules.forEach(function(sURN) { var oModule = mModules[sURN]; if ( oModule && bDeleteExports && sURN.match(/\.js$/) ) { // @evo-todo move to compat layer? setGlobalProperty(urnToUI5(sURN), undefined); } if ( oModule && (bUnloadAll || oModule.state === PRELOADED) ) { delete mModules[sURN]; } }); }
javascript
{ "resource": "" }
q19679
getAllModules
train
function getAllModules() { var mSnapshot = Object.create(null); forEach(mModules, function(sURN, oModule) { mSnapshot[sURN] = { state: oModule.state, ui5: urnToUI5(sURN) }; }); return mSnapshot; }
javascript
{ "resource": "" }
q19680
train
function(module, shim) { if ( Array.isArray(shim) ) { shim = { deps : shim }; } mShims[module + '.js'] = shim; }
javascript
{ "resource": "" }
q19681
handleConfigObject
train
function handleConfigObject(oCfg, mHandlers) { function processConfig(key, value) { var handler = mHandlers[key]; if ( typeof handler === 'function' ) { if ( handler.length === 1) { handler(value); } else if ( value != null ) { forEach(value, handler); } } else { log.warning("configuration option " + key + " not supported (ignored)"); } } // Make sure the 'baseUrl' handler is called first as // other handlers (e.g. paths) depend on it if (oCfg.baseUrl) { processConfig("baseUrl", oCfg.baseUrl); } forEach(oCfg, function(key, value) { // Ignore "baseUrl" here as it will be handled above if (key !== "baseUrl") { processConfig(key, value); } }); }
javascript
{ "resource": "" }
q19682
train
function(oWindow, sRootId) { this.oWindow = oWindow; this.oDomNode = oWindow.document.getElementById(sRootId); if (!this.oDomNode) { var oDiv = this.oWindow.document.createElement("DIV"); oDiv.setAttribute("id", sRootId); oDiv.style.overflow = "auto"; oDiv.style.tabIndex = "-1"; oDiv.style.position = "absolute"; oDiv.style.bottom = "0px"; oDiv.style.left = "0px"; oDiv.style.right = "202px"; oDiv.style.height = "200px"; oDiv.style.border = "1px solid gray"; oDiv.style.fontFamily = "Arial monospaced for SAP,monospace"; oDiv.style.fontSize = "11px"; oDiv.style.zIndex = "999999"; this.oWindow.document.body.appendChild(oDiv); this.oDomNode = oDiv; } this.iLogLevel = 3; /* Log.LogLevel.INFO */ this.sLogEntryClassPrefix = undefined; this.clear(); this.setFilter(LogViewer.NO_FILTER); }
javascript
{ "resource": "" }
q19683
processPlaceholder
train
function processPlaceholder (sPlaceholder, oParam) { var sISODate = new Date().toISOString(); var sProcessed = sPlaceholder.replace("{{parameters.NOW_ISO}}", sISODate); sProcessed = sProcessed.replace("{{parameters.TODAY_ISO}}", sISODate.slice(0, 10)); if (oParam) { for (var oProperty in oParam) { sProcessed = sProcessed.replace("{{parameters." + oProperty + "}}", oParam[oProperty].value); } } return sProcessed; }
javascript
{ "resource": "" }
q19684
process
train
function process (oObject, oTranslator, iCurrentLevel, iMaxLevel, oParams) { if (iCurrentLevel === iMaxLevel) { return; } if (Array.isArray(oObject)) { oObject.forEach(function (vItem, iIndex, aArray) { if (typeof vItem === "object") { process(vItem, oTranslator, iCurrentLevel + 1, iMaxLevel, oParams); } else if (isProcessable(vItem, oObject, oParams)) { aArray[iIndex] = processPlaceholder(vItem, oParams); } else if (isTranslatable(vItem) && oTranslator) { aArray[iIndex] = oTranslator.getText(vItem.substring(2, vItem.length - 2)); } }, this); } else { for (var sProp in oObject) { if (typeof oObject[sProp] === "object") { process(oObject[sProp], oTranslator, iCurrentLevel + 1, iMaxLevel, oParams); } else if (isProcessable(oObject[sProp], oObject, oParams)) { oObject[sProp] = processPlaceholder(oObject[sProp], oParams); } else if (isTranslatable(oObject[sProp]) && oTranslator) { oObject[sProp] = oTranslator.getText(oObject[sProp].substring(2, oObject[sProp].length - 2)); } } } }
javascript
{ "resource": "" }
q19685
_getElementTreeLeftColumnOfListItem
train
function _getElementTreeLeftColumnOfListItem(controls, paddingLeft) { var html = "<offset style=\"padding-left:" + paddingLeft + "px\" >"; if (controls.content.length > 0) { html += "<arrow down=\"true\"></arrow>"; } else { html += "<place-holder></place-holder>"; } html += "</offset>"; return html; }
javascript
{ "resource": "" }
q19686
_getElementTreeRightColumnOfListItem
train
function _getElementTreeRightColumnOfListItem(control, numberOfIssues) { var splitControlName = control.name.split("."); var name = splitControlName[splitControlName.length - 1]; var nameSpace = control.name.replace(name, ""); var hideShowClass = (numberOfIssues > 0) ? "showNumbOfIssues" : "hideNumbOfIssues"; return "<tag data-search=\"" + control.name + control.id + "\">" + "&#60;" + "<namespace>" + nameSpace + "</namespace>" + name + "<attribute>&#32;id=\"<attribute-value>" + control.id + "</attribute-value>\"</attribute>" + "&#62;" + "</tag>" + "<span class = " + hideShowClass + ">[" + numberOfIssues + " issue(s)] </span>"; }
javascript
{ "resource": "" }
q19687
_findNearestDOMParent
train
function _findNearestDOMParent(element, parentNodeName) { while (element.nodeName !== parentNodeName) { if (element.nodeName === "CONTROL-TREE") { break; } element = element.parentNode; } return element; }
javascript
{ "resource": "" }
q19688
ElementTree
train
function ElementTree(id, instantiationOptions) { var areInstantiationOptionsAnObject = _isObject(instantiationOptions); var options; /** * Make sure that the options parameter is Object and * that the ElementTree can be instantiate without initial options. */ if (areInstantiationOptionsAnObject) { options = instantiationOptions; } else { options = {}; } // Save DOM reference this._ElementTreeContainer = document.getElementById(id); /** * Method fired when the number of issues against an element is clicked */ this.onIssueCountClicked = options.onIssueCountClicked ? options.onIssueCountClicked : function () {}; /** * Method fired when the selected element in the ElementTree is changed. * @param {string} selectedElementId - The selected element id */ this.onSelectionChanged = options.onSelectionChanged ? options.onSelectionChanged : function (selectedElementId) {}; /** * Method fired when the hovered element in the ElementTree is changed. * @param {string} hoveredElementId - The hovered element id */ this.onHoverChanged = options.onHoverChanged ? options.onHoverChanged : function (hoveredElementId) {}; /** * Method fired when the mouse is out of the ElementTree. */ this.onMouseOut = options.onMouseOut ? options.onMouseOut : function () {}; /** * Method fired when the initial ElementTree rendering is done. */ this.onInitialRendering = options.onInitialRendering ? options.onInitialRendering : function () {}; // Object with the tree model that will be visualized this.setData(options.data); }
javascript
{ "resource": "" }
q19689
_storeBreakpoints
train
function _storeBreakpoints() { if (bHasLocalStorage) { localStorage.setItem("sap-ui-support.aSupportInfosBreakpoints/" + document.location.href, JSON.stringify(aSupportInfosBreakpoints)); } }
javascript
{ "resource": "" }
q19690
_storeXMLModifications
train
function _storeXMLModifications() { if (bHasLocalStorage) { localStorage.setItem("sap-ui-support.aSupportXMLModifications/" + document.location.href, JSON.stringify(aSupportXMLModifications)); } }
javascript
{ "resource": "" }
q19691
train
function (oConfig, oParent) { if (!oConfig.name) { Log.error("A name has to be specified for every route", this); } if (this._oRoutes[oConfig.name]) { Log.error("Route with name " + oConfig.name + " already exists", this); } this._oRoutes[oConfig.name] = this._createRoute(this, oConfig, oParent); }
javascript
{ "resource": "" }
q19692
train
function (sName, oParameters) { if (oParameters === undefined) { //even if there are only optional parameters crossroads cannot navigate with undefined oParameters = {}; } var oRoute = this.getRoute(sName); if (!oRoute) { Log.warning("Route with name " + sName + " does not exist", this); return; } return oRoute.getURL(oParameters); }
javascript
{ "resource": "" }
q19693
train
function (sHash) { return Object.keys(this._oRoutes).some(function(sRouteName) { return this._oRoutes[sRouteName].match(sHash); }.bind(this)); }
javascript
{ "resource": "" }
q19694
train
function (sViewName, sViewType, sViewId) { Log.warning("Deprecated API Router#getView called - use Router#getViews instead.", this); var oView = this._oViews._getViewWithGlobalId({ viewName: sViewName, type: sViewType, id: sViewId }); this.fireViewCreated({ view: oView, viewName: sViewName, type: sViewType }); return oView; }
javascript
{ "resource": "" }
q19695
train
function(oData, fnFunction, oListener) { return this.attachEvent(Router.M_EVENTS.BYPASSED, oData, fnFunction, oListener); }
javascript
{ "resource": "" }
q19696
train
function(oData, fnFunction, oListener) { this.attachEvent(Router.M_EVENTS.TITLE_CHANGED, oData, fnFunction, oListener); return this; }
javascript
{ "resource": "" }
q19697
patch
train
function patch(oOldDom, oNewDom) { // start checking with most common use case and backwards compatible if (oOldDom.childElementCount != oNewDom.childElementCount || oOldDom.tagName != oNewDom.tagName) { oOldDom.parentNode.replaceChild(oNewDom, oOldDom); return false; } // go with native... if nodes are equal there is nothing to do // http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-isEqualNode if (oOldDom.isEqualNode(oNewDom)) { return true; } // remove outdated attributes from old dom var aOldAttributes = oOldDom.attributes; for (var i = 0, ii = aOldAttributes.length; i < ii; i++) { var sAttrName = aOldAttributes[i].name; if (oNewDom.getAttribute(sAttrName) === null) { oOldDom.removeAttribute(sAttrName); ii = ii - 1; i = i - 1; } } // patch new or changed attributes to the old dom var aNewAttributes = oNewDom.attributes; for (var i = 0, ii = aNewAttributes.length; i < ii; i++) { var sAttrName = aNewAttributes[i].name, vOldAttrValue = oOldDom.getAttribute(sAttrName), vNewAttrValue = oNewDom.getAttribute(sAttrName); if (vOldAttrValue === null || vOldAttrValue !== vNewAttrValue) { oOldDom.setAttribute(sAttrName, vNewAttrValue); } } // check whether more child nodes to continue or not var iNewChildNodesCount = oNewDom.childNodes.length; if (!iNewChildNodesCount && !oOldDom.hasChildNodes()) { return true; } // maybe no more child elements if (!oNewDom.childElementCount) { // but child nodes(e.g. Text Nodes) still needs to be replaced if (!iNewChildNodesCount) { // new dom does not have any child node, so we can clean the old one oOldDom.textContent = ""; } else if (iNewChildNodesCount == 1 && oNewDom.firstChild.nodeType == 3 /* TEXT_NODE */) { // update the text content for the first text node oOldDom.textContent = oNewDom.textContent; } else { // in case of comments or other node types are used oOldDom.innerHTML = oNewDom.innerHTML; } return true; } // patch child nodes for (var i = 0, r = 0, ii = iNewChildNodesCount; i < ii; i++) { var oOldDomChildNode = oOldDom.childNodes[i], oNewDomChildNode = oNewDom.childNodes[i - r]; if (oNewDomChildNode.nodeType == 1 /* ELEMENT_NODE */) { // recursively patch child elements if (!patch(oOldDomChildNode, oNewDomChildNode)) { // if patch is not possible we replace nodes // in this case replaced node is removed r = r + 1; } } else { // when not element update only node values oOldDomChildNode.nodeValue = oNewDomChildNode.nodeValue; } } return true; }
javascript
{ "resource": "" }
q19698
_submit
train
function _submit(){ // execute the request and use the metadata if available if (that.bUseBatch) { that.updateSecurityToken(); // batch requests only need the path without the service URL // extract query of url and combine it with the path... var sUriQuery = URI.parse(oRequest.requestUri).query; //var sRequestUrl = sPath.replace(/\/$/, ""); // remove trailing slash if any //sRequestUrl += sUriQuery ? "?" + sUriQuery : ""; var sRequestUrl = that._createRequestUrl(sPath, null, sUriQuery, that.bUseBatch); oRequest = that._createRequest(sRequestUrl, "GET", true); var oBatchRequest = that._createBatchRequest([oRequest],true); oRequestHandle = that._request(oBatchRequest, _handleSuccess, _handleError, OData.batchHandler, undefined, that.getServiceMetadata()); } else { oRequestHandle = that._request(oRequest, _handleSuccess, _handleError, that.oHandler, undefined, that.getServiceMetadata()); } if (fnHandleUpdate) { // Create a wrapper for the request handle to be able to differentiate // between intentionally aborted requests and failed requests var oWrappedHandle = { abort: function() { oRequestHandle.bAborted = true; oRequestHandle.abort(); } }; fnHandleUpdate(oWrappedHandle); } }
javascript
{ "resource": "" }
q19699
train
function (sUrl, bAnnotations, bPrefetch) { var oPromise; function convertXMLMetadata(oJSON) { var Converter = sODataVersion === "4.0" || bAnnotations ? _V4MetadataConverter : _V2MetadataConverter, oData = oJSON.$XML; delete oJSON.$XML; // be nice to the garbage collector return jQuery.extend(new Converter().convertXMLMetadata(oData, sUrl), oJSON); } if (sUrl in mUrl2Promise) { if (bPrefetch) { throw new Error("Must not prefetch twice: " + sUrl); } oPromise = mUrl2Promise[sUrl].then(convertXMLMetadata); delete mUrl2Promise[sUrl]; } else { oPromise = new Promise(function (fnResolve, fnReject) { jQuery.ajax(bAnnotations ? sUrl : sUrl + sQueryStr, { method : "GET", headers : mHeaders }).then(function (oData, sTextStatus, jqXHR) { var sDate = jqXHR.getResponseHeader("Date"), sETag = jqXHR.getResponseHeader("ETag"), oJSON = {$XML : oData}, sLastModified = jqXHR.getResponseHeader("Last-Modified"); if (sDate) { oJSON.$Date = sDate; } if (sETag) { oJSON.$ETag = sETag; } if (sLastModified) { oJSON.$LastModified = sLastModified; } fnResolve(oJSON); }, function (jqXHR, sTextStatus, sErrorMessage) { var oError = _Helper.createError(jqXHR, "Could not load metadata"); Log.error("GET " + sUrl, oError.message, "sap.ui.model.odata.v4.lib._MetadataRequestor"); fnReject(oError); }); }); if (bPrefetch) { mUrl2Promise[sUrl] = oPromise; } else { oPromise = oPromise.then(convertXMLMetadata); } } return oPromise; }
javascript
{ "resource": "" }