_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q18800
handleGetTransports
train
function handleGetTransports(sUri, sMethod, oData, mOptions, resolve, reject){ if (sUri.match(/^\/sap\/bc\/lrep\/actions\/gettransports\//)){ resolve({ response: { "transports": [ { "transportId": "U31K008488", "description": "The Ultimate Transport", "owner": "Fantasy Owner", "locked": true } ], "localonly": false, "errorCode": "" } }); } }
javascript
{ "resource": "" }
q18801
train
function (oChange, aActiveContexts) { var sChangeContext = oChange.context || ""; if (!sChangeContext) { // change is free of context (always applied) return true; } return aActiveContexts && aActiveContexts.indexOf(sChangeContext) !== -1; }
javascript
{ "resource": "" }
q18802
train
function (aContextObjects) { var aDesignTimeContextIdsByUrl = this._getContextIdsFromUrl(); if (aDesignTimeContextIdsByUrl.length === 0) { // [default: runtime] use runtime contexts return this._getContextParametersFromAPI(aContextObjects) .then(this._getActiveContextsByAPIParameters.bind(this, aContextObjects)); } else { // [designtime] use url parameters to determine the current active context(s) return Promise.resolve(this._getActiveContextsByUrlParameters(aContextObjects, aDesignTimeContextIdsByUrl)); } }
javascript
{ "resource": "" }
q18803
train
function (aContextObjects) { var aRequiredContextParameters = []; aContextObjects.forEach(function (oContext) { oContext.parameters.forEach(function (oContextParameter) { var sSelector = oContextParameter.selector; if (aRequiredContextParameters.indexOf(sSelector) === -1) { aRequiredContextParameters.push(sSelector); } }); }); return this._oContext.getValue(aRequiredContextParameters); }
javascript
{ "resource": "" }
q18804
train
function (aContextObjects, aRuntimeContextParameters) { var that = this; var aActiveContexts = []; aContextObjects.forEach(function (oContext) { if (that._isContextObjectActive(oContext, aRuntimeContextParameters)) { aActiveContexts.push(oContext.id); } }); return aActiveContexts; }
javascript
{ "resource": "" }
q18805
train
function(aContextObjects, aDesignTimeContextIdsByUrl) { var aActiveContexts = []; aContextObjects.forEach(function (oContext) { var bContextActive = ((aDesignTimeContextIdsByUrl ? Array.prototype.indexOf.call(aDesignTimeContextIdsByUrl, oContext.id) : -1)) !== -1; if (bContextActive) { aActiveContexts.push(oContext.id); } }); return aActiveContexts; }
javascript
{ "resource": "" }
q18806
train
function(oContext, aRuntimeContextParameters) { var that = this; var bContextActive = true; var aParameterOfContext = oContext.parameters; aParameterOfContext.every(function (oParameter) { bContextActive = bContextActive && that._checkContextParameter(oParameter, aRuntimeContextParameters); return bContextActive; // breaks loop on false }); return bContextActive; }
javascript
{ "resource": "" }
q18807
train
function (oParameter, aRuntimeContext) { var sSelector = oParameter.selector; var sOperator = oParameter.operator; var oValue = oParameter.value; switch (sOperator) { case "EQ": return this._checkEquals(sSelector, oValue, aRuntimeContext); case "NE": return !this._checkEquals(sSelector, oValue, aRuntimeContext); default: Log.info("A context within a flexibility change with the operator '" + sOperator + "' could not be verified"); return false; } }
javascript
{ "resource": "" }
q18808
train
function () { var aPublicElements = []; var mComponents = core.mObjects.component; var mUIAreas = core.mUIAreas; for (var i in mComponents) { aPublicElements = aPublicElements.concat( getPublicElementsInside(mComponents[i]) ); } for (var key in mUIAreas) { aPublicElements = aPublicElements.concat( getPublicElementsInside(mUIAreas[key]) ); } return aPublicElements; }
javascript
{ "resource": "" }
q18809
train
function (classNameSelector) { if (typeof classNameSelector === "string") { return elements.filter(function (element) { return element.getMetadata().getName() === classNameSelector; }); } if (typeof classNameSelector === "function") { return elements.filter(function (element) { return element instanceof classNameSelector; }); } }
javascript
{ "resource": "" }
q18810
train
function (type) { var log = jQuery.sap.log.getLogEntries(), loggedObjects = [], elemIds; // Add logEntries that have support info object, // and that have the same type as the type provided log.forEach(function (logEntry) { if (!logEntry.supportInfo) { return; } if (!elemIds){ elemIds = elements.map(function (element) { return element.getId(); }); } var hasElemId = !!logEntry.supportInfo.elementId, typeMatch = logEntry.supportInfo.type === type || type === undefined, scopeMatch = !hasElemId || jQuery.inArray(logEntry.supportInfo.elementId, elemIds) > -1; /** * Give the developer the ability to pass filtering function */ if (typeof type === "function" && type(logEntry) && scopeMatch) { loggedObjects.push(logEntry); return; } if (typeMatch && scopeMatch) { loggedObjects.push(logEntry); } }); return loggedObjects; }
javascript
{ "resource": "" }
q18811
createUniversalUTCDate
train
function createUniversalUTCDate(oDate, sCalendarType) { if (sCalendarType) { return UniversalDate.getInstance(createUTCDate(oDate), sCalendarType); } else { return new UniversalDate(createUTCDate(oDate).getTime()); } }
javascript
{ "resource": "" }
q18812
createUTCDate
train
function createUTCDate(oDate) { var oUTCDate = new Date(Date.UTC(0, 0, 1)); oUTCDate.setUTCFullYear(oDate.getFullYear(), oDate.getMonth(), oDate.getDate()); return oUTCDate; }
javascript
{ "resource": "" }
q18813
checkNumericLike
train
function checkNumericLike(value, message) { if (value == undefined || value === Infinity || isNaN(value)) {//checks also for null. throw message; } }
javascript
{ "resource": "" }
q18814
train
function(element) { var links = element.querySelectorAll("a.xref, a.link, area"), i, link, href, startsWithHash, startsWithHTTP; for (i = 0; i < links.length; i++) { link = links[i]; href = link.getAttribute("href"); startsWithHash = href.indexOf("#") == 0; startsWithHTTP = href.indexOf("http") == 0; // absolute links should open in a new window if (startsWithHTTP) { link.setAttribute('target', '_blank'); } // absolute links and links starting with # are ok and should not be modified if (startsWithHTTP || startsWithHash) { continue; } // API reference are recognized by "/docs/api/" string if (href.indexOf("/docs/api/") > -1) { href = href.substr(0, href.lastIndexOf(".html")); href = href.substr(href.lastIndexOf('/') + 1); href = "#/api/" + href; } else if (href.indexOf("explored.html") > -1) { // explored app links have explored.html in them href = href.split("../").join(""); href = oConfig.exploredURI + href; } else { // we assume all other links are links to other documentation pages href = href.substr(0, href.lastIndexOf(".html")); href = "#/topic/" + href; } link.setAttribute("href", href); } }
javascript
{ "resource": "" }
q18815
train
function (event) { var href = event.oSource.getHref() || event.oSource.getTarget(); href = href.replace("#/", "").split('/'); /** @type string */ var page = href[0]; /** @type string */ var parameter = href[1]; event.preventDefault(); this.getRouter().navTo(page, {id: parameter}, true); }
javascript
{ "resource": "" }
q18816
train
function (oEvent) { var isOpenUI5 = this.getView().getModel("welcomeView").getProperty("/isOpenUI5"), sUrl = isOpenUI5 ? "http://openui5.org/download.html" : "https://tools.hana.ondemand.com/#sapui5"; window.open(sUrl, "_blank"); }
javascript
{ "resource": "" }
q18817
train
function(size) { var result = 0, i; this.checkOffset(size); for (i = this.index + size - 1; i >= this.index; i--) { result = (result << 8) + this.byteAt(i); } this.index += size; return result; }
javascript
{ "resource": "" }
q18818
train
function(asUTF8) { var result = getRawData(this); if (result === null || typeof result === "undefined") { return ""; } // if the data is a base64 string, we decode it before checking the encoding ! if (this.options.base64) { result = base64.decode(result); } if (asUTF8 && this.options.binary) { // JSZip.prototype.utf8decode supports arrays as input // skip to array => string step, utf8decode will do it. result = out.utf8decode(result); } else { // no utf8 transformation, do the array => string step. result = utils.transformTo("string", result); } if (!asUTF8 && !this.options.binary) { result = out.utf8encode(result); } return result; }
javascript
{ "resource": "" }
q18819
train
function(dec, bytes) { var hex = "", i; for (i = 0; i < bytes; i++) { hex += String.fromCharCode(dec & 0xff); dec = dec >>> 8; } return hex; }
javascript
{ "resource": "" }
q18820
train
function() { var result = {}, i, attr; for (i = 0; i < arguments.length; i++) { // arguments is not enumerable in some browsers for (attr in arguments[i]) { if (arguments[i].hasOwnProperty(attr) && typeof result[attr] === "undefined") { result[attr] = arguments[i][attr]; } } } return result; }
javascript
{ "resource": "" }
q18821
train
function(path) { if (path.slice(-1) == '/') { path = path.substring(0, path.length - 1); } var lastSlash = path.lastIndexOf('/'); return (lastSlash > 0) ? path.substring(0, lastSlash) : ""; }
javascript
{ "resource": "" }
q18822
train
function(input) { if (input.length !== 0) { // with an empty Uint8Array, Opera fails with a "Offset larger than array size" input = utils.transformTo("uint8array", input); this.data.set(input, this.index); this.index += input.length; } }
javascript
{ "resource": "" }
q18823
train
function(name, data, o) { if (arguments.length === 1) { if (utils.isRegExp(name)) { var regexp = name; return this.filter(function(relativePath, file) { return !file.options.dir && regexp.test(relativePath); }); } else { // text return this.filter(function(relativePath, file) { return !file.options.dir && relativePath === name; })[0] || null; } } else { // more than one argument : we have data ! name = this.root + name; fileAdd.call(this, name, data, o); } return this; }
javascript
{ "resource": "" }
q18824
train
function(options) { options = extend(options || {}, { base64: true, compression: "STORE", type: "base64" }); utils.checkSupport(options.type); var zipData = [], localDirLength = 0, centralDirLength = 0, writer, i; // first, generate all the zip parts. for (var name in this.files) { if (!this.files.hasOwnProperty(name)) { continue; } var file = this.files[name]; var compressionName = file.options.compression || options.compression.toUpperCase(); var compression = compressions[compressionName]; if (!compression) { throw new Error(compressionName + " is not a valid compression method !"); } var compressedObject = generateCompressedObjectFrom.call(this, file, compression); var zipPart = generateZipParts.call(this, name, file, compressedObject, localDirLength); localDirLength += zipPart.fileRecord.length + compressedObject.compressedSize; centralDirLength += zipPart.dirRecord.length; zipData.push(zipPart); } var dirEnd = ""; // end of central dir signature dirEnd = signature.CENTRAL_DIRECTORY_END + // number of this disk "\x00\x00" + // number of the disk with the start of the central directory "\x00\x00" + // total number of entries in the central directory on this disk decToHex(zipData.length, 2) + // total number of entries in the central directory decToHex(zipData.length, 2) + // size of the central directory 4 bytes decToHex(centralDirLength, 4) + // offset of start of central directory with respect to the starting disk number decToHex(localDirLength, 4) + // .ZIP file comment length "\x00\x00"; // we have all the parts (and the total length) // time to create a writer ! var typeName = options.type.toLowerCase(); if(typeName==="uint8array"||typeName==="arraybuffer"||typeName==="blob"||typeName==="nodebuffer") { writer = new Uint8ArrayWriter(localDirLength + centralDirLength + dirEnd.length); }else{ writer = new StringWriter(localDirLength + centralDirLength + dirEnd.length); } for (i = 0; i < zipData.length; i++) { writer.append(zipData[i].fileRecord); writer.append(zipData[i].compressedObject.compressedContent); } for (i = 0; i < zipData.length; i++) { writer.append(zipData[i].dirRecord); } writer.append(dirEnd); var zip = writer.finalize(); switch(options.type.toLowerCase()) { // case "zip is an Uint8Array" case "uint8array" : case "arraybuffer" : case "nodebuffer" : return utils.transformTo(options.type.toLowerCase(), zip); case "blob" : return utils.arrayBuffer2Blob(utils.transformTo("arraybuffer", zip)); // case "zip is a string" case "base64" : return (options.base64) ? base64.encode(zip) : zip; default : // case "string" : return zip; } }
javascript
{ "resource": "" }
q18825
stringToArrayLike
train
function stringToArrayLike(str, array) { for (var i = 0; i < str.length; ++i) { array[i] = str.charCodeAt(i) & 0xFF; } return array; }
javascript
{ "resource": "" }
q18826
arrayLikeToArrayLike
train
function arrayLikeToArrayLike(arrayFrom, arrayTo) { for (var i = 0; i < arrayFrom.length; i++) { arrayTo[i] = arrayFrom[i]; } return arrayTo; }
javascript
{ "resource": "" }
q18827
train
function(expectedSignature) { var signature = this.reader.readString(4); if (signature !== expectedSignature) { throw new Error("Corrupted zip or bug : unexpected signature " + "(" + utils.pretty(signature) + ", expected " + utils.pretty(expectedSignature) + ")"); } }
javascript
{ "resource": "" }
q18828
train
function() { var i, file; for (i = 0; i < this.files.length; i++) { file = this.files[i]; this.reader.setIndex(file.localHeaderOffset); this.checkSignature(sig.LOCAL_FILE_HEADER); file.readLocalPart(this.reader); file.handleUTF8(); } }
javascript
{ "resource": "" }
q18829
train
function() { var offset = this.reader.lastIndexOfSignature(sig.CENTRAL_DIRECTORY_END); if (offset === -1) { throw new Error("Corrupted zip : can't find end of central directory"); } this.reader.setIndex(offset); this.checkSignature(sig.CENTRAL_DIRECTORY_END); this.readBlockEndOfCentral(); /* extract from the zip spec : 4) If one of the fields in the end of central directory record is too small to hold required data, the field should be set to -1 (0xFFFF or 0xFFFFFFFF) and the ZIP64 format record should be created. 5) The end of central directory record and the Zip64 end of central directory locator record must reside on the same disk when splitting or spanning an archive. */ if (this.diskNumber === utils.MAX_VALUE_16BITS || this.diskWithCentralDirStart === utils.MAX_VALUE_16BITS || this.centralDirRecordsOnThisDisk === utils.MAX_VALUE_16BITS || this.centralDirRecords === utils.MAX_VALUE_16BITS || this.centralDirSize === utils.MAX_VALUE_32BITS || this.centralDirOffset === utils.MAX_VALUE_32BITS) { this.zip64 = true; /* Warning : the zip64 extension is supported, but ONLY if the 64bits integer read from the zip file can fit into a 32bits integer. This cannot be solved : Javascript represents all numbers as 64-bit double precision IEEE 754 floating point numbers. So, we have 53bits for integers and bitwise operations treat everything as 32bits. see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Bitwise_Operators and http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf section 8.5 */ // should look for a zip64 EOCD locator offset = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR); if (offset === -1) { throw new Error("Corrupted zip : can't find the ZIP64 end of central directory locator"); } this.reader.setIndex(offset); this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR); this.readBlockZip64EndOfCentralLocator(); // now the zip64 EOCD record this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir); this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_END); this.readBlockZip64EndOfCentral(); } }
javascript
{ "resource": "" }
q18830
train
function(reader, from, length, compression, uncompressedSize) { return function() { var compressedFileData = utils.transformTo(compression.uncompressInputType, this.getCompressedContent()); var uncompressedFileData = compression.uncompress(compressedFileData); if (uncompressedFileData.length !== uncompressedSize) { throw new Error("Bug : uncompressed data size mismatch"); } return uncompressedFileData; }; }
javascript
{ "resource": "" }
q18831
train
function (oTreeViewModelRules) { var aSelectedRules = storage.getSelectedRules(); if (!aSelectedRules) { return null; } if (!oTreeViewModelRules) { return null; } aSelectedRules.forEach(function (oRuleDescriptor) { Object.keys(oTreeViewModelRules).forEach(function(iKey) { oTreeViewModelRules[iKey].nodes.forEach(function(oRule) { if (oRule.id === oRuleDescriptor.ruleId) { oRule.selected = oRuleDescriptor.selected; if (!oRule.selected) { oTreeViewModelRules[iKey].selected = false; } } }); }); }); return oTreeViewModelRules; }
javascript
{ "resource": "" }
q18832
train
function (aSelectedRules) { var oTreeViewModelRules = this.model.getProperty("/treeModel"); // deselect all Object.keys(oTreeViewModelRules).forEach(function(iKey) { oTreeViewModelRules[iKey].nodes.forEach(function(oRule) { oRule.selected = false; }); }); // select those from aSelectedRules aSelectedRules.forEach(function (oRuleDescriptor) { Object.keys(oTreeViewModelRules).forEach(function(iKey) { oTreeViewModelRules[iKey].nodes.forEach(function(oRule) { if (oRule.id === oRuleDescriptor.ruleId) { oRule.selected = true; } }); }); }); // syncs the parent and child selected/deselected state this.treeTable.syncParentNoteWithChildrenNotes(oTreeViewModelRules); // apply selection to ui this.treeTable.updateSelectionFromModel(); // update the count in ui this.getSelectedRules(); if (storage.readPersistenceCookie(constants.COOKIE_NAME)) { this.persistSelection(); } }
javascript
{ "resource": "" }
q18833
train
function (tempTreeModelWithAdditionalRuleSets, oTreeModelWithSelection) { Object.keys(tempTreeModelWithAdditionalRuleSets).forEach(function(iKey) { Object.keys(oTreeModelWithSelection).forEach(function(iKey) { if (tempTreeModelWithAdditionalRuleSets[iKey].id === oTreeModelWithSelection[iKey].id) { tempTreeModelWithAdditionalRuleSets[iKey] = oTreeModelWithSelection[iKey]; } }); }); return tempTreeModelWithAdditionalRuleSets; }
javascript
{ "resource": "" }
q18834
train
function (oTreeModel, aAdditionalRuleSetsNames) { if (!aAdditionalRuleSetsNames) { return; } aAdditionalRuleSetsNames.forEach(function (sRuleName) { Object.keys(oTreeModel).forEach(function(iKey) { if (oTreeModel[iKey].name === sRuleName) { oTreeModel[iKey].selected = false; oTreeModel[iKey].nodes.forEach(function(oRule){ oRule.selected = false; }); } }); }); return oTreeModel; }
javascript
{ "resource": "" }
q18835
genValidHourValues
train
function genValidHourValues(b24H, sLeadingChar) { var iStart = b24H ? 0 : 1, b2400 = this._oTimePicker.getSupport2400() ? 24 : 23,//if getSupport2400, the user could type 24 in the input iEnd = b24H ? b2400 : 12; return genValues(iStart, iEnd, sLeadingChar); }
javascript
{ "resource": "" }
q18836
train
function (oOptions, sType) { var oObject; try { if (sType === "Component" && !this.async) { Log.error("sap.ui.core.routing.Target doesn't support loading component in synchronous mode, please switch routing to async"); throw new Error("sap.ui.core.routing.Target doesn't support loading component in synchronous mode, please switch routing to async"); } if (!oOptions) { Log.error("the oOptions parameter of getObject is mandatory", this); throw new Error("the oOptions parameter of getObject is mandatory"); } oObject = this._get(oOptions, sType); } catch (e) { return Promise.reject(e); } if (oObject instanceof Promise) { return oObject; } else if (oObject.isA("sap.ui.core.mvc.View")) { return oObject.loaded(); } else { return Promise.resolve(oObject); } }
javascript
{ "resource": "" }
q18837
train
function (sName, sType, oObject) { var oInstanceCache; this._checkName(sName, sType); assert(sType === "View" || sType === "Component", "sType must be either 'View' or 'Component'"); oInstanceCache = this._oCache[sType.toLowerCase()][sName]; if (!oInstanceCache) { oInstanceCache = this._oCache[sType.toLowerCase()][sName] = {}; } oInstanceCache[undefined] = oObject; return this; }
javascript
{ "resource": "" }
q18838
train
function () { EventProvider.prototype.destroy.apply(this); if (this.bIsDestroyed) { return this; } function destroyObject(oObject) { if (oObject && oObject.destroy) { oObject.destroy(); } } Object.keys(this._oCache).forEach(function (sType) { var oTypeCache = this._oCache[sType]; Object.keys(oTypeCache).forEach(function (sKey) { var oInstanceCache = oTypeCache[sKey]; Object.keys(oInstanceCache).forEach(function(sId) { var vObject = oInstanceCache[sId]; if (vObject instanceof Promise) { // if the promise isn't replaced by the real object yet // wait until the promise resolves to destroy the object vObject.then(destroyObject); } else { destroyObject(vObject); } }); }); }.bind(this)); this._oCache = undefined; this.bIsDestroyed = true; return this; }
javascript
{ "resource": "" }
q18839
train
function (sName, sType) { if (!sName) { var sMessage = "A name for the " + sType.toLowerCase() + " has to be defined"; Log.error(sMessage, this); throw Error(sMessage); } }
javascript
{ "resource": "" }
q18840
train
function(oRM, oControl) { // render an invisible, but easily identifiable placeholder for the content oRM.write("<div id=\"" + RenderPrefixes.Dummy + oControl.getId() + "\" style=\"display:none\">"); // Note: we do not render the content string here, but only in onAfterRendering // This has the advantage that syntax errors don't affect the whole control tree // but only this control... oRM.write("</div>"); }
javascript
{ "resource": "" }
q18841
cleanTree
train
function cleanTree (oSymbol) { delete oSymbol.treeName; delete oSymbol.parent; if (oSymbol.children) { oSymbol.children.forEach(o => cleanTree(o)); } }
javascript
{ "resource": "" }
q18842
addInfixOperator
train
function addInfixOperator(sId, iLbp) { // Note: this function is executed at load time only! mFilterParserSymbols[sId] = { lbp : iLbp, led : function (oToken, oLeft) { oToken.type = "Edm.Boolean"; // Note: currently we only support logical operators oToken.precedence = iLbp; oToken.left = oLeft; oToken.right = this.expression(iLbp); return oToken; } }; }
javascript
{ "resource": "" }
q18843
addLeafSymbol
train
function addLeafSymbol(sId) { // Note: this function is executed at load time only! mFilterParserSymbols[sId] = { lbp : 0, nud : function (oToken) { oToken.precedence = 99; // prevent it from being enclosed in brackets return oToken; } }; }
javascript
{ "resource": "" }
q18844
brackets
train
function brackets() { for (;;) { oToken = that.advance(); if (!oToken || oToken.id === ';') { that.expected("')'", oToken); } sValue += oToken.value; if (oToken.id === ")") { return; } if (oToken.id === "(") { brackets(); } } }
javascript
{ "resource": "" }
q18845
tokenizeDoubleQuotedString
train
function tokenizeDoubleQuotedString(sNext, sOption, iAt) { var c, sEscape, bEscaping = false, i; for (i = 1; i < sNext.length; i += 1) { if (bEscaping) { bEscaping = false; } else { c = sNext[i]; if (c === "%") { sEscape = sNext.slice(i + 1, i + 3); if (rEscapeDigits.test(sEscape)) { c = unescape(sEscape); i += 2; } } if (c === '"') { return sNext.slice(0, i + 1); } bEscaping = c === '\\'; } } throw new SyntaxError("Unterminated string at " + iAt + ": " + sOption); }
javascript
{ "resource": "" }
q18846
tokenize
train
function tokenize(sOption) { var iAt = 1, // The token's position for error messages; we count starting with 1 sId, aMatches, sNext = sOption, iOffset, oToken, aTokens = [], sValue; while (sNext.length) { aMatches = rToken.exec(sNext); iOffset = 0; if (aMatches) { sValue = aMatches[0]; if (aMatches[7]) { sId = "OPTION"; } else if (aMatches[6] || aMatches[4]) { sId = "VALUE"; } else if (aMatches[5]) { sId = "PATH"; if (sValue === "false" || sValue === "true" || sValue === "null") { sId = "VALUE"; } else if (sValue === "not") { sId = "not"; aMatches = rNot.exec(sNext); if (aMatches) { sValue = aMatches[0]; } } } else if (aMatches[3]) { // a %-escaped delimiter sId = unescape(aMatches[3]); } else if (aMatches[2]) { // an operator sId = aMatches[2]; iOffset = aMatches[1].length; } else { // a delimiter sId = aMatches[0]; } if (sId === '"') { sId = "VALUE"; sValue = tokenizeDoubleQuotedString(sNext, sOption, iAt); } else if (sId === "'") { sId = "VALUE"; sValue = tokenizeSingleQuotedString(sNext, sOption, iAt); } oToken = { at : iAt + iOffset, id : sId, value : sValue }; } else { throw new SyntaxError("Unknown character '" + sNext[0] + "' at " + iAt + ": " + sOption); } sNext = sNext.slice(sValue.length); iAt += sValue.length; aTokens.push(oToken); } return aTokens; }
javascript
{ "resource": "" }
q18847
train
function (sSampleId, sIframePath) { var aIFramePathParts = sIframePath.split("/"), i; for (i = 0; i < aIFramePathParts.length - 1; i++) { if (aIFramePathParts[i] == "..") { // iframe path has parts pointing one folder up so remove last part of the sSampleId sSampleId = sSampleId.substring(0, sSampleId.lastIndexOf(".")); } else { // append the part of the iframe path to the sample's id sSampleId += "." + aIFramePathParts[i]; } } return sSampleId; }
javascript
{ "resource": "" }
q18848
train
function(oSyncPoint) { // application cachebuster mechanism (copy of array for later modification) var oConfig = oConfiguration.getAppCacheBuster(); if (oConfig && oConfig.length > 0) { oConfig = oConfig.slice(); // flag to activate the cachebuster var bActive = true; // fallback for old boolean configuration (only 1 string entry) // restriction: the values true, false and x are reserved as fallback values // and cannot be used as base url locations var sValue = String(oConfig[0]).toLowerCase(); if (oConfig.length === 1) { if (sValue === "true" || sValue === "x") { // register the current base URL (if it is a relative URL) // hint: if UI5 is referenced relative on a server it might be possible // with the mechanism to register another base URL. var oUri = URI(sOrgBaseUrl); oConfig = oUri.is("relative") ? [oUri.toString()] : []; } else if (sValue === "false") { bActive = false; } } // activate the cachebuster if (bActive) { // initialize the AppCacheBuster AppCacheBuster.init(); // register the components fnRegister(oConfig, oSyncPoint); } } }
javascript
{ "resource": "" }
q18849
train
function() { // activate the session (do not create the session for compatibility reasons with mIndex previously) oSession.active = true; // store the original function / property description to intercept fnValidateProperty = ManagedObject.prototype.validateProperty; descScriptSrc = Object.getOwnPropertyDescriptor(HTMLScriptElement.prototype, "src"); descLinkHref = Object.getOwnPropertyDescriptor(HTMLLinkElement.prototype, "href"); // function shortcuts (better performance when used frequently!) var fnConvertUrl = AppCacheBuster.convertURL; var fnNormalizeUrl = AppCacheBuster.normalizeURL; // resources URL's will be handled via standard // UI5 cachebuster mechanism (so we simply ignore them) var fnIsACBUrl = function(sUrl) { if (this.active === true && sUrl && typeof (sUrl) === "string") { sUrl = fnNormalizeUrl(sUrl); return !sUrl.match(oFilter); } return false; }.bind(oSession); // enhance xhr with appCacheBuster functionality fnXhrOpenOrig = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function(sMethod, sUrl) { if (sUrl && fnIsACBUrl(sUrl)) { arguments[1] = fnConvertUrl(sUrl); } fnXhrOpenOrig.apply(this, arguments); }; fnEnhancedXhrOpen = XMLHttpRequest.prototype.open; // enhance the validateProperty function to intercept URI types // test via: new sap.ui.commons.Image({src: "acctest/img/Employee.png"}).getSrc() // new sap.ui.commons.Image({src: "./acctest/../acctest/img/Employee.png"}).getSrc() ManagedObject.prototype.validateProperty = function(sPropertyName, oValue) { var oMetadata = this.getMetadata(), oProperty = oMetadata.getProperty(sPropertyName), oArgs; if (oProperty && oProperty.type === "sap.ui.core.URI") { oArgs = Array.prototype.slice.apply(arguments); try { if (fnIsACBUrl(oArgs[1] /* oValue */)) { oArgs[1] = fnConvertUrl(oArgs[1] /* oValue */); } } catch (e) { // URI normalization or conversion failed, fall back to normal processing } } // either forward the modified or the original arguments return fnValidateProperty.apply(this, oArgs || arguments); }; // create an interceptor description which validates the value // of the setter whether to rewrite the URL or not var fnCreateInterceptorDescriptor = function(descriptor) { var newDescriptor = { get: descriptor.get, set: function(val) { if (fnIsACBUrl(val)) { val = fnConvertUrl(val); } descriptor.set.call(this, val); }, enumerable: descriptor.enumerable, configurable: descriptor.configurable }; newDescriptor.set._sapUiCoreACB = true; return newDescriptor; }; // try to setup the property descriptor interceptors (not supported on all browsers, e.g. iOS9) var bError = false; try { Object.defineProperty(HTMLScriptElement.prototype, "src", fnCreateInterceptorDescriptor(descScriptSrc)); } catch (ex) { Log.error("Your browser doesn't support redefining the src property of the script tag. Disabling AppCacheBuster as it is not supported on your browser!\nError: " + ex); bError = true; } try { Object.defineProperty(HTMLLinkElement.prototype, "href", fnCreateInterceptorDescriptor(descLinkHref)); } catch (ex) { Log.error("Your browser doesn't support redefining the href property of the link tag. Disabling AppCacheBuster as it is not supported on your browser!\nError: " + ex); bError = true; } // in case of setup issues we stop the AppCacheBuster support if (bError) { this.exit(); } }
javascript
{ "resource": "" }
q18850
train
function(descriptor) { var newDescriptor = { get: descriptor.get, set: function(val) { if (fnIsACBUrl(val)) { val = fnConvertUrl(val); } descriptor.set.call(this, val); }, enumerable: descriptor.enumerable, configurable: descriptor.configurable }; newDescriptor.set._sapUiCoreACB = true; return newDescriptor; }
javascript
{ "resource": "" }
q18851
train
function() { // remove the function interceptions ManagedObject.prototype.validateProperty = fnValidateProperty; // only remove xhr interception if xhr#open was not modified meanwhile if (XMLHttpRequest.prototype.open === fnEnhancedXhrOpen) { XMLHttpRequest.prototype.open = fnXhrOpenOrig; } // remove the property descriptor interceptions (but only if not overridden again) var descriptor; if ((descriptor = Object.getOwnPropertyDescriptor(HTMLScriptElement.prototype, "src")) && descriptor.set && descriptor.set._sapUiCoreACB === true) { Object.defineProperty(HTMLScriptElement.prototype, "src", descScriptSrc); } if ((descriptor = Object.getOwnPropertyDescriptor(HTMLLinkElement.prototype, "href")) && descriptor.set && descriptor.set._sapUiCoreACB === true) { Object.defineProperty(HTMLLinkElement.prototype, "href", descLinkHref); } // clear the session (disables URL rewrite for session) oSession.index = {}; oSession.active = false; // create a new session for the next initialization oSession = { index: {}, active: false }; }
javascript
{ "resource": "" }
q18852
train
function(sUrl) { // local resources are registered with "./" => we remove the leading "./"! // (code location for this: sap/ui/Global.js:sap.ui.localResources) // we by default normalize all relative URLs for a common base var oUri = URI(sUrl || "./"); if (oUri.is("relative")) { //(sUrl.match(/^\.\/|\..\//g)) { oUri = oUri.absoluteTo(sLocation); } //return oUri.normalize().toString(); // prevent to normalize the search and hash to avoid "+" in the search string // because for search strings the space will be normalized as "+" return oUri.normalizeProtocol().normalizeHostname().normalizePort().normalizePath().toString(); }
javascript
{ "resource": "" }
q18853
_traverseFilter
train
function _traverseFilter (vFilters, fnCheck) { vFilters = vFilters || []; if (vFilters instanceof Filter) { vFilters = [vFilters]; } // filter has more sub-filter instances (we ignore the subfilters below the any/all operators) for (var i = 0; i < vFilters.length; i++) { // check single Filter var oFilter = vFilters[i]; fnCheck(oFilter); // check subfilter for lambda expressions (e.g. Any, All, ...) _traverseFilter(oFilter.oCondition, fnCheck); // check multi filter if necessary _traverseFilter(oFilter.aFilters, fnCheck); } }
javascript
{ "resource": "" }
q18854
train
function () { //get all open popups from InstanceManager var aAllOpenPopups = fnGetPopups(); var aValidatedPopups = []; var aInvalidatedPopups = []; aAllOpenPopups.forEach(function(oOpenPopup) { // check if non-adaptable popup var bValid = _aPopupFilters.every(function (fnFilter) { return fnFilter(oOpenPopup); }); bValid && _aPopupFilters.length > 0 ? aValidatedPopups.push(oOpenPopup) : aInvalidatedPopups.push(oOpenPopup); }); // get max Z-Index from validated popups var iMaxValidatedZIndex = aValidatedPopups.length > 0 ? Math.max.apply(null, fnGetZIndexFromPopups(aValidatedPopups)) : -1; // get minimum Z-Index from invalidated popups var iMinInvalidatedZIndex = aInvalidatedPopups.length > 0 ? Math.min.apply(null, fnGetZIndexFromPopups(aInvalidatedPopups)) : -1; // compare Z-Index of adaptable and non-adaptable popups - the higher one wins if (iMaxValidatedZIndex < iMinInvalidatedZIndex) { return this._getNextMinZIndex(iMinInvalidatedZIndex); } else { return Popup.getNextZIndex(); } }
javascript
{ "resource": "" }
q18855
train
function (iCurrent) { // deduct indices reserved from current z-index var iMaxZIndex = iCurrent - Z_INDICES_RESERVED; // initial minimum z-index var iMinZIndex = iCurrent - Z_INDEX_STEP; var iNextZIndex = fnGetLastZIndex(iMinZIndex, iMaxZIndex, aAssignedZIndices); aAssignedZIndices.push(iNextZIndex); return iNextZIndex; }
javascript
{ "resource": "" }
q18856
setClientDevice
train
function setClientDevice() { var iClientId = 0; if (Device.system.combi) { iClientId = 1; } else if (Device.system.desktop) { iClientId = 2; } else if (Device.system.tablet) { iClientId = 4; } else if (Device.system.phone) { iClientId = 3; } return iClientId; }
javascript
{ "resource": "" }
q18857
createFESR
train
function createFESR(oInteraction, oFESRHandle) { return [ format(ROOT_ID, 32), // root_context_id format(sFESRTransactionId, 32), // transaction_id format(oInteraction.navigation, 16), // client_navigation_time format(oInteraction.roundtrip, 16), // client_round_trip_time format(oFESRHandle.timeToInteractive, 16), // end_to_end_time format(oInteraction.completeRoundtrips, 8), // completed network_round_trips format(sPassportAction, 40), // passport_action format(oInteraction.networkTime, 16), // network_time format(oInteraction.requestTime, 16), // request_time format(CLIENT_OS, 20), // client_os "SAP_UI5" // client_type ].join(","); }
javascript
{ "resource": "" }
q18858
createFESRopt
train
function createFESRopt(oInteraction, oFESRHandle) { return [ format(oFESRHandle.appNameShort, 20, true), // application_name format(oFESRHandle.stepName, 20, true), // step_name "", // not assigned format(CLIENT_MODEL, 20), // client_model format(oInteraction.bytesSent, 16), // client_data_sent format(oInteraction.bytesReceived, 16), // client_data_received "", // network_protocol "", // network_provider format(oInteraction.processing, 16), // client_processing_time oInteraction.requestCompression ? "X" : "", // compressed - empty if not compressed "", // not assigned "", // persistency_accesses "", // persistency_time "", // persistency_data_transferred format(oInteraction.busyDuration, 16), // extension_1 - busy duration "", // extension_2 format(CLIENT_DEVICE, 1), // extension_3 - client device "", // extension_4 format(formatInteractionStartTimestamp(oInteraction.start), 20), // extension_5 - interaction start time format(oFESRHandle.appNameLong, 70, true) // application_name with 70 characters, trimmed from left ].join(","); }
javascript
{ "resource": "" }
q18859
format
train
function format(vField, iLength, bCutFromFront) { if (!vField) { vField = vField === 0 ? "0" : ""; } else if (typeof vField === "number") { var iField = vField; vField = Math.round(vField).toString(); // Calculation of figures may be erroneous because incomplete performance entries lead to negative // numbers. In that case we set a -1, so the "dirty" record can be identified as such. if (vField.length > iLength || iField < 0) { vField = "-1"; } } else { vField = bCutFromFront ? vField.substr(-iLength, iLength) : vField.substr(0, iLength); } return vField; }
javascript
{ "resource": "" }
q18860
train
function(oComponent) { var aTechnicalParameters = flUtils.getTechnicalParametersForComponent(oComponent); return aTechnicalParameters && aTechnicalParameters[VariantUtil.variantTechnicalParameterName] && Array.isArray(aTechnicalParameters[VariantUtil.variantTechnicalParameterName]) && aTechnicalParameters[VariantUtil.variantTechnicalParameterName][0]; }
javascript
{ "resource": "" }
q18861
train
function() { this._ExtensionHelper = ExtensionHelper; this._ColumnResizeHelper = ColumnResizeHelper; this._InteractiveResizeHelper = InteractiveResizeHelper; this._ReorderHelper = ReorderHelper; this._ExtensionDelegate = ExtensionDelegate; this._RowHoverHandler = RowHoverHandler; this._KNOWNCLICKABLECONTROLS = KNOWNCLICKABLECONTROLS; }
javascript
{ "resource": "" }
q18862
train
function(iColIndex, oEvent) { var oTable = this.getTable(); if (oTable && TableUtils.Column.isColumnMovable(oTable.getColumns()[iColIndex])) { // Starting column drag & drop. We wait 200ms to make sure it is no click on the column to open the menu. oTable._mTimeouts.delayedColumnReorderTimerId = setTimeout(function() { ReorderHelper.initReordering(this, iColIndex, oEvent); }.bind(oTable), 200); } }
javascript
{ "resource": "" }
q18863
train
function(oRm) { oRm.write("<div"); oRm.addClass("sapMListUl"); oRm.addClass("sapMGrowingList"); oRm.writeAttribute("id", this._oControl.getId() + "-triggerList"); oRm.addStyle("display", "none"); oRm.writeClasses(); oRm.writeStyles(); oRm.write(">"); oRm.renderControl(this._getTrigger()); oRm.write("</div>"); }
javascript
{ "resource": "" }
q18864
train
function() { if (!this._oControl || this._bLoading) { return; } // if max item count not reached or if we do not know the count var oBinding = this._oControl.getBinding("items"); if (oBinding && !oBinding.isLengthFinal() || this._iLimit < this._oControl.getMaxItemsCount()) { // The GrowingEnablement has its own busy indicator. Do not show the busy indicator, if existing, of the parent control. if (this._oControl.getMetadata().hasProperty("enableBusyIndicator")) { this._bParentEnableBusyIndicator = this._oControl.getEnableBusyIndicator(); this._oControl.setEnableBusyIndicator(false); } this._iLimit += this._oControl.getGrowingThreshold(); this._updateTriggerDelayed(true); this.updateItems("Growing"); } }
javascript
{ "resource": "" }
q18865
train
function(sChangeReason) { this._bLoading = false; this._updateTriggerDelayed(false); this._oControl.onAfterPageLoaded(this.getInfo(), sChangeReason); // After the data has been loaded, restore the busy indicator handling of the parent control. if (this._oControl.setEnableBusyIndicator) { this._oControl.setEnableBusyIndicator(this._bParentEnableBusyIndicator); } }
javascript
{ "resource": "" }
q18866
train
function() { var sTriggerID = this._oControl.getId() + "-trigger", sTriggerText = this._oControl.getGrowingTriggerText(); sTriggerText = sTriggerText || sap.ui.getCore().getLibraryResourceBundle("sap.m").getText("LOAD_MORE_DATA"); this._oControl.addNavSection(sTriggerID); if (this._oTrigger) { this.setTriggerText(sTriggerText); return this._oTrigger; } // The growing button is changed to span tag as h1 tag was semantically incorrect. this._oTrigger = new CustomListItem({ id: sTriggerID, busyIndicatorDelay: 0, type: ListType.Active, content: new HTML({ content: '<div class="sapMGrowingListTrigger">' + '<div class="sapMSLITitleDiv sapMGrowingListTriggerText">' + '<span class="sapMSLITitle" id="' + sTriggerID + 'Text">' + encodeXML(sTriggerText) + '</span>' + '</div>' + '<div class="sapMGrowingListDescription sapMSLIDescription" id="' + sTriggerID + 'Info"></div>' + '</div>' }) }).setParent(this._oControl, null, true).attachPress(this.requestNewPage, this).addEventDelegate({ onsapenter : function(oEvent) { this.requestNewPage(); oEvent.preventDefault(); }, onsapspace : function(oEvent) { this.requestNewPage(); oEvent.preventDefault(); }, onAfterRendering : function(oEvent) { this._oTrigger.$().attr({ "tabindex": 0, "role": "button", "aria-labelledby": sTriggerID + "Text" + " " + sTriggerID + "Info" }); } }, this); // stop the eventing between item and the list this._oTrigger.getList = function() {}; // defines the tag name this._oTrigger.TagName = "div"; return this._oTrigger; }
javascript
{ "resource": "" }
q18867
train
function(oBinding) { var aSorters = oBinding.aSorters || []; var oSorter = aSorters[0] || {}; return (oSorter.fnGroup) ? oSorter.sPath || "" : ""; }
javascript
{ "resource": "" }
q18868
train
function(oContext, oBindingInfo, bSuppressInvalidate) { var oControl = this._oControl, oBinding = oBindingInfo.binding, oItem = this.createListItem(oContext, oBindingInfo); if (oBinding.isGrouped()) { // creates group header if need var aItems = oControl.getItems(true), oLastItem = aItems[aItems.length - 1], sModelName = oBindingInfo.model, oGroupInfo = oBinding.getGroup(oItem.getBindingContext(sModelName)); if (oLastItem && oLastItem.isGroupHeader()) { oControl.removeAggregation("items", oLastItem, true); this._fnAppendGroupItem = this.appendGroupItem.bind(this, oGroupInfo, oLastItem, bSuppressInvalidate); oLastItem = aItems[aItems.length - 1]; } if (!oLastItem || oGroupInfo.key !== oBinding.getGroup(oLastItem.getBindingContext(sModelName)).key) { var oGroupHeader = (oBindingInfo.groupHeaderFactory) ? oBindingInfo.groupHeaderFactory(oGroupInfo) : null; if (oControl.getGrowingDirection() == ListGrowingDirection.Upwards) { this.applyPendingGroupItem(); this._fnAppendGroupItem = this.appendGroupItem.bind(this, oGroupInfo, oGroupHeader, bSuppressInvalidate); } else { this.appendGroupItem(oGroupInfo, oGroupHeader, bSuppressInvalidate); } } } oControl.addAggregation("items", oItem, bSuppressInvalidate); if (bSuppressInvalidate) { this._aChunk.push(oItem); } }
javascript
{ "resource": "" }
q18869
train
function(oContext, oBindingInfo) { this._iRenderedDataItems++; var oItem = oBindingInfo.factory(ManagedObjectMetadata.uid("clone"), oContext); return oItem.setBindingContext(oContext, oBindingInfo.model); }
javascript
{ "resource": "" }
q18870
train
function(aContexts, oModel) { if (!aContexts.length) { return; } var aItems = this._oControl.getItems(true); for (var i = 0, c = 0, oItem; i < aItems.length; i++) { oItem = aItems[i]; // group headers are not in binding context if (!oItem.isGroupHeader()) { oItem.setBindingContext(aContexts[c++], oModel); } } }
javascript
{ "resource": "" }
q18871
train
function(aContexts, oBindingInfo, bSuppressInvalidate) { for (var i = 0; i < aContexts.length; i++) { this.addListItem(aContexts[i], oBindingInfo, bSuppressInvalidate); } }
javascript
{ "resource": "" }
q18872
train
function(aContexts, oBindingInfo, bSuppressInvalidate) { this.destroyListItems(bSuppressInvalidate); this.addListItems(aContexts, oBindingInfo, bSuppressInvalidate); if (bSuppressInvalidate) { var bHasFocus = this._oContainerDomRef.contains(document.activeElement); this.applyChunk(false); bHasFocus && this._oControl.focus(); } else { this.applyPendingGroupItem(); } }
javascript
{ "resource": "" }
q18873
train
function(oContext, oBindingInfo, iIndex) { var oItem = this.createListItem(oContext, oBindingInfo); this._oControl.insertAggregation("items", oItem, iIndex, true); this._aChunk.push(oItem); }
javascript
{ "resource": "" }
q18874
train
function(sChangeReason) { if (!this._bDataRequested) { this._bDataRequested = true; this._onBeforePageLoaded(sChangeReason); } // set iItemCount to initial value if not set or no items at the control yet if (!this._iLimit || this.shouldReset(sChangeReason) || !this._oControl.getItems(true).length) { this._iLimit = this._oControl.getGrowingThreshold(); } // send the request to get the context this._oControl.getBinding("items").getContexts(0, this._iLimit); }
javascript
{ "resource": "" }
q18875
train
function(bLoading) { var oTrigger = this._oTrigger, oControl = this._oControl; // If there are no visible columns then also hide the trigger. if (!oTrigger || !oControl || !oControl.shouldRenderItems() || !oControl.getDomRef()) { return; } var oBinding = oControl.getBinding("items"); if (!oBinding) { return; } // update busy state oTrigger.setBusy(bLoading); oTrigger.$().toggleClass("sapMGrowingListBusyIndicatorVisible", bLoading); if (bLoading) { oTrigger.setActive(false); oControl.$("triggerList").css("display", ""); } else { var aItems = oControl.getItems(true), iItemsLength = aItems.length, iBindingLength = oBinding.getLength() || 0, bLengthFinal = oBinding.isLengthFinal(), bHasScrollToLoad = oControl.getGrowingScrollToLoad(), oTriggerDomRef = oTrigger.getDomRef(); // put the focus to the newly added item if growing button is pressed if (oTriggerDomRef && oTriggerDomRef.contains(document.activeElement)) { (aItems[this._iLastItemsCount] || oControl).focus(); } // show, update or hide the growing button if (!iItemsLength || !this._iLimit || (bLengthFinal && this._iLimit >= iBindingLength) || (bHasScrollToLoad && this._getHasScrollbars())) { oControl.$("triggerList").css("display", "none"); } else { if (bLengthFinal) { oControl.$("triggerInfo").css("display", "block").text(this._getListItemInfo()); } oTrigger.$().removeClass("sapMGrowingListBusyIndicatorVisible"); oControl.$("triggerList").css("display", ""); } // store the last item count to be able to focus to the newly added item when the growing button is pressed this._iLastItemsCount = this._oControl.getItems(true).length; // at the beginning we should scroll to last item if (bHasScrollToLoad && this._oScrollPosition === undefined && oControl.getGrowingDirection() == ListGrowingDirection.Upwards) { this._oScrollPosition = { left : 0, top : 0 }; } // scroll to last position if (iItemsLength > 0 && this._oScrollPosition) { var oScrollDelegate = this._oScrollDelegate, oScrollPosition = this._oScrollPosition; oScrollDelegate.scrollTo(oScrollPosition.left, oScrollDelegate.getScrollHeight() - oScrollPosition.top); this._oScrollPosition = null; } } }
javascript
{ "resource": "" }
q18876
train
function () { var sTargetName; EventProvider.prototype.destroy.apply(this); for (sTargetName in this._mTargets) { if (this._mTargets.hasOwnProperty(sTargetName)) { this._mTargets[sTargetName].destroy(); } } this._mTargets = null; this._oCache = null; this._oConfig = null; this.bIsDestroyed = true; return this; }
javascript
{ "resource": "" }
q18877
train
function (sName, oTargetOptions) { var oOldTarget = this.getTarget(sName), oTarget; if (oOldTarget) { Log.error("Target with name " + sName + " already exists", this); } else { oTarget = this._createTarget(sName, oTargetOptions); this._addParentTo(oTarget); } return this; }
javascript
{ "resource": "" }
q18878
train
function (sName, oTargetOptions) { var oTarget, oOptions; oOptions = jQuery.extend(true, { _name: sName }, this._oConfig, oTargetOptions); oTarget = this._constructTarget(oOptions); oTarget.attachDisplay(function (oEvent) { var oParameters = oEvent.getParameters(); this.fireDisplay({ name : sName, view : oParameters.view, control : oParameters.control, config : oParameters.config, data: oParameters.data }); }, this); this._mTargets[sName] = oTarget; return oTarget; }
javascript
{ "resource": "" }
q18879
addSapParams
train
function addSapParams(oUri) { ['sap-client', 'sap-server'].forEach(function(sName) { if (!oUri.hasSearch(sName)) { var sValue = sap.ui.getCore().getConfiguration().getSAPParam(sName); if (sValue) { oUri.addSearch(sName, sValue); } } }); }
javascript
{ "resource": "" }
q18880
mergeDefinitionSource
train
function mergeDefinitionSource(mDefinitions, mDefinitionSource, mSourceData, oSource) { if (mSourceData) { for (var sName in mDefinitions) { if (!mDefinitionSource[sName] && mSourceData[sName] && mSourceData[sName].uri) { mDefinitionSource[sName] = oSource; } } } }
javascript
{ "resource": "" }
q18881
getManifestEntry
train
function getManifestEntry(oMetadata, oManifest, sKey, bMerged) { var oData = oManifest.getEntry(sKey); // merge / extend should only be done for objects or when entry wasn't found if (oData !== undefined && !isPlainObject(oData)) { return oData; } // merge the configuration of the parent manifest with local manifest // the configuration of the static component metadata will be ignored var oParent, oParentData; if (bMerged && (oParent = oMetadata.getParent()) instanceof ComponentMetadata) { oParentData = oParent.getManifestEntry(sKey, bMerged); } // only extend / clone if there is data // otherwise "null" will be converted into an empty object if (oParentData || oData) { oData = jQuery.extend(true, {}, oParentData, oData); } return oData; }
javascript
{ "resource": "" }
q18882
createMetadataProxy
train
function createMetadataProxy(oMetadata, oManifest) { // create a proxy for the metadata object and simulate to be an // instance of the original metadata object of the Component // => retrieving the prototype from the original metadata to // support to proxy sub-classes of ComponentMetadata var oMetadataProxy = Object.create(Object.getPrototypeOf(oMetadata)); // provide internal access to the static metadata object oMetadataProxy._oMetadata = oMetadata; oMetadataProxy._oManifest = oManifest; // copy all functions from the metadata object except of the // manifest related functions which will be instance specific now for (var m in oMetadata) { if (!/^(getManifest|getManifestObject|getManifestEntry|getMetadataVersion)$/.test(m) && typeof oMetadata[m] === "function") { oMetadataProxy[m] = oMetadata[m].bind(oMetadata); } } // return the content of the manifest instead of the static metadata oMetadataProxy.getManifest = function() { return oManifest && oManifest.getJson(); }; oMetadataProxy.getManifestObject = function() { return oManifest; }; oMetadataProxy.getManifestEntry = function(sKey, bMerged) { return getManifestEntry(oMetadata, oManifest, sKey, bMerged); }; oMetadataProxy.getMetadataVersion = function() { return 2; // instance specific manifest => metadata version 2! }; return oMetadataProxy; }
javascript
{ "resource": "" }
q18883
activateServices
train
function activateServices(oComponent) { var oServices = oComponent.getManifestEntry("/sap.ui5/services"); for (var sService in oServices) { if (oServices[sService].lazy === false) { oComponent.getService(sService); } } }
javascript
{ "resource": "" }
q18884
getPreloadModelConfigsFromManifest
train
function getPreloadModelConfigsFromManifest(oManifest, oComponentData, mCacheTokens) { var mModelConfigs = { afterManifest: {}, afterPreload: {} }; // deep clone is needed as the mainfest only returns a read-only copy (freezed object) var oManifestDataSources = jQuery.extend(true, {}, oManifest.getEntry("/sap.app/dataSources")); var oManifestModels = jQuery.extend(true, {}, oManifest.getEntry("/sap.ui5/models")); var mAllModelConfigurations = Component._createManifestModelConfigurations({ models: oManifestModels, dataSources: oManifestDataSources, manifest: oManifest, componentData: oComponentData, cacheTokens: mCacheTokens }); // Read internal URI parameter to enable model preload for testing purposes // Specify comma separated list of model names. Use an empty segment for the "default" model // Examples: // sap-ui-xx-preload-component-models-<componentName>=, => prelaod default model (empty string key) // sap-ui-xx-preload-component-models-<componentName>=foo, => prelaod "foo" + default model (empty string key) // sap-ui-xx-preload-component-models-<componentName>=foo,bar => prelaod "foo" + "bar" models var sPreloadModels = new UriParameters(window.location.href).get("sap-ui-xx-preload-component-models-" + oManifest.getComponentName()); var aPreloadModels = sPreloadModels && sPreloadModels.split(","); for (var sModelName in mAllModelConfigurations) { var mModelConfig = mAllModelConfigurations[sModelName]; // activate "preload" flag in case URI parameter for testing is used (see code above) if (!mModelConfig.preload && aPreloadModels && aPreloadModels.indexOf(sModelName) > -1 ) { mModelConfig.preload = true; Log.warning("FOR TESTING ONLY!!! Activating preload for model \"" + sModelName + "\" (" + mModelConfig.type + ")", oManifest.getComponentName(), "sap.ui.core.Component"); } // ResourceModels with async=false should be always loaded beforehand to get rid of sync requests under the hood (regardless of the "preload" flag) if (mModelConfig.type === "sap.ui.model.resource.ResourceModel" && Array.isArray(mModelConfig.settings) && mModelConfig.settings.length > 0 && mModelConfig.settings[0].async !== true ) { // Use separate config object for ResourceModels as the resourceBundle might be // part of the Component-preload which isn't available when the regular "preloaded"-models are created mModelConfigs.afterPreload[sModelName] = mModelConfig; } else if (mModelConfig.preload) { // Only create models: // - which are flagged for preload (mModelConfig.preload) or activated via internal URI param (see above) // - in case the model class is already loaded (otherwise log a warning) if (sap.ui.loader._.getModuleState(mModelConfig.type.replace(/\./g, "/") + ".js")) { mModelConfigs.afterManifest[sModelName] = mModelConfig; } else { Log.warning("Can not preload model \"" + sModelName + "\" as required class has not been loaded: \"" + mModelConfig.type + "\"", oManifest.getComponentName(), "sap.ui.core.Component"); } } } return mModelConfigs; }
javascript
{ "resource": "" }
q18885
collectLoadManifestPromises
train
function collectLoadManifestPromises(oMetadata, oManifest) { // ComponentMetadata classes with a static manifest or with legacy metadata // do already have a manifest, so no action required if (!oMetadata._oManifest) { // TODO: If the "manifest" property is set, the code to load the manifest.json could be moved up to run in // parallel with the ResourceModels that are created (after the Component-preload has finished) to trigger // a potential request a bit earlier. Right now the whole component loading would be delayed by the async request. var sName = oMetadata.getComponentName(); var sDefaultManifestUrl = getManifestUrl(sName); var pLoadManifest; if (oManifest) { // Apply a copy of the already loaded manifest to be used by the static metadata class pLoadManifest = Promise.resolve(JSON.parse(JSON.stringify(oManifest.getRawJson()))); } else { // We need to load the manifest.json for the metadata class as // it might differ from the one already loaded // If the manifest.json is part of the Component-preload it will be taken from there pLoadManifest = LoaderExtensions.loadResource({ url: sDefaultManifestUrl, dataType: "json", async: true }).catch(function(oError) { Log.error( "Failed to load component manifest from \"" + sDefaultManifestUrl + "\" (component " + sName + ")! Reason: " + oError ); // If the request fails, ignoring the error would end up in a sync call, which would fail, too. return {}; }); } aManifestsToLoad.push(pLoadManifest); aMetadataObjects.push(oMetadata); } var oParentMetadata = oMetadata.getParent(); if (oParentMetadata && (oParentMetadata instanceof ComponentMetadata) && !oParentMetadata.isBaseClass()) { collectLoadManifestPromises(oParentMetadata); } }
javascript
{ "resource": "" }
q18886
train
function() { // create a copy of arguments for local modification // and later handover to Component constructor var args = Array.prototype.slice.call(arguments); // inject the manifest to the settings object var mSettings; if (args.length === 0 || typeof args[0] === "object") { mSettings = args[0] = args[0] || {}; } else if (typeof args[0] === "string") { mSettings = args[1] = args[1] || {}; } mSettings._metadataProxy = oMetadataProxy; // mixin created "models" into "mSettings" if (mModels) { mSettings._manifestModels = mModels; } // call the original constructor of the component class var oInstance = Object.create(oClass.prototype); oClass.apply(oInstance, args); return oInstance; }
javascript
{ "resource": "" }
q18887
train
function(oPromise) { // In order to make the error handling of the Promise.all() happen after all Promises finish, we catch all rejected Promises and make them resolve with an marked object. oPromise = oPromise.then( function(v) { return { result: v, rejected: false }; }, function(v) { return { result: v, rejected: true }; } ); return oPromise; }
javascript
{ "resource": "" }
q18888
train
function(sTemplateName) { var sUrl = sap.ui.require.toUrl(sTemplateName.replace(/\./g, "/")) + ".fragment.html"; var sHTML = _mHTMLTemplates[sUrl]; var sResourceName; if (!sHTML) { sResourceName = sTemplateName.replace(/\./g, "/") + ".fragment.html"; sHTML = LoaderExtensions.loadResource(sResourceName); // TODO discuss // a) why caching at all (more precise: why for HTML fragment although we refused to do it for other view/fragment types - risk of a memory leak!) // b) why cached via URL instead of via name? Any special scenario in mind? _mHTMLTemplates[sUrl] = sHTML; } return sHTML; }
javascript
{ "resource": "" }
q18889
train
function() { var sName; // lazy load of LocaleData to avoid cyclic dependencies if ( !LocaleData ) { LocaleData = sap.ui.requireSync("sap/ui/core/LocaleData"); } if (this.calendarType) { for (sName in CalendarType) { if (sName.toLowerCase() === this.calendarType.toLowerCase()) { this.calendarType = sName; return this.calendarType; } } Log.warning("Parameter 'calendarType' is set to " + this.calendarType + " which isn't a valid value and therefore ignored. The calendar type is determined from format setting and current locale"); } var sLegacyDateFormat = this.oFormatSettings.getLegacyDateFormat(); switch (sLegacyDateFormat) { case "1": case "2": case "3": case "4": case "5": case "6": return CalendarType.Gregorian; case "7": case "8": case "9": return CalendarType.Japanese; case "A": case "B": return CalendarType.Islamic; case "C": return CalendarType.Persian; } return LocaleData.getInstance(this.getLocale()).getPreferredCalendarType(); }
javascript
{ "resource": "" }
q18890
train
function(sFormatLocale) { var oFormatLocale = convertToLocaleOrNull(sFormatLocale), mChanges; check(sFormatLocale == null || typeof sFormatLocale === "string" && oFormatLocale, "sFormatLocale must be a BCP47 language tag or Java Locale id or null"); if ( toLanguageTag(oFormatLocale) !== toLanguageTag(this.formatLocale) ) { this.formatLocale = oFormatLocale; mChanges = this._collect(); mChanges.formatLocale = toLanguageTag(oFormatLocale); this._endCollect(); } return this; }
javascript
{ "resource": "" }
q18891
train
function(sAnimationMode) { checkEnum(Configuration.AnimationMode, sAnimationMode, "animationMode"); // Set the animation to on or off depending on the animation mode to ensure backward compatibility. this.animation = (sAnimationMode !== Configuration.AnimationMode.minimal && sAnimationMode !== Configuration.AnimationMode.none); // Set the animation mode and update html attributes. this.animationMode = sAnimationMode; if (this._oCore && this._oCore._setupAnimation) { this._oCore._setupAnimation(); } }
javascript
{ "resource": "" }
q18892
train
function(bRTL) { check(bRTL === null || typeof bRTL === "boolean", "bRTL must be null or a boolean"); var oldRTL = this.getRTL(), mChanges; this.rtl = bRTL; if ( oldRTL != this.getRTL() ) { // also take the derived RTL flag into account for the before/after comparison! mChanges = this._collect(); mChanges.rtl = this.getRTL(); this._endCollect(); } return this; }
javascript
{ "resource": "" }
q18893
train
function(mSettings) { function applyAll(ctx, m) { var sName, sMethod; for ( sName in m ) { sMethod = "set" + sName.slice(0,1).toUpperCase() + sName.slice(1); if ( sName === 'formatSettings' && ctx.oFormatSettings ) { applyAll(ctx.oFormatSettings, m[sName]); } else if ( typeof ctx[sMethod] === 'function' ) { ctx[sMethod](m[sName]); } else { Log.warning("Configuration.applySettings: unknown setting '" + sName + "' ignored"); } } } assert(typeof mSettings === 'object', "mSettings must be an object"); this._collect(); // block events applyAll(this, mSettings); this._endCollect(); // might fire localizationChanged return this; }
javascript
{ "resource": "" }
q18894
checkEnum
train
function checkEnum(oEnum, sValue, sPropertyName) { var aValidValues = []; for (var sKey in oEnum) { if (oEnum.hasOwnProperty(sKey)) { if (oEnum[sKey] === sValue) { return; } aValidValues.push(oEnum[sKey]); } } throw new Error("Unsupported Enumeration value for " + sPropertyName + ", valid values are: " + aValidValues.join(", ")); }
javascript
{ "resource": "" }
q18895
train
function() { function fallback(that) { var oLocale = that.oConfiguration.language; // if any user settings have been defined, add the private use subtag "sapufmt" if ( !jQuery.isEmptyObject(that.mSettings) ) { // TODO move to Locale/LocaleData var l = oLocale.toString(); if ( l.indexOf("-x-") < 0 ) { l = l + "-x-sapufmt"; } else if ( l.indexOf("-sapufmt") <= l.indexOf("-x-") ) { l = l + "-sapufmt"; } oLocale = new Locale(l); } return oLocale; } return this.oConfiguration.formatLocale || fallback(this); }
javascript
{ "resource": "" }
q18896
train
function(sStyle, sPattern) { check(sStyle == "short" || sStyle == "medium" || sStyle == "long" || sStyle == "full", "sStyle must be short, medium, long or full"); this._set("dateFormats-" + sStyle, sPattern); return this; }
javascript
{ "resource": "" }
q18897
train
function(sType, sSymbol) { check(sType == "decimal" || sType == "group" || sType == "plusSign" || sType == "minusSign", "sType must be decimal, group, plusSign or minusSign"); this._set("symbols-latn-" + sType, sSymbol); return this; }
javascript
{ "resource": "" }
q18898
train
function(mCurrencies) { check(typeof mCurrencies === "object" || mCurrencies == null, "mCurrencyDigits must be an object"); Object.keys(mCurrencies || {}).forEach(function(sCurrencyDigit) { check(typeof sCurrencyDigit === "string"); check(typeof mCurrencies[sCurrencyDigit] === "object"); }); this._set("currency", mCurrencies); return this; }
javascript
{ "resource": "" }
q18899
train
function(sFormatId) { sFormatId = sFormatId ? String(sFormatId).toUpperCase() : ""; check(!sFormatId || M_ABAP_DATE_FORMAT_PATTERN.hasOwnProperty(sFormatId), "sFormatId must be one of ['1','2','3','4','5','6','7','8','9','A','B','C'] or empty"); var mChanges = this.oConfiguration._collect(); this.sLegacyDateFormat = mChanges.legacyDateFormat = sFormatId; this.setDatePattern("short", M_ABAP_DATE_FORMAT_PATTERN[sFormatId].pattern); this.setDatePattern("medium", M_ABAP_DATE_FORMAT_PATTERN[sFormatId].pattern); this.oConfiguration._endCollect(); return this; }
javascript
{ "resource": "" }