code
stringlengths
31
2.05k
label_name
stringclasses
5 values
label
int64
0
4
for(var t,r=this;r instanceof En;){var e=Fe(r);e.__index__=0,e.__values__=T,t?u.__wrapped__=e:t=e;var u=e,r=r.__wrapped__}return u.__wrapped__=n,t},An.prototype.reverse=function(){var n=this.__wrapped__;return n instanceof Un?(this.__actions__.length&&(n=new Un(this)),n=n.reverse(),n.__actions__.push({func:Qe,args:[Ge],thisArg:T}),new On(n,this.__chain__)):this.thru(Ge)},An.prototype.toJSON=An.prototype.valueOf=An.prototype.value=function(){return wr(this.__wrapped__,this.__actions__)},An.prototype.first=An.prototype.head,
Base
1
}),r}function B(n,t){return function(r){return n(t(r))}}function L(n,t){for(var r=-1,e=n.length,u=0,i=[];++r<e;){var o=n[r];o!==t&&"__lodash_placeholder__"!==o||(n[r]="__lodash_placeholder__",i[u++]=r)}return i}function U(n){var t=-1,r=Array(n.size);return n.forEach(function(n){r[++t]=n}),r}function C(n){var t=-1,r=Array(n.size);return n.forEach(function(n){r[++t]=[n,n]}),r}function D(n){if(Rn.test(n)){for(var t=On.lastIndex=0;On.test(n);)++t;n=t}else n=Qn(n);return n}function M(n){return Rn.test(n)?n.match(On)||[]:n.split("");
Base
1
return this.reverse().takeWhile(n).reverse()},Un.prototype.toArray=function(){return this.take(4294967295)},mt(Un.prototype,function(n,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),e=/^(?:head|last)$/.test(t),u=An[e?"take"+("last"==t?"Right":""):t],i=e||/^find/.test(t);u&&(An.prototype[t]=function(){function t(n){return n=u.apply(An,a([n],f)),e&&h?n[0]:n}var o=this.__wrapped__,f=e?[1]:arguments,c=o instanceof Un,l=f[0],s=c||ff(o);s&&r&&typeof l=="function"&&1!=l.length&&(c=s=false);var h=this.__chain__,p=!!this.__actions__.length,l=i&&!h,c=c&&!p;
Base
1
return r}function s(n,t,r,e){var u=null==n?0:n.length;for(e&&u&&(r=n[--u]);u--;)r=t(r,n[u],u,n);return r}function h(n,t){for(var r=-1,e=null==n?0:n.length;++r<e;)if(t(n[r],r,n))return true;return false}function p(n,t,r){var e;return r(n,function(n,r,u){if(t(n,r,u))return e=r,false}),e}function _(n,t,r,e){var u=n.length;for(r+=e?1:-1;e?r--:++r<u;)if(t(n[r],r,n))return r;return-1}function v(n,t,r){if(t===t)n:{--r;for(var e=n.length;++r<e;)if(n[r]===t){n=r;break n}n=-1}else n=_(n,d,r);return n}function g(n,t,r,e){
Base
1
Or(n,0,t).join("")):n},An.trimStart=function(n,t,r){return(n=Iu(n))&&(r||t===T)?n.replace(on,""):n&&(t=yr(t))?(n=M(n),t=I(n,M(t)),Or(n,t).join("")):n},An.truncate=function(n,t){var r=30,e="...";if(du(t))var u="separator"in t?t.separator:u,r="length"in t?Eu(t.length):r,e="omission"in t?yr(t.omission):e;n=Iu(n);var i=n.length;if(Rn.test(n))var o=M(n),i=o.length;if(r>=i)return n;if(i=r-D(e),1>i)return e;if(r=o?Or(o,0,i).join(""):n.slice(0,i),u===T)return r+e;if(o&&(i+=r.length-i),hf(u)){if(n.slice(i).search(u)){
Base
1
An.toInteger=Eu,An.toLength=ku,An.toLower=function(n){return Iu(n).toLowerCase()},An.toNumber=Su,An.toSafeInteger=function(n){return n?pt(Eu(n),-9007199254740991,9007199254740991):0===n?n:0},An.toString=Iu,An.toUpper=function(n){return Iu(n).toUpperCase()},An.trim=function(n,t,r){return(n=Iu(n))&&(r||t===T)?n.replace(un,""):n&&(t=yr(t))?(n=M(n),r=M(t),t=I(n,r),r=R(n,r)+1,Or(n,t,r).join("")):n},An.trimEnd=function(n,t,r){return(n=Iu(n))&&(r||t===T)?n.replace(fn,""):n&&(t=yr(t))?(n=M(n),t=R(n,M(t))+1,
Base
1
Or(n,0,t).join("")):n},An.trimStart=function(n,t,r){return(n=Iu(n))&&(r||t===T)?n.replace(on,""):n&&(t=yr(t))?(n=M(n),t=I(n,M(t)),Or(n,t).join("")):n},An.truncate=function(n,t){var r=30,e="...";if(du(t))var u="separator"in t?t.separator:u,r="length"in t?Eu(t.length):r,e="omission"in t?yr(t.omission):e;n=Iu(n);var i=n.length;if(Rn.test(n))var o=M(n),i=o.length;if(r>=i)return n;if(i=r-D(e),1>i)return e;if(r=o?Or(o,0,i).join(""):n.slice(0,i),u===T)return r+e;if(o&&(i+=r.length-i),hf(u)){if(n.slice(i).search(u)){ var f=r;for(u.global||(u=Xu(u.source,Iu(_n.exec(u))+"g")),u.lastIndex=0;o=u.exec(f);)var c=o.index;r=r.slice(0,c===T?i:c)}}else n.indexOf(yr(u),i)!=i&&(u=r.lastIndexOf(u),-1<u&&(r=r.slice(0,u)));return r+e},An.unescape=function(n){return(n=Iu(n))&&G.test(n)?n.replace(V,tt):n},An.uniqueId=function(n){var t=++fi;return Iu(n)+t},An.upperCase=Tf,An.upperFirst=$f,An.each=nu,An.eachRight=tu,An.first=qe,Nu(An,function(){var n={};return mt(An,function(t,r){oi.call(An.prototype,r)||(n[r]=t)}),n}(),{chain:false
Base
1
window.onpageshow=function(event) { /** * Same as above for Safari (does not execute Javascript on history back) * persisted indicates if the document is loading from a cache (not reliable) * * @link https://web.dev/bfcache/ */ if (event.persisted || window.performance && (performance.navigation.type == 2 || (performance.getEntriesByType && performance.getEntriesByType("navigation")[0] && performance.getEntriesByType("navigation")[0].type === 'back_forward'))) { location.reload(); } };
Pillar
3
constructor(el, options) { super(el, options); this.delay = parseInt(localStorage.sidekiqTimeInterval) || 5000; this.startPolling(); document.addEventListener("interval:update", this.handleUpdate.bind(this)); }
Class
2
model() { return this.store.findAll("pending-post", { username: this.username, }); },
Base
1
htmlConverter: sourceDocument.getURL('get', $.param({ sheet: 'CKEditor.HTMLConverter', outputSyntax: 'plain', language: $('html').attr('lang') || '' })) }, editor.config['xwiki-source']); // The source command is not registered if the editor is loaded in-line. var sourceCommand = editor.getCommand('source'); if (sourceCommand) { editor.on('beforeSetMode', this.onBeforeSetMode.bind(this)); editor.on('beforeModeUnload', this.onBeforeModeUnload.bind(this)); editor.on('mode', this.onMode.bind(this)); // The default source command is not asynchronous so it becomes (re)enabled right after the editing mode is // changed. In our case switching between WYSIWYG and Source mode is asynchronous because we need to convert the // edited content on the server side. Thus we need to prevent the source command from being enabled while the // conversion takes place. // CKEDITOR-66: Switch to source corrupt page when connection lost or when connection is very slow var oldCheckAllowed = sourceCommand.checkAllowed; sourceCommand.checkAllowed = function() { return !this.running && oldCheckAllowed.apply(this, arguments); }; } },
Compound
4
language: $('html').attr('lang') || '' }))
Compound
4
function preprocessRFC2822(s) { // Remove comments and folding whitespace and replace multiple-spaces with a single space return s .replace(/\([^)]*\)|[\n\t]/g, " ") .replace(/(\s\s+)/g, " ") .trim(); }
Base
1
function RestWrite(config, auth, className, query, data, originalData, clientSDK, context, action) { if (auth.isReadOnly) { throw new Parse.Error( Parse.Error.OPERATION_FORBIDDEN, 'Cannot perform a write operation when using readOnlyMasterKey' ); } this.config = config; this.auth = auth; this.className = className; this.clientSDK = clientSDK; this.storage = {}; this.runOptions = {}; this.context = context || {}; if (action) { this.runOptions.action = action; } if (!query) { if (this.config.allowCustomObjectId) { if (Object.prototype.hasOwnProperty.call(data, 'objectId') && !data.objectId) { throw new Parse.Error( Parse.Error.MISSING_OBJECT_ID, 'objectId must not be empty, null or undefined' ); } } else { if (data.objectId) { throw new Parse.Error(Parse.Error.INVALID_KEY_NAME, 'objectId is an invalid field name.'); } if (data.id) { throw new Parse.Error(Parse.Error.INVALID_KEY_NAME, 'id is an invalid field name.'); } } } this.checkProhibitedKeywords(data); // When the operation is complete, this.response may have several // fields. // response: the actual data to be returned // status: the http status code. if not present, treated like a 200 // location: the location header. if not present, no location header this.response = null; // Processing this operation may mutate our data, so we operate on a // copy this.query = deepcopy(query); this.data = deepcopy(data); // We never change originalData, so we do not need a deep copy this.originalData = originalData; // The timestamp we'll use for this whole operation this.updatedAt = Parse._encode(new Date()).iso; // Shared SchemaController to be reused to reduce the number of loadSchema() calls per request // Once set the schemaData should be immutable this.validSchemaController = null; this.pendingOps = { operations: null, identifier: null, }; }
Variant
0
RestWrite.prototype.checkProhibitedKeywords = function (data) { if (this.config.requestKeywordDenylist) { // Scan request data for denied keywords for (const keyword of this.config.requestKeywordDenylist) { const match = Utils.objectContainsKeyValue(data, keyword.key, keyword.value); if (match) { throw new Parse.Error( Parse.Error.INVALID_KEY_NAME, `Prohibited keyword in request data: ${JSON.stringify(keyword)}.` ); } } } };
Variant
0
objectId: this.objectId(), }, }) .execute() .then(results => { results.results.forEach(session => this.config.cacheController.user.del(session.sessionToken) ); }); } return promise .then(() => { // Transform the password if (this.data.password === undefined) { // ignore only if undefined. should proceed if empty ('') return Promise.resolve(); } if (this.query) { this.storage['clearSessions'] = true; // Generate a new session only if the user requested if (!this.auth.isMaster && !this.auth.isMaintenance) { this.storage['generateNewSession'] = true; } } return this._validatePasswordPolicy().then(() => { return passwordCrypto.hash(this.data.password).then(hashedPassword => { this.data._hashed_password = hashedPassword; delete this.data.password; }); }); }) .then(() => { return this._validateUserName(); }) .then(() => { return this._validateEmail(); }); };
Class
2
views: [path.join(__dirname, "templates"), path.join(__dirname, "othertemplates")], "view cache": true, "view options": { autoEscape: false }, }, }, function (_err: Error | null, res?: string) { expect(res).toEqual("Hi <p>Ben</p>"); } ); });
Base
1
function cb(err: Error, _res?: string) { expect(err).toBeTruthy(); expect(err.message).toMatch( buildRegEx(` var tR='',__l,__lP,include=E.include.bind(E),includeFile=E.includeFile.bind(E) function layout(p,d){__l=p;__lP=d} tR+='Hi ' tR+=E.e(badSyntax(=!) if(__l)tR=await includeFile(__l,Object.assign(it,{body:tR},__lP)) if(cb){cb(null,tR)} return tR `) ); done(); } renderFile(errFilePath, { name: "Ada Lovelace", async: true }, cb); });
Base
1
views: [path.join(__dirname, "templates"), path.join(__dirname, "othertemplates")], "view cache": true, "view options": { autoEscape: false }, }, }, function (_err: Error | null, res?: string) { expect(res).toEqual("Hi <p>Ben</p>"); } ); }); });
Base
1
function headerValueNormalize (potentialValue) { // To normalize a byte sequence potentialValue, remove // any leading and trailing HTTP whitespace bytes from // potentialValue. return potentialValue.replace( /^[\r\n\t ]+|[\r\n\t ]+$/g, '' ) }
Base
1
function getFileLink(file) { var file_name = highlight(file.name, filter_terms); return ( '<a data-nodrag="true" href="' + getFileUrl(file) + '" title="' + file.description + '"><i class="fas fa-paperclip extra-card-field-file-icon"></i>' + file_name + "</a>" ); }
Base
1
function getValueRenderedWithTlpColor({ label, tlp_color }, filter_terms) { const color = $sce.getTrustedHtml( `<span class="extra-card-field-color card-field-${tlp_color}"></span>` ); return color + highlight(label, filter_terms); }
Base
1
function getCardFieldListValues(values, filter_terms) { function getValueRendered(value) { if (value.color) { return getValueRenderedWithColor(value, filter_terms); } else if (value.tlp_color) { return getValueRenderedWithTlpColor(value, filter_terms); } else if (value.avatar_url) { return getCardFieldUserValue(value, filter_terms); } return highlight(value.label, filter_terms); } function getValueRenderedWithColor(value, filter_terms) { const r = parseInt(value.color.r, 10); const g = parseInt(value.color.g, 10); const b = parseInt(value.color.b, 10); const color = $sce.getTrustedHtml(`<span class="extra-card-field-color" style="background: rgb(${r}, ${g}, ${b})"></span>`); return color + highlight(value.label, filter_terms); } function getValueRenderedWithTlpColor({ label, tlp_color }, filter_terms) { const color = $sce.getTrustedHtml( `<span class="extra-card-field-color card-field-${tlp_color}"></span>` ); return color + highlight(label, filter_terms); } return $sce.trustAsHtml(values.map(getValueRendered).join(", ")); }
Base
1
function getValueRendered(value) { if (value.color) { return getValueRenderedWithColor(value, filter_terms); } else if (value.tlp_color) { return getValueRenderedWithTlpColor(value, filter_terms); } else if (value.avatar_url) { return getCardFieldUserValue(value, filter_terms); } return highlight(value.label, filter_terms); }
Base
1
function getCardFieldDateValue(value) { return moment(value).fromNow(); }
Base
1
function getCardFieldFileValue(artifact_id, field_id, file_descriptions, filter_terms) { function getFileUrl(file) { return ( "/plugins/tracker/attachments/" + encodeURIComponent(file.id) + "-" + encodeURIComponent(file.name) ); } function getFileLink(file) { var file_name = highlight(file.name, filter_terms); return ( '<a data-nodrag="true" href="' + getFileUrl(file) + '" title="' + file.description + '"><i class="fas fa-paperclip extra-card-field-file-icon"></i>' + file_name + "</a>" ); } return file_descriptions.map(getFileLink).join(", "); }
Base
1
function getValueRenderedWithColor(value, filter_terms) { const r = parseInt(value.color.r, 10); const g = parseInt(value.color.g, 10); const b = parseInt(value.color.b, 10); const color = $sce.getTrustedHtml(`<span class="extra-card-field-color" style="background: rgb(${r}, ${g}, ${b})"></span>`); return color + highlight(value.label, filter_terms); }
Base
1
function getCardFieldPermissionsValue(values) { return values.join(", "); }
Base
1
function getCardFieldUserValue(value, filter_terms) { let display_name; if (value.user_url === null) { display_name = highlight(value.display_name, filter_terms); return `<div class="tlp-avatar-mini"> </div><span>${display_name}</span>`; } display_name = highlight(value.display_name, filter_terms); return `<a data-nodrag="true" class="extra-card-field-user" href="${value.user_url}"> <div class="tlp-avatar-mini"><img src="${value.avatar_url}" /></div><span>${display_name}</span> </a>`; }
Base
1
label: SharedPropertiesService.getKanban().label, }); $window.sessionStorage.setItem("tuleap_feedback", message); $window.location.href = "/plugins/agiledashboard/?group_id=" + SharedPropertiesService.getProjectId(); }
Base
1
__add_row(row) { var tr = document.createElement('tr'); tr.id = "tr_" + this.__uuidv4(); for (var col of row) { var td = document.createElement('td'); td.innerHTML = col; tr.appendChild(td); } this.__add_action_button(tr); this.tbody.appendChild(tr); return tr.id; }
Base
1
content: function() { return '<img style="width: 500px; height: 150px;" src="' + $(this).data('network-preview') + '" />'; },
Base
1
function reset_graph_history() { var table = eventGraph.menu_history.items["table_graph_history_actiontable"]; dataHandler.fetch_graph_history(function(history_formatted, network_previews) { table.set_table_data(history_formatted); for(var i=0; i<history_formatted.length; i++) { var history = history_formatted[i]; var cur_email = history[2]; var tr = eventGraph.menu_history.items.table_graph_history_actiontable.get_DOM_row(i); if (!(cur_email == user_email || is_siteadmin)) { // disable delete button var btn_del = $(tr).find('.btn-danger'); btn_del.prop('disabled', true); } // set tooltip preview var preview = network_previews[i]; if (typeof preview == 'string') { var btn_plot = $(tr).find('.btn-success'); btn_plot.data('network-preview', preview); btn_plot.popover({ container: 'body', content: function() { return '<img style="width: 500px; height: 150px;" src="' + $(this).data('network-preview') + '" />'; }, placement: 'right', trigger: 'hover', template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content" style="width: 500px; height: 150px;"></div></div>', html: true, }); } } }); }
Base
1
async function _alertFromGet(type) { if (urlParams.has(type)) { var msg = urlParams.get(type); var div = document.createElement("div"); div.innerHTML = msg; var text = div.textContent || div.innerText || ""; if (!empty(text)) { switch (type) { case 'error': avideoAlertError(text); break; case 'msg': avideoAlertInfo(text); break; case 'success': avideoAlertSuccess(text); break; case 'toast': avideoToast(text); break; } var url = removeGetParam(window.location.href, type); window.history.pushState({}, document.title, url); } } }
Base
1
encode: function (content, k) { let encoded = ""; content = btoa(content); content = btoa(content); for (i = 0; i < content.length; i++) { let a = content.charCodeAt(i); let b = a ^ k; encoded = encoded + String.fromCharCode(b); } return btoa(encoded); }
Class
2
function confirmAjaxAction(action, service, id) { $( "#dialog-confirm" ).dialog({ resizable: false, height: "auto", width: 400, modal: true, title: "Are you sure you want to "+ action + " " + id + "?", buttons: { "Sure": function() { $( this ).dialog( "close" ); if(service == "haproxy") { ajaxActionServers(action, id); if(action == "restart" || action == "reload") { if(localStorage.getItem('restart')) { localStorage.removeItem('restart'); $("#apply").css('display', 'none'); } } } else if (service == "waf") { ajaxActionWafServers(action, id) } else if (service == "nginx") { ajaxActionNginxServers(action, id) } else if (service == "keepalived") { ajaxActionKeepalivedServers(action, id) } else if (service == "apache") { ajaxActionApacheServers(action, id) } else if (service == "waf_nginx") { ajaxActionWafNginxServers(action, id) } }, Cancel: function() { $( this ).dialog( "close" ); } } }); }
Class
2
"Sure": function() { $( this ).dialog( "close" ); if(service == "haproxy") { ajaxActionServers(action, id); if(action == "restart" || action == "reload") { if(localStorage.getItem('restart')) { localStorage.removeItem('restart'); $("#apply").css('display', 'none'); } } } else if (service == "waf") { ajaxActionWafServers(action, id) } else if (service == "nginx") { ajaxActionNginxServers(action, id) } else if (service == "keepalived") { ajaxActionKeepalivedServers(action, id) } else if (service == "apache") { ajaxActionApacheServers(action, id) } else if (service == "waf_nginx") { ajaxActionWafNginxServers(action, id) } },
Class
2
Cancel: function() { $( this ).dialog( "close" ); }
Class
2
token: $('#token').val() }, type: "POST", success: function (data) { data = data.replace(/\s+/g, ' '); if (data.indexOf('error:') != '-1') { toastr.error(data); } else { $("#dialog-settings-service").html(data) $( "input[type=checkbox]" ).checkboxradio(); $("#dialog-settings-service").dialog({ resizable: false, height: "auto", width: 400, modal: true, title: "Settings for " + name, buttons: { "Save": function () { $(this).dialog("close"); serverSettingsSave(id, name, service, $(this)); }, Cancel: function () { $(this).dialog("close"); } } }); } } }); }
Class
2
success: function (data) { data = data.replace(/\s+/g, ' '); if (data.indexOf('error:') != '-1') { toastr.error(data); } else { $("#dialog-settings-service").html(data) $( "input[type=checkbox]" ).checkboxradio(); $("#dialog-settings-service").dialog({ resizable: false, height: "auto", width: 400, modal: true, title: "Settings for " + name, buttons: { "Save": function () { $(this).dialog("close"); serverSettingsSave(id, name, service, $(this)); }, Cancel: function () { $(this).dialog("close"); } } }); } }
Class
2
"Save": function () { $(this).dialog("close"); serverSettingsSave(id, name, service, $(this)); },
Class
2
commit: function (cb) { var cmd = ['git', 'commit', '-am', '"' + this._version + '"'].join(' ') this._exec(cmd, cb) },
Class
2
tag: function (cb) { var cmd = ['git', 'tag', 'v' + this._version].join(' ') this._exec(cmd, cb) },
Class
2
untag: function (cb) { var cmd = ['git', 'tag', '-d', 'v' + this._version].join(' ') this._exec(cmd, cb) },
Class
2
_exec: function (cmd, cb) { child.exec(cmd, this._options, cb) }
Class
2
function GitFn (version, options) { this._version = version this._options = { cwd: options.dir, env: process.env, setsid: false, stdio: [0, 1, 2] } }
Class
2
await this.sequelize.query('select :one as foo, :two as bar', { raw: true, replacements: new Date() }) .should.be.rejectedWith(Error, /Named parameter ":\w+" has no value in the given object\./g); });
Base
1
minifySql(sql) { // replace all consecutive whitespaces with a single plain space character return sql.replace(/\s+/g, ' ') // remove space before coma .replace(/ ,/g, ',') // remove whitespace at start & end .trim(); }
Base
1
expectsql(query, assertions) { const expectations = assertions.query || assertions; let expectation = expectations[Support.sequelize.dialect.name]; const dialect = Support.sequelize.dialect; if (!expectation) { if (expectations['default'] !== undefined) { expectation = expectations['default']; if (typeof expectation === 'string') { // replace [...] with the proper quote character for the dialect // except for ARRAY[...] expectation = expectation.replace(/(?<!ARRAY)\[([^\]]+)]/g, `${dialect.TICK_CHAR_LEFT}$1${dialect.TICK_CHAR_RIGHT}`); } } else { throw new Error(`Undefined expectation for "${Support.sequelize.dialect.name}"!`); } } if (query instanceof Error) { expect(query.message).to.equal(expectation.message); } else { expect(query.query || query).to.equal(expectation); } if (assertions.bind) { const bind = assertions.bind[Support.sequelize.dialect.name] || assertions.bind['default'] || assertions.bind; expect(query.bind).to.deep.equal(bind); } },
Base
1
async function doExport(socket, data, type) { sockets.warnDeprecated(socket, 'POST /api/v3/users/:uid/exports/:type'); if (!socket.uid) { throw new Error('[[error:invalid-uid]]'); } if (!data || parseInt(data.uid, 10) <= 0) { throw new Error('[[error:invalid-data]]'); } await user.isAdminOrSelf(socket.uid, data.uid); api.users.generateExport(socket, { type, ...data }); }
Base
1
Loader.addWorkerEvents = function (worker) { worker.on('exit', (code, signal) => { if (code !== 0) { if (Loader.timesStarted < numProcs * 3) { Loader.timesStarted += 1; if (Loader.crashTimer) { clearTimeout(Loader.crashTimer); } Loader.crashTimer = setTimeout(() => { Loader.timesStarted = 0; }, 10000); } else { console.log(`${numProcs * 3} restarts in 10 seconds, most likely an error on startup. Halting.`); process.exit(); } } console.log(`[cluster] Child Process (${worker.pid}) has exited (code: ${code}, signal: ${signal})`); if (!(worker.suicide || code === 0)) { console.log('[cluster] Spinning up another process...'); forkWorker(worker.index, worker.isPrimary); } }); worker.on('message', (message) => { if (message && typeof message === 'object' && message.action) { switch (message.action) { case 'restart': console.log('[cluster] Restarting...'); Loader.restart(); break; case 'pubsub': workers.forEach((w) => { w.send(message); }); break; case 'socket.io': workers.forEach((w) => { if (w !== worker) { w.send(message); } }); break; } } }); };
Class
2
sessionId: request.signedCookies ? request.signedCookies[nconf.get('sessionKey')] : null, request: request, }); const sessionData = await getSessionAsync(sessionId); if (sessionData && sessionData.passport && sessionData.passport.user) { request.session = sessionData; socket.uid = parseInt(sessionData.passport.user, 10); } else { socket.uid = 0; } request.uid = socket.uid; callback(); }
Class
2
WebCryptography.prototype.encryptFile = function (key, file, File) { return __awaiter(this, void 0, void 0, function () { var bKey, abPlaindata, abCipherdata; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.getKey(key)]; case 1: bKey = _a.sent(); return [4 /*yield*/, file.toArrayBuffer()]; case 2: abPlaindata = _a.sent(); return [4 /*yield*/, this.encryptArrayBuffer(bKey, abPlaindata)]; case 3: abCipherdata = _a.sent(); return [2 /*return*/, File.create({ name: file.name, mimeType: 'application/octet-stream', data: abCipherdata, })]; } }); }); };
Base
1
default_1.prototype.setCipherKey = function (val) { this.cipherKey = val; return this; };
Base
1
url: _this._getFileUrl({ id: msgPayload.file.id, name: msgPayload.file.name, channel: channel, }), }; _this._listenerManager.announceFile(announce); } else { var announce = {}; announce.channel = null; announce.subscription = null; // deprecated --> announce.actualChannel = subscriptionMatch != null ? channel : null; announce.subscribedChannel = subscriptionMatch != null ? subscriptionMatch : channel; // <-- deprecated announce.channel = channel; announce.subscription = subscriptionMatch; announce.timetoken = publishMetaData.publishTimetoken; announce.publisher = message.issuingClientId; if (message.userMetadata) { announce.userMetadata = message.userMetadata; } if (_this._config.cipherKey) { announce.message = _this._crypto.decrypt(message.payload); } else { announce.message = message.payload; } _this._listenerManager.announceMessage(announce); } });
Base
1
WebCryptography.prototype.decryptString = function (key, ciphertext) { return __awaiter(this, void 0, void 0, function () { var abCiphertext, abIv, abPayload, abPlaintext; return __generator(this, function (_a) { switch (_a.label) { case 0: abCiphertext = Buffer.from(ciphertext); abIv = abCiphertext.slice(0, 16); abPayload = abCiphertext.slice(16); return [4 /*yield*/, crypto.subtle.decrypt({ name: 'AES-CBC', iv: abIv }, key, abPayload)]; case 1: abPlaintext = _a.sent(); return [2 /*return*/, Buffer.from(abPlaintext).toString('utf8')]; } }); }); };
Base
1
this.encryptFile = function (key, file) { return cryptography.encryptFile(key, file, _this.File); };
Base
1
function prepareMessagePayload$1(modules, messagePayload) { var crypto = modules.crypto, config = modules.config; var stringifiedPayload = JSON.stringify(messagePayload); if (config.cipherKey) { stringifiedPayload = crypto.encrypt(stringifiedPayload); stringifiedPayload = JSON.stringify(stringifiedPayload); } return stringifiedPayload; }
Base
1
function __processMessage(modules, message) { var config = modules.config, crypto = modules.crypto; if (!config.cipherKey) return message; try { return crypto.decrypt(message); } catch (e) { return message; } }
Base
1
WebCryptography.prototype.decryptArrayBuffer = function (key, ciphertext) { return __awaiter(this, void 0, void 0, function () { var abIv; return __generator(this, function (_a) { abIv = ciphertext.slice(0, 16); return [2 /*return*/, crypto.subtle.decrypt({ name: 'AES-CBC', iv: abIv }, key, ciphertext.slice(16))]; }); }); };
Base
1
WebCryptography.prototype.decryptFile = function (key, file, File) { return __awaiter(this, void 0, void 0, function () { var bKey, abCipherdata, abPlaindata; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.getKey(key)]; case 1: bKey = _a.sent(); return [4 /*yield*/, file.toArrayBuffer()]; case 2: abCipherdata = _a.sent(); return [4 /*yield*/, this.decryptArrayBuffer(bKey, abCipherdata)]; case 3: abPlaindata = _a.sent(); return [2 /*return*/, File.create({ name: file.name, data: abPlaindata, })]; } }); }); };
Base
1
var preparePayload = function (_a, payload) { var crypto = _a.crypto, config = _a.config; var stringifiedPayload = JSON.stringify(payload); if (config.cipherKey) { stringifiedPayload = crypto.encrypt(stringifiedPayload); stringifiedPayload = JSON.stringify(stringifiedPayload); } return stringifiedPayload || ''; };
Base
1
default_1.prototype.getVersion = function () { return '7.3.3'; };
Base
1
this.decryptFile = function (key, file) { return cryptography.decryptFile(key, file, _this.File); };
Base
1
WebCryptography.prototype.encryptString = function (key, plaintext) { return __awaiter(this, void 0, void 0, function () { var abIv, abPlaintext, abPayload, ciphertext; return __generator(this, function (_a) { switch (_a.label) { case 0: abIv = crypto.getRandomValues(new Uint8Array(16)); abPlaintext = Buffer.from(plaintext).buffer; return [4 /*yield*/, crypto.subtle.encrypt({ name: 'AES-CBC', iv: abIv }, key, abPlaintext)]; case 1: abPayload = _a.sent(); ciphertext = concatArrayBuffer(abIv.buffer, abPayload); return [2 /*return*/, Buffer.from(ciphertext).toString('utf8')]; } }); }); };
Base
1
WebCryptography.prototype.getKey = function (key) { return __awaiter(this, void 0, void 0, function () { var bKey, abHash, abKey; return __generator(this, function (_a) { switch (_a.label) { case 0: bKey = Buffer.from(key); return [4 /*yield*/, crypto.subtle.digest('SHA-256', bKey.buffer)]; case 1: abHash = _a.sent(); abKey = Buffer.from(Buffer.from(abHash).toString('hex').slice(0, 32), 'utf8').buffer; return [2 /*return*/, crypto.subtle.importKey('raw', abKey, 'AES-CBC', true, ['encrypt', 'decrypt'])]; } }); }); };
Base
1
function __processMessage$1(modules, message) { var config = modules.config, crypto = modules.crypto; if (!config.cipherKey) return message; try { return crypto.decrypt(message); } catch (e) { return message; } }
Base
1
default_1.prototype.setCipherKey = function (val) { this.cipherKey = val; return this; };
Base
1
default_1.prototype.getVersion = function () { return '7.3.3'; };
Base
1
url: _this._getFileUrl({ id: msgPayload.file.id, name: msgPayload.file.name, channel: channel, }), }; _this._listenerManager.announceFile(announce); } else { var announce = {}; announce.channel = null; announce.subscription = null; // deprecated --> announce.actualChannel = subscriptionMatch != null ? channel : null; announce.subscribedChannel = subscriptionMatch != null ? subscriptionMatch : channel; // <-- deprecated announce.channel = channel; announce.subscription = subscriptionMatch; announce.timetoken = publishMetaData.publishTimetoken; announce.publisher = message.issuingClientId; if (message.userMetadata) { announce.userMetadata = message.userMetadata; } if (_this._config.cipherKey) { announce.message = _this._crypto.decrypt(message.payload); } else { announce.message = message.payload; } _this._listenerManager.announceMessage(announce); } });
Base
1
function default_1(_a) { var subscribeEndpoint = _a.subscribeEndpoint, leaveEndpoint = _a.leaveEndpoint, heartbeatEndpoint = _a.heartbeatEndpoint, setStateEndpoint = _a.setStateEndpoint, timeEndpoint = _a.timeEndpoint, getFileUrl = _a.getFileUrl, config = _a.config, crypto = _a.crypto, listenerManager = _a.listenerManager; this._listenerManager = listenerManager; this._config = config; this._leaveEndpoint = leaveEndpoint; this._heartbeatEndpoint = heartbeatEndpoint; this._setStateEndpoint = setStateEndpoint; this._subscribeEndpoint = subscribeEndpoint; this._getFileUrl = getFileUrl; this._crypto = crypto; this._channels = {}; this._presenceChannels = {}; this._heartbeatChannels = {}; this._heartbeatChannelGroups = {}; this._channelGroups = {}; this._presenceChannelGroups = {}; this._pendingChannelSubscriptions = []; this._pendingChannelGroupSubscriptions = []; this._currentTimetoken = 0; this._lastTimetoken = 0; this._storedTimetoken = null; this._subscriptionStatusAnnounced = false; this._isOnline = true; this._reconnectionManager = new reconnection_manager_1.default({ timeEndpoint: timeEndpoint }); this._dedupingManager = new deduping_manager_1.default({ config: config }); }
Base
1
function __processMessage(modules, message) { var config = modules.config, crypto = modules.crypto; if (!config.cipherKey) return message; try { return crypto.decrypt(message); } catch (e) { return message; } }
Base
1
var preparePayload = function (_a, payload) { var crypto = _a.crypto, config = _a.config; var stringifiedPayload = JSON.stringify(payload); if (config.cipherKey) { stringifiedPayload = crypto.encrypt(stringifiedPayload); stringifiedPayload = JSON.stringify(stringifiedPayload); } return stringifiedPayload || ''; };
Base
1
function __processMessage(modules, message) { var config = modules.config, crypto = modules.crypto; if (!config.cipherKey) return message; try { return crypto.decrypt(message); } catch (e) { return message; } }
Base
1
function prepareMessagePayload(modules, messagePayload) { var crypto = modules.crypto, config = modules.config; var stringifiedPayload = JSON.stringify(messagePayload); if (config.cipherKey) { stringifiedPayload = crypto.encrypt(stringifiedPayload); stringifiedPayload = JSON.stringify(stringifiedPayload); } return stringifiedPayload; }
Base
1
this.encryptFile = function (key, file) { return cryptography.encryptFile(key, file, _this.File); };
Base
1
this.decryptFile = function (key, file) { return cryptography.decryptFile(key, file, _this.File); };
Base
1
NodeCryptography.prototype.encryptStream = function (key, stream) { var output = new stream_1.PassThrough(); var bIv = this.getIv(); var aes = (0, crypto_1.createCipheriv)(this.algo, key, bIv); output.write(bIv); stream.pipe(aes).pipe(output); return output; };
Base
1
WebCryptography.prototype.decryptArrayBuffer = function (key, ciphertext) { return __awaiter(this, void 0, void 0, function () { var abIv; return __generator(this, function (_a) { abIv = ciphertext.slice(0, 16); return [2 /*return*/, crypto.subtle.decrypt({ name: 'AES-CBC', iv: abIv }, key, ciphertext.slice(16))]; }); }); };
Base
1
WebCryptography.prototype.encryptString = function (key, plaintext) { return __awaiter(this, void 0, void 0, function () { var abIv, abPlaintext, abPayload, ciphertext; return __generator(this, function (_a) { switch (_a.label) { case 0: abIv = crypto.getRandomValues(new Uint8Array(16)); abPlaintext = Buffer.from(plaintext).buffer; return [4 /*yield*/, crypto.subtle.encrypt({ name: 'AES-CBC', iv: abIv }, key, abPlaintext)]; case 1: abPayload = _a.sent(); ciphertext = concatArrayBuffer(abIv.buffer, abPayload); return [2 /*return*/, Buffer.from(ciphertext).toString('utf8')]; } }); }); };
Base
1
WebCryptography.prototype.decryptFile = function (key, file, File) { return __awaiter(this, void 0, void 0, function () { var bKey, abCipherdata, abPlaindata; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.getKey(key)]; case 1: bKey = _a.sent(); return [4 /*yield*/, file.toArrayBuffer()]; case 2: abCipherdata = _a.sent(); return [4 /*yield*/, this.decryptArrayBuffer(bKey, abCipherdata)]; case 3: abPlaindata = _a.sent(); return [2 /*return*/, File.create({ name: file.name, data: abPlaindata, })]; } }); }); };
Base
1
WebCryptography.prototype.decryptString = function (key, ciphertext) { return __awaiter(this, void 0, void 0, function () { var abCiphertext, abIv, abPayload, abPlaintext; return __generator(this, function (_a) { switch (_a.label) { case 0: abCiphertext = Buffer.from(ciphertext); abIv = abCiphertext.slice(0, 16); abPayload = abCiphertext.slice(16); return [4 /*yield*/, crypto.subtle.decrypt({ name: 'AES-CBC', iv: abIv }, key, abPayload)]; case 1: abPlaintext = _a.sent(); return [2 /*return*/, Buffer.from(abPlaintext).toString('utf8')]; } }); }); };
Base
1
WebCryptography.prototype.encryptFile = function (key, file, File) { return __awaiter(this, void 0, void 0, function () { var bKey, abPlaindata, abCipherdata; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.getKey(key)]; case 1: bKey = _a.sent(); return [4 /*yield*/, file.toArrayBuffer()]; case 2: abPlaindata = _a.sent(); return [4 /*yield*/, this.encryptArrayBuffer(bKey, abPlaindata)]; case 3: abCipherdata = _a.sent(); return [2 /*return*/, File.create({ name: file.name, mimeType: 'application/octet-stream', data: abCipherdata, })]; } }); }); };
Base
1
WebCryptography.prototype.getKey = function (key) { return __awaiter(this, void 0, void 0, function () { var bKey, abHash, abKey; return __generator(this, function (_a) { switch (_a.label) { case 0: bKey = Buffer.from(key); return [4 /*yield*/, crypto.subtle.digest('SHA-256', bKey.buffer)]; case 1: abHash = _a.sent(); abKey = Buffer.from(Buffer.from(abHash).toString('hex').slice(0, 32), 'utf8').buffer; return [2 /*return*/, crypto.subtle.importKey('raw', abKey, 'AES-CBC', true, ['encrypt', 'decrypt'])]; } }); }); };
Base
1
function PubNubFile(_a) { var stream = _a.stream, data = _a.data, encoding = _a.encoding, name = _a.name, mimeType = _a.mimeType; if (stream instanceof stream_1.Readable) { this.data = stream; if (stream instanceof fs_1.ReadStream) { // $FlowFixMe: incomplete flow node definitions this.name = (0, path_1.basename)(stream.path); } } else if (data instanceof Buffer) { this.data = Buffer.from(data); } else if (typeof data === 'string') { // $FlowFixMe: incomplete flow node definitions this.data = Buffer.from(data, encoding !== null && encoding !== void 0 ? encoding : 'utf8'); } if (name) { this.name = (0, path_1.basename)(name); } if (mimeType) { this.mimeType = mimeType; } if (this.data === undefined) { throw new Error("Couldn't construct a file out of supplied options."); } if (this.name === undefined) { throw new Error("Couldn't guess filename out of the options. Please provide one."); } }
Base
1
function class_1(setup) { var _this = this; setup.cbor = new common_1.default(function (buffer) { return cbor_sync_1.default.decode(Buffer.from(buffer)); }, base64_codec_1.decode); setup.networking = new networking_1.default({ keepAlive: node_1.keepAlive, del: web_node_1.del, get: web_node_1.get, post: web_node_1.post, patch: web_node_1.patch, proxy: node_1.proxy, getfile: web_node_1.getfile, postfile: web_node_1.postfile, }); setup.sdkFamily = 'Nodejs'; setup.PubNubFile = node_3.default; setup.cryptography = new node_2.default(); if (!('ssl' in setup)) { setup.ssl = true; } _this = _super.call(this, setup) || this; return _this; }
Base
1
constructor({ config }) { this._config = config; this._iv = '0123456789012345'; this._allowedKeyEncodings = ['hex', 'utf8', 'base64', 'binary']; this._allowedKeyLengths = [128, 256]; this._allowedModes = ['ecb', 'cbc']; this._defaultOptions = { encryptKey: true, keyEncoding: 'utf8', keyLength: 256, mode: 'cbc', }; }
Base
1
url: this._getFileUrl({ id: msgPayload.file.id, name: msgPayload.file.name, channel, }), }; this._listenerManager.announceFile(announce); } else { const announce = {}; announce.channel = null; announce.subscription = null; // deprecated --> announce.actualChannel = subscriptionMatch != null ? channel : null; announce.subscribedChannel = subscriptionMatch != null ? subscriptionMatch : channel; // <-- deprecated announce.channel = channel; announce.subscription = subscriptionMatch; announce.timetoken = publishMetaData.publishTimetoken; announce.publisher = message.issuingClientId; if (message.userMetadata) { announce.userMetadata = message.userMetadata; } if (this._config.cipherKey) { announce.message = this._crypto.decrypt(message.payload); } else { announce.message = message.payload; } this._listenerManager.announceMessage(announce); } });
Base
1
exports.start = function (args, returnPromise) { let command = exports.path; if (!fs.existsSync(command)) { console.log('Could not find chromedriver in default path: ', command); console.log('Falling back to use global chromedriver bin'); command = process.platform === 'win32' ? 'chromedriver.exe' : 'chromedriver'; } const cp = require('child_process').spawn(command, args); cp.stdout.pipe(process.stdout); cp.stderr.pipe(process.stderr); exports.defaultInstance = cp; if (!returnPromise) { return cp; } const port = getPortFromArgs(args); const pollInterval = 100; const timeout = 10000; return tcpPortUsed.waitUntilUsed(port, pollInterval, timeout) .then(function () { return cp; }); };
Base
1
function getPortFromArgs(args) { let port = 9515; if (!args) { return port; } const portRegexp = /--port=(\d*)/; const portArg = args.find(function (arg) { return portRegexp.test(arg); }); if (portArg) { port = parseInt(portRegexp.exec(portArg)[1]); } return port; }
Base
1
exports.stop = function () { if (exports.defaultInstance != null) { exports.defaultInstance.kill(); } };
Base
1
async function writeUpdate(newVersion, shouldCommit) { const helper = fs.readFileSync('./lib/chromedriver.js', 'utf8'); const versionExport = 'exports.version'; const regex = new RegExp(`^.*${versionExport}.*$`, 'gm'); const updated = helper.replace(regex, `${versionExport} = '${newVersion}';`); const currentMajor = semver.major(currentVersionInPackageJson); const newMajor = semver.major(semver.coerce(newVersion)); const version = currentMajor !== newMajor ? `${newMajor}.0.0` : semver.inc(currentVersionInPackageJson, 'patch'); execSync(`npm version ${version} --git-tag-version=false`); fs.writeFileSync('./lib/chromedriver.js', updated, 'utf8'); if (!shouldCommit) return; execSync('git add :/'); execSync(`git commit -m "Bump version to ${version}"`); execSync(`git tag -s ${version} -m ${version}`); }
Base
1
regx : RegExp( `&${match[1]};`,"g"), val: match[3] }; } }
Base
1
!function(){var t;t=jQuery,Craft.QuickPostWidget=Garnish.Base.extend({params:null,initFields:null,formHtml:null,$widget:null,$form:null,$spinner:null,$errorList:null,loading:!1,init:function(i,r,e,n){this.params=r,this.initFields=e,this.formHtml=n,this.$widget=t("#widget"+i),this.initForm(this.$widget.find("form:first"))},initForm:function(t){this.$form=t,this.$spinner=this.$form.find(".spinner"),this.initFields();var i=this.$form.find("> .buttons > .btngroup > .menubtn"),r=i.data("menubtn").menu.$container.find("> ul > li > a");i.menubtn(),this.addListener(this.$form,"submit","handleFormSubmit"),this.addListener(r,"click","saveAndContinueEditing")},handleFormSubmit:function(t){t.preventDefault(),this.save(this.onSave.bind(this))},saveAndContinueEditing:function(){this.save(this.gotoEntry.bind(this))},save:function(i){var r=this;if(!this.loading){this.loading=!0,this.$spinner.removeClass("hidden");var e=Garnish.getPostData(this.$form),n=t.extend({enabled:1},e,this.params);Craft.postActionRequest("entries/save-entry",n,(function(e,n){if(r.loading=!1,r.$spinner.addClass("hidden"),r.$errorList&&r.$errorList.children().remove(),"success"===n)if(e.success)Craft.cp.displayNotice(Craft.t("app","Entry saved.")),i(e);else if(Craft.cp.displayError(Craft.t("app","Couldn’t save entry.")),e.errors)for(var s in r.$errorList||(r.$errorList=t('<ul class="errors"/>').insertAfter(r.$form)),e.errors)if(e.errors.hasOwnProperty(s))for(var a=0;a<e.errors[s].length;a++){var o=e.errors[s][a];t("<li>"+o+"</li>").appendTo(r.$errorList)}}))}},onSave:function(i){var r=t(this.formHtml);if(this.$form.replaceWith(r),Craft.initUiElements(r),this.initForm(r),void 0!==Craft.RecentEntriesWidget)for(var e=0;e<Craft.RecentEntriesWidget.instances.length;e++){var n=Craft.RecentEntriesWidget.instances[e];n.params.sectionId&&n.params.sectionId!=this.params.sectionId||n.addEntry({url:i.cpEditUrl,title:i.title,dateCreated:i.dateCreated,username:i.authorUsername})}},gotoEntry:function(t){Craft.redirectTo(t.cpEditUrl)}})}();
Base
1
!function(){var t;t=jQuery,Craft.QuickPostWidget=Garnish.Base.extend({params:null,initFields:null,formHtml:null,$widget:null,$form:null,$spinner:null,$errorList:null,loading:!1,init:function(i,r,e,n){this.params=r,this.initFields=e,this.formHtml=n,this.$widget=t("#widget"+i),this.initForm(this.$widget.find("form:first"))},initForm:function(t){this.$form=t,this.$spinner=this.$form.find(".spinner"),this.initFields();var i=this.$form.find("> .buttons > .btngroup > .menubtn"),r=i.data("menubtn").menu.$container.find("> ul > li > a");i.menubtn(),this.addListener(this.$form,"submit","handleFormSubmit"),this.addListener(r,"click","saveAndContinueEditing")},handleFormSubmit:function(t){t.preventDefault(),this.save(this.onSave.bind(this))},saveAndContinueEditing:function(){this.save(this.gotoEntry.bind(this))},save:function(i){var r=this;if(!this.loading){this.loading=!0,this.$spinner.removeClass("hidden");var e=Garnish.getPostData(this.$form),n=t.extend({enabled:1},e,this.params);Craft.postActionRequest("entries/save-entry",n,(function(e,n){if(r.loading=!1,r.$spinner.addClass("hidden"),r.$errorList&&r.$errorList.children().remove(),"success"===n)if(e.success)Craft.cp.displayNotice(Craft.t("app","Entry saved.")),i(e);else if(Craft.cp.displayError(Craft.t("app","Couldn’t save entry.")),e.errors)for(var s in r.$errorList||(r.$errorList=t('<ul class="errors"/>').insertAfter(r.$form)),e.errors)if(e.errors.hasOwnProperty(s))for(var a=0;a<e.errors[s].length;a++){var o=e.errors[s][a];t("<li>"+o+"</li>").appendTo(r.$errorList)}}))}},onSave:function(i){var r=t(this.formHtml);if(this.$form.replaceWith(r),Craft.initUiElements(r),this.initForm(r),void 0!==Craft.RecentEntriesWidget)for(var e=0;e<Craft.RecentEntriesWidget.instances.length;e++){var n=Craft.RecentEntriesWidget.instances[e];n.params.sectionId&&n.params.sectionId!=this.params.sectionId||n.addEntry({url:i.cpEditUrl,title:i.title,dateCreated:i.dateCreated,username:i.authorUsername})}},gotoEntry:function(t){Craft.redirectTo(t.cpEditUrl)}})}();
Base
1
!function(){var t;t=jQuery,Craft.QuickPostWidget=Garnish.Base.extend({params:null,initFields:null,formHtml:null,$widget:null,$form:null,$spinner:null,$errorList:null,loading:!1,init:function(i,r,e,n){this.params=r,this.initFields=e,this.formHtml=n,this.$widget=t("#widget"+i),this.initForm(this.$widget.find("form:first"))},initForm:function(t){this.$form=t,this.$spinner=this.$form.find(".spinner"),this.initFields();var i=this.$form.find("> .buttons > .btngroup > .menubtn"),r=i.data("menubtn").menu.$container.find("> ul > li > a");i.menubtn(),this.addListener(this.$form,"submit","handleFormSubmit"),this.addListener(r,"click","saveAndContinueEditing")},handleFormSubmit:function(t){t.preventDefault(),this.save(this.onSave.bind(this))},saveAndContinueEditing:function(){this.save(this.gotoEntry.bind(this))},save:function(i){var r=this;if(!this.loading){this.loading=!0,this.$spinner.removeClass("hidden");var e=Garnish.getPostData(this.$form),n=t.extend({enabled:1},e,this.params);Craft.postActionRequest("entries/save-entry",n,(function(e,n){if(r.loading=!1,r.$spinner.addClass("hidden"),r.$errorList&&r.$errorList.children().remove(),"success"===n)if(e.success)Craft.cp.displayNotice(Craft.t("app","Entry saved.")),i(e);else if(Craft.cp.displayError(Craft.t("app","Couldn’t save entry.")),e.errors)for(var s in r.$errorList||(r.$errorList=t('<ul class="errors"/>').insertAfter(r.$form)),e.errors)if(e.errors.hasOwnProperty(s))for(var a=0;a<e.errors[s].length;a++){var o=e.errors[s][a];t("<li>"+o+"</li>").appendTo(r.$errorList)}}))}},onSave:function(i){var r=t(this.formHtml);if(this.$form.replaceWith(r),Craft.initUiElements(r),this.initForm(r),void 0!==Craft.RecentEntriesWidget)for(var e=0;e<Craft.RecentEntriesWidget.instances.length;e++){var n=Craft.RecentEntriesWidget.instances[e];n.params.sectionId&&n.params.sectionId!=this.params.sectionId||n.addEntry({url:i.cpEditUrl,title:i.title,dateCreated:i.dateCreated,username:i.authorUsername})}},gotoEntry:function(t){Craft.redirectTo(t.cpEditUrl)}})}();
Base
1
!function(){var t;t=jQuery,Craft.QuickPostWidget=Garnish.Base.extend({params:null,initFields:null,formHtml:null,$widget:null,$form:null,$spinner:null,$errorList:null,loading:!1,init:function(i,r,e,n){this.params=r,this.initFields=e,this.formHtml=n,this.$widget=t("#widget"+i),this.initForm(this.$widget.find("form:first"))},initForm:function(t){this.$form=t,this.$spinner=this.$form.find(".spinner"),this.initFields();var i=this.$form.find("> .buttons > .btngroup > .menubtn"),r=i.data("menubtn").menu.$container.find("> ul > li > a");i.menubtn(),this.addListener(this.$form,"submit","handleFormSubmit"),this.addListener(r,"click","saveAndContinueEditing")},handleFormSubmit:function(t){t.preventDefault(),this.save(this.onSave.bind(this))},saveAndContinueEditing:function(){this.save(this.gotoEntry.bind(this))},save:function(i){var r=this;if(!this.loading){this.loading=!0,this.$spinner.removeClass("hidden");var e=Garnish.getPostData(this.$form),n=t.extend({enabled:1},e,this.params);Craft.postActionRequest("entries/save-entry",n,(function(e,n){if(r.loading=!1,r.$spinner.addClass("hidden"),r.$errorList&&r.$errorList.children().remove(),"success"===n)if(e.success)Craft.cp.displayNotice(Craft.t("app","Entry saved.")),i(e);else if(Craft.cp.displayError(Craft.t("app","Couldn’t save entry.")),e.errors)for(var s in r.$errorList||(r.$errorList=t('<ul class="errors"/>').insertAfter(r.$form)),e.errors)if(e.errors.hasOwnProperty(s))for(var a=0;a<e.errors[s].length;a++){var o=e.errors[s][a];t("<li>"+o+"</li>").appendTo(r.$errorList)}}))}},onSave:function(i){var r=t(this.formHtml);if(this.$form.replaceWith(r),Craft.initUiElements(r),this.initForm(r),void 0!==Craft.RecentEntriesWidget)for(var e=0;e<Craft.RecentEntriesWidget.instances.length;e++){var n=Craft.RecentEntriesWidget.instances[e];n.params.sectionId&&n.params.sectionId!=this.params.sectionId||n.addEntry({url:i.cpEditUrl,title:i.title,dateCreated:i.dateCreated,username:i.authorUsername})}},gotoEntry:function(t){Craft.redirectTo(t.cpEditUrl)}})}();
Base
1
!function(){var t;t=jQuery,Craft.QuickPostWidget=Garnish.Base.extend({params:null,initFields:null,formHtml:null,$widget:null,$form:null,$spinner:null,$errorList:null,loading:!1,init:function(i,r,e,n){this.params=r,this.initFields=e,this.formHtml=n,this.$widget=t("#widget"+i),this.initForm(this.$widget.find("form:first"))},initForm:function(t){this.$form=t,this.$spinner=this.$form.find(".spinner"),this.initFields();var i=this.$form.find("> .buttons > .btngroup > .menubtn"),r=i.data("menubtn").menu.$container.find("> ul > li > a");i.menubtn(),this.addListener(this.$form,"submit","handleFormSubmit"),this.addListener(r,"click","saveAndContinueEditing")},handleFormSubmit:function(t){t.preventDefault(),this.save(this.onSave.bind(this))},saveAndContinueEditing:function(){this.save(this.gotoEntry.bind(this))},save:function(i){var r=this;if(!this.loading){this.loading=!0,this.$spinner.removeClass("hidden");var e=Garnish.getPostData(this.$form),n=t.extend({enabled:1},e,this.params);Craft.postActionRequest("entries/save-entry",n,(function(e,n){if(r.loading=!1,r.$spinner.addClass("hidden"),r.$errorList&&r.$errorList.children().remove(),"success"===n)if(e.success)Craft.cp.displayNotice(Craft.t("app","Entry saved.")),i(e);else if(Craft.cp.displayError(Craft.t("app","Couldn’t save entry.")),e.errors)for(var s in r.$errorList||(r.$errorList=t('<ul class="errors"/>').insertAfter(r.$form)),e.errors)if(e.errors.hasOwnProperty(s))for(var a=0;a<e.errors[s].length;a++){var o=e.errors[s][a];t("<li>"+o+"</li>").appendTo(r.$errorList)}}))}},onSave:function(i){var r=t(this.formHtml);if(this.$form.replaceWith(r),Craft.initUiElements(r),this.initForm(r),void 0!==Craft.RecentEntriesWidget)for(var e=0;e<Craft.RecentEntriesWidget.instances.length;e++){var n=Craft.RecentEntriesWidget.instances[e];n.params.sectionId&&n.params.sectionId!=this.params.sectionId||n.addEntry({url:i.cpEditUrl,title:i.title,dateCreated:i.dateCreated,username:i.authorUsername})}},gotoEntry:function(t){Craft.redirectTo(t.cpEditUrl)}})}();
Base
1
!function(){var t;t=jQuery,Craft.QuickPostWidget=Garnish.Base.extend({params:null,initFields:null,formHtml:null,$widget:null,$form:null,$spinner:null,$errorList:null,loading:!1,init:function(i,r,e,n){this.params=r,this.initFields=e,this.formHtml=n,this.$widget=t("#widget"+i),this.initForm(this.$widget.find("form:first"))},initForm:function(t){this.$form=t,this.$spinner=this.$form.find(".spinner"),this.initFields();var i=this.$form.find("> .buttons > .btngroup > .menubtn"),r=i.data("menubtn").menu.$container.find("> ul > li > a");i.menubtn(),this.addListener(this.$form,"submit","handleFormSubmit"),this.addListener(r,"click","saveAndContinueEditing")},handleFormSubmit:function(t){t.preventDefault(),this.save(this.onSave.bind(this))},saveAndContinueEditing:function(){this.save(this.gotoEntry.bind(this))},save:function(i){var r=this;if(!this.loading){this.loading=!0,this.$spinner.removeClass("hidden");var e=Garnish.getPostData(this.$form),n=t.extend({enabled:1},e,this.params);Craft.postActionRequest("entries/save-entry",n,(function(e,n){if(r.loading=!1,r.$spinner.addClass("hidden"),r.$errorList&&r.$errorList.children().remove(),"success"===n)if(e.success)Craft.cp.displayNotice(Craft.t("app","Entry saved.")),i(e);else if(Craft.cp.displayError(Craft.t("app","Couldn’t save entry.")),e.errors)for(var s in r.$errorList||(r.$errorList=t('<ul class="errors"/>').insertAfter(r.$form)),e.errors)if(e.errors.hasOwnProperty(s))for(var a=0;a<e.errors[s].length;a++){var o=e.errors[s][a];t("<li>"+o+"</li>").appendTo(r.$errorList)}}))}},onSave:function(i){var r=t(this.formHtml);if(this.$form.replaceWith(r),Craft.initUiElements(r),this.initForm(r),void 0!==Craft.RecentEntriesWidget)for(var e=0;e<Craft.RecentEntriesWidget.instances.length;e++){var n=Craft.RecentEntriesWidget.instances[e];n.params.sectionId&&n.params.sectionId!=this.params.sectionId||n.addEntry({url:i.cpEditUrl,title:i.title,dateCreated:i.dateCreated,username:i.authorUsername})}},gotoEntry:function(t){Craft.redirectTo(t.cpEditUrl)}})}();
Base
1
!function(){var t;t=jQuery,Craft.QuickPostWidget=Garnish.Base.extend({params:null,initFields:null,formHtml:null,$widget:null,$form:null,$spinner:null,$errorList:null,loading:!1,init:function(i,r,e,n){this.params=r,this.initFields=e,this.formHtml=n,this.$widget=t("#widget"+i),this.initForm(this.$widget.find("form:first"))},initForm:function(t){this.$form=t,this.$spinner=this.$form.find(".spinner"),this.initFields();var i=this.$form.find("> .buttons > .btngroup > .menubtn"),r=i.data("menubtn").menu.$container.find("> ul > li > a");i.menubtn(),this.addListener(this.$form,"submit","handleFormSubmit"),this.addListener(r,"click","saveAndContinueEditing")},handleFormSubmit:function(t){t.preventDefault(),this.save(this.onSave.bind(this))},saveAndContinueEditing:function(){this.save(this.gotoEntry.bind(this))},save:function(i){var r=this;if(!this.loading){this.loading=!0,this.$spinner.removeClass("hidden");var e=Garnish.getPostData(this.$form),n=t.extend({enabled:1},e,this.params);Craft.postActionRequest("entries/save-entry",n,(function(e,n){if(r.loading=!1,r.$spinner.addClass("hidden"),r.$errorList&&r.$errorList.children().remove(),"success"===n)if(e.success)Craft.cp.displayNotice(Craft.t("app","Entry saved.")),i(e);else if(Craft.cp.displayError(Craft.t("app","Couldn’t save entry.")),e.errors)for(var s in r.$errorList||(r.$errorList=t('<ul class="errors"/>').insertAfter(r.$form)),e.errors)if(e.errors.hasOwnProperty(s))for(var a=0;a<e.errors[s].length;a++){var o=e.errors[s][a];t("<li>"+o+"</li>").appendTo(r.$errorList)}}))}},onSave:function(i){var r=t(this.formHtml);if(this.$form.replaceWith(r),Craft.initUiElements(r),this.initForm(r),void 0!==Craft.RecentEntriesWidget)for(var e=0;e<Craft.RecentEntriesWidget.instances.length;e++){var n=Craft.RecentEntriesWidget.instances[e];n.params.sectionId&&n.params.sectionId!=this.params.sectionId||n.addEntry({url:i.cpEditUrl,title:i.title,dateCreated:i.dateCreated,username:i.authorUsername})}},gotoEntry:function(t){Craft.redirectTo(t.cpEditUrl)}})}();
Base
1