_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
27
233k
language
stringclasses
1 value
meta_information
dict
q3600
train
function (prefix, preout, messages) { if (prefix && this.LEVELS[prefix] < this.level) { return; } var msg = ""; for (var i = 0; i < messages.length; i++) { 0 < i ? msg += ' ' + messages[i]:
javascript
{ "resource": "" }
q3601
hyphenateText
train
function hyphenateText(dom, forceHyphenateAllChildren) { if (dom.childNodes !== undefined) { dom.childNodes.forEach(function(node) { if (node.nodeName === '#text' && !isSkippable(node) && (forceHyphenateAllChildren || isPresent(options.elements, dom.tagName))) { node.value =
javascript
{ "resource": "" }
q3602
isSkippable
train
function isSkippable(node) { var result = false; if (node && node.parentNode && node.parentNode.attrs && Array.isArray(node.parentNode.attrs)) { node.parentNode.attrs.forEach(function(attr) { if (attr.name &&
javascript
{ "resource": "" }
q3603
isIgnoredFile
train
function isIgnoredFile(file) { if (options.ignore !== undefined) { var result = false; options.ignore.forEach(function(pattern) { if (minimatch(file, pattern)) {
javascript
{ "resource": "" }
q3604
filter
train
function filter(tree, query, options) { var compiledQuery = _.isFunction(query) ? query : _.matches(query); var settings = _.defaults(options, { childNode: ['children'] }); settings.childNode = _.castArray(settings.childNode); var seekDown = function seekDown(tree) { return tree.filter(function (branch, index) { return compiledQuery(branch, index); }).map(function (branch) { settings.childNode.some(function (key) { if (_.has(branch, key)) { if (_.isArray(branch[key])) {
javascript
{ "resource": "" }
q3605
hasChildren
train
function hasChildren(branch, options) { var settings = _.defaults(options, { childNode: ['children'] }); return settings.childNode.some(function (key) {
javascript
{ "resource": "" }
q3606
attemptNext
train
function attemptNext() { if (--settings.attempts > 0 && dirty) { dirty = false; // Mark sweep as clean - will get dirty if resolver sees a function return
javascript
{ "resource": "" }
q3607
sortBy
train
function sortBy(tree, propertyName) { var _this = this; // It is needed an array structure to sort. if (!_.isArray(tree)) tree = [tree]; tree.forEach(function (item) { return _(item).keys().forEach(function (key) {
javascript
{ "resource": "" }
q3608
train
function() { this.jsonInit({ "message0": "%1", "args0": [ { "type": "field_variable", "name": "CLONE_NAME_OPTION", "variableTypes": [Blockly.CLONE_NAME_VARIABLE_TYPE], "variable": Blockly.Msg.DEFAULT_CLONE_NAME } ], "colour": Blockly.Colours.control.secondary,
javascript
{ "resource": "" }
q3609
defaultTheme
train
function defaultTheme(theme) { if (theme == null) return Form.defaultProps.theme if (typeof theme !== 'object') { throw new Error('Invalid Frig theme. Expected an object') }
javascript
{ "resource": "" }
q3610
Argument
train
function Argument(handler, options, desc) { if (!options.hasOwnProperty('scope')) { options.scope =
javascript
{ "resource": "" }
q3611
train
function(model, at){ model = new this._Model(model, this.options.Model.options); if (!this.hasModel(model)) { // Attach events to the model that will signal collection events this.attachModelEvents(model); // If _models is empty, then we make sure to push instead of splice. at = this.length == 0 ? void 0 : at; if (at != void 0) { this._models.splice(at, 0, model); } else {
javascript
{ "resource": "" }
q3612
train
function(index){ var len = arguments.length, i = 0, results; if (len > 1) { results = []; while(len--){ results.push(this.get(arguments[i++]));
javascript
{ "resource": "" }
q3613
train
function(model){ if (this.hasModel(model)) { // Clean up when removing so that it doesn't try removing itself from the collection this.detachModelEvents(model);
javascript
{ "resource": "" }
q3614
train
function(oldModel, newModel){ var index; if (oldModel && newModel && this.hasModel(oldModel) && !this.hasModel(newModel)) { index = this.indexOf(oldModel); if (index > -1) {
javascript
{ "resource": "" }
q3615
fireRequest
train
function fireRequest(urlStr, callback) { var start = Date.now(); request({ url: urlStr, method: 'GET', maxRedirects: 8, timeout: 10 * 1000 //headers: { 'User-Agent': 'woobot/2.0'
javascript
{ "resource": "" }
q3616
validate
train
function validate(options) { const schema = joi.object().keys({ actionName: joi.string().required(), authKey: joi.string().required(), modelName: joi.string().required(), acl: joi.object(), aclContextName: joi.string().required() }); const errorMsg = 'Invalid rule options: '; const aclContext
javascript
{ "resource": "" }
q3617
makeme
train
function makeme (dir,mode,cb){ var callback = function(err,parent){ //console.log('makeme: ',dir) if(err) throw new Error(err) if(parent){ // replace root of dir with parent dir = path.join(parent,path.basename(dir)); } fs.mkdir(dir,mode,function(err){ if(err !== null){ if( err.code === 'EEXIST' && err.path === dir){ // make sure the directory really does exist fs.stat(dir,function(staterr,stat){ // as mkdirP guys say, this is very strange if(staterr || !stat.isDirectory()){ if(cb) cb(err); }
javascript
{ "resource": "" }
q3618
handleStatforPath
train
function handleStatforPath(p, mode, parent,next){ return function(exists){ if(!exists){ //console.log('no path ' + p + ' so recurse');
javascript
{ "resource": "" }
q3619
makedir
train
function makedir(p,mode,next){ if (typeof mode === 'function' || mode === undefined) { next = mode; mode = 0777 & (~process.umask()); } if (typeof mode === 'string') mode = parseInt(mode, 8); p = path.resolve(p); // recursively make sure that directory exists. // var parent = path.dirname(p); if(parent){ fs.exists(p,handleStatforPath(p,mode,parent,next)); }else{ // following convention, if the path is actually a dot at this // point, prepend the current process root dir and carry on // back up the stack. // if(p === '.'){
javascript
{ "resource": "" }
q3620
process
train
function process(segments, parent) { var last = segments.pop(); if (last) { parent[last] = parent[last] || {};
javascript
{ "resource": "" }
q3621
isExtendOf
train
function isExtendOf(name, variable) { var offset = typeof variable === 'object' && variable ? Object.getPrototypeOf(variable) : null, pattern = offset ? new RegExp('^' + name + '$') : null; // It is not quite feasible to compare the inheritance using `instanceof` (all constructors would have to // be registered somehow then) we simply compare the constructor function names. // As a side effect, this enables polymorphic to compare against the exact type (unless a developer
javascript
{ "resource": "" }
q3622
parameterize
train
function parameterize(candidate) { candidate.param = candidate.param.map(function(param) { var value; if ('value' in param) { value = param.value; } else if ('reference' in param) { value = candidate.param.reduce(function(p, c) {
javascript
{ "resource": "" }
q3623
matchSignature
train
function matchSignature(list, arg) { var types = arg.map(function(variable) { return new RegExp('^(' + type(variable) + ')'); }); return list.filter(function(config) { var variadic = false, result; // result is true if no more arguments are provided than the signature allows OR the last // argument in the signature is variadic result = arg.length <= config.arguments.length || (config.arguments[config.arguments.length - 1] && config.arguments[config.arguments.length - 1].type === '...'); // test each given argument agains the configured signatures if (result) { arg.forEach(function(value, index) { var expect = config.arguments[index] ? config.arguments[index].type : null; // look at ourself and ahead - if there is a following item, and it is variadic, it may be
javascript
{ "resource": "" }
q3624
prepare
train
function prepare(list, arg) { return list.map(function(config) { var item = { // the function to call call: config.call, // all configured arguments arguments: config.arguments, // the calculated specificity specificity: config.arguments.map(function(argument, index) { var value = 'value' in argument, specificity = 0; // if a argument not a variadic one and the value is specified if (argument.type !== '...' && index < arg.length) { ++specificity; // bonus points if the exact type matches (explicit by type) // OR there is no default value (explicitly provided) if (Number(argument.type === type(arg[index], true) || isExtendOf(argument.type, arg[index]) || !value)) { ++specificity; } // extra bonus points if the type is explicity the same (in case of inheritance) if (new RegExp('^' + type(arg[index], true) + '!$').test(argument.type)){ ++specificity; } } return specificity; }).join(''), // the parameters with which the `call` may be executed param: config.arguments.map(function(argument, index) { var result = {}; result.name = argument.name;
javascript
{ "resource": "" }
q3625
prioritize
train
function prioritize(list, arg) { return list.sort(function(a, b) { var typing = function(item, index) { return +(item.type === type(arg[index], true)); }; // if the calculated specificity is not equal it has precedence if (a.specificity !== b.specificity) { // the shortest specificity OR ELSE the highest specificity wins
javascript
{ "resource": "" }
q3626
isTypeAtIndex
train
function isTypeAtIndex(type, list, index) { return list.length > index && 'type'
javascript
{ "resource": "" }
q3627
delegate
train
function delegate(arg) { // create a list of possible candidates based on the given arguments var candidate = matchSignature(registry, arg); // prepare the configured signatures/arguments based on the arguments actually recieved candidate = prepare(candidate, arg); // prioritize the candidates candidate = prioritize(candidate, arg); // and finally, filter any candidate which does not fully comply with the signature based on the - now - parameters candidate = candidate.filter(function(item) { var variadic = false, min = item.arguments.map(function(argument,
javascript
{ "resource": "" }
q3628
cast
train
function cast(type, variable) { var result = variable; switch (type) { case 'number': result = +result; break; case 'int': result = parseInt(result,
javascript
{ "resource": "" }
q3629
numberType
train
function numberType(type, variable, explicit) { // if the integer value is identical to the float value, it is an integer return
javascript
{ "resource": "" }
q3630
type
train
function type(variable, explicit) { var result = typeof variable; switch (result) { case 'number': result = numberType(result, variable, explicit); break; case 'object': result = objectType(result, variable, explicit); break;
javascript
{ "resource": "" }
q3631
prepareArgument
train
function prepareArgument(match, name) { var result = { type: match ? match[1] : false, name: match ? match[2] : name };
javascript
{ "resource": "" }
q3632
parse
train
function parse(signature) { var pattern = /^(?:void|([a-zA-Z]+!?|\.{3})(?:[:\s]+([a-zA-Z]+)(?:(=)(@)?(.*))?)?)?$/; return signature.split(/\s*,\s*/).map(function(argument, index, all) { var result = prepareArgument(argument.match(pattern), 'var' + (index + 1)); if (result.type === false) { throw new Error('polymorphic: invalid argument "' + argument + '" in signature "' + signature + '"'); } else if (result.type === '...' && index < all.length - 1)
javascript
{ "resource": "" }
q3633
polymorph
train
function polymorph() { var arg = Array.prototype.slice.call(arguments), candidate = delegate(arg); if (!candidate) { throw new Error('polymorph: signature not found "' + arg.map(function(variable) {
javascript
{ "resource": "" }
q3634
getRouteFiles
train
function getRouteFiles (pathName) { var items = fs.readdirSync(pathName); var files = []; items.forEach(function(itemName) { var fullName = path.join(pathName, itemName); var fsStat = fs.statSync(fullName); // If directory, then scan for "routes.js" if (fsStat.isDirectory()) { getRouteFiles(fullName).forEach(function(a) {
javascript
{ "resource": "" }
q3635
applyRules
train
function applyRules(rules, model, user) { const rulePromises = _.map(rules, (rule) => rule.applyTo(model, user)); return Promise.all(rulePromises) //TODO validate rule results to handle optional vs. required
javascript
{ "resource": "" }
q3636
readSecure
train
function readSecure(user, options) { // jscs:disable // jshint -W040 const self = this; // jshint +W040 // jscs:enable const shield = self.constructor.shield; const action = 'read'; const rules = shield.getApplicableRules(action); return shield._fetch.call(self, options) .then(function runShieldRules(result) { // TODO: investigate what happens if
javascript
{ "resource": "" }
q3637
readAllSecure
train
function readAllSecure(user, options) { // jscs:disable // jshint -W040 const self = this; // jshint +W040 // jscs:enable const shield = self.constructor.shield; const action = 'read'; const rules = shield.getApplicableRules(action); return shield._fetchAll.call(self, options) .then(function runShieldRules(collection) { // TODO: investigate what happens if
javascript
{ "resource": "" }
q3638
deleteSecure
train
function deleteSecure(user, options) { // jscs:disable // jshint -W040 const self = this; // jshint +W040 // jscs:enable const Model = self.constructor; const shield = Model.shield; const action = 'delete'; const rules = shield.getApplicableRules(action); const primaryKey = Model.idAttribute; const query = {}; const tmpModel = Model.forge(query); query[primaryKey] = self.get(primaryKey); return tmpModel.read(user)
javascript
{ "resource": "" }
q3639
updateSecure
train
function updateSecure(user, options) { // jscs:disable // jshint -W040 const self = this; // jshint +W040 // jscs:enable const Model = self.constructor; const shield = Model.shield; const action = 'update'; const rules = shield.getApplicableRules(action); const primaryKey = Model.idAttribute; const query = {}; const tmpModel = Model.forge(query); // validate that the model isNew if (self.isNew()) { return Promise.reject( new AuthError('attempt to update a new record') ); } query[primaryKey] = self.get(primaryKey);
javascript
{ "resource": "" }
q3640
createSecure
train
function createSecure(user, options) { // jscs:disable // jshint -W040 const self = this; // jshint +W040 // jscs:enable let shield; let action; let rules; // validate that the model isNew if (!self.isNew()) { return Promise.reject( new AuthError('attempt to create a record that exists') ); }
javascript
{ "resource": "" }
q3641
bypass
train
function bypass(method, options) { // jscs:disable // jshint -W040 const self = this; // jshint +W040 // jscs:enable const shield = self.constructor.shield; if (!_.includes(shield.protectedMethods, method)) { return
javascript
{ "resource": "" }
q3642
addError
train
function addError(data, error) { if (!data.error) { data.error
javascript
{ "resource": "" }
q3643
createTmpHashAction
train
function createTmpHashAction(contentHashFields, multiRowFields) { let tmpHashFields = []; // where there fields from the contentHashFields in the multiRowFields? let fieldClash = false; // add the original content hash fields to an new array // but check that there are not in the multiRowFields. for (let i = 0; i < contentHashFields.length; i++) { let found = false;
javascript
{ "resource": "" }
q3644
RenderManager
train
function RenderManager(view) { this.running = false; this._frame = 0; this.view = view; this.skipFrames = 0; this.skipFramesCounter = 0; this.onEnterFrame = new signals.Signal(); this.onExitFrame
javascript
{ "resource": "" }
q3645
mergeMap
train
function mergeMap(instance, data) { // for each key in canReflect.eachKey(instance, function(value, prop) { if(!canReflect.hasKey(data, prop)) { canReflect.deleteKeyValue(instance, prop); return; } var newValue = canReflect.getKeyValue(data, prop); canReflect.deleteKeyValue(data, prop); // cases: // a. list // b. map // c. primitive // if the data is typed, we would just replace it if (canReflect.isPrimitive(value)) { canReflect.setKeyValue(instance, prop, newValue); return; } var newValueIsList = Array.isArray(newValue), currentValueIsList = canReflect.isMoreListLikeThanMapLike(value); if
javascript
{ "resource": "" }
q3646
Command
train
function Command(handler, options, desc)
javascript
{ "resource": "" }
q3647
loadJSON
train
function loadJSON (file, callback) { loadText(file, function (err, data) { if (err) { callback(err, null) } else { var json = null try { json = JSON.parse(data)
javascript
{ "resource": "" }
q3648
train
function(req, res, next) { async.parallel({ applications: (fn) => { const spy = { stash: {} }; applications.get(req, spy, () => { if(spy.stash.code !== 200) { return fn(new Error('Error getting applications.')); } return fn(null, spy.stash.body); }); }, hosts: (fn) => { const spy = { stash: {} }; hosts.get(req, spy, () => { if(spy.stash.code !== 200) { return fn(new Error('Error getting hosts.')); } return fn(null, spy.stash.body);
javascript
{ "resource": "" }
q3649
HTTPError
train
function HTTPError(statusCode, message) { if (!(this instanceof HTTPError)) { return new HTTPError(statusCode, message); } assert(statusCode >= 400, 'Not a valid HTTP error
javascript
{ "resource": "" }
q3650
map
train
function map(schema, valueSchema) { if (!objtools.isPlainObject(schema)) { valueSchema = schema; schema =
javascript
{ "resource": "" }
q3651
train
function() { this.jsonInit({ "message0": "%1", "args0": [ { "type": "field_dropdown", "name": "ON", "options": [ [Blockly.Msg.MOTION_IFON_EDGE, '_edge_'], [Blockly.Msg.MOTION_IFON_POINTER, '_mouse_'], ] }
javascript
{ "resource": "" }
q3652
train
function (src, dst, config, headers, callback) { if (_.isFunction(headers)) { callback = headers; headers = undefined; } var options = config.options; if (!fsys.isFileSync(src)) { return callback(new Error('source file not found. path:', src)); } _.defaults(options || (options = {}), DEFAULT_OPTIONS); var encode = options.encode; var compress = options.compress; var firebug = options.firebug; var linenos = options.linenos; var urlopt = options.url; var raw = fs.readFileSync(src, encode); var styl = stylus(raw) .set('filename', dst) .set('compress', compress) .set('firebug', firebug) .set('linenos', linenos) .define('b64', stylus.url(urlopt)) ; if (options.nib) { // use nib library styl.use(nib()); } // extend options if (config.hasOwnProperty('extend') && headers && common.isUAOverride(config, headers) && config.extend.hasOwnProperty('content')) { options = obj.copy(config.extend.content, config).options; logger.debug('Override stylus options:', options); } // define functions and constant values
javascript
{ "resource": "" }
q3653
incrementalProp
train
function incrementalProp(state1, state2, propName, compare) { const values1 = state1[propName]; const values2 = state2[propName]; let result; // Note: Values may be undefined if no data was read. if (((values1 && values1.length !== 0) || state1.ended) && ((values2 && values2.length !== 0) || state2.ended)) { const minLen = Math.min( values1 ? values1.length : 0,
javascript
{ "resource": "" }
q3654
train
function (context) { context.setCookie = function (name, value, options) { var cookieStr = cookie.serialize(name, value, options); if (res) { var header = res.getHeader('Set-Cookie') || []; if (!Array.isArray(header)) { header = [header]; } header.push(cookieStr); res.setHeader('Set-Cookie', header); } else { document.cookie = cookieStr; } cookies[name] = value;
javascript
{ "resource": "" }
q3655
onList
train
function onList(newList) { var current = this.currentList || []; newList = newList || []; if (current[offPatchesSymbol]) { current[offPatchesSymbol](this.onPatchesNotify, "notify"); } var patches = diff(current, newList); this.currentList = newList; this.onPatchesNotify(patches);
javascript
{ "resource": "" }
q3656
onPatchesNotify
train
function onPatchesNotify(patches) { // we are going to collect all patches this.patches.push.apply(this.patches, patches); // TODO: share priority
javascript
{ "resource": "" }
q3657
clean
train
function clean(object, follow = false) { // check if object is an object if (is(object) && !empty(object)) { // clone the object to use as the result and // so it is immutable let result = clone(object); // if follow is true flatten the object keys so // its easy to get the path to delete and so // it's easy to check if values are null/undefined // if follow is false it will just be the base // object therefore it will only check the base keys const keysObject = follow ? deflate(object) : object; // loop over the keys of the object Object.keys(keysObject).forEach((key) => { // get the value of the current key const
javascript
{ "resource": "" }
q3658
train
function(id) { var canvasContainer = document.createElement("div"); canvasContainer.id = id; canvasContainer.width = window.innerWidth;
javascript
{ "resource": "" }
q3659
train
function(element, mode) { var style = element.style; switch(mode) { case DOMMode.FULLSCREEN: style.position = "fixed"; style.left = "0px"; style.top = "0px"; style.width = '100%'; style.height = '100%'; break; case DOMMode.CONTAINER: style.position = "absolute"; style.left = "0px"; style.top
javascript
{ "resource": "" }
q3660
del
train
function del(object, path) { // check if the object is an object and isn't empty if (is(object) && !empty(object)) { // clone the object let cloned = clone(object); // set the new value for the cloned object so we // can manipulate it const result = cloned; // get the path parts const pathParts = getPathParts(path); // loop over all the path parts for (let index = 0; index < pathParts.length; index += 1) { // get the current key const key = pathParts[index]; // check if the current path is the last key if (index === pathParts.length - 1) {
javascript
{ "resource": "" }
q3661
train
function(e, ui) { var dst = $(this), targets = $.grep(ui.helper.data('files')||[], function(h) { return h? true : false; }), result = [], dups = [], faults = [], isCopy = ui.helper.hasClass('elfinder-drag-helper-plus'), c = 'class', cnt, hash, i, h; if (typeof e.button === 'undefined' || ui.helper.data('namespace') !== namespace || ! self.insideWorkzone(e.pageX, e.pageY)) { return false; } if (dst.hasClass(self.res(c, 'cwdfile'))) { hash = self.cwdId2Hash(dst.attr('id')); } else if (dst.hasClass(self.res(c, 'navdir'))) { hash = self.navId2Hash(dst.attr('id'));
javascript
{ "resource": "" }
q3662
train
function() { var full; if (node.hasClass(cls)) { return node.get(0); } else { full = node.find('.' + cls);
javascript
{ "resource": "" }
q3663
train
function(type, order, stickFolders, alsoTreeview) { this.storage('sortType', (this.sortType = this.sortRules[type] ? type : 'name')); this.storage('sortOrder', (this.sortOrder = /asc|desc/.test(order) ? order : 'asc')); this.storage('sortStickFolders',
javascript
{ "resource": "" }
q3664
train
function(a, b) { var self = elFinder.prototype.naturalCompare; if (typeof self.loc == 'undefined') { self.loc = (navigator.userLanguage || navigator.browserLanguage || navigator.language || 'en-US'); } if (typeof self.sort == 'undefined') { if ('11'.localeCompare('2', self.loc, {numeric: true}) > 0) { // Native support if (window.Intl && window.Intl.Collator) { self.sort = new Intl.Collator(self.loc, {numeric: true}).compare; } else { self.sort = function(a, b) { return a.localeCompare(b, self.loc, {numeric: true}); }; } } else { /* * Edited for elFinder (emulates localeCompare() by numeric) by Naoki Sawada aka nao-pon */ /* * Huddle/javascript-natural-sort (https://github.com/Huddle/javascript-natural-sort) */ /* * Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license * Author: Jim Palmer (based on chunking idea from Dave Koelle) * http://opensource.org/licenses/mit-license.php */ self.sort = function(a, b) { var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi, sre = /(^[ ]*|[ ]*$)/g, dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/, hre = /^0x[0-9a-f]+$/i, ore = /^0/, syre = /^[\x01\x21-\x2f\x3a-\x40\x5b-\x60\x7b-\x7e]/, // symbol first - (Naoki Sawada) i = function(s) { return self.sort.insensitive && (''+s).toLowerCase() || ''+s; }, // convert all to strings strip whitespace // first character is "_", it's smallest - (Naoki Sawada) x = i(a).replace(sre, '').replace(/^_/, "\x01") || '',
javascript
{ "resource": "" }
q3665
train
function(file1, file2) { var self = this, type = self.sortType, asc = self.sortOrder == 'asc', stick = self.sortStickFolders, rules = self.sortRules, sort = rules[type], d1 = file1.mime == 'directory', d2
javascript
{ "resource": "" }
q3666
train
function(prefix, phash, glue) { var i = 0, ext = '', p, name; prefix = this.i18n(false, prefix); phash = phash || this.cwd().hash; glue = (typeof glue === 'undefined')? ' ' : glue; if (p = prefix.match(/^(.+)(\.[^.]+)$/)) { ext = p[2]; prefix = p[1]; } name = prefix+ext; if (!this.fileByName(name,
javascript
{ "resource": "" }
q3667
train
function(file, asObject) { var self = this, template = { 'background' : 'url(\'{url}\') 0 0 no-repeat', 'background-size' : 'contain' }, style = '', cssObj = {}, i = 0; if (file.icon) { style = 'style="'; $.each(template, function(k, v) { if (i++ === 0) { v = v.replace('{url}', self.escape(file.icon));
javascript
{ "resource": "" }
q3668
train
function(mimeType) { var prefix = 'elfinder-cwd-icon-', mime = mimeType.toLowerCase(), isText = this.textMimes[mime];
javascript
{ "resource": "" }
q3669
train
function(f) { var isObj = typeof(f) == 'object' ? true : false, mime = isObj ? f.mime : f, kind; if (isObj && f.alias && mime != 'symlink-broken') { kind = 'Alias'; } else if (this.kinds[mime]) { if (isObj && mime === 'directory' && (! f.phash || f.isroot)) { kind = 'Root'; } else { kind = this.kinds[mime];
javascript
{ "resource": "" }
q3670
train
function(format, date) { var self = this, output, d, dw, m, y, h, g, i, s; if (! date) { date = new Date(); } h = date[self.getHours](); g = h > 12 ? h - 12 : h; i = date[self.getMinutes](); s = date[self.getSeconds](); d = date[self.getDate](); dw = date[self.getDay](); m = date[self.getMonth]() + 1; y = date[self.getFullYear](); output = format.replace(/[a-z]/gi, function(val) { switch (val) { case 'd': return d > 9 ? d : '0'+d; case 'j': return d; case 'D': return self.i18n(self.i18.daysShort[dw]); case 'l': return self.i18n(self.i18.days[dw]); case 'm': return m > 9 ? m : '0'+m; case 'n': return m; case 'M': return self.i18n(self.i18.monthsShort[m-1]); case 'F': return self.i18n(self.i18.months[m-1]); case 'Y': return y;
javascript
{ "resource": "" }
q3671
train
function(file, t) { var self = this, ts = t || file.ts, i18 = self.i18, date, format, output, d, dw, m, y, h, g, i, s; if (self.options.clientFormatDate && ts > 0) { date = new Date(ts*1000); format = ts >= this.yesterday ? this.fancyFormat : this.dateFormat; output = self.date(format, date); return ts >= this.yesterday ? output.replace('$1',
javascript
{ "resource": "" }
q3672
train
function(num) { var v = new Number(num); if (v) { if (v.toLocaleString) { return v.toLocaleString(); } else {
javascript
{ "resource": "" }
q3673
train
function(o) { var c = ''; if (!o.read && !o.write) { c = 'elfinder-na'; } else if (!o.read) { c = 'elfinder-wo'; } else if (!o.write) { c =
javascript
{ "resource": "" }
q3674
train
function(f) { var p = []; f.read && p.push(this.i18n('read')); f.write && p.push(this.i18n('write')); return p.length ?
javascript
{ "resource": "" }
q3675
train
function(s) { var n = 1, u = 'b'; if (s == 'unknown') { return this.i18n('unknown'); } if (s > 1073741824) { n = 1073741824; u = 'GB'; } else if (s > 1048576) { n = 1048576; u = 'MB'; } else if (s > 1024) {
javascript
{ "resource": "" }
q3676
train
function(mime, target) { target = target || this.cwd().hash; var res = true, // default is allow mimeChecker = this.option('uploadMime', target), allow, deny, check = function(checker) { var ret = false; if (typeof checker === 'string' && checker.toLowerCase() === 'all') { ret = true; } else if (Array.isArray(checker) && checker.length) { $.each(checker, function(i, v) { v = v.toLowerCase(); if (v === 'all' || mime.indexOf(v) === 0) { ret = true; return false; } }); } return ret; }; if
javascript
{ "resource": "" }
q3677
train
function(tasks) { var l = tasks.length, chain = function(task, idx) { ++idx; if (tasks[idx]) { return chain(task.then(tasks[idx]), idx); } else { return task;
javascript
{ "resource": "" }
q3678
train
function(url) { var dfd = $.Deferred(), ifm; try { ifm = $('<iframe width="1" height="1" scrolling="no" frameborder="no" style="position:absolute; top:-1px; left:-1px" crossorigin="use-credentials">') .attr('src', url) .one('load', function() { var ifm = $(this);
javascript
{ "resource": "" }
q3679
train
function(files, opts) { var self = this, cwd = this.getUI('cwd'), cwdHash = this.cwd().hash, newItem = $(); opts = opts || {}; $.each(files, function(i, f) { if (f.phash === cwdHash || self.searchStatus.state > 1) {
javascript
{ "resource": "" }
q3680
train
function(url) { if (url.match(/^http/i)) { return url; } if (url.substr(0,2) === '//') { return window.location.protocol + url; } var root = window.location.protocol + '//' + window.location.host, reg = /[^\/]+\/\.\.\//, ret; if (url.substr(0, 1) === '/') { ret = root + url; } else { ret
javascript
{ "resource": "" }
q3681
train
function (checkUrl) { var url; checkUrl = this.convAbsUrl(checkUrl); if (location.origin && window.URL) { try { url = new URL(checkUrl); return location.origin === url.origin; } catch(e) {} } url =
javascript
{ "resource": "" }
q3682
train
function() { var self = this, node = this.getUI(), ni = node.css('z-index'); if (ni && ni !== 'auto' && ni !== 'inherit') { self.zIndex = ni; } else { node.parents().each(function(i, n) { var
javascript
{ "resource": "" }
q3683
train
function(urls) { var self = this; if (typeof urls === 'string') { urls = [ urls ]; } $.each(urls, function(i, url) { url = self.convAbsUrl(url).replace(/^https?:/i, ''); if (! $("head > link[href='+url+']").length)
javascript
{ "resource": "" }
q3684
train
function(func, arr, opts) { var dfrd = $.Deferred(), abortFlg = false, parms = Object.assign({ interval : 0, numPerOnce : 1 }, opts || {}), resArr = [], vars =[], curVars = [], exec, tm; dfrd._abort = function(resolve) { tm && clearTimeout(tm); vars = []; abortFlg = true; if (dfrd.state() === 'pending') { dfrd[resolve? 'resolve' : 'reject'](resArr); } }; dfrd.fail(function() { dfrd._abort(); }).always(function() { dfrd._abort = function() {}; }); if (typeof func === 'function' && Array.isArray(arr)) { vars = arr.concat(); exec = function() { var i, len, res; if (abortFlg) { return; } curVars = vars.splice(0, parms.numPerOnce); len
javascript
{ "resource": "" }
q3685
train
function(dir, update) { var self = this, prev = update? dir : (self.file(dir.hash) || dir), prevTs = prev.ts, change = false; // backup original stats if (update || !dir._realStats) { dir._realStats = { locked: dir.locked || 0, dirs: dir.dirs || 0, ts: dir.ts
javascript
{ "resource": "" }
q3686
train
function(xhr, o) { var opts = o || {}; if (xhr) { opts.quiet && (xhr.quiet = true); if (opts.abort && xhr._requestId) { this.request({ data: {
javascript
{ "resource": "" }
q3687
train
function (trans, val) { var key, tmpArr = {}, isArr = $.isArray(trans); for (key in trans) { if (isArr
javascript
{ "resource": "" }
q3688
train
function(arrayBuffer, sliceSize) { var segments= [], fi = 0; while(fi * sliceSize < arrayBuffer.byteLength){
javascript
{ "resource": "" }
q3689
train
function(e, ui) { var dst = $(this), helper = ui.helper, cl = hover+' '+dropover, hash, status; e.stopPropagation(); helper.data('dropover', helper.data('dropover') + 1); dst.data('dropover', true); if (ui.helper.data('namespace') !== fm.namespace || ! insideNavbar(e.clientX) || ! fm.insideWorkzone(e.pageX, e.pageY)) { dst.removeClass(cl); helper.removeClass('elfinder-drag-helper-move elfinder-drag-helper-plus'); return; } dst.addClass(hover); if (dst.is('.'+collapsed+':not(.'+expanded+')')) { dst.data('expandTimer', setTimeout(function() { dst.is('.'+collapsed+'.'+hover) && dst.children('.'+arrow).trigger('click'); }, 500)); } if (dst.is('.elfinder-ro,.elfinder-na')) { dst.removeClass(dropover); helper.removeClass('elfinder-drag-helper-move elfinder-drag-helper-plus'); return; } hash = fm.navId2Hash(dst.attr('id')); dst.data('dropover', hash); $.each(ui.helper.data('files'),
javascript
{ "resource": "" }
q3690
train
function(e, d) { selectTm && cancelAnimationFrame(selectTm); if (! e.data || ! e.data.selected || ! e.data.selected.length) { selectTm = requestAnimationFrame(function() {
javascript
{ "resource": "" }
q3691
train
function(ql) { var fm = ql.fm, mimes = fm.arrayFlip(['text/html', 'application/xhtml+xml']), preview = ql.preview; preview.on(ql.evUpdate, function(e) { var file = e.file, jqxhr, loading; if (mimes[file.mime] && ql.dispInlineRegex.test(file.mime) && (!ql.options.getSizeMax || file.size <= ql.options.getSizeMax)) { e.stopImmediatePropagation(); loading = $('<div class="elfinder-quicklook-info-data"> '+fm.i18n('nowLoading')+'<span class="elfinder-info-spinner"></div>').appendTo(ql.info.find('.elfinder-quicklook-info')); // stop loading on change file if not loaded yet preview.one('change', function() { jqxhr.state() == 'pending' && jqxhr.reject(); }).addClass('elfinder-overflow-auto'); jqxhr = fm.request({ data : {cmd : 'get', target : file.hash, conv
javascript
{ "resource": "" }
q3692
train
function(ql) { var fm = ql.fm, mimes = fm.arrayFlip(['text/x-markdown']), preview = ql.preview, marked = null, show = function(data, loading) { ql.hideinfo(); var doc = $('<iframe class="elfinder-quicklook-preview-html"/>').appendTo(preview)[0].contentWindow.document; doc.open(); doc.write(marked(data.content)); doc.close(); loading.remove(); }, error = function(loading) { marked = false; loading.remove(); }; preview.on(ql.evUpdate, function(e) { var file = e.file, jqxhr, loading; if (mimes[file.mime] && fm.options.cdns.marked && marked !== false && ql.dispInlineRegex.test(file.mime) && (!ql.options.getSizeMax || file.size <= ql.options.getSizeMax)) { e.stopImmediatePropagation(); loading = $('<div class="elfinder-quicklook-info-data"> '+fm.i18n('nowLoading')+'<span class="elfinder-info-spinner"></div>').appendTo(ql.info.find('.elfinder-quicklook-info')); // stop loading on change file if not loaded yet preview.one('change', function() { jqxhr.state() == 'pending' && jqxhr.reject(); }).addClass('elfinder-overflow-auto'); jqxhr = fm.request({ data : {cmd :
javascript
{ "resource": "" }
q3693
train
function(ql) { var fm = ql.fm, mime = 'application/pdf', preview = ql.preview, active = false; if ((fm.UA.Safari && fm.OS === 'mac' && !fm.UA.iOS) || fm.UA.IE) { active = true; } else { $.each(navigator.plugins, function(i, plugins) { $.each(plugins, function(i, plugin) { if (plugin.type === mime) {
javascript
{ "resource": "" }
q3694
train
function(ql) { var fm = ql.fm, mime = 'application/x-shockwave-flash', preview = ql.preview, active = false; $.each(navigator.plugins, function(i, plugins) { $.each(plugins, function(i, plugin) { if (plugin.type === mime) { return !(active = true); } }); }); active && preview.on(ql.evUpdate, function(e) { var file = e.file, node; if (file.mime === mime && ql.dispInlineRegex.test(file.mime)) { e.stopImmediatePropagation();
javascript
{ "resource": "" }
q3695
train
function(element) { var pnode = element; var x = pnode.offsetLeft; var y = pnode.offsetTop; while ( pnode.offsetParent ) { pnode = pnode.offsetParent; if (pnode != document.body && pnode.currentStyle['position']
javascript
{ "resource": "" }
q3696
catchClientError
train
function catchClientError(req, res, next) { const { end } = res; res.end = function() { // console.log(`Catch client response : ${req.url} ${res.statusCode}`); const errorRoute = Route .routes('err') .filter((obj) => { return obj.extra.status === res.statusCode && obj.route !== req.url; });
javascript
{ "resource": "" }
q3697
loadQuote
train
async function loadQuote(store, quoteId) { const quote = await fetchQuote(quoteId) await store.update(state =>
javascript
{ "resource": "" }
q3698
nextQuote
train
async function nextQuote(store) { await store.update(state => { state.quoteId = state.quoteId + 1 if
javascript
{ "resource": "" }
q3699
prevQuote
train
async function prevQuote(store) { await store.update(state => { state.quoteId = state.quoteId - 1 if
javascript
{ "resource": "" }