_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q57400
train
function (evt) { var uArray = ariaUtilsArray; if (!evt || !evt.changedProperties || uArray.contains(evt.changedProperties, "decimalFormatSymbols") || uArray.contains(evt.changedProperties, "currencyFormats")) { var symbols = ariaUtilsEnvironmentNumber.getDecimalFormatSymbols(); var formats = ariaUtilsEnvironmentNumber.getCurrencyFormats(); var exps = this._buildRegEx(symbols.groupingSeparator, symbols.decimalSeparator); if (exps.valid) { this._removeGrouping = exps.group; this._replaceDecimal = exps.decimal; this._decimal = symbols.decimalSeparator; this._grouping = symbols.groupingSeparator; this._strictGrouping = symbols.strictGrouping; } var uType = ariaUtilsType; if (!uType.isString(formats.currencyFormat) && !uType.isFunction(formats.currencyFormat)) { this.$logError(this.INVALID_FORMAT, ["currencyFormat", this.CURRENCY_BEAN]); // still valid for building the regular expressions } else { this._format = formats.currencyFormat; this._currency = formats.currencySymbol; } } }
javascript
{ "resource": "" }
q57401
train
function (integer, patternDescription, formatSymbols) { if (!patternDescription.hasGrouping) { // No grouping is used in the pattern, no need to do anything return integer; } var grouping = formatSymbols.groupingSeparator, pattern = patternDescription.integer, repeat = patternDescription.regularGroup; var lengths = []; if (repeat > 0) { lengths = repeat; } else { // The pattern is not regular, build the array for chunk var tokens = pattern.split(","); for (var i = tokens.length - 1; i > 0; i -= 1) { // The last token shouldn't be considered because it should contain the remainings lengths.push(tokens[i].length); } } return ariaUtilsString.chunk(integer, lengths).join(grouping); }
javascript
{ "resource": "" }
q57402
train
function (information) { var event = information.event; var keyCode = event.keyCode; if (this._isShiftF10Pressed(event) || (keyCode == ariaDomEvent.KC_ARROW_UP && this._checkCloseItem(information))) { this.focus(); this._toggleDropdown(); return true; } if (keyCode == ariaDomEvent.KC_ESCAPE) { if (this._dropDownOpen) { this._toggleDropdown(); return true; } } if (keyCode == ariaDomEvent.KC_TAB) { return true; } return false; }
javascript
{ "resource": "" }
q57403
train
function () { this.navigationInterceptor.destroyElements(); this.navigationInterceptor = null; if (this._cfg.waiAria) { var dropDownIcon = this._getDropdownIcon(); if (dropDownIcon) { dropDownIcon.setAttribute("aria-expanded", "false"); } } this._setPopupOpenProperty(false); this.controller.setListWidget(null); var report = null; // Check _toggleDropdown already triggered if (!this._hasFocus) { // Added to keep the behaviour similar to click on close button click PTR 04661445 report = this.controller.toggleDropdown(this.getTextInputField().value, this._dropdownPopup != null); // to reset the dropdown display report.displayDropDown = false; } this.$DropDownTextInput._afterDropdownClose.call(this); if (report) { this._reactToControllerReport(report, { hasFocus : false }); // note that _reactToControllerReport might destroy the widget (this._cfg may be null here) } this._dropDownOpen = false; this.refreshPopup = false; this._keepFocus = false; }
javascript
{ "resource": "" }
q57404
train
function () { var waiAria = this._cfg.waiAria; this.navigationInterceptor = DomNavigationManager.ModalNavigationHandler(this._dropdownPopup.domElement, !waiAria); this.navigationInterceptor.ensureElements(); this._setPopupOpenProperty(true); // when the popup is clicked, don't give it focus, allow focus to be passed to the List in _refreshPopup this._keepFocus = true; var list = this.controller.getListWidget(); this._dropDownOpen = true; this._focusMultiSelect(list); if (waiAria) { var dropDownIcon = this._getDropdownIcon(); if (dropDownIcon) { dropDownIcon.setAttribute("aria-expanded", "true"); } } }
javascript
{ "resource": "" }
q57405
train
function (evt, args) { if (this._dropdownPopup) { this.refreshPopup = true; this._dropdownPopup.refresh(); } this._focusMultiSelect(args.list); }
javascript
{ "resource": "" }
q57406
train
function () { // clean this._data.templates = []; this._data.modules = []; this._data.dataFragments = []; // refresh var startTemplates = this._data.templates; var startModules = this._data.modules; var startDatas = this._data.dataFragments; // this two should change if not null, as new objects are created. var selectedTemplate = this._data.selectedTemplate; var selectedModule = this._data.selectedModule; // The previous way of retrieving elements was to recursively look in the DOM // But a problem appeared with this when event delegation was implemented (because DOM elements // do not have any more a reference to the widget instance object until the getDom() method on the widget is // called, which may not happen at all, so we cannot recognize corresponding widgets). // We now use the hierarchies from the refresh manager. var refreshMgr = this.bridge.getAriaPackage().templates.RefreshManager; if (refreshMgr != null) { refreshMgr.updateHierarchies(); var hierarchies = refreshMgr.getHierarchies(); this._convertRefreshMgrHierarchies(hierarchies, startTemplates, startModules, startDatas); } // not used now, but could be used later to display customizations in the inspector // this._data.customizations = this.bridge.getAriaPackage().environment.Environment.getCustomizations(); // if not -> nullify if (selectedTemplate == this._data.selectedTemplate) { this._data.selectedTemplate = null; } if (selectedModule == this._data.selectedModule) { this._data.selectedModule = null; } this.$raiseEvent("contentChanged"); }
javascript
{ "resource": "" }
q57407
train
function (hierarchies, startTemplates, startModules, startDatas, widgetsContainer) { for (var i = 0, l = hierarchies.length; i < l; i++) { this._convertRefreshMgrHierarchy(hierarchies[i], startTemplates, startModules, startDatas, widgetsContainer); } }
javascript
{ "resource": "" }
q57408
train
function (node, tplContainer, moduleContainer, dataFragmentsContainer, widgetsContainer) { if (node.type == "template" || node.type == "templateWidget") { var templateCtxt = node.elem; if (node.type == "templateWidget") { if (templateCtxt.behavior) { templateCtxt = templateCtxt.behavior.subTplCtxt; } else { templateCtxt = templateCtxt.subTplCtxt; } } var selectedTemplate = this._data.selectedTemplate; var selectedModule = this._data.selectedModule; var subContent = [], widgets = [], moduleRegistered = false, moduleDescription; var moduleCtrlFactory = this.bridge.getAriaPackage().templates.ModuleCtrlFactory; this.$assert(190, !!templateCtxt); this.$assert(191, !!moduleCtrlFactory); // var data = templateCtxt.data; var moduleCtrl = templateCtxt.moduleCtrl; if (moduleCtrl) { // check if module is already in the list of modules of the application for (var index = 0, len = moduleContainer.length; index < len; index++) { moduleDescription = moduleContainer[index]; if (moduleDescription.moduleCtrl == moduleCtrl) { // if it was a subtemplate with the same module, current would be true -> new outer template if (!moduleDescription.current) { moduleDescription.outerTemplateCtxts.push(templateCtxt); moduleDescription.current = true; } moduleRegistered = true; } else { moduleDescription.current = false; } } // if not, add it, with current dom to identify if (!moduleRegistered) { var newModuleDescription = { moduleCtrl : moduleCtrl, outerTemplateCtxts : [templateCtxt], current : true, isReloadable : moduleCtrlFactory.isModuleCtrlReloadable(moduleCtrl) }; if (selectedModule && selectedModule.moduleCtrl == moduleCtrl) { this._data.selectedModule = newModuleDescription; } moduleContainer.push(newModuleDescription); } } var templateDescription = { templateCtxt : templateCtxt, content : subContent, moduleCtrl : moduleCtrl, widgets : widgets }; if (selectedTemplate && selectedTemplate.templateCtxt == templateCtxt) { this._data.selectedTemplate = templateDescription; } tplContainer.push(templateDescription); widgetsContainer = widgets; tplContainer = subContent; } else if (node.type == "widget") { var widget = node.elem.behavior; // register widgets if (widgetsContainer && widget) { var widgetDescription = { widget : widget }; widgetsContainer.push(widgetDescription); if (node.content) { var content = []; widgetDescription.content = content; widgetsContainer = content; } } } // else if (node.type == "section") { // we do not currently display sections in the inspector (but this could be improved in the future) // } if (node.content) { this._convertRefreshMgrHierarchies(node.content, tplContainer, moduleContainer, dataFragmentsContainer, widgetsContainer); } }
javascript
{ "resource": "" }
q57409
train
function (domElt, color) { this.clearHightlight(); color = color ? color : "#ACC2FF"; var pos = this.bridge.getAriaPackage().utils.Dom.calculatePosition(domElt); var marker = this.bridge.getDocument().createElement('div'); marker.style.cssText = ["position:absolute;top:", pos.top, "px;left:", pos.left, "px;width:", ((domElt.offsetWidth - 8 > 0) ? domElt.offsetWidth - 8 : 0), "px;height:", ((domElt.offsetHeight - 8 > 0) ? domElt.offsetHeight - 8 : 0), "px; border:dashed 4px " + color + ";z-index: 999999999999999;z-index: 999999999999999;"].join(''); this._holder.appendChild(marker); marker = null; this._hideTimeout = setTimeout(aria.utils.Function.bind(this.clearHightlight, this), 2000); }
javascript
{ "resource": "" }
q57410
train
function (templateCtxt, tplSource) { ariaUtilsJson.setValue(this._data, "locked", true); if (tplSource) { tplSource = this._data.selectedTemplate.tplSrcEdit; } // do some cleaning this.clearHightlight(); // do not close if target IS the contextual menu if (this._mainContextual && templateCtxt.tplClasspath != this._mainContextual.CONTEXTUAL_TEMPLATE_CLASSPATH) { this._mainContextual.close(); } // replace in this scope Aria and aria var oSelf = this; var doIt = function () { // var Aria = oSelf.bridge.getAria(), aria = oSelf.bridge.getAriaPackage(); // ... and call for reload templateCtxt.$reload(tplSource, { fn : oSelf._unlock, scope : oSelf }); }; doIt(); }
javascript
{ "resource": "" }
q57411
train
function (moduleCtrl) { var moduleFactory = this.bridge.getAriaPackage().templates.ModuleCtrlFactory; ariaUtilsJson.setValue(this._data, "locked", true); // do some cleaning this.clearHightlight(); moduleFactory.reloadModuleCtrl(moduleCtrl, { fn : this._unlock, scope : this }); }
javascript
{ "resource": "" }
q57412
train
function (templateCtxt) { var moduleCtrl = templateCtxt.moduleCtrlPrivate; // find associated module var modules = this._data.modules, i, l; for (i = 0, l = modules.length; i < l; i++) { if (modules[i].moduleCtrl == moduleCtrl) { this._data.selectedModule = modules[i]; break; } else { this._data.selectedModule = null; } } // find associated template description this._data.selectedTemplate = this._findTemplateDes(this._data.templates, templateCtxt); }
javascript
{ "resource": "" }
q57413
train
function (container, templateCtxt) { var contentSearch = null, i, l; for (i = 0, l = container.length; i < l; i++) { var description = container[i]; if (description.templateCtxt == templateCtxt) { return description; } else { contentSearch = this._findTemplateDes(description.content, templateCtxt); if (contentSearch) { return contentSearch; } } } return null; }
javascript
{ "resource": "" }
q57414
train
function (cfg) { var hasChanged = false, prefName, newVal; var prefs = ['maxWidth', 'maxHeight', 'minWidth', 'width', 'height']; for (var i = 0, len = prefs.length; i < len; i++) { prefName = prefs[i]; newVal = cfg[prefName]; if (newVal && newVal != this._cfg[prefName]) { this._cfg[prefName] = newVal; hasChanged = true; } } if (cfg.maximized !== this._cfg.maximized) { this._cfg.maximized = cfg.maximized; hasChanged = true; } if (cfg.maximized) { this._cfg.widthMaximized = cfg.widthMaximized; this._cfg.heightMaximized = cfg.heightMaximized; hasChanged = true; } else { this._cfg.widthMaximized = null; this._cfg.heightMaximized = null; } if (hasChanged) { this.$Container._updateSize.call(this); } }
javascript
{ "resource": "" }
q57415
train
function (args) { var div = args.cfg.tplDiv; if (div) { aria.utils.Dom.replaceHTML(div, "#TEMPLATE ERROR#"); } this.$callback(args.cb, { success : false }); }
javascript
{ "resource": "" }
q57416
train
function (classes, printOptions) { classes = classes.replace(/(\s|^)\s*xPrint\w*/g, ''); if (printOptions == "adaptX") { classes += " xPrintAdaptX"; } else if (printOptions == "adaptY") { classes += " xPrintAdaptY"; } else if (printOptions == "adaptXY") { classes += " xPrintAdaptX xPrintAdaptY"; } else if (printOptions == "hidden") { classes += " xPrintHide"; } return classes; }
javascript
{ "resource": "" }
q57417
train
function (cfg, cb) { var appE = Aria.getClassRef("aria.core.environment.Customizations"); if (appE && appE.isCustomized() && !appE.descriptorLoaded()) { // the application is customized but the descriptor hasn't been loaded yet: register to the event appE.$onOnce({ 'descriptorLoaded' : { fn : this._startLoad, scope : this, args : { cfg : cfg, cb : cb } } }); } else { // no descriptor was specified, or it has already been loaded: go ahead this._startLoad(null, { cfg : cfg, cb : cb }); } }
javascript
{ "resource": "" }
q57418
train
function (div) { if (typeof(div) == "string") { div = aria.utils.Dom.getElementById(div); } if (aria && aria.utils && aria.utils.Dom) { return aria.templates.TemplateCtxtManager.disposeFromDom(div); } }
javascript
{ "resource": "" }
q57419
train
function (cfg) { if (!ariaCoreJsonValidator.normalize({ json : cfg, beanName : "aria.templates.CfgBeans.InitCSSTemplateCfg" })) { return false; } this._cfg = cfg; // Get an insatnce of the CSS template var tpl = Aria.getClassInstance(cfg.classpath); if (!tpl) { this.$logError(this.TEMPLATE_CONSTR_ERROR, [cfg.classpath]); return false; } this._tpl = tpl; // Main macro (not configurable) cfg.macro = this.checkMacro({ name : "main", args : cfg.args }); this.tplClasspath = cfg.classpath; // We no longer create new methods in a closure each time a new instance of a template is created, // instead we use the interface mechanism to expose methods to the template and prevent access to the // template context ariaTemplatesICSS.call(tpl, this); // TEMPORARY PERF IMPROVMENT : interface on these two functions results in poor performances. // Investigation ongoing on interceptors var oSelf = this; tpl.__$write = function () { return oSelf.__$write.apply(oSelf, arguments); }; if (!tpl.__$initTemplate()) { return false; } this.__loadLibs(tpl.__$csslibs, "csslibs"); return true; }
javascript
{ "resource": "" }
q57420
train
function () { if (this.__cachedOutput) { return this.__cachedOutput; } // Call the main macro to let the template engine evaluate the text this.$assert(156, this._out == null); this._out = []; this._callMacro(null, "main"); var text = this._out.join(""); if (ariaCoreAppEnvironment.applicationSettings.hasOwnProperty("imgUrlMapping") && ariaCoreAppEnvironment.applicationSettings.imgUrlMapping !== null) { text = this._prefixCSSImgUrl(text); } this._out = null; this.__cachedOutput = text; return text; }
javascript
{ "resource": "" }
q57421
train
function (classPrefix) { var text = this._getOutput(); // Format the prefix for the CSS text var prefix = "." + classPrefix + " "; var prefixed = this.__prefixingAlgorithm(text, prefix); this.__prefixedText = prefixed.text; this.__numSelectors = prefixed.selectors; }
javascript
{ "resource": "" }
q57422
train
function (cssText) { cssText = cssText.replace(/\burl\s*\(\s*["']?([^"'\r\n,]+|[^'\r\n,]+|[^"\r\n,]+)["']?\s*\)/gi, ariaUtilsFunction.bind(function (match, urlpart) { var prefixedUrl = ariaCoreAppEnvironment.applicationSettings.imgUrlMapping(urlpart, this.tplClasspath); return this._parseImgUrl(prefixedUrl); }, this)); return cssText; }
javascript
{ "resource": "" }
q57423
train
function (url) { var tmp = url.replace(/\burl\s*/gi, ""); // removing url word tmp = tmp.charAt(0) === "(" ? tmp.substring(1, tmp.length - 1) : tmp; // removing brackets tmp = tmp.charAt(0) === "\'" || tmp.charAt(0) === "\"" ? tmp.substring(1, tmp.length - 1) : tmp; // removing quotes return tmp; }
javascript
{ "resource": "" }
q57424
train
function (event) { if (event.keyCode == aria.DomEvent.KC_SPACE) { this._setRadioValue(); event.preventDefault(true); } else if (event.keyCode == aria.DomEvent.KC_LEFT) { this._navigate(-1); event.preventDefault(true); } else if (event.keyCode == aria.DomEvent.KC_RIGHT) { this._navigate(+1); event.preventDefault(true); } else if (event.keyCode == aria.DomEvent.KC_DOWN) { this._navigate(+1); event.preventDefault(true); } else if (event.keyCode == aria.DomEvent.KC_UP) { this._navigate(-1); event.preventDefault(true); } }
javascript
{ "resource": "" }
q57425
train
function (direction) { if (!this._cfg || !this._cfg.bind || !this._cfg.bind.value) { // no binding for the value : return return; } var currentBinding = this._cfg.bind.value; var index = ariaUtilsArray.indexOf(this._instances, this), radioButtonNb = this._instances.length; var bindings, next, nextBinding; var waiAria = this._cfg.waiAria; while (index >= 0 && index < radioButtonNb) { index = index + direction; if (waiAria) { if (index < 0) { index = radioButtonNb - 1; } else if (index >= radioButtonNb) { index = 0; } } else if (index < 0 || index >= radioButtonNb) { break; } next = this._instances[index]; bindings = next._cfg.bind; if (!next.getProperty("disabled") && bindings) { nextBinding = bindings.value; if (nextBinding) { // next radio button needs to be bound to the same data. Otherwise, continue. if (currentBinding.inside === nextBinding.inside && currentBinding.to === nextBinding.to) { next._setRadioValue(); next._focus(); break; } } } } }
javascript
{ "resource": "" }
q57426
train
function () { var newValue = this._cfg.keyValue; this._cfg.value = newValue; this.setProperty("value", newValue); // setProperty on value might destroy the widget if (this._cfg) { this._setState(); this._updateDomForState(); if (this._cfg.onchange) { this.evalCallback(this._cfg.onchange); } } }
javascript
{ "resource": "" }
q57427
train
function (className) { var loggingLevel = this._loggingLevels[className]; if (!!loggingLevel) { // If there is a logging level stored for the exact classname passed in parameter return loggingLevel; } else { // Else, look for package names var str = className; while (str.indexOf(".") != -1) { str = str.substring(0, str.lastIndexOf(".")); if (this._loggingLevels[str]) { return this._loggingLevels[str]; } else if (this._loggingLevels[str + ".*"]) { return this._loggingLevels[str + ".*"]; } } return this._loggingLevels["*"] || false; } }
javascript
{ "resource": "" }
q57428
train
function (appender) { var apps = this._appenders; for (var i = 0, l = apps.length; i < l; i++) { if (!appender || apps[i] === appender) { apps[i].$dispose(); apps.splice(i, 1); i--; l--; } } }
javascript
{ "resource": "" }
q57429
train
function (classpath) { var apps = this._appenders; if (classpath) { apps = []; for (var i = 0; i < this._appenders.length; i++) { if (this._appenders[i].$classpath == classpath) { apps.push(this._appenders[i]); } } } return apps; }
javascript
{ "resource": "" }
q57430
train
function (msg, msgArgs, errorContext) { if (msgArgs) { msg = ariaUtilsString.substitute(msg, msgArgs); } for (var error in errorContext) { if (errorContext.hasOwnProperty(error)) { msg += "\n" + error + " : " + errorContext[error] + "\n"; } } return msg; }
javascript
{ "resource": "" }
q57431
train
function (className, msg, msgArgs, o) { this.log(className, this.LEVEL_INFO, msgArgs, msg, o); }
javascript
{ "resource": "" }
q57432
train
function (className, msg, msgArgs, o) { this.log(className, this.LEVEL_WARN, msgArgs, msg, o); }
javascript
{ "resource": "" }
q57433
train
function (className, level, msgArgs, msgText, objOrErr) { if (!this.isValidLevel(level)) { this.error(this.$classpath, "Invalid level passed for logging the message"); } else { if (this.isLogEnabled(level, className)) { var msg = this.prepareLoggedMessage(msgText, msgArgs); var apps = this.getAppenders(); for (var i = 0; i < apps.length; i++) { if (level == this.LEVEL_DEBUG) { apps[i].debug(className, msg, msgText, objOrErr); } if (level == this.LEVEL_INFO) { apps[i].info(className, msg, msgText, objOrErr); } if (level == this.LEVEL_WARN) { apps[i].warn(className, msg, msgText, objOrErr); } if (level == this.LEVEL_ERROR) { apps[i].error(className, msg, msgText, objOrErr); } } } } }
javascript
{ "resource": "" }
q57434
train
function (req, jsonData) { var sender = req.sender; req.data = (sender && sender.classpath == "aria.modules.RequestMgr") ? sender.requestObject.requestHandler.prepareRequestBody(jsonData, sender.requestObject) : ariaUtilsJson.convertToJsonString(jsonData); }
javascript
{ "resource": "" }
q57435
train
function (req, path, preventTimestamp) { if (path) { // change request url and method to target the requested file: req.url = ariaCoreDownloadMgr.resolveURL(path, true); if (preventTimestamp !== true) { req.url = ariaCoreDownloadMgr.getURLWithTimestamp(req.url, true); } req.method = "GET"; req.jsonp = null; // not a json-p request } }
javascript
{ "resource": "" }
q57436
train
function (force, cssText) { if (force !== true) { aria.templates.CSSMgr.__textToDOM(ariaUtilsObject.keys(aria.templates.CSSMgr.__styleTagPool)); } else { // Having an empty text to dom go deeper in the CSSMgr to force a reload var styleBuilder = {}; for (var id in aria.templates.CSSMgr.__styleTagPool) { if (aria.templates.CSSMgr.__styleTagPool.hasOwnProperty(id)) { styleBuilder[id] = (id === "tpl" && cssText) ? [cssText] : []; } } aria.templates.CSSMgr.__reloadStyleTags(styleBuilder); } }
javascript
{ "resource": "" }
q57437
train
function () { var scope = aria.ext.StressCss; scope.original__load = aria.templates.CSSMgr.__load; scope.original__unload = aria.templates.CSSMgr.__unload; aria.templates.CSSMgr.__load = function () { return []; }; aria.templates.CSSMgr.__unload = function () {}; // and force a refresh refreshCSS(); }
javascript
{ "resource": "" }
q57438
train
function () { var scope = aria.ext.StressCss; aria.templates.CSSMgr.__load = scope.original__load; aria.templates.CSSMgr.__unload = scope.original__unload; refreshCSS(); }
javascript
{ "resource": "" }
q57439
train
function (includeWidgetCSS) { // __textLoaded contains a copy of what is inside the DOM var cm = aria.templates.CSSMgr, all = cm.__textLoaded; var selectors = []; for (var path in all) { if (all.hasOwnProperty(path)) { if (includeWidgetCSS !== true && cm.__styleTagAssociation[path] === "wgt") { continue; } selectors = selectors.concat(extractSelectors(all[path].text, path)); } } return selectors; }
javascript
{ "resource": "" }
q57440
train
function (selector, incremental) { if (!selector) { // This is a baseline if (incremental) { // Everything should be removed refreshCSS(true); } else { // Nothing should be removed return; } } else { var textLoaded = aria.templates.CSSMgr.__textLoaded[selector.location]; // remember the original text selector.original = textLoaded.text; if (incremental) { // Keep only the selector refreshCSS(true, selector.descriptor); } else { // Remove the selector textLoaded.text = textLoaded.text.replace(selector.descriptor, ""); refreshCSS(); } } }
javascript
{ "resource": "" }
q57441
train
function (selector, incremental) { if (!selector) { if (incremental) { // Everything was removed refreshCSS(); } else { // Nothing was be removed return; } } else { // Simply put back the original style aria.templates.CSSMgr.__textLoaded[selector.location].text = selector.original; refreshCSS(); } }
javascript
{ "resource": "" }
q57442
train
function (test) { if (test.callback) { test.callback.fn.apply(test.callback.scope, test.callback.args); } }
javascript
{ "resource": "" }
q57443
train
function (test) { var end = +(new Date()); test.runTime = end - test.start; results[test.name] = { name : test.name, runTime : test.runTime, baseline : results["__baseline__"] ? (results["__baseline__"].runTime - test.runTime) : NaN }; addSelector(test.selector, test.cfg.incremental); // Yeld before calling the callback setTimeout(function () { next(test); }, 15); }
javascript
{ "resource": "" }
q57444
train
function (test) { if (test.iteration >= test.cfg.repeat) { return completeTest(test); } test.iteration += 1; test.cfg.action.call(null, test.name, test.iteration - 1, generateTestCallback(test, this)); }
javascript
{ "resource": "" }
q57445
train
function (elm, properties) { for (var prop in properties) { if (properties.hasOwnProperty(prop)) { try { var name = prop.replace(/\-([a-z])/ig, innerReplaceRule); var value = properties[prop]; elm.style[name] = (typeof value == 'number' && name != 'zIndex') ? (value + 'px') : value; } catch (ex) {} } } }
javascript
{ "resource": "" }
q57446
train
function () { var document = Aria.$window.document; reportHolder = document.createElement('iframe'); var block = document.createElement('iframe'); reportHolder.scrolling = 'no'; reportHolder.frameBorder = 'no'; document.body.appendChild(reportHolder); reportHolder.doc = reportHolder.contentDocument || reportHolder.contentWindow.document; reportHolder.doc.write('<html><head></head><body></body></html>'); reportHolder.doc.close(); logHolder = reportHolder.doc.createElement('div'); var close = reportHolder.doc.createElement('a'); reportHolder.resize = function () { if (reportHolder) { var body = reportHolder.doc.body; style(reportHolder, { width : body.scrollWidth, height : body.scrollHeight }); } }; resizeInterval = setInterval(reportHolder.resize, 100); style(reportHolder, { position : 'fixed', top : 10, right : 10, zIndex : 10000, background : 'white', padding : 2, border : 'solid 2px #aaa', width : 250, height : 60, borderRadius : 4, boxShadow : '0 0 8px #eee' }); style(reportHolder.doc.body, { 'font' : '12px Helvetica,Arials,sans-serif', color : '#444' }); style(logHolder, { whiteSpace : 'nowrap' }); close.innerHTML = '&#215;'; style(close, { position : 'absolute', top : 0, right : 0, textDecoration : 'none', fontWeight : 'bold', cursor : 'pointer', color : 'red', fontSize : '1.3em', lineHeight : 8 }); close.onclick = function () { close.onclick = null; clearInterval(resizeInterval); close = null; block.parentNode.removeChild(block); return closeReport(); }; style(block, { height : Aria.$window.screen.height * 2, width : Aria.$window.screen.width, position : 'absolute', top : 0, left : 0, visible : 'hidden', display : 'none', zIndex : 0 }); document.body.appendChild(block); reportHolder.doc.body.appendChild(close); reportHolder.doc.body.appendChild(logHolder); }
javascript
{ "resource": "" }
q57447
train
function (test) { var baseline = !(test.selector && test.selector.name !== "*"); if (!logHolder) { return; // logging was not enabled } var remaining = test.cfg.allSelectors.length; var heading = 'Testing <strong>' + (baseline ? test.name : test.selector.name) + '</strong>'; var message = '<br />' + (baseline ? 'baseline' : test.selector.location); var footer = '<br />' + remaining + ' remaining test' + (remaining === 1 ? '' : 's'); logHolder.innerHTML = heading + message + footer; }
javascript
{ "resource": "" }
q57448
train
function (incremental) { if (!reportHolder || !results) { return; // logging was not enabled } var table = '<table><thead><tr><th>Selector</th><th> </th><th>ms</th><th>Total</th></tr></thead><tbody>'; // Extract the 10 slowest results var resultsArray = []; for (var res in results) { if (results.hasOwnProperty(res) && res !== "__baseline__") { resultsArray.push(results[res]); } } var sorted = resultsArray.sort(function (a, b) { if (a.baseline === b.baseline) { return 0; } if (incremental) { return a.baseline > b.baseline ? 1 : -1; } else { return a.baseline > b.baseline ? -1 : 1; } }).slice(0, 20); for (var i = 0, len = sorted.length; i < len; i += 1) { var item = sorted[i]; table += '<tr><td style="font:11px monospace">Removing <strong>' + item.name + '</strong></td><td style="text-align:right">' + (item.baseline > 0 ? '<span style="color:green">saves</span>' : '<span style="color:red">adds</span>') + '</td><td style="text-align:right; font:11px monospace">' + Math.abs(item.baseline) + 'ms</td>' + '<td style="text-align:right; font:11px monospace">' + item.runTime + 'ms</td></tr>\n'; } table += '</tbody></table><hr/>'; // Summary table += '<table><tr><td style="text-align:right; font:10px monospace">Selectors Tested:</td><td style="font:10px monospace">' + resultsArray.length + '</td></tr>' + '<tr><td style="text-align:right; font:10px monospace">Baseline Time:</td><td style="font:10px monospace">' + results["__baseline__"].runTime + 'ms</td></tr>'; style(reportHolder, { width : 600 }); logHolder.innerHTML = table; }
javascript
{ "resource": "" }
q57449
train
function (test) { test.iteration = 0; removeSelector(test.selector, test.cfg.incremental); log(test); test.start = +(new Date()); executeAction(test); }
javascript
{ "resource": "" }
q57450
train
function (cfg, callback) { if (cfg.allSelectors.length > 0) { var selector = cfg.allSelectors.splice(0, 1)[0]; var one = { name : selector.name, cfg : cfg, selector : selector, callback : { fn : allTests, scope : this, args : [cfg, callback] } }; runTest(one); } else { logResults(cfg.incremental); aria.ext.StressCss.__callback(callback); } }
javascript
{ "resource": "" }
q57451
train
function (cfg, callback) { results = {}; // Generate a test targeting any CSS var all = { name : "__baseline__", cfg : cfg, selector : null, callback : { fn : allTests, scope : this, args : [cfg, callback] } }; runTest(all); }
javascript
{ "resource": "" }
q57452
train
function (cfg) { cfg = cfg || {}; for (var prop in defaults) { if (defaults.hasOwnProperty(prop) && !(prop in cfg)) { cfg[prop] = defaults[prop]; } } cfg.allSelectors = getAllSelectors(cfg.widget); return cfg; }
javascript
{ "resource": "" }
q57453
train
function (item, container) { if (item && !ariaUtilsArray.contains(container, item)) { container.push(item); } }
javascript
{ "resource": "" }
q57454
train
function (container, toAdd) { var entry; for (var i = 0, len = toAdd.length; i < len; i++) { entry = toAdd[i]; this.addIfMissing(entry, container); } }
javascript
{ "resource": "" }
q57455
train
function (container, property) { var output = [], entry; for (var i = 0, len = container.length; i < len; i++) { entry = container[i]; if (entry[property]) { output.push(entry[property]); } } return output; }
javascript
{ "resource": "" }
q57456
train
function (container, keyName) { for (var element in container) { if (container.hasOwnProperty(element)) { container[element][keyName] = element; } } }
javascript
{ "resource": "" }
q57457
train
function (msg, errors, scope) { scope.$logError.apply(scope, [msg + ":"]); for (var i = 0, len = errors.length; i < len; i++) { scope.$logError.apply(scope, [(i + 1) + " - " + errors[i].msgId, errors[i].msgArgs]); } }
javascript
{ "resource": "" }
q57458
train
function (errorMessage) { var msg = null; for (var i = 0; i < errorMessage.length; i++) { if (msg === null && errorMessage[i]) { msg = errorMessage[i]; } } return msg; }
javascript
{ "resource": "" }
q57459
train
function (out) { var errorMessage; if (this._WidgetCfg.formatError) {// framework errors errorMessage = this._WidgetCfg.formatErrorMessages; } else if (this._WidgetCfg.error) {// template errors errorMessage = this._WidgetCfg.errorMessages; } var div = new ariaWidgetsContainerDiv({ sclass : "errortip", width : 289, margins : "0 0 0 0" }, this._context); var msg = this._checkErrorMessage(errorMessage); if (this._WidgetCfg.waiAria) { div.addExtraAttributes('aria-hidden="true"'); this._widget.waiReadText(msg, { alert: true }); } out.registerBehavior(div); div.writeMarkupBegin(out); out.write(msg); div.writeMarkupEnd(out); this._div = div; }
javascript
{ "resource": "" }
q57460
train
function () { if (this._validationPopup) { return; } // create the section var section = this._context.createSection({ fn : this._renderValidationContent, scope : this }); // we no longer store the section in this._section as the section is properly disposed by the popup when it // is disposed var popup = new ariaPopupsPopup(); this._validationPopup = popup; this._validationPopup.$on({ "onAfterClose" : this._afterValidationClose, "onPositioned" : this._onTooltipPositioned, scope : this }); ariaTemplatesLayout.$on({ "viewportResized" : this._onViewportResized, scope : this }); this._validationPopup.open({ section : section, domReference : this._field, preferredPositions : this._getPreferredPositions(), closeOnMouseClick : true, closeOnMouseScroll : false, waiAria: this._WidgetCfg.waiAria }); }
javascript
{ "resource": "" }
q57461
train
function () { var errorTipPosition = this._WidgetCfg.errorTipPosition; var preferredPositions = [this._preferredPositions[errorTipPosition]]; for (var i in this._preferredPositions) { if (this._preferredPositions.hasOwnProperty(i) && errorTipPosition != i) { preferredPositions.push(this._preferredPositions[i]); } } return preferredPositions; }
javascript
{ "resource": "" }
q57462
train
function (evt) { var position = evt.position; if (position) { // state is named after the position, except for topRight where it is named normal var state = position.reference.replace(" right", "Right").replace(" left", "Left"); if (state === 'topRight') { state = 'normal'; } var div = this._div, frame = div._frame; // Make sure that the div is initialised (only once), // as _onTooltipPositioned can be called several times for the same popup div.getDom(); // this is backward compatibility for skin without errortooltip position states if (frame.checkState(state)) { frame.changeState(state); } } }
javascript
{ "resource": "" }
q57463
train
function (target, options) { if (ariaCoreBrowser.isOldIE || ariaCoreBrowser.isSafari) { this.fireKeydownEventAdaptedForKeyNav = function (target, options) { // For IE and Safari: simulate(target, "keydown", options); }; } else { this.fireKeydownEventAdaptedForKeyNav = function (target, options) { // For other browsers than IE and Safari: // Shitty implementation for keynav: // Other browser that safari and IE need to listen to keydown // and keypress, so we need to simulate both of them for these browser (firefox for instance) simulate(target, "keydown", options); simulate(target, "keypress", options); }; } this.fireKeydownEventAdaptedForKeyNav(target, options); }
javascript
{ "resource": "" }
q57464
train
function (mode) { var debug = this.isDebug(); if (debug !== mode && (mode === true || mode === false)) { ariaCoreAppEnvironment.setEnvironment({ "appSettings" : { "debug" : mode } }, null, true); } }
javascript
{ "resource": "" }
q57465
train
function (mode) { var dev = this.isDevMode(); if (dev !== mode && (mode === true || mode === false)) { ariaCoreAppEnvironment.setEnvironment({ "appSettings" : { "devMode" : mode } }, null, true); } }
javascript
{ "resource": "" }
q57466
train
function (escape) { var currentValue = this.hasEscapeHtmlByDefault(); if (currentValue !== escape && (escape === true || escape === false)) { aria.core.AppEnvironment.setEnvironment({ "templateSettings" : { "escapeHtmlByDefault" : escape } }, null, true); } }
javascript
{ "resource": "" }
q57467
train
function (config) { this._config = config; this._pageProvider = config.pageProvider; ariaEmbedPlaceholderManager.register(this); this._pageProvider.$addListeners({ "pageDefinitionChange" : this._onPageDefinitionChangeListener }); this._pageProvider.loadSiteConfig({ onsuccess : { fn : this._loadRootModule, scope : this }, onfailure : this._getErrorCallbackConfig([this.SITE_CONFIG_NOT_AVAILABLE]) }); }
javascript
{ "resource": "" }
q57468
train
function (siteConfig) { var valid = this.isConfigValid(siteConfig, "aria.pageEngine.CfgBeans.Site", this.INVALID_SITE_CONFIGURATION); if (!valid) { return; } var helper = new ariaPageEngineUtilsSiteConfigHelper(siteConfig); this._siteConfigHelper = helper; // Initialization var appData = helper.getAppData(); appData.menus = appData.menus || {}; var initArgs = { appData : appData, pageEngine : this._wrapper }; var rootModuleConfig = this._config.rootModule; if (rootModuleConfig) { var customControllerClasspath = rootModuleConfig.classpath; if (rootModuleConfig.initArgs) { ariaUtilsJson.inject(initArgs, rootModuleConfig.initArgs); } var that = this; Aria.load({ classes : [customControllerClasspath], oncomplete : function () { if (Aria.getClassRef(customControllerClasspath).classDefinition.$extends !== "aria.pageEngine.SiteRootModule") { that._errorCallback([that.INVALID_ROOTMODULE_PARENT]); return; } that._createModuleCtrl(rootModuleConfig); }, onerror : this._getErrorCallbackConfig([this.MISSING_DEPENDENCIES]) }); } else { this._createModuleCtrl({ classpath : "aria.pageEngine.SiteRootModule", initArgs : initArgs }); } }
javascript
{ "resource": "" }
q57469
train
function (loadModule) { this._rootModule = loadModule.moduleCtrlPrivate; this._data = this._rootModule.getData().storage; var siteHelper = this._siteConfigHelper; ariaUtilsCSSLoader.add(siteHelper.getSiteCss()); var classesToLoad = siteHelper.getListOfContentProcessors(); var navigationManagerClass = siteHelper.getNavigationManagerClass(); if (navigationManagerClass) { classesToLoad.push(navigationManagerClass); } if (siteHelper.siteConfig.animations) { classesToLoad.push("aria.pageEngine.utils.AnimationsManager"); } var commonModulesToLoad = siteHelper.getCommonModulesDescription({ priority : 1 }); this._utils.wiseConcat(classesToLoad, this._utils.extractPropertyFromArrayElements(commonModulesToLoad, "classpath")); Aria.load({ classes : classesToLoad, oncomplete : { fn : this._loadGlobalModules, scope : this, args : commonModulesToLoad }, onerror : this._getErrorCallbackConfig([this.MISSING_DEPENDENCIES]) }); }
javascript
{ "resource": "" }
q57470
train
function (commonModulesToLoad) { this._rootModule.loadModules(null, { page : [], common : commonModulesToLoad }, { fn : this._onSiteReady, scope : this }); }
javascript
{ "resource": "" }
q57471
train
function () { var helper = this._siteConfigHelper; this.contentProcessors = helper.getContentProcessorInstances(); this._firstDiv = helper.getRootDiv(); if (!this._animationsDisabled && helper.siteConfig.animations) { this._animationsManager = new aria.pageEngine.utils.AnimationsManager(); this._secondDiv = this._animationsManager.createHiddenDiv(this._firstDiv); } this._navigationManager = helper.getNavigationManager({ fn : "navigate", scope : this }, helper.siteConfig.storage); this.navigate({ url : this._navigationManager ? this._navigationManager.getUrl() : null, pageId : this._navigationManager ? this._navigationManager.getPageId() : null, replace : true }, this._config.oncomplete); }
javascript
{ "resource": "" }
q57472
train
function (pageRequest, cb) { var pageId = pageRequest.pageId; var forceReload = pageRequest.forceReload; if (!forceReload && pageId && pageId == this.currentPageId) { this.$callback(cb); if (this._navigationManager) { this._navigationManager.update(pageRequest); ariaUtilsJson.setValue(this._data, "pageInfo", pageRequest); } } else { this._previousPageCSS = this._currentPageCSS; this._currentPageCSS = []; this._pageProvider.loadPageDefinition(pageRequest, { onsuccess : { fn : this._getPageDependencies, scope : this, args : { pageRequest : pageRequest, cb : cb } }, onfailure : this._getErrorCallbackConfig([this.PAGE_NOT_AVAILABLE, pageId]) }); } }
javascript
{ "resource": "" }
q57473
train
function (cfg, args) { var valid = this.isConfigValid(cfg, "aria.pageEngine.CfgBeans.PageDefinition", this.INVALID_PAGE_DEFINITION); if (!valid) { this.$callback(args.cb); return; } var pageConfigHelper = this._getPageConfigHelper(cfg); ariaUtilsJson.inject(pageConfigHelper.getMenus(), this._siteConfigHelper.getAppData().menus); this._pageConfigHelper = pageConfigHelper; this._lazyContent = true; this._loadPageDependencies({ lazy : false, pageId : cfg.pageId, cb : { fn : this._displayPage, scope : this, args : { cb : args.cb, pageConfig : cfg, pageRequest : args.pageRequest } } }); }
javascript
{ "resource": "" }
q57474
train
function (args) { var subModules = args.subModules; this._rootModule.loadModules(args.pageId, subModules, args.cb); }
javascript
{ "resource": "" }
q57475
train
function (cfg, beanName, error) { try { ariaCoreJsonValidator.normalize({ json : cfg, beanName : beanName }, true); } catch (ex) { this._utils.logMultipleErrors(error, ex.errors, this); if (this._config.onerror) { this.$callback(this._config.onerror, [error]); } return false; } return true; }
javascript
{ "resource": "" }
q57476
train
function (args) { if (!this._pageConfigHelper) { this.$callback(args.cb); return; } var pageConfig = args.pageConfig, cfg = pageConfig.pageComposition, pageId = pageConfig.pageId; this.$raiseEvent({ name : "beforePageTransition", from : this.currentPageId, to : pageId }); this.currentPageId = pageId; this._pageConfigs[pageId] = pageConfig; var pageRequest = args.pageRequest; pageRequest.url = pageConfig.url; pageRequest.pageId = pageConfig.pageId; pageRequest.title = pageConfig.title; var json = ariaUtilsJson; json.setValue(this._data, "pageData", cfg.pageData); json.setValue(this._data, "pageInfo", pageRequest); var cfgTemplate = { classpath : cfg.template, div : this._getContainer(!pageConfig.animation), moduleCtrl : this._rootModule }; this._modulesInPage = []; // if the div does not change, let's dispose the previous template first if (cfgTemplate.div == this._getContainer() && this._isTemplateLoaded) { Aria.disposeTemplate(this._getContainer()); } Aria.loadTemplate(cfgTemplate, { fn : this._afterTemplateLoaded, scope : this, args : { pageConfig : pageConfig, cb : args.cb, div : cfgTemplate.div, pageRequest : pageRequest } }); }
javascript
{ "resource": "" }
q57477
train
function (success, args) { if (this._navigationManager) { this._navigationManager.update(args.pageRequest); } var browser = ariaCoreBrowser; if (browser.isOldIE && browser.majorVersion < 8) { ariaCoreTimer.addCallback({ fn : function () { args.div.style.zoom = 0; args.div.style.zoom = 1; args.div = null; }, scope : this, delay : 0 }); } this._isTemplateLoaded = true; if (this._animationsManager && args.pageConfig.animation) { this._animationsManager.$on({ "animationend" : { fn : this._pageTransitionComplete, args : args }, scope : this }); this._animationsManager.startPageTransition(this._getContainer(false), this._getContainer(), args.pageConfig.animation); } else { this._finishDisplay(args); } }
javascript
{ "resource": "" }
q57478
train
function (args, params) { this._animationsManager.$removeListeners({ "animationend" : this._pageTransitionComplete, scope : this }); this._activeDiv = (this._activeDiv + 1) % 2; Aria.disposeTemplate(this._getContainer(false)); this._finishDisplay(params); }
javascript
{ "resource": "" }
q57479
train
function (params) { ariaUtilsCSSLoader.remove(this._previousPageCSS); this.$raiseEvent({ name : "pageReady", pageId : params.pageConfig.pageId }); if (params.cb) { this.$callback(params.cb); } this._loadPageDependencies({ lazy : true, pageId : params.pageConfig.pageId, cb : { fn : this._afterLazyDependenciesLoad, scope : this } }); }
javascript
{ "resource": "" }
q57480
train
function (active) { if (!this._animationsManager) { return this._firstDiv; } active = !(active === false); if (active) { return this._activeDiv === 0 ? this._firstDiv : this._secondDiv; } else { return this._activeDiv === 1 ? this._firstDiv : this._secondDiv; } }
javascript
{ "resource": "" }
q57481
train
function () { if (!this._pageConfigHelper) { return; } var lazyPlaceholders = this._pageConfigHelper.getLazyPlaceholdersIds(); this._lazyContent = false; this.$raiseEvent({ name : "contentChange", contentPaths : lazyPlaceholders }); this._pageConfigHelper.$dispose(); }
javascript
{ "resource": "" }
q57482
train
function (placeholderPath) { var outputContent; var typeUtil = ariaUtilsType; var pageConfig = this._pageConfigs[this.currentPageId]; if (pageConfig) { var placeholders = pageConfig.pageComposition.placeholders; var content = placeholders[placeholderPath] || []; outputContent = []; var plainContent; if (!typeUtil.isArray(content)) { content = [content]; } for (var i = 0, ii = content.length; i < ii; i++) { var item = content[i]; if (typeUtil.isObject(item)) { if (this._lazyContent && item.lazy) { outputContent.push({ loading : true, width : item.lazy.width || null, height : item.lazy.height || null, color : item.lazy.color || null, innerHTML : item.lazy.innerHTML || null }); } else { if (item.template) { outputContent.push(this._getTemplateCfg(item, pageConfig)); } else if (item.contentId) { plainContent = this._getPlaceholderContents(pageConfig, item.contentId); outputContent = outputContent.concat(plainContent); } } } else { outputContent.push(item); } } } return outputContent; }
javascript
{ "resource": "" }
q57483
train
function (item, pageConfig) { var templateCfg = { classpath : item.template }; var args = item.args || []; var extraArg = {}; if (item.contentId) { extraArg.contents = this._getPlaceholderContents(pageConfig, item.contentId); } args.push(extraArg); templateCfg.args = args; if (item.module) { var module = this._rootModule.getPageModule(this.currentPageId, item.module); templateCfg.moduleCtrl = module; this._modulesInPage.push(module); } if (item.data) { templateCfg.data = item.data; } return templateCfg; }
javascript
{ "resource": "" }
q57484
train
function (pageConfig, contentId) { var outputContent = []; var content = pageConfig.contents.placeholderContents ? pageConfig.contents.placeholderContents[contentId] : null; if (!content) { return outputContent; } if (!ariaUtilsType.isArray(content)) { content = [content]; } for (var i = 0, length = content.length; i < length; i++) { outputContent = outputContent.concat(this.processContent(content[i])); } return outputContent; }
javascript
{ "resource": "" }
q57485
train
function (content) { var contentType = content.contentType; if (contentType && contentType in this.contentProcessors) { return this.processContent(this.contentProcessors[contentType].processContent(content)); } return content.value || ""; }
javascript
{ "resource": "" }
q57486
train
function (msg) { var config = this._config; this.$logError.apply(this, msg); if (config.onerror) { this.$callback(config.onerror, msg); } }
javascript
{ "resource": "" }
q57487
train
function (event) { var pageId = event.pageId; if (this.currentPageId == pageId) { this._rootModule.unloadPageModules(pageId); this.navigate({ pageId : pageId, url : this._navigationManager ? this._navigationManager.getUrl() : null, forceReload : true }); } }
javascript
{ "resource": "" }
q57488
train
function() { var groupId = getString(libsignal.crypto.getRandomBytes(16)); return this.getGroup(groupId).then(function(group) { if (group === undefined) { return groupId; } else { console.warn("group id collision"); // probably a bad sign. return this.generateNewGroupId(); } }); }
javascript
{ "resource": "" }
q57489
train
function() { var collection = []; for (let id of this.store._keys) { if (id.startsWith("unprocessed")) { collection.push(this.get(id)); } } return Promise.resolve(collection); }
javascript
{ "resource": "" }
q57490
findProjectRoot
train
function findProjectRoot(currentPath) { var result = undefined; try { var packageStats = lstatSync(path.join(currentPath, 'package.json')); if (packageStats.isFile()) { result = currentPath; } } catch (error) { if (currentPath !== path.resolve('/')) { result = findProjectRoot(path.join(currentPath, '..')); } } return result; }
javascript
{ "resource": "" }
q57491
loadTemplate
train
function loadTemplate() { generateData(); return new Promise(function(resolve, reject) { // Load handlebars page template. $.get('src/demo-template.html', function(response) { template = response; render(); resolve(); }).fail(function() { reject(); }); }); }
javascript
{ "resource": "" }
q57492
generateData
train
function generateData() { var totalTransactions = 20; var totalAmount = 0; var transactions = []; // Generate transactions for (var i = 0; i < totalTransactions; i++) { // Transactions var transaction = faker.helpers.createTransaction(); transaction.date = getDate(); totalAmount += parseFloat(transaction.amount); // Other transactions transaction.other = []; for (var j = 0; j < totalTransactions; j++) { other = faker.helpers.createTransaction(); other.date = getDate(); transaction.other.push(other); } transactions.push(transaction); } dataView.transactions = transactions.sort(compare); dataView.selectedTransaction = transactions[0]; dataView.totalAmount = toCurrency(totalAmount); }
javascript
{ "resource": "" }
q57493
compare
train
function compare(a, b) { var date1 = new Date(a.date); var date2 = new Date(b.date); if (date1 < date2) { return -1; } if (date1 > date2) { return 1; } return 0; }
javascript
{ "resource": "" }
q57494
addClickHandler
train
function addClickHandler() { $('.transaction-list-item').click(function() { var index = $('.transaction-list-item').index(this); dataView.selectedTransaction = dataView.transactions[index]; render(); }); }
javascript
{ "resource": "" }
q57495
clearSubObject
train
function clearSubObject (object, path, pathIndex) { const key = path[pathIndex] if (path.length < pathIndex + 2) { delete object[key] return true } const subObj = object[key] const didClear = clearSubObject(subObj, path, pathIndex + 1) if (didClear && keys(subObj).length <= 0) { delete object[key] return true } return false }
javascript
{ "resource": "" }
q57496
removeChildInternals
train
function removeChildInternals (withoutInternal) { return _.chain(withoutInternal) .map((item, key) => { const withoutInternal = removeInternalValues(item) if (withoutInternal !== undefined && withoutInternal !== item) { return [key, withoutInternal] } }) .filter() .fromPairs() .value() }
javascript
{ "resource": "" }
q57497
maybeMerge
train
function maybeMerge (first, second) { if (Object.keys(second).length > 0) { return Object.assign({}, first, second) // don't mutate the object } return first }
javascript
{ "resource": "" }
q57498
typeToPropType
train
function typeToPropType(typeInfo) { if (typeInfo.type === "string") { return React.PropTypes.string; } else if (typeInfo.type === "boolean") { return React.PropTypes.bool; } else if (typeInfo.type === "number") { return React.PropTypes.number; } else if (typeInfo.type === "enum") { return React.PropTypes.oneOf(typeInfo.values); } else if (typeInfo.type === "any") { return React.PropTypes.any; } else if (typeInfo.type === "reference") { if (typeInfo.name === "Function") { return React.PropTypes.func; } else if (typeInfo.name === "Array") { var itemPropType = typeToPropType(typeInfo.typeArguments[0]); return itemPropType ? React.PropTypes.arrayOf(itemPropType) : React.PropTypes.array; } else if (getIn(window, typeInfo.name)) { var instance = getIn(window, typeInfo.name); return React.PropTypes.instanceOf(instance); } } else { console.warn("react-winjs typeToPropType: unable to find propType for type: " + JSON.stringify(typeInfo, null, 2)); } }
javascript
{ "resource": "" }
q57499
train
function (propType) { return { propType: propType, preCtorInit: function property_preCtorInit(element, options, data, displayName, propName, value) { options[propName] = value; }, update: function property_update(winjsComponent, propName, oldValue, newValue) { if (oldValue !== newValue) { winjsComponent.winControl[propName] = newValue; } } }; }
javascript
{ "resource": "" }