_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q19200
train
function (control) { var aggregations = control.getMetadata().getAllAggregations(); var aggregationsBindingData = Object.create(null); for (var key in aggregations) { if (aggregations.hasOwnProperty(key) && control.getBinding(key)) { aggregationsBindingData[key] = Object.create(null); aggregationsBindingData[key].model = this._getModelFromContext(control, key); } } return aggregationsBindingData; }
javascript
{ "resource": "" }
q19201
train
function (controlId) { var result = Object.create(null); var control = sap.ui.getCore().byId(controlId); var bindingContext; if (!control) { return result; } bindingContext = control.getBindingContext(); result.meta = Object.create(null); result.contextPath = bindingContext ? bindingContext.getPath() : null; result.aggregations = controlInformation._getBindDataForAggregations(control); result.properties = controlInformation._getBindDataForProperties(control); return result; }
javascript
{ "resource": "" }
q19202
train
function (context) { var that = context; assert(!!that, "No ToolPopup instance given for _fnGetInitialFocus"); // if there is an initial focus it was already set to the Popup onBeforeRendering if (!that._bFocusSet) { _fnGetNewFocusElement(that); } else { that._sInitialFocusId = that.oPopup._sInitialFocusId; } return that._sInitialFocusId; }
javascript
{ "resource": "" }
q19203
train
function (context) { var oElement; var oFocusControl; var that = context; var defaultFocusableElements = [that._mParameters.firstFocusable, that._mParameters.lastFocusable]; // jQuery custom selectors ":sapTabbable" var aTabbables = jQuery(":sapTabbable", that.$()).get(); // search the first tabbable element for (var i = 0; i < aTabbables.length; i++) { if (defaultFocusableElements.indexOf(aTabbables[i].id) === -1) { oElement = aTabbables[i]; break; } } // If a tabbable element is part of a control, focus the control instead // jQuery Plugin "control" oFocusControl = jQuery(oElement).control(); if (oFocusControl[0]) { var oFocusDomRef = oFocusControl[0].getFocusDomRef(); oElement = oFocusDomRef || oElement; } else { // if there is no tabbable element in the content use the first fake // element to set the focus to the toolpopup oElement = defaultFocusableElements[0] ? window.document.getElementById(defaultFocusableElements[0]) : null; } // oElement might not be available if this function is called during destroy if (oElement) { if (oElement) { oElement.focus(); } that._sInitialFocusId = oElement.id; } }
javascript
{ "resource": "" }
q19204
_fnGetFocusControlById
train
function _fnGetFocusControlById(oToolPopup, id) { var oControl, parent; if (!id) { return null; } oControl = sap.ui.getCore().byId(id); while (!oControl && oControl !== oToolPopup) { if (!id || !document.getElementById(id)) { return null; } parent = document.getElementById(id).parentNode; id = parent.id; oControl = sap.ui.getCore().byId(id); } return oControl; }
javascript
{ "resource": "" }
q19205
train
function (oThis) { if (!oThis.getOpener()) { var sId = ""; if (oThis.oPopup) { if (oThis.oPopup._oPosition.of instanceof sap.ui.core.Element) { sId = oThis.oPopup._oPosition.of.getId(); } else { if (oThis.oPopup._oPosition.of.length > 0) { sId = oThis.oPopup._oPosition.of[0].id; } else { sId = oThis.oPopup._oPosition.of.id; } } } if (sId !== "") { oThis.setAssociation("opener", sId, true); } else { Log.error("Neither an opener was set properly nor a corresponding one can be distinguished", "", "sap.ui.ux3.ToolPopup"); } } }
javascript
{ "resource": "" }
q19206
train
function (oThis) { var sParam = "sapUiUx3ToolPopupArrowWidth"; oThis.sArrowWidth = Parameters.get(sParam); oThis.iArrowWidth = parseInt(oThis.sArrowWidth); sParam = "sapUiUx3ToolPopupArrowHeight"; oThis.sArrowHeight = Parameters.get(sParam); oThis.iArrowHeight = parseInt(oThis.sArrowHeight); sParam = "sapUiUx3ToolPopupArrowRightMarginCorrection"; oThis.sArrowPadding = Parameters.get(sParam); oThis.iArrowPadding = parseInt(oThis.sArrowPadding); sParam = "sapUiUx3ToolPopupArrowRightMarginCorrectionInverted"; oThis.sArrowPaddingInverted = Parameters.get(sParam); oThis.iArrowPaddingInverted = parseInt(oThis.sArrowPaddingInverted); }
javascript
{ "resource": "" }
q19207
train
function (oThis) { // do not mirror the arrow direction here in RTL mode, because otherwise the offset is calculated wrong // (Because the offset mirroring happens inside popup) // the arrow is later mirrored at the output... // this is the default case if no match was found var sDirection = "Left"; // if 'my' is not set check if it was previously set via 'setPosition' var my = oThis._my; var at = oThis._at; if (!my && oThis.oPopup) { my = oThis.oPopup._oPosition.my; } if (!at && oThis.oPopup) { at = oThis.oPopup._oPosition.at; } oThis._bHorizontalArrow = false; if (my && at) { var aMy = my.split(" "); var aAt = at.split(" "); // create a rule like "my:top|left at:left|top" var sRule = "my:" + aMy[0] + "|" + aMy[1]; sRule += " at:" + aAt[0] + "|" + aAt[1]; if (ToolPopup.ARROW_LEFT.exec(sRule)) { oThis._bHorizontalArrow = true; sDirection = "Left"; } else if (ToolPopup.ARROW_RIGHT.exec(sRule)) { oThis._bHorizontalArrow = true; sDirection = "Right"; } else if (ToolPopup.ARROW_UP.exec(sRule)) { sDirection = "Up"; } else if (ToolPopup.ARROW_DOWN.exec(sRule)) { sDirection = "Down"; } if (oThis.getDomRef() && oThis.isOpen()) { var $This = oThis.$(); // jQuery Plugin "rect" var oPopRect = $This.rect(); var $Opener = jQuery(document.getElementById(oThis.getOpener())); // jQuery Plugin "rect" var oOpenerRect = $Opener.rect(); if (oOpenerRect) { // check if the ToolPopup was positioned at another side relative to the opener due to any collision. if (oThis._bHorizontalArrow) { // left/right arrow var iPopRight = oPopRect.left + $This.outerWidth(true) + oThis.iArrowWidth; var iOpenerRight = oOpenerRect.left + $Opener.outerWidth(true); if (iPopRight <= iOpenerRight) { sDirection = "Right"; } else { sDirection = "Left"; } } else { // up/down arrow var iPopBottom = oPopRect.top + $This.outerHeight(true) + oThis.iArrowWidth; var iOpenerBottom = oOpenerRect.top + $Opener.outerHeight(true); if (iPopBottom <= iOpenerBottom) { sDirection = "Down"; } else { sDirection = "Up"; } } } } } return sDirection; }
javascript
{ "resource": "" }
q19208
train
function(rm, oControl) { // execute the template with the above options var sHTML = fnTemplate(oControl.getContext() || {}, { data: { renderManager: rm, rootControl: oControl, view: oView }, helpers: HandlebarsTemplate.RENDER_HELPERS }); // write the markup rm.write(sHTML); }
javascript
{ "resource": "" }
q19209
train
function (oContext) { oControl = oContext; // Get and calculate padding's this._iREMSize = parseInt(jQuery("body").css("font-size")); this._iChildControlMargin = parseInt(Parameters.get("_sap_f_ShellBar_ChildMargin")); this._iDoubleChildControlMargin = this._iChildControlMargin * 2; this._iCoPilotWidth = parseInt(Parameters.get("_sap_f_ShellBar_CoPilotWidth")) + this._iDoubleChildControlMargin; this._iHalfCoPilotWidth = this._iCoPilotWidth / 2; // Delegate used to attach on ShellBar lifecycle events this._oDelegate = { onAfterRendering: this.onAfterRendering, onBeforeRendering: this.onBeforeRendering }; // Attach Event Delegates oControl.addDelegate(this._oDelegate, false, this); // Init resize handler method this._fnResize = this._resize; // Attach events oControl._oOverflowToolbar.attachEvent("_controlWidthChanged", this._handleResize, this); }
javascript
{ "resource": "" }
q19210
train
function (oSelector, oAppComponent, oView) { var sControlId = this.getControlIdBySelector(oSelector, oAppComponent); return this._byId(sControlId, oView); }
javascript
{ "resource": "" }
q19211
train
function (oSelector, oAppComponent) { if (!oSelector){ return undefined; } if (typeof oSelector === "string") { oSelector = { id: oSelector }; } var sControlId = oSelector.id; if (oSelector.idIsLocal) { if (oAppComponent) { sControlId = oAppComponent.createId(sControlId); } else { throw new Error("App Component instance needed to get a control's ID from selector"); } } else { // does nothing except in the case of a FLP prefix var pattern = /^application-[^-]*-[^-]*-component---/igm; var bHasFlpPrefix = !!pattern.exec(oSelector.id); if (bHasFlpPrefix) { sControlId = sControlId.replace(/^application-[^-]*-[^-]*-component---/g, ""); if (oAppComponent) { sControlId = oAppComponent.createId(sControlId); } else { throw new Error("App Component instance needed to get a control's ID from selector"); } } } return sControlId; }
javascript
{ "resource": "" }
q19212
train
function (vControl, oAppComponent, mAdditionalSelectorInformation) { var sControlId = vControl; if (typeof sControlId !== "string") { sControlId = (vControl) ? this.getId(vControl) : undefined; } else if (!oAppComponent) { throw new Error("App Component instance needed to get a selector from string ID"); } if (mAdditionalSelectorInformation && (mAdditionalSelectorInformation.id || mAdditionalSelectorInformation.idIsLocal)) { throw new Error("A selector of control with the ID '" + sControlId + "' was requested, " + "but core properties were overwritten by the additionally passed information."); } var bValidId = this.checkControlId(sControlId, oAppComponent); if (!bValidId) { throw new Error("Generated ID attribute found - to offer flexibility a stable control ID is needed to assign the changes to, but for this control the ID was generated by SAPUI5 " + sControlId); } var oSelector = Object.assign({}, mAdditionalSelectorInformation, { id: "", idIsLocal: false }); if (this.hasLocalIdSuffix(sControlId, oAppComponent)) { // get local Id for control at root component and use it as selector ID var sLocalId = oAppComponent.getLocalId(sControlId); oSelector.id = sLocalId; oSelector.idIsLocal = true; } else { oSelector.id = sControlId; } return oSelector; }
javascript
{ "resource": "" }
q19213
train
function (vControl, oAppComponent, bSuppressLogging) { var sControlId = vControl instanceof ManagedObject ? vControl.getId() : vControl; var bIsGenerated = ManagedObjectMetadata.isGeneratedId(sControlId); if (!bIsGenerated || this.hasLocalIdSuffix(vControl, oAppComponent)) { return true; } else { var sHasConcatenatedId = sControlId.indexOf("--") !== -1; if (!bSuppressLogging && !sHasConcatenatedId) { Log.warning("Control ID was generated dynamically by SAPUI5. To support SAPUI5 flexibility, a stable control ID is needed to assign the changes to.", sControlId); } return false; } }
javascript
{ "resource": "" }
q19214
train
function (vControl, oAppComponent) { var sControlId = (vControl instanceof ManagedObject) ? vControl.getId() : vControl; if (!oAppComponent) { Log.error("Determination of a local ID suffix failed due to missing app component for " + sControlId); return false; } return !!oAppComponent.getLocalId(sControlId); }
javascript
{ "resource": "" }
q19215
train
function(oFragment, sIdPrefix) { var oParseError = XMLHelper.getParseError(oFragment); if (oParseError.errorCode !== 0) { throw new Error(oFragment.parseError.reason); } var oControlNodes = oFragment.documentElement; var aRootChildren = [], aChildren = []; if (oControlNodes.localName === "FragmentDefinition") { aRootChildren = this._getElementNodeChildren(oControlNodes); } else { aRootChildren = [oControlNodes]; } aChildren = [].concat(aRootChildren); // get all children and their children function oCallback(oChild) { aChildren.push(oChild); } for (var i = 0, n = aRootChildren.length; i < n; i++) { this._traverseXmlTree(oCallback, aRootChildren[i]); } for (var j = 0, m = aChildren.length; j < m; j++) { // aChildren[j].id is not available in IE11, therefore using .getAttribute/.setAttribute if (aChildren[j].getAttribute("id")) { aChildren[j].setAttribute("id", sIdPrefix + "." + aChildren[j].getAttribute("id")); } else { throw new Error("At least one control does not have a stable ID"); } } return oControlNodes; }
javascript
{ "resource": "" }
q19216
train
function(oNode) { var aChildren = []; var aNodes = oNode.childNodes; for (var i = 0, n = aNodes.length; i < n; i++) { if (aNodes[i].nodeType === 1) { aChildren.push(aNodes[i]); } } return aChildren; }
javascript
{ "resource": "" }
q19217
train
function(oElement, sType) { var oInstance = ObjectPath.get(sType); if (typeof oInstance === "function") { return oElement instanceof oInstance; } else { return false; } }
javascript
{ "resource": "" }
q19218
train
function(oControl) { var sControlType = this._getControlTypeInXml(oControl); jQuery.sap.require(sControlType); var ControlType = ObjectPath.get(sControlType); return ControlType.getMetadata(); }
javascript
{ "resource": "" }
q19219
train
function (oControl) { var sControlType = oControl.namespaceURI; sControlType = sControlType ? sControlType + "." : ""; // add a dot if there is already a prefix sControlType += oControl.localName; return sControlType; }
javascript
{ "resource": "" }
q19220
train
function(fnCallback, oRootNode) { function recurse(oParent, oCurrentNode, bIsAggregation) { var oAggregations; if (!bIsAggregation) { var oMetadata = this._getControlMetadataInXml(oCurrentNode); oAggregations = oMetadata.getAllAggregations(); } var aChildren = this._getElementNodeChildren(oCurrentNode); aChildren.forEach(function(oChild) { var bIsCurrentNodeAggregation = oAggregations && oAggregations[oChild.localName]; recurse.call(this, oCurrentNode, oChild, bIsCurrentNodeAggregation); // if it's an aggregation, we don't call the callback function if (!bIsCurrentNodeAggregation) { fnCallback(oChild); } }.bind(this)); } recurse.call(this, oRootNode, oRootNode, false); }
javascript
{ "resource": "" }
q19221
train
function(parentId, moduleName) { moduleName = normalizeModule(parentId, moduleName); var module = define.modules[moduleName]; if (!module) { module = define.payloads[moduleName]; if (typeof module === 'function') { var exports = {}; var mod = { id: moduleName, uri: '', exports: exports, packaged: true }; var req = function(module, callback) { return _require(moduleName, module, callback); }; var returnValue = module(req, exports, mod); exports = returnValue || mod.exports; define.modules[moduleName] = exports; delete define.payloads[moduleName]; } module = define.modules[moduleName] = exports || module; } return module; }
javascript
{ "resource": "" }
q19222
transformVersionInfo
train
function transformVersionInfo() { // get the transitive dependencies of the given libs from the sap.ui.versioninfo // only do this once if mKnownLibs is not created yet if (sap.ui.versioninfo && sap.ui.versioninfo.libraries && !mKnownLibs) { // flatten dependency lists for all libs mKnownLibs = {}; sap.ui.versioninfo.libraries.forEach(function(oLib, i) { mKnownLibs[oLib.name] = {}; var mDeps = oLib.manifestHints && oLib.manifestHints.dependencies && oLib.manifestHints.dependencies.libs; for (var sDep in mDeps) { if (!mDeps[sDep].lazy) { mKnownLibs[oLib.name][sDep] = true; } } }); } // get transitive dependencies for a component if (sap.ui.versioninfo && sap.ui.versioninfo.components && !mKnownComponents) { mKnownComponents = {}; Object.keys(sap.ui.versioninfo.components).forEach(function(sComponentName) { var oComponentInfo = sap.ui.versioninfo.components[sComponentName]; mKnownComponents[sComponentName] = { library: oComponentInfo.library, dependencies: [] }; var mDeps = oComponentInfo.manifestHints && oComponentInfo.manifestHints.dependencies && oComponentInfo.manifestHints.dependencies.libs; for (var sDep in mDeps) { if (!mDeps[sDep].lazy) { mKnownComponents[sComponentName].dependencies.push(sDep); } } }); } }
javascript
{ "resource": "" }
q19223
process
train
function process(vValue, oModel, sPath, iCurrentLevel, iMaxLevel) { var bReachedMaxLevel = iCurrentLevel === iMaxLevel; if (bReachedMaxLevel) { Log.warning("BindingResolver maximum level processing reached. Please check for circular dependencies."); } if (!vValue || bReachedMaxLevel) { return vValue; } if (Array.isArray(vValue)) { vValue.forEach(function (vItem, iIndex, aArray) { if (typeof vItem === "object") { process(vItem, oModel, sPath, iCurrentLevel + 1, iMaxLevel); } else if (typeof vItem === "string") { aArray[iIndex] = resolveBinding(vItem, oModel, sPath); } }, this); return vValue; } else if (typeof vValue === "object") { for (var sProp in vValue) { if (typeof vValue[sProp] === "object") { process(vValue[sProp], oModel, sPath, iCurrentLevel + 1, iMaxLevel); } else if (typeof vValue[sProp] === "string") { vValue[sProp] = resolveBinding(vValue[sProp], oModel, sPath); } } return vValue; } else if (typeof vValue === "string") { return resolveBinding(vValue, oModel, sPath); } else { return vValue; } }
javascript
{ "resource": "" }
q19224
resolveBinding
train
function resolveBinding(sBinding, oModel, sPath) { if (!sBinding) { return sBinding; } var oBindingInfo = ManagedObject.bindingParser(sBinding); if (!oBindingInfo) { return sBinding; } if (!sPath) { sPath = "/"; } oSimpleControl.setModel(oModel); oSimpleControl.bindObject(sPath); oSimpleControl.bindProperty("resolved", oBindingInfo); var vValue = oSimpleControl.getResolved(); oSimpleControl.unbindProperty("resolved"); oSimpleControl.unbindObject(); oSimpleControl.setModel(null); return vValue; }
javascript
{ "resource": "" }
q19225
train
function (mAggregate) { return !!mAggregate && Object.keys(mAggregate).some(function (sAlias) { return mAggregate[sAlias].grandTotal; }); }
javascript
{ "resource": "" }
q19226
train
function (mAggregate) { return !!mAggregate && Object.keys(mAggregate).some(function (sAlias) { var oDetails = mAggregate[sAlias]; return oDetails.min || oDetails.max; }); }
javascript
{ "resource": "" }
q19227
toggleSizeClasses
train
function toggleSizeClasses(iSize) { var sCurrentSizeClass = 'sapMSize' + iSize, oRef = this.$(), i, sClass; if (oRef) { for (i = 0; i < 3; i++) { sClass = 'sapMSize' + i; if (sClass === sCurrentSizeClass) { oRef.addClass(sClass); } else { oRef.removeClass(sClass); } } } }
javascript
{ "resource": "" }
q19228
mixInto
train
function mixInto(fnClass, bDefaultValue) { // add the properties fnClass.getMetadata().addSpecialSetting("stashed", {type: "boolean", defaultValue: !!bDefaultValue}); // mix the required methods into the target fnClass fnClass.prototype.setStashed = function(bStashed) { if (this.stashed === true && !bStashed) { if (this.sParentId) { var oControl = unstash(this, sap.ui.getCore().byId(this.sParentId)); // we need to set the property to the stashed control oControl.stashed = false; return; } } else if (bStashed) { Log.warning("Cannot re-stash a control", this.getId()); } }; fnClass.prototype.getStashed = function() { return this.stashed; }; var fnDestroy = fnClass.prototype.destroy; fnClass.prototype.destroy = function() { delete stashedControls[this.getId()]; fnDestroy.apply(this, arguments); }; fnClass.prototype._stash = function(sParentId, sParentAggregationName) { // for later unstash these parent infos have to be kept this.sParentId = sParentId; this.sParentAggregationName = sParentAggregationName; stashedControls[this.getId()] = this; }; }
javascript
{ "resource": "" }
q19229
train
function (oRouteMatch) { var that = this; var mRouteArguments = oRouteMatch.getParameter("arguments"); this.sLayer = mRouteArguments.layer; this.sNamespace = mRouteArguments.namespace || ""; var oPage = this.getView().getContent()[0]; oPage.setBusy(true); that.sNamespace = decodeURIComponent(that.sNamespace); oPage.setTitle(this._shortenNamespace()); LRepConnector.getContent(that.sLayer, that.sNamespace).then( that._onContentReceived.bind(that, oPage), function(){ oPage.setBusy(false); }).then(function () { LRepConnector.requestPending = false; }); }
javascript
{ "resource": "" }
q19230
train
function (oPage, oData) { var oContentModel = this.getView().getModel("content"); oContentModel.setData(oData); oPage.setBusy(false); this.filterListByQuery(""); this.byId("search").setValue(""); }
javascript
{ "resource": "" }
q19231
train
function (sQuery) { // add filter for search var aFilters = []; if (sQuery && sQuery.length > 0) { aFilters = new Filter({ filters: [ new Filter("name", FilterOperator.Contains, sQuery), new Filter("fileType", FilterOperator.Contains, sQuery) ], and: false }); } // update list binding var oList = this.byId("masterComponentsList"); var oBinding = oList.getBinding("items"); oBinding.filter(aFilters, "content"); }
javascript
{ "resource": "" }
q19232
train
function (oEvent) { var sSource = oEvent.getSource(); var sContentBindingPath = sSource.getBindingContextPath().substring(1); var sContentModelData = this.getView().getModel("content").getData(); var sContent = sContentModelData[sContentBindingPath]; var sContentName = sContent.name; var sContentFileType = sContentModelData[sContentBindingPath].fileType; var oRouter = UIComponent.getRouterFor(this); this.sNamespace = (this.sNamespace ? this.sNamespace : '/'); if (sContentFileType) { // show details to a file var mRouteParameters = { "layer": this.sLayer, "namespace": encodeURIComponent(this.sNamespace), "fileName": sContentName, "fileType": sContentFileType }; oRouter.navTo("ContentDetails", mRouteParameters); } else { // navigation to a namespace this.sNamespace += sContentName + '/'; oRouter.navTo("LayerContentMaster", {"layer": this.sLayer, "namespace": encodeURIComponent(this.sNamespace)}); } }
javascript
{ "resource": "" }
q19233
train
function () { var oRouter = UIComponent.getRouterFor(this); if (!this.sNamespace || this.sNamespace === "/") { oRouter.navTo("Layers"); } else { var sSplittedNamespace = this.sNamespace.split("/"); sSplittedNamespace.splice(-2, 1); var sTargetNamespace = sSplittedNamespace.join("/"); oRouter.navTo("LayerContentMaster", {"layer": this.sLayer, "namespace": encodeURIComponent(sTargetNamespace)}, true); } }
javascript
{ "resource": "" }
q19234
train
function () { if (!this.sNamespace || this.sNamespace === '/') { return "[" + this.sLayer + "] /"; } var aSplittedNamespace = this.sNamespace.split('/'); var sNamespaceDepth = aSplittedNamespace.length; if (sNamespaceDepth > 2) { return "[" + this.sLayer + "] .../" + aSplittedNamespace[sNamespaceDepth - 2]; } return "[" + this.sLayer + "] /" + this.sNamespace[sNamespaceDepth - 1]; }
javascript
{ "resource": "" }
q19235
train
function (oEvent) { var sSource = oEvent.getSource(); sap.ui.require(["sap/ui/fl/support/apps/contentbrowser/utils/ErrorUtils"], function (ErrorUtils) { ErrorUtils.handleMessagePopoverPress(sSource); }); }
javascript
{ "resource": "" }
q19236
train
function(oOverlay) { var oModel = oOverlay.getElement().getModel(); if (oModel){ var oMetaModel = oModel.getMetaModel(); if (oMetaModel && oMetaModel.loaded){ oMetaModel.loaded().then(function(){ this.evaluateEditable([oOverlay], {onRegistration: true}); }.bind(this)); } } Plugin.prototype.registerElementOverlay.apply(this, arguments); }
javascript
{ "resource": "" }
q19237
train
function (oEvent) { // open field ext ui var oUshellContainer = FlUtils.getUshellContainer(); var oCrossAppNav = oUshellContainer.getService("CrossApplicationNavigation"); var sHrefForFieldExtensionUi = (oCrossAppNav && oCrossAppNav.hrefForExternal({ target : { semanticObject : "CustomField", action : "develop" }, params : { businessContexts : this._oCurrentFieldExtInfo.BusinessContexts.map( function( oBusinessContext){ return oBusinessContext.BusinessContext; }), serviceName : this._oCurrentFieldExtInfo.ServiceName, serviceVersion : this._oCurrentFieldExtInfo.ServiceVersion, entityType : this._oCurrentFieldExtInfo.EntityType } })); Utils.openNewWindow(sHrefForFieldExtensionUi); }
javascript
{ "resource": "" }
q19238
train
function(oOverlay) { return { asSibling: this._isEditableCheck.call(this, oOverlay, true), asChild: this._isEditableCheck.call(this, oOverlay, false) }; }
javascript
{ "resource": "" }
q19239
addUrlForSchema
train
function addUrlForSchema(oMetaModel, sSchema, sReferenceUri, sDocumentUri) { var sUrl0, mUrls = oMetaModel.mSchema2MetadataUrl[sSchema]; if (!mUrls) { mUrls = oMetaModel.mSchema2MetadataUrl[sSchema] = {}; mUrls[sReferenceUri] = false; } else if (!(sReferenceUri in mUrls)) { sUrl0 = Object.keys(mUrls)[0]; if (mUrls[sUrl0]) { // document already processed, no different URLs allowed reportAndThrowError(oMetaModel, "A schema cannot span more than one document: " + sSchema + " - expected reference URI " + sUrl0 + " but instead saw " + sReferenceUri, sDocumentUri); } mUrls[sReferenceUri] = false; } }
javascript
{ "resource": "" }
q19240
getQualifier
train
function getQualifier(sTerm, sExpectedTerm) { if (sTerm === sExpectedTerm) { return ""; } if (sTerm.indexOf(sExpectedTerm) === 0 && sTerm[sExpectedTerm.length] === "#" && sTerm.indexOf("@", sExpectedTerm.length) < 0) { return sTerm.slice(sExpectedTerm.length + 1); } }
javascript
{ "resource": "" }
q19241
getValueListQualifier
train
function getValueListQualifier(sTerm) { var sQualifier = getQualifier(sTerm, sValueListMapping); return sQualifier !== undefined ? sQualifier : getQualifier(sTerm, sValueList); }
javascript
{ "resource": "" }
q19242
maybeParameter
train
function maybeParameter(sName, aOverloads) { return aOverloads.some(function (oOverload) { return oOverload.$Parameter && oOverload.$Parameter.some(function (oParameter) { return oParameter.$Name === sName; }); }); }
javascript
{ "resource": "" }
q19243
reportAndThrowError
train
function reportAndThrowError(oMetaModel, sMessage, sDetails) { var oError = new Error(sDetails + ": " + sMessage); oMetaModel.oModel.reportError(sMessage, sODataMetaModel, oError); throw oError; }
javascript
{ "resource": "" }
q19244
train
function () { var aContexts = [], oPromise = this.fetchContexts(), that = this; if (oPromise.isFulfilled()) { aContexts = oPromise.getResult(); } else { oPromise.then(function (aContexts) { that.setContexts(aContexts); that._fireChange({reason: ChangeReason.Change}); }); aContexts.dataRequested = true; } this.setContexts(aContexts); }
javascript
{ "resource": "" }
q19245
prepareKeyPredicate
train
function prepareKeyPredicate(sSegment) { aEditUrl.push({path : sInstancePath, prefix : sSegment, type : oType}); }
javascript
{ "resource": "" }
q19246
stripPredicate
train
function stripPredicate(sSegment) { var i = sSegment.indexOf("("); return i >= 0 ? sSegment.slice(0, i) : sSegment; }
javascript
{ "resource": "" }
q19247
pushToEditUrl
train
function pushToEditUrl(sSegment) { if (sSegment.includes("($uid=")) { prepareKeyPredicate(stripPredicate(sSegment)); } else { aEditUrl.push(sSegment); } }
javascript
{ "resource": "" }
q19248
train
function () { var oView = this.getView(), // Collect all possible items from all lists aItems = [].concat( oView.byId("allList").getItems(), oView.byId("apiList").getItems(), oView.byId("documentationList").getItems(), oView.byId("samplesList").getItems() ), iLen = aItems.length, oItem; while (iLen--) { oItem = aItems[iLen]; // Access control lazy loading method if available if (oItem._getLinkSender) { // Set link href to allow open in new window functionality oItem._getLinkSender().setHref("#/" + oItem.getCustomData()[0].getValue()); } } }
javascript
{ "resource": "" }
q19249
_showYearPicker
train
function _showYearPicker(){ var oDate = this._getFocusedDate(); var oYearPicker = this.getAggregation("yearPicker"); if (oYearPicker.getDomRef()) { // already rendered oYearPicker.$().css("display", ""); } else { var oRm = sap.ui.getCore().createRenderManager(); var $Container = this.$("content"); oRm.renderControl(oYearPicker); oRm.flush($Container[0], false, true); // insert it oRm.destroy(); } this._showOverlay(); oYearPicker.setDate(oDate.toLocalJSDate()); if (this._iMode == 0) { // remove tabindex from month var oMonthsRow = this.getAggregation("monthsRow"); jQuery(oMonthsRow._oItemNavigation.getItemDomRefs()[oMonthsRow._oItemNavigation.getFocusedIndex()]).attr("tabindex", "-1"); } _togglePrevNexYearPicker.call(this); this._iMode = 1; }
javascript
{ "resource": "" }
q19250
replaceLambdaVariables
train
function replaceLambdaVariables(sPath, mLambdaVariableToPath) { var aSegments = sPath.split("/"); aSegments[0] = mLambdaVariableToPath[aSegments[0]]; return aSegments[0] ? aSegments.join("/") : sPath; }
javascript
{ "resource": "" }
q19251
train
function(oTable) { return { columnCount: oTable.getColumns().length, visibleColumnCount: TableColumnUtils.TableUtils.getVisibleColumnCount(oTable), columnMap: TableColumnUtils.getColumnMap(oTable) }; }
javascript
{ "resource": "" }
q19252
train
function(oTable) { var i; var oColumn; var oColumnMapItem = {}; var oColumnMap = {}; var aColumns = oTable.getColumns(); var iMaxLevel = TableColumnUtils.TableUtils.getHeaderRowCount(oTable); var oParentReferences = {}; for (var iColumnIndex = 0; iColumnIndex < aColumns.length; iColumnIndex++) { oColumn = aColumns[iColumnIndex]; oColumnMapItem = {}; oColumnMapItem.id = oColumn.getId(); oColumnMapItem.column = oColumn; oColumnMapItem.levelInfo = []; oColumnMapItem.parents = []; for (var iLevel = 0; iLevel < iMaxLevel; iLevel++) { oColumnMapItem.levelInfo[iLevel] = {}; oColumnMapItem.levelInfo[iLevel].spannedColumns = []; var iHeaderSpan = TableColumnUtils.getHeaderSpan(oColumn, iLevel); // collect columns which are spanned by the current column for (i = 1; i < iHeaderSpan; i++) { var oSpannedColumn = aColumns[iColumnIndex + i]; if (oSpannedColumn) { var sPannedColumnId = oSpannedColumn.getId(); oColumnMapItem.levelInfo[iLevel].spannedColumns.push(aColumns[iColumnIndex + i]); if (!oParentReferences[sPannedColumnId]) { oParentReferences[sPannedColumnId] = []; } oParentReferences[sPannedColumnId].push({column: oColumn, level: iLevel}); } } } oColumnMap[oColumnMapItem.id] = oColumnMapItem; } var aColumnIds = Object.keys(oParentReferences); for (i = 0; i < aColumnIds.length; i++) { var sColumnId = aColumnIds[i]; oColumnMap[sColumnId].parents = oParentReferences[sColumnId]; } return oColumnMap; }
javascript
{ "resource": "" }
q19253
train
function(oTable, sColumnId, iLevel) { var oColumnMapItem = TableColumnUtils.getColumnMapItem(oTable, sColumnId); if (!oColumnMapItem) { return undefined; } var aParents = []; for (var i = 0; i < oColumnMapItem.parents.length; i++) { var oParent = oColumnMapItem.parents[i]; if (iLevel === undefined || oParent.level === iLevel) { aParents.push(oParent); } } return aParents; }
javascript
{ "resource": "" }
q19254
train
function(oTable, sColumnId, iLevel) { var oColumnMapItem = TableColumnUtils.getColumnMapItem(oTable, sColumnId); if (!oColumnMapItem) { return undefined; } var aChildren = []; var iEnd; if (iLevel === undefined) { iEnd = oColumnMapItem.levelInfo.length; } else { iEnd = iLevel + 1; } for (var i = iLevel || 0; i < iEnd; i++) { var oLevelInfo = oColumnMapItem.levelInfo[i]; for (var j = 0; j < oLevelInfo.spannedColumns.length; j++) { aChildren.push({column: oLevelInfo.spannedColumns[j], level: i}); } } return aChildren; }
javascript
{ "resource": "" }
q19255
train
function(oColumn) { var oTable = oColumn.getParent(); if (!oTable || !oTable.getEnableColumnReordering()) { // Column reordering is not active at all return false; } var iCurrentIndex = oTable.indexOfColumn(oColumn); if (iCurrentIndex < oTable.getComputedFixedColumnCount() || iCurrentIndex < oTable._iFirstReorderableIndex) { // No movement of fixed columns or e.g. the first column in the TreeTable return false; } if (TableColumnUtils.hasHeaderSpan(oColumn) || TableColumnUtils.getParentSpannedColumns(oTable, oColumn.getId()).length != 0) { // No movement if the column is spanned by an other column or itself defines a span return false; } return true; }
javascript
{ "resource": "" }
q19256
train
function(oColumn, iNewIndex) { var oTable = oColumn.getParent(), iCurrentIndex = oTable.indexOfColumn(oColumn), aColumns = oTable.getColumns(); if (iNewIndex > iCurrentIndex) { // The index is always given for the current table setup // -> A move consists of a remove and an insert, so if a column is moved to a higher index the index must be shifted iNewIndex--; } if (iNewIndex < 0) { iNewIndex = 0; } else if (iNewIndex > aColumns.length) { iNewIndex = aColumns.length; } return iNewIndex; }
javascript
{ "resource": "" }
q19257
train
function(oColumn, iNewIndex) { var oTable = oColumn.getParent(); if (!oTable || iNewIndex === undefined || !TableColumnUtils.isColumnMovable(oColumn)) { // Column is not movable at all return false; } iNewIndex = TableColumnUtils.normalizeColumnMoveTargetIndex(oColumn, iNewIndex); if (iNewIndex < oTable.getComputedFixedColumnCount() || iNewIndex < oTable._iFirstReorderableIndex) { // No movement of fixed columns or e.g. the first column in the TreeTable return false; } var iCurrentIndex = oTable.indexOfColumn(oColumn), aColumns = oTable.getColumns(); if (iNewIndex > iCurrentIndex) { // Column moved to higher index // The column to be moved will appear after this column. var oBeforeColumn = aColumns[iNewIndex >= aColumns.length ? aColumns.length - 1 : iNewIndex]; var oTargetBoundaries = TableColumnUtils.getColumnBoundaries(oTable, oBeforeColumn.getId()); if (TableColumnUtils.hasHeaderSpan(oBeforeColumn) || oTargetBoundaries.endIndex > iNewIndex) { return false; } } else { var oAfterColumn = aColumns[iNewIndex]; // The column to be moved will appear before this column. if (TableColumnUtils.getParentSpannedColumns(oTable, oAfterColumn.getId()).length != 0) { // If column which is currently at the desired target position is spanned by previous columns // also the column to reorder would be spanned after the move. return false; } } return true; }
javascript
{ "resource": "" }
q19258
train
function(oColumn, iNewIndex) { if (!TableColumnUtils.isColumnMovableTo(oColumn, iNewIndex)) { return false; } var oTable = oColumn.getParent(), iCurrentIndex = oTable.indexOfColumn(oColumn); if (iNewIndex === iCurrentIndex) { return false; } iNewIndex = TableColumnUtils.normalizeColumnMoveTargetIndex(oColumn, iNewIndex); var bExecuteDefault = oTable.fireColumnMove({ column: oColumn, newPos: iNewIndex }); if (!bExecuteDefault) { // No execution of the movement when event default is prevented return false; } oTable._bReorderInProcess = true; /* The AnalyticalBinding does not support calls like: * oBinding.updateAnalyticalInfo(...); * oBinding.getContexts(...); * oBinding.updateAnalyticalInfo(...); * oBinding.getContexts(...); * A call chain like above can lead to some problems: * - A request according to the analytical info passed in line 1 would be sent, but not for the info in line 3. * - After the change event (updateRows) the binding returns an incorrect length of 0. * The solution is to only trigger a request at the end of a process. */ oTable.removeColumn(oColumn, true); oTable.insertColumn(oColumn, iNewIndex); oTable._bReorderInProcess = false; return true; }
javascript
{ "resource": "" }
q19259
train
function(oTable, iColumnIndex, iWidth, bFireEvent, iColumnSpan) { if (!oTable || iColumnIndex == null || iColumnIndex < 0 || iWidth == null || iWidth <= 0) { return false; } if (iColumnSpan == null || iColumnSpan <= 0) { iColumnSpan = 1; } if (bFireEvent == null) { bFireEvent = true; } var aColumns = oTable.getColumns(); if (iColumnIndex >= aColumns.length || !aColumns[iColumnIndex].getVisible()) { return false; } var aVisibleColumns = []; for (var i = iColumnIndex; i < aColumns.length; i++) { var oColumn = aColumns[i]; if (oColumn.getVisible()) { aVisibleColumns.push(oColumn); // Consider only the required amount of visible columns. if (aVisibleColumns.length === iColumnSpan) { break; } } } var aResizableColumns = []; for (var i = 0; i < aVisibleColumns.length; i++) { var oVisibleColumn = aVisibleColumns[i]; if (oVisibleColumn.getResizable()) { aResizableColumns.push(oVisibleColumn); } } if (aResizableColumns.length === 0) { return false; } var iSpanWidth = 0; for (var i = 0; i < aVisibleColumns.length; i++) { var oVisibleColumn = aVisibleColumns[i]; iSpanWidth += TableColumnUtils.getColumnWidth(oTable, oVisibleColumn.getIndex()); } var iPixelDelta = iWidth - iSpanWidth; var iSharedPixelDelta = Math.round(iPixelDelta / aResizableColumns.length); var bResizeWasPerformed = false; var oTableElement = oTable.getDomRef(); // Fix Auto Columns if a column in the scrollable area was resized: // Set minimum widths of all columns with variable width except those in aResizableColumns. // As a result, flexible columns cannot shrink smaller as their current width after the resize // (see setMinColWidths in Table.js). if (!TableColumnUtils.TableUtils.isFixedColumn(oTable, iColumnIndex)) { oTable._getVisibleColumns().forEach(function(col) { var width = col.getWidth(), colElement; if (oTableElement && aResizableColumns.indexOf(col) < 0 && TableColumnUtils.TableUtils.isVariableWidth(width)) { colElement = oTableElement.querySelector("th[data-sap-ui-colid=\"" + col.getId() + "\"]"); if (colElement) { col._minWidth = Math.max(colElement.offsetWidth, TableColumnUtils.getMinColumnWidth()); } } }); } // Resize all resizable columns. Share the width change (pixel delta) between them. for (var i = 0; i < aResizableColumns.length; i++) { var oResizableColumn = aResizableColumns[i]; var iColumnWidth = TableColumnUtils.getColumnWidth(oTable, oResizableColumn.getIndex()); var iNewWidth = iColumnWidth + iSharedPixelDelta; var iColMinWidth = TableColumnUtils.getMinColumnWidth(); if (iNewWidth < iColMinWidth) { iNewWidth = iColMinWidth; } var iWidthChange = iNewWidth - iColumnWidth; // Distribute any remaining delta to the remaining columns. if (Math.abs(iWidthChange) < Math.abs(iSharedPixelDelta)) { var iRemainingColumnCount = aResizableColumns.length - (i + 1); iPixelDelta -= iWidthChange; iSharedPixelDelta = Math.round(iPixelDelta / iRemainingColumnCount); } if (iWidthChange !== 0) { var bExecuteDefault = true; var sWidth = iNewWidth + "px"; if (bFireEvent) { bExecuteDefault = oTable.fireColumnResize({ column: oResizableColumn, width: sWidth }); } if (bExecuteDefault) { oResizableColumn.setWidth(sWidth); bResizeWasPerformed = true; } } } return bResizeWasPerformed; }
javascript
{ "resource": "" }
q19260
train
function(sLocationUrl) { // Try to request the har file from the given location url var mHarFileContent = null; var oRequest = new XMLHttpRequest(); oRequest.open("GET", sLocationUrl, false); oRequest.addEventListener("load", function() { if (this.status === 200) { mHarFileContent = JSON.parse(this.responseText); } }); oRequest.send(); try { mHarFileContent = JSON.parse(oRequest.responseText); } catch (e) { throw new Error("Har file could not be loaded."); } // Validate version of the har file if (mHarFileContent && (!mHarFileContent.log || !mHarFileContent.log.version || parseInt(mHarFileContent.log.version, 10) != this.sDefaultMajorHarVersion)) { this.oLog.error(sModuleName + " - Incompatible version. Please provide .har file with version " + this.sDefaultMajorHarVersion + ".x"); } return mHarFileContent; }
javascript
{ "resource": "" }
q19261
train
function(mHarFileContent) { var aEntries; if (!mHarFileContent.log.entries || !mHarFileContent.log.entries.length) { this.oLog.info(sModuleName + " - Empty entries array or the provided har file is empty."); aEntries = []; } else { // Add start and end timestamps to determine the request and response order. aEntries = mHarFileContent.log.entries; for (var i = 0; i < aEntries.length; i++) { aEntries[i]._timestampStarted = new Date(aEntries[i].startedDateTime).getTime(); aEntries[i]._timestampFinished = aEntries[i]._timestampStarted + aEntries[i].time; aEntries[i]._initialOrder = i; } // Sort by response first, then by request to ensure the correct order. this.prepareEntriesOrder(aEntries, "_timestampFinished"); this.prepareEntriesOrder(aEntries, "_timestampStarted"); // Build a map with the sorted entries in the correct custom groups and by URL groups. mHarFileContent._groupedEntries = {}; for (var j = 0; j < aEntries.length; j++) { this.addEntryToMapping(mHarFileContent, aEntries, j); } } mHarFileContent.log.entries = aEntries; return mHarFileContent; }
javascript
{ "resource": "" }
q19262
train
function(sMethod, sUrl) { var sUrlResourcePart = new URI(sUrl).resource(); sUrlResourcePart = this.replaceEntriesUrlByRegex(sUrlResourcePart); return sMethod + sUrlResourcePart; }
javascript
{ "resource": "" }
q19263
train
function(sUrl) { for (var i = 0; i < this.aEntriesUrlReplace.length; i++) { var oEntry = this.aEntriesUrlReplace[i]; if (oEntry.regex instanceof RegExp && oEntry.value !== undefined) { sUrl = sUrl.replace(oEntry.regex, oEntry.value); } else { this.oLog.warning(sModuleName + " - Invalid regular expression for url replace."); } } return sUrl; }
javascript
{ "resource": "" }
q19264
train
function(bDeleteRecordings) { // Check for the filename or ask for it (if configured) var sFilename = (this.sFilename || this.sDefaultFilename); if (this.bPromptForDownloadFilename) { sFilename = window.prompt("Enter file name", sFilename + ".har"); } else { sFilename = sFilename + ".har"; } // The content skeleton var mHarContent = { log: { version: "1.2", creator: { name: "RequestRecorder", version: "1.0" }, entries: this.aRequests } }; // Check if recorded entries should be cleared. if (bDeleteRecordings) { this.deleteRecordedEntries(); } // Inject the data into the dom and download it (if configured). if (!this.bIsDownloadDisabled) { var sString = JSON.stringify(mHarContent, null, 4); var a = document.createElement("a"); document.body.appendChild(a); var oBlob = new window.Blob([sString], { type: "octet/stream" }); var sUrl = window.URL.createObjectURL(oBlob); a.href = sUrl; a.download = sFilename; a.click(); window.URL.revokeObjectURL(sUrl); } return mHarContent; }
javascript
{ "resource": "" }
q19265
train
function(mDelaySettings, iTime) { if (mDelaySettings) { if (mDelaySettings.factor !== undefined && typeof mDelaySettings.factor === 'number') { iTime *= mDelaySettings.factor; } if (mDelaySettings.offset !== undefined && typeof mDelaySettings.offset === 'number') { iTime += mDelaySettings.offset; } if (mDelaySettings.max !== undefined && typeof mDelaySettings.max === 'number') { iTime = Math.min(mDelaySettings.max, iTime); } if (mDelaySettings.min !== undefined && typeof mDelaySettings.min === 'number') { iTime = Math.max(mDelaySettings.min, iTime); } } return iTime; }
javascript
{ "resource": "" }
q19266
train
function(oXhr, oEntry) { var fnRespond = function() { if (oXhr.readyState !== 0) { var sResponseText = oEntry.response.content.text; // Transform headers to the required format for XMLHttpRequests. var oHeaders = {}; oEntry.response.headers.forEach(function(mHeader) { oHeaders[mHeader.name] = mHeader.value; }); // Support for injected callbacks if (typeof sResponseText === "function") { sResponseText = sResponseText(); } oXhr.respond( oEntry.response.status, oHeaders, sResponseText ); } }; // If the request is async, a possible delay will be applied. if (oXhr.async) { // Create new browser task with the setTimeout function to make sure that responses of async requests are not delievered too fast. setTimeout(function() { fnRespond(); }, this.calculateDelay(this.mDelaySettings, oEntry.time)); } else { fnRespond(); } }
javascript
{ "resource": "" }
q19267
train
function(sUrl, aEntriesUrlFilter) { if (this.bIsPaused) { return true; } var that = this; return aEntriesUrlFilter.every(function(regex) { if (regex instanceof RegExp) { return !regex.test(sUrl); } else { that.oLog.error(sModuleName + " - Invalid regular expression for filter."); return true; } }); }
javascript
{ "resource": "" }
q19268
train
function(mOptions) { mOptions = mOptions || {}; if (typeof mOptions !== "object") { throw new Error("Parameter object isn't a valid object"); } // Reset all parameters to default this.mHarFileContent = null; this.aRequests = []; this.sFilename = ""; this.bIsRecording = false; this.bIsPaused = false; this.bIsDownloadDisabled = false; if (this.oSinonXhr) { this.oSinonXhr.filters = this.aSinonFilters; this.aSinonFilters = []; this.oSinonXhr.restore(); this.oSinonXhr = null; } // Restore native XHR functions if they were overwritten. for (var sFunctionName in this.mXhrNativeFunctions) { if (this.mXhrNativeFunctions.hasOwnProperty(sFunctionName)) { window.XMLHttpRequest.prototype[sFunctionName] = this.mXhrNativeFunctions[sFunctionName]; } } this.mXhrNativeFunctions = {}; // Set options to provided values or to default this.bIsDownloadDisabled = mOptions.disableDownload === true; this.bPromptForDownloadFilename = mOptions.promptForDownloadFilename === true; if (mOptions.delay) { if (mOptions.delay === true) { this.mDelaySettings = {}; // Use delay of recording } else { this.mDelaySettings = mOptions.delay; } } else { this.mDelaySettings = { max: 0 }; // default: no delay } if (mOptions.entriesUrlFilter) { if (Array.isArray(mOptions.entriesUrlFilter)) { this.aEntriesUrlFilter = mOptions.entriesUrlFilter; } else { this.aEntriesUrlFilter = [mOptions.entriesUrlFilter]; } } else { this.aEntriesUrlFilter = [new RegExp(".*")]; // default: no filtering } if (mOptions.entriesUrlReplace) { if (Array.isArray(mOptions.entriesUrlReplace)) { this.aEntriesUrlReplace = mOptions.entriesUrlReplace; } else { this.aEntriesUrlReplace = [mOptions.entriesUrlReplace]; } } else { this.aEntriesUrlReplace = []; } if (mOptions.customGroupNameCallback && typeof mOptions.customGroupNameCallback === "function") { this.fnCustomGroupNameCallback = mOptions.customGroupNameCallback; } else { this.fnCustomGroupNameCallback = function() { return false; }; // default: Empty Callback function used } }
javascript
{ "resource": "" }
q19269
train
function(locationUrl, options) { try { // Try to start play-mode this.play(locationUrl, options); } catch (e) { // If play-mode could not be started, try to record instead. var oUri = new URI(locationUrl); var sExtension = oUri.suffix(); // Check if the provided URL is a har file, maybe the wrong url is provided if (sExtension != "har") { _private.oLog.warning(sModuleName + " - Invalid file extension: " + sExtension + ", please use '.har' files."); } this.record(oUri.filename().replace("." + sExtension, ""), options); } }
javascript
{ "resource": "" }
q19270
train
function(filename, options) { _private.oLog.info(sModuleName + " - Record"); if (window.XMLHttpRequest.name === 'FakeXMLHttpRequest') { _private.oLog.warning(sModuleName + " - Sinon FakeXMLHttpRequest is enabled by another application, recording could be defective"); } if (_private.isRecordStarted()) { _private.oLog.error(sModuleName + " - RequestRecorder is already recording, please stop first..."); return; } _private.init(options); _private.sFilename = filename; _private.bIsRecording = true; // Overwrite the open method to get the required request parameters (method, URL, headers) and assign // a group name if provided. _private.mXhrNativeFunctions.open = window.XMLHttpRequest.prototype.open; window.XMLHttpRequest.prototype.open = function() { this._requestParams = this._requestParams || {}; this._requestParams.method = arguments[0]; this._requestParams.url = arguments[1]; this._requestParams.customGroupName = _private.fnCustomGroupNameCallback(); this._requestParams.headers = this._requestParams.headers || []; _private.mXhrNativeFunctions.open.apply(this, arguments); }; // Overwrite the setRequestHeader method to record the request headers. _private.mXhrNativeFunctions.setRequestHeader = window.XMLHttpRequest.prototype.setRequestHeader; window.XMLHttpRequest.prototype.setRequestHeader = function(sHeaderName, sHeaderValue) { this._requestParams = this._requestParams || { headers: [] }; this._requestParams.headers.push({ name: sHeaderName, value: sHeaderValue }); _private.mXhrNativeFunctions.setRequestHeader.apply(this, arguments); }; // Overwrite the send method to get the response and the collected data from the XMLHttpRequest _private.mXhrNativeFunctions.send = window.XMLHttpRequest.prototype.send; window.XMLHttpRequest.prototype.send = function() { if (!_private.isUrlFiltered(this._requestParams.url, _private.aEntriesUrlFilter)) { var fTimestamp = _private.preciseDateNow(); // If the onreadystatechange is already specified by another application, it is called, too. var fnOldStateChanged = this.onreadystatechange; this.onreadystatechange = function() { if (this.readyState === 4) { _private.aRequests.push(_private.prepareRequestForHar(this, fTimestamp)); _private.oLog.info( sModuleName + " - Record XMLHttpRequest. Method: " + this._requestParams.method + ", URL: " + this._requestParams.url ); } if (fnOldStateChanged) { fnOldStateChanged.apply(this, arguments); } }; } _private.mXhrNativeFunctions.send.apply(this, arguments); }; }
javascript
{ "resource": "" }
q19271
train
function() { _private.oLog.info(sModuleName + " - Stop"); var mHarContent = null; if (_private.isRecordStarted()) { mHarContent = _private.getHarContent(true); } // do this for a full cleanup _private.init(); return mHarContent; }
javascript
{ "resource": "" }
q19272
train
function(deleteRecordings) { var bDeleteRecordings = deleteRecordings || false; _private.oLog.info(sModuleName + " - Get Recordings"); return _private.getHarContent(bDeleteRecordings); }
javascript
{ "resource": "" }
q19273
train
function(url, response, method, status, headers) { var aHeaders = headers || []; aHeaders.push({ "name": "Content-Type", "value": "application/json;charset=utf-8" }); this.addResponse(url, response, method, status, aHeaders); }
javascript
{ "resource": "" }
q19274
train
function(url, response, method, status, headers) { if (!_private.isPlayStarted()) { throw new Error("Start the player first before you add a response."); } var sMethod = method || "GET"; var aHeaders = headers || [{ "name": "Content-Type", "value": "text/plain;charset=utf-8" }]; var iStatus = status || 200; var oEntry = { "startedDateTime": new Date().toISOString(), "time": 0, "request": { "headers": [], "url": url, "method": sMethod }, "response": { "status": iStatus, "content": { "text": response }, "headers": aHeaders } }; var iIndex = _private.mHarFileContent.log.entries.push(oEntry) - 1; _private.addEntryToMapping(_private.mHarFileContent, _private.mHarFileContent.log.entries, iIndex); }
javascript
{ "resource": "" }
q19275
remove
train
function remove(id) { var oItem = sap.ui.getCore().byId(id); if (oItem) { oItem.destroy(); } }
javascript
{ "resource": "" }
q19276
train
function(oContext) { var oGroup = this.fnGroup(oContext); if (typeof oGroup === "string" || typeof oGroup === "number" || typeof oGroup === "boolean" || oGroup == null) { oGroup = { key: oGroup }; } return oGroup; }
javascript
{ "resource": "" }
q19277
location
train
function location(doclet) { var filename = (doclet.meta && doclet.meta.filename) || "unknown"; return " #" + ui5data(doclet).id + "@" + filename + (doclet.meta.lineno != null ? ":" + doclet.meta.lineno : "") + (doclet.synthetic ? "(synthetic)" : ""); }
javascript
{ "resource": "" }
q19278
unwrap
train
function unwrap(docletSrc) { if (!docletSrc) { return ''; } // note: keep trailing whitespace for @examples // extra opening/closing stars are ignored // left margin is considered a star and a space // use the /m flag on regex to avoid having to guess what this platform's newline is docletSrc = docletSrc.replace(/^\/\*\*+/, '') // remove opening slash+stars .replace(/\**\*\/$/, "\\Z") // replace closing star slash with end-marker .replace(/^\s*(\* ?|\\Z)/gm, '') // remove left margin like: spaces+star or spaces+end-marker .replace(/\s*\\Z$/g, ''); // remove end-marker return docletSrc; }
javascript
{ "resource": "" }
q19279
preprocessComment
train
function preprocessComment(e) { var src = e.comment; // add a default visibility if ( !/@private|@public|@protected|@sap-restricted|@ui5-restricted/.test(src) ) { src = unwrap(src); src = src + "\n@private"; src = wrap(src); // console.log("added default visibility to '" + src + "'"); } if ( /@class/.test(src) && /@static/.test(src) ) { warning("combination of @class and @static is no longer supported with jsdoc3, converting it to @namespace and @classdesc: (line " + e.lineno + ")"); src = unwrap(src); src = src.replace(/@class/, "@classdesc").replace(/@static/, "@namespace"); src = wrap(src); //console.log(src); } return src; }
javascript
{ "resource": "" }
q19280
train
function(e) { pathPrefixes = env.opts._.reduce(function(result, fileOrDir) { fileOrDir = path.resolve( path.normalize(fileOrDir) ); if ( fs.statSync(fileOrDir).isDirectory() ) { // ensure a trailing path separator if ( fileOrDir.indexOf(path.sep, fileOrDir.length - path.sep.length) < 0 ) { fileOrDir += path.sep; } result.push(fileOrDir); } return result; }, []); resourceNamePrefixes = pluginConfig.resourceNamePrefixes || []; if ( !Array.isArray(resourceNamePrefixes) ) { resourceNamePrefixes = [resourceNamePrefixes]; } resourceNamePrefixes.forEach(ensureEndingSlash); while ( resourceNamePrefixes.length < pathPrefixes.length ) { resourceNamePrefixes.push(''); } debug("path prefixes " + JSON.stringify(pathPrefixes)); debug("resource name prefixes " + JSON.stringify(resourceNamePrefixes)); }
javascript
{ "resource": "" }
q19281
train
function (e) { currentProgram = undefined; currentModule = { name: null, resource: getResourceName(e.filename), module: getModuleName(getResourceName(e.filename)), localNames: Object.create(null) }; }
javascript
{ "resource": "" }
q19282
train
function(a, fnCallback) { var o = {}; if (a) { for (var i = 0, l = a.length; i < l; i++) { var oValue = a[i]; if (typeof oValue === "string") { o[oValue] = typeof fnCallback === "function" && fnCallback(oValue) || {}; } } } return o; }
javascript
{ "resource": "" }
q19283
parse
train
function parse(sValue) { sValue = sValue.trim(); var oTokenizer = new JSTokenizer(); var aResult = []; var sBuffer = ""; var iParenthesesCounter = 0; oTokenizer.init(sValue, 0); for (;;) { var sSymbol = oTokenizer.next(); if ( sSymbol === '"' || sSymbol === "'" ) { var pos = oTokenizer.getIndex(); oTokenizer.string(); sBuffer += sValue.slice(pos, oTokenizer.getIndex()); sSymbol = oTokenizer.getCh(); } if ( !sSymbol ) { break; } switch (sSymbol) { case "(": iParenthesesCounter++; break; case ")": iParenthesesCounter--; break; } if (sSymbol === ";" && iParenthesesCounter === 0) { aResult.push(sBuffer.trim()); sBuffer = ""; } else { sBuffer += sSymbol; } } if (sBuffer) { aResult.push(sBuffer.trim()); } return aResult; }
javascript
{ "resource": "" }
q19284
initPreprocessor
train
function initPreprocessor(oPreprocessor, bAsync) { var oPreprocessorImpl; if (typeof oPreprocessor.preprocessor === "string") { var sPreprocessorName = oPreprocessor.preprocessor.replace(/\./g, "/"); // module string given, resolve and retrieve object if (bAsync) { return new Promise(function(resolve, reject) { sap.ui.require([sPreprocessorName], function(oPreprocessorImpl) { resolve(oPreprocessorImpl); }); }); } else { return sap.ui.requireSync(sPreprocessorName); } } else if (typeof oPreprocessor.preprocessor === "function" && !oPreprocessor.preprocessor.process) { oPreprocessorImpl = { process: oPreprocessor.preprocessor }; } else { oPreprocessorImpl = oPreprocessor.preprocessor; } if (bAsync) { return Promise.resolve(oPreprocessorImpl); } else { return oPreprocessorImpl; } }
javascript
{ "resource": "" }
q19285
initPreprocessorQueues
train
function initPreprocessorQueues(oView, mSettings) { var oViewClass = oView.getMetadata().getClass(); function resolvePreprocessors(oPreprocessor) { oPreprocessor.preprocessor = initPreprocessor(oPreprocessor, mSettings.async); } // shallow copy to avoid issues when manipulating the internal object structure oView.mPreprocessors = jQuery.extend({}, mSettings.preprocessors); for (var _sType in oViewClass.PreprocessorType) { // build the array structure var sType = oViewClass.PreprocessorType[_sType]; if (oView.mPreprocessors[sType] && !Array.isArray(oView.mPreprocessors[sType])) { oView.mPreprocessors[sType] = [oView.mPreprocessors[sType]]; } else if (!oView.mPreprocessors[sType]) { oView.mPreprocessors[sType] = []; } oView.mPreprocessors[sType].forEach(alignPreprocessorStructure); oView.mPreprocessors[sType] = getPreprocessorQueue.call(oView, oViewClass._sType, sType); oView.mPreprocessors[sType].forEach(resolvePreprocessors); } }
javascript
{ "resource": "" }
q19286
train
function(oThis, mSettings) { if (!sap.ui.getCore().getConfiguration().getControllerCodeDeactivated()) { // only set when used internally var oController = mSettings.controller, sName = oController && typeof oController.getMetadata === "function" && oController.getMetadata().getName(), bAsync = mSettings.async; if (!oController && oThis.getControllerName) { // get optional default controller name var defaultController = oThis.getControllerName(); if (defaultController) { // check for controller replacement var CustomizingConfiguration = sap.ui.require('sap/ui/core/CustomizingConfiguration'); var sControllerReplacement = CustomizingConfiguration && CustomizingConfiguration.getControllerReplacement(defaultController, ManagedObject._sOwnerId); if (sControllerReplacement) { defaultController = typeof sControllerReplacement === "string" ? sControllerReplacement : sControllerReplacement.controllerName; } // create controller if (bAsync) { oController = Controller.create({name: defaultController}); } else { oController = sap.ui.controller(defaultController, true /* oControllerImpl = true: do not extend controller inside factory; happens below (potentially async)! */); } } } else if (oController) { // if passed controller is not extended yet we need to do it. var sOwnerId = ManagedObject._sOwnerId; if (!oController._isExtended()) { if (bAsync) { oController = Controller.extendByCustomizing(oController, sName, bAsync) .then(function(oController) { return Controller.extendByProvider(oController, sName, sOwnerId, bAsync); }); } else { oController = Controller.extendByCustomizing(oController, sName, bAsync); oController = Controller.extendByProvider(oController, sName, sOwnerId, bAsync); } } else if (bAsync) { oController = Promise.resolve(oController); } } if ( oController ) { var connectToView = function(oController) { oThis.oController = oController; oController.oView = oThis; }; if (bAsync) { if (!oThis.oAsyncState) { throw new Error("The view " + oThis.sViewName + " runs in sync mode and therefore cannot use async controller extensions!"); } return oController.then(connectToView); } else { connectToView(oController); } } } else { sap.ui.controller("sap.ui.core.mvc.EmptyControllerImpl", {"_sap.ui.core.mvc.EmptyControllerImpl":true}); oThis.oController = sap.ui.controller("sap.ui.core.mvc.EmptyControllerImpl"); } }
javascript
{ "resource": "" }
q19287
preProcessSymbols
train
function preProcessSymbols(symbols) { // Create treeName and modify module names symbols.forEach(oSymbol => { let sModuleClearName = oSymbol.name.replace(/^module:/, ""); oSymbol.displayName = sModuleClearName; oSymbol.treeName = sModuleClearName.replace(/\//g, "."); }); // Create missing - virtual namespaces symbols.forEach(oSymbol => { oSymbol.treeName.split(".").forEach((sPart, i, a) => { let sName = a.slice(0, (i + 1)).join("."); if (!symbols.find(o => o.treeName === sName)) { symbols.push({ name: sName, displayName: sName, treeName: sName, lib: oSymbol.lib, kind: "namespace" }); } }); }); // Discover parents symbols.forEach(oSymbol => { let aParent = oSymbol.treeName.split("."), sParent; // Extract parent name aParent.pop(); sParent = aParent.join("."); // Mark parent if (symbols.find(({treeName}) => treeName === sParent)) { oSymbol.parent = sParent; } }); // Attach children info symbols.forEach(oSymbol => { if (oSymbol.parent) { let oParent = symbols.find(({treeName}) => treeName === oSymbol.parent); if (!oParent.nodes) oParent.nodes = []; oParent.nodes.push({ name: oSymbol.displayName, description: formatters._preProcessLinksInTextBlock(oSymbol.description), href: "#/api/" + encodeURIComponent(oSymbol.name) }); } }); // Clean list - keep file size down symbols.forEach(o => { delete o.treeName; delete o.parent; }); }
javascript
{ "resource": "" }
q19288
createApiRefApiJson
train
function createApiRefApiJson(oChainObject) { if (returnOutputFiles) { // If requested, return data instead of writing to FS (required by UI5 Tooling/UI5 Builder) return JSON.stringify(oChainObject.parsedData); } let sOutputDir = path.dirname(oChainObject.outputFile); // Create dir if it does not exist if (!fs.existsSync(sOutputDir)) { fs.mkdirSync(sOutputDir); } // Write result to file fs.writeFileSync(oChainObject.outputFile, JSON.stringify(oChainObject.parsedData) /* Transform back to string */, 'utf8'); }
javascript
{ "resource": "" }
q19289
getLibraryPromise
train
function getLibraryPromise(oChainObject) { return new Promise(function(oResolve) { fs.readFile(oChainObject.libraryFile, 'utf8', (oError, oData) => { oChainObject.libraryFileData = oData; oResolve(oChainObject); }); }); }
javascript
{ "resource": "" }
q19290
extractComponentAndDocuindexUrl
train
function extractComponentAndDocuindexUrl(oChainObject) { oChainObject.modules = []; if (oChainObject.libraryFileData) { let $ = cheerio.load(oChainObject.libraryFileData, { ignoreWhitespace: true, xmlMode: true, lowerCaseTags: false }); // Extract documentation URL oChainObject.docuPath = $("appData documentation").attr("indexUrl"); // Extract components $("ownership > component").each((i, oComponent) => { if (oComponent.children) { if (oComponent.children.length === 1) { oChainObject.defaultComponent = $(oComponent).text(); } else { let sCurrentComponentName = $(oComponent).find("name").text(); let aCurrentModules = []; $(oComponent).find("module").each((a, oC) => { aCurrentModules.push($(oC).text().replace(/\//g, ".")); }); oChainObject.modules.push({ componentName: sCurrentComponentName, modules: aCurrentModules }); } } }); } return oChainObject; }
javascript
{ "resource": "" }
q19291
flattenComponents
train
function flattenComponents(oChainObject) { if (oChainObject.modules && oChainObject.modules.length > 0) { oChainObject.customSymbolComponents = {}; oChainObject.modules.forEach(oComponent => { let sCurrentComponent = oComponent.componentName; oComponent.modules.forEach(sModule => { oChainObject.customSymbolComponents[sModule] = sCurrentComponent; }); }); } return oChainObject; }
javascript
{ "resource": "" }
q19292
extractSamplesFromDocuIndex
train
function extractSamplesFromDocuIndex(oChainObject) { // If we have not extracted docuPath we return early if (!oChainObject.docuPath) { return oChainObject; } return new Promise(function(oResolve) { // Join .library path with relative docuindex.json path let sPath = path.join(path.dirname(oChainObject.libraryFile), oChainObject.docuPath); // Normalize path to resolve relative path sPath = path.normalize(sPath); fs.readFile(sPath, 'utf8', (oError, oFileData) => { if (!oError) { oFileData = JSON.parse(oFileData); if (oFileData.explored && oFileData.explored.entities && oFileData.explored.entities.length > 0) { oChainObject.entitiesWithSamples = []; oFileData.explored.entities.forEach(oEntity => { oChainObject.entitiesWithSamples.push(oEntity.id); }); } } // We aways resolve as this data is not mandatory oResolve(oChainObject); }); }); }
javascript
{ "resource": "" }
q19293
getAPIJSONPromise
train
function getAPIJSONPromise(oChainObject) { return new Promise(function(oResolve, oReject) { fs.readFile(sInputFile, 'utf8', (oError, sFileData) => { if (oError) { oReject(oError); } else { oChainObject.fileData = JSON.parse(sFileData); oResolve(oChainObject); } }); }); }
javascript
{ "resource": "" }
q19294
train
function (target) { var result = ""; if (target) { target.forEach(function (element) { result += element + '<br>'; }); } result = this._preProcessLinksInTextBlock(result); return result; }
javascript
{ "resource": "" }
q19295
train
function (namespace) { var result, aNamespaceParts = namespace.split("."); if (aNamespaceParts[0] === "Org" && aNamespaceParts[1] === "OData") { result = '<a href="' + this.ANNOTATIONS_NAMESPACE_LINK + namespace + '.xml">' + namespace + '</a>'; } else { result = namespace; } result = this._preProcessLinksInTextBlock(result); return result; }
javascript
{ "resource": "" }
q19296
train
function (description, since) { var result = description || ""; result += '<br>For more information, see ' + this.handleExternalUrl(this.ANNOTATIONS_LINK, "OData v4 Annotations"); if (since) { result += '<br><br><i>Since: ' + since + '.</i>'; } result = this._preProcessLinksInTextBlock(result); return result; }
javascript
{ "resource": "" }
q19297
train
function (description, since) { var result = description || ""; if (since) { result += '<br><br><i>Since: ' + since + '.</i>'; } result = this._preProcessLinksInTextBlock(result); return result; }
javascript
{ "resource": "" }
q19298
train
function (defaultValue) { var sReturn; switch (defaultValue) { case null: case undefined: sReturn = ''; break; case '': sReturn = 'empty string'; break; default: sReturn = defaultValue; } return Array.isArray(sReturn) ? sReturn.join(', ') : sReturn; }
javascript
{ "resource": "" }
q19299
train
function (name, params) { var result = '<pre class="prettyprint">new '; if (name) { result += name + '('; } if (params) { params.forEach(function (element, index, array) { result += element.name; if (element.optional) { result += '?'; } if (index < array.length - 1) { result += ', '; } }); } if (name) { result += ')</pre>'; } return result; }
javascript
{ "resource": "" }