_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q58100 | toTitleCase | validation | function toTitleCase() {
var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
return input.toString().replace(/\w\S*/g, function (text) {
return text.charAt(0).toUpperCase() + text.substr(1).toLowerCase();
});
} | javascript | {
"resource": ""
} |
q58101 | stripHTML | validation | function stripHTML(source) {
var fragment = document.createDocumentFragment();
var element = document.createElement('div');
fragment.appendChild(element);
element.innerHTML = source;
return fragment.firstChild.innerText;
} | javascript | {
"resource": ""
} |
q58102 | getHTML | validation | function getHTML(element) {
var wrapper = document.createElement('div');
wrapper.appendChild(element);
return wrapper.innerHTML;
} | javascript | {
"resource": ""
} |
q58103 | formatTime | validation | function formatTime() {
var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var displayHours = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var inverted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
// Bail if the va... | javascript | {
"resource": ""
} |
q58104 | getIconUrl | validation | function getIconUrl() {
var url = new URL(this.config.iconUrl, window.location);
var cors = url.host !== window.location.host || browser.isIE && !window.svg4everybody;
return {
url: this.config.iconUrl,
cors: cors
};
} | javascript | {
"resource": ""
} |
q58105 | findElements | validation | function findElements() {
try {
this.elements.controls = getElement.call(this, this.config.selectors.controls.wrapper); // Buttons
this.elements.buttons = {
play: getElements.call(this, this.config.selectors.buttons.play),
pause: getElement.call(this, this.config.selectors.buttons.... | javascript | {
"resource": ""
} |
q58106 | createLabel | validation | function createLabel(key) {
var attr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var text = i18n.get(key, this.config);
var attributes = Object.assign({}, attr, {
class: [attr.class, this.config.classNames.hidden].filter(Boolean).join(' ')
});
return createE... | javascript | {
"resource": ""
} |
q58107 | createBadge | validation | function createBadge(text) {
if (is$1.empty(text)) {
return null;
}
var badge = createElement('span', {
class: this.config.classNames.menu.value
});
badge.appendChild(createElement('span', {
class: this.config.classNames.menu.badge
}, text));
return badge;
} | javascript | {
"resource": ""
} |
q58108 | createTime | validation | function createTime(type, attrs) {
var attributes = getAttributesFromSelector(this.config.selectors.display[type], attrs);
var container = createElement('div', extend(attributes, {
class: "".concat(attributes.class ? attributes.class : '', " ").concat(this.config.classNames.display.time, " ").trim(),
... | javascript | {
"resource": ""
} |
q58109 | createMenuItem | validation | function createMenuItem(_ref) {
var _this3 = this;
var value = _ref.value,
list = _ref.list,
type = _ref.type,
title = _ref.title,
_ref$badge = _ref.badge,
badge = _ref$badge === void 0 ? null : _ref$badge,
_ref$checked = _ref.checked,
checked = ... | javascript | {
"resource": ""
} |
q58110 | formatTime$1 | validation | function formatTime$1() {
var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var inverted = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
// Bail if the value isn't a number
if (!is$1.number(time)) {
return time;
} // Always di... | javascript | {
"resource": ""
} |
q58111 | updateTimeDisplay | validation | function updateTimeDisplay() {
var target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var inverted = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
// Bail i... | javascript | {
"resource": ""
} |
q58112 | updateVolume | validation | function updateVolume() {
if (!this.supported.ui) {
return;
} // Update range
if (is$1.element(this.elements.inputs.volume)) {
controls.setRange.call(this, this.elements.inputs.volume, this.muted ? 0 : this.volume);
} // Update mute state
if (is$1.element(this.elements.buttons... | javascript | {
"resource": ""
} |
q58113 | setRange | validation | function setRange(target) {
var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
if (!is$1.element(target)) {
return;
} // eslint-disable-next-line
target.value = value; // Webkit range fill
controls.updateRangeFill.call(this, target);
} | javascript | {
"resource": ""
} |
q58114 | updateRangeFill | validation | function updateRangeFill(target) {
// Get range from event if event passed
var range = is$1.event(target) ? target.target : target; // Needs to be a valid <input type='range'>
if (!is$1.element(range) || range.getAttribute('type') !== 'range') {
return;
} // Set aria values for https://githu... | javascript | {
"resource": ""
} |
q58115 | updateSeekTooltip | validation | function updateSeekTooltip(event) {
var _this5 = this;
// Bail if setting not true
if (!this.config.tooltips.seek || !is$1.element(this.elements.inputs.seek) || !is$1.element(this.elements.display.seekTooltip) || this.duration === 0) {
return;
} // Calculate percentage
var percent = 0... | javascript | {
"resource": ""
} |
q58116 | timeUpdate | validation | function timeUpdate(event) {
// Only invert if only one time element is displayed and used for both duration and currentTime
var invert = !is$1.element(this.elements.display.duration) && this.config.invertTime; // Duration
controls.updateTimeDisplay.call(this, this.elements.display.currentTime, invert ?... | javascript | {
"resource": ""
} |
q58117 | durationUpdate | validation | function durationUpdate() {
// Bail if no UI or durationchange event triggered after playing/seek when invertTime is false
if (!this.supported.ui || !this.config.invertTime && this.currentTime) {
return;
} // If duration is the 2**32 (shaka), Infinity (HLS), DASH-IF (Number.MAX_SAFE_INTEGER || Num... | javascript | {
"resource": ""
} |
q58118 | updateSetting | validation | function updateSetting(setting, container, input) {
var pane = this.elements.settings.panels[setting];
var value = null;
var list = container;
if (setting === 'captions') {
value = this.currentTrack;
} else {
value = !is$1.empty(input) ? input : this[setting]; // Get default
... | javascript | {
"resource": ""
} |
q58119 | getLabel | validation | function getLabel(setting, value) {
switch (setting) {
case 'speed':
return value === 1 ? i18n.get('normal', this.config) : "".concat(value, "×");
case 'quality':
if (is$1.number(value)) {
var label = i18n.get("qualityLabel.".concat(value), this.config);
... | javascript | {
"resource": ""
} |
q58120 | setQualityMenu | validation | function setQualityMenu(options) {
var _this6 = this;
// Menu required
if (!is$1.element(this.elements.settings.panels.quality)) {
return;
}
var type = 'quality';
var list = this.elements.settings.panels.quality.querySelector('[role="menu"]'); // Set options if passed and filter b... | javascript | {
"resource": ""
} |
q58121 | getBadge | validation | function getBadge(quality) {
var label = i18n.get("qualityBadge.".concat(quality), _this6.config);
if (!label.length) {
return null;
}
return controls.createBadge.call(_this6, label);
} | javascript | {
"resource": ""
} |
q58122 | setSpeedMenu | validation | function setSpeedMenu(options) {
var _this8 = this;
// Menu required
if (!is$1.element(this.elements.settings.panels.speed)) {
return;
}
var type = 'speed';
var list = this.elements.settings.panels.speed.querySelector('[role="menu"]'); // Set the speed options
if (is$1.array... | javascript | {
"resource": ""
} |
q58123 | getMenuSize | validation | function getMenuSize(tab) {
var clone = tab.cloneNode(true);
clone.style.position = 'absolute';
clone.style.opacity = 0;
clone.removeAttribute('hidden'); // Append to parent so we get the "real" size
tab.parentNode.appendChild(clone); // Get the sizes before we remove
var width = clone.s... | javascript | {
"resource": ""
} |
q58124 | showMenuPanel | validation | function showMenuPanel() {
var _this9 = this;
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var tabFocus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var target = this.elements.container.querySelector("#plyr-settings-".concat(this... | javascript | {
"resource": ""
} |
q58125 | setDownloadUrl | validation | function setDownloadUrl() {
var button = this.elements.buttons.download; // Bail if no button
if (!is$1.element(button)) {
return;
} // Set attribute
button.setAttribute('href', this.download);
} | javascript | {
"resource": ""
} |
q58126 | replace | validation | function replace(input) {
var result = input;
Object.entries(props).forEach(function (_ref2) {
var _ref3 = _slicedToArray(_ref2, 2),
key = _ref3[0],
value = _ref3[1];
result = replaceAll(result, "{".concat(key, "}"), value);
});
return result;
... | javascript | {
"resource": ""
} |
q58127 | parseUrl$2 | validation | function parseUrl$2(input) {
var safe = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
var url = input;
if (safe) {
var parser = document.createElement('a');
parser.href = url;
url = parser.href;
}
try {
return new URL(url);
} catch (e) {
return nu... | javascript | {
"resource": ""
} |
q58128 | buildUrlParams | validation | function buildUrlParams(input) {
var params = new URLSearchParams();
if (is$1.object(input)) {
Object.entries(input).forEach(function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
key = _ref2[0],
value = _ref2[1];
params.set(key, value);
});
}
return params;
... | javascript | {
"resource": ""
} |
q58129 | update | validation | function update() {
var _this = this;
var tracks = captions.getTracks.call(this, true); // Get the wanted language
var _this$captions = this.captions,
active = _this$captions.active,
language = _this$captions.language,
meta = _this$captions.meta,
currentTrackNode = _... | javascript | {
"resource": ""
} |
q58130 | toggle | validation | function toggle(input) {
var passive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
// If there's no full support
if (!this.supported.ui) {
return;
}
var toggled = this.captions.toggled; // Current state
var activeClass = this.config.classNames.captio... | javascript | {
"resource": ""
} |
q58131 | set | validation | function set(index) {
var passive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
var tracks = captions.getTracks.call(this); // Disable captions if setting to -1
if (index === -1) {
captions.toggle.call(this, false, passive);
return;
}
if (!is$1.numb... | javascript | {
"resource": ""
} |
q58132 | setLanguage | validation | function setLanguage(input) {
var passive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
if (!is$1.string(input)) {
this.debug.warn('Invalid language argument', input);
return;
} // Normalize
var language = input.toLowerCase();
this.captions.languag... | javascript | {
"resource": ""
} |
q58133 | getTracks | validation | function getTracks() {
var _this2 = this;
var update = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
// Handle media or textTracks missing or null
var tracks = Array.from((this.media || {}).textTracks || []); // For HTML5, use cache instead of current tracks when it exi... | javascript | {
"resource": ""
} |
q58134 | findTrack | validation | function findTrack(languages) {
var _this3 = this;
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var tracks = captions.getTracks.call(this);
var sortIsDefault = function sortIsDefault(track) {
return Number((_this3.captions.meta.get(track) || {}).def... | javascript | {
"resource": ""
} |
q58135 | getLabel | validation | function getLabel(track) {
var currentTrack = track;
if (!is$1.track(currentTrack) && support.textTracks && this.captions.toggled) {
currentTrack = captions.getCurrentTrack.call(this);
}
if (is$1.track(currentTrack)) {
if (!is$1.empty(currentTrack.label)) {
return currentTra... | javascript | {
"resource": ""
} |
q58136 | getProviderByUrl | validation | function getProviderByUrl(url) {
// YouTube
if (/^(https?:\/\/)?(www\.)?(youtube\.com|youtube-nocookie\.com|youtu\.?be)\/.+$/.test(url)) {
return providers.youtube;
} // Vimeo
if (/^https?:\/\/player.vimeo.com\/video\/\d{0,9}(?=\b|\/)/.test(url)) {
return providers.vimeo;
}
return null;
... | javascript | {
"resource": ""
} |
q58137 | get | validation | function get() {
return (Fullscreen.native || this.player.config.fullscreen.fallback) && this.player.config.fullscreen.enabled && this.player.supported.ui && this.player.isVideo;
} | javascript | {
"resource": ""
} |
q58138 | toggleNativeControls | validation | function toggleNativeControls() {
var toggle = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
if (toggle && this.isHTML5) {
this.media.setAttribute('controls', '');
} else {
this.media.removeAttribute('controls');
}
} | javascript | {
"resource": ""
} |
q58139 | build | validation | function build() {
var _this = this;
// Re-attach media element listeners
// TODO: Use event bubbling?
this.listeners.media(); // Don't setup interface if no support
if (!this.supported.ui) {
this.debug.warn("Basic support only for ".concat(this.provider, " ").concat(this.type)); // Re... | javascript | {
"resource": ""
} |
q58140 | setTitle | validation | function setTitle() {
// Find the current text
var label = i18n.get('play', this.config); // If there's a media title set, use that for the label
if (is$1.string(this.config.title) && !is$1.empty(this.config.title)) {
label += ", ".concat(this.config.title);
} // If there's a play button, se... | javascript | {
"resource": ""
} |
q58141 | checkPlaying | validation | function checkPlaying(event) {
var _this3 = this;
// Class hooks
toggleClass(this.elements.container, this.config.classNames.playing, this.playing);
toggleClass(this.elements.container, this.config.classNames.paused, this.paused);
toggleClass(this.elements.container, this.config.classNames.sto... | javascript | {
"resource": ""
} |
q58142 | checkLoading | validation | function checkLoading(event) {
var _this4 = this;
this.loading = ['stalled', 'waiting'].includes(event.type); // Clear timer
clearTimeout(this.timers.loading); // Timer to prevent flicker when seeking
this.timers.loading = setTimeout(function () {
// Update progress bar loading class state... | javascript | {
"resource": ""
} |
q58143 | toggleControls | validation | function toggleControls(force) {
var controls = this.elements.controls;
if (controls && this.config.hideControls) {
// Don't hide controls if a touch-device user recently seeked. (Must be limited to touch devices, or it occasionally prevents desktop controls from hiding.)
var recentTouchSeek = ... | javascript | {
"resource": ""
} |
q58144 | removeCurrent | validation | function removeCurrent() {
var className = player.config.classNames.tabFocus;
var current = getElements.call(player, ".".concat(className));
toggleClass(current, className, false);
} | javascript | {
"resource": ""
} |
q58145 | setPlayerSize | validation | function setPlayerSize(measure) {
// If we don't need to measure the viewport
if (!measure) {
return setAspectRatio.call(player);
}
var rect = elements.container.getBoundingClientRect();
var width = rect.width,
height = rect.height;
return s... | javascript | {
"resource": ""
} |
q58146 | subscribe | validation | function subscribe(bundleIds, callbackFn) {
// listify
bundleIds = bundleIds.push ? bundleIds : [bundleIds];
var depsNotFound = [],
i = bundleIds.length,
numWaiting = i,
fn,
bundleId,
r,
q; // define callback function
fn = fu... | javascript | {
"resource": ""
} |
q58147 | publish | validation | function publish(bundleId, pathsNotFound) {
// exit if id isn't defined
if (!bundleId) return;
var q = bundleCallbackQueue[bundleId]; // cache result
bundleResultCache[bundleId] = pathsNotFound; // exit if queue is empty
if (!q) return; // empty callback queue
while (q.lengt... | javascript | {
"resource": ""
} |
q58148 | executeCallbacks | validation | function executeCallbacks(args, depsNotFound) {
// accept function as argument
if (args.call) args = {
success: args
}; // success and error callbacks
if (depsNotFound.length) (args.error || devnull)(depsNotFound);else (args.success || devnull)(args);
} | javascript | {
"resource": ""
} |
q58149 | loadFile | validation | function loadFile(path, callbackFn, args, numTries) {
var doc = document,
async = args.async,
maxTries = (args.numRetries || 0) + 1,
beforeCallbackFn = args.before || devnull,
pathStripped = path.replace(/^(css|img)!/, ''),
isLegacyIECss,
e;
... | javascript | {
"resource": ""
} |
q58150 | loadjs | validation | function loadjs(paths, arg1, arg2) {
var bundleId, args; // bundleId (if string)
if (arg1 && arg1.trim) bundleId = arg1; // args (default is {})
args = (bundleId ? arg2 : arg1) || {}; // throw error if bundle is already defined
if (bundleId) {
if (bundleId in bundleIdCache) {
... | javascript | {
"resource": ""
} |
q58151 | getTitle | validation | function getTitle(videoId) {
var _this2 = this;
var url = format(this.config.urls.youtube.api, videoId);
fetch(url).then(function (data) {
if (is$1.object(data)) {
var title = data.title,
height = data.height,
width = data.width; // Set title
_this2.co... | javascript | {
"resource": ""
} |
q58152 | Ads | validation | function Ads(player) {
var _this = this;
_classCallCheck(this, Ads);
this.player = player;
this.config = player.config.ads;
this.playing = false;
this.initialized = false;
this.elements = {
container: null,
displayContainer: null
};
this.manager = null;
... | javascript | {
"resource": ""
} |
q58153 | load | validation | function load() {
var _this2 = this;
if (!this.enabled) {
return;
} // Check if the Google IMA3 SDK is loaded or load it ourselves
if (!is$1.object(window.google) || !is$1.object(window.google.ima)) {
loadScript(this.player.config.urls.googleIMA.sdk).then(function () {
... | javascript | {
"resource": ""
} |
q58154 | setupIMA | validation | function setupIMA() {
// Create the container for our advertisements
this.elements.container = createElement('div', {
class: this.player.config.classNames.ads
});
this.player.elements.container.appendChild(this.elements.container); // So we can run VPAID2
google.ima.settings... | javascript | {
"resource": ""
} |
q58155 | PreviewThumbnails | validation | function PreviewThumbnails(player) {
_classCallCheck(this, PreviewThumbnails);
this.player = player;
this.thumbnails = [];
this.loaded = false;
this.lastMouseMoveTime = Date.now();
this.mouseDown = false;
this.loadedImages = [];
this.elements = {
thumb: {},
scrubbi... | javascript | {
"resource": ""
} |
q58156 | clamp | validation | function clamp() {
var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var max = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 255;
return Math.min(Math.max(input, min), max)... | javascript | {
"resource": ""
} |
q58157 | togglePlay | validation | function togglePlay(input) {
// Toggle based on current state if nothing passed
var toggle = is$1.boolean(input) ? input : !this.playing;
if (toggle) {
this.play();
} else {
this.pause();
}
} | javascript | {
"resource": ""
} |
q58158 | newSource | validation | function newSource(type, init) {
// Bail if new type isn't known, it's the current type, or current type is empty (video is default) and new type is video
if (!(type in types) || !init && type === currentType || !currentType.length && type === types.video) {
return;
}
swi... | javascript | {
"resource": ""
} |
q58159 | validation | function (str) {
const args = arguments
let flag = true
let i = 1
str = str.replace(/%s/g, () => {
const arg = args[i++]
if (typeof arg === 'undefined') {
flag = false
return ''
}
return arg
})
return flag ? str : ''
} | javascript | {
"resource": ""
} | |
q58160 | preprocessCartForServer | validation | function preprocessCartForServer( {
coupon,
is_coupon_applied,
is_coupon_removed,
currency,
temporary,
extra,
products,
tax,
} ) {
const needsUrlCoupon = ! (
coupon ||
is_coupon_applied ||
is_coupon_removed ||
typeof document === 'undefined'
);
const urlCoupon = needsUrlCoupon ? url.parse( document.U... | javascript | {
"resource": ""
} |
q58161 | getNewMessages | validation | function getNewMessages( previousCartValue, nextCartValue ) {
previousCartValue = previousCartValue || {};
nextCartValue = nextCartValue || {};
const nextCartMessages = nextCartValue.messages || [];
// If there is no previous cart then just return the messages for the new cart
if (
! previousCartValue ||
! pr... | javascript | {
"resource": ""
} |
q58162 | isRedirectToValidForSsr | validation | function isRedirectToValidForSsr( redirectToQueryValue ) {
if ( 'undefined' === typeof redirectToQueryValue ) {
return true;
}
const redirectToDecoded = decodeURIComponent( redirectToQueryValue );
return (
redirectToDecoded.startsWith( 'https://wordpress.com/theme' ) ||
redirectToDecoded.startsWith( 'https:/... | javascript | {
"resource": ""
} |
q58163 | highlight | validation | function highlight( term, html, wrapperNode ) {
debug( 'Starting highlight' );
if ( ! wrapperNode ) {
wrapperNode = document.createElement( 'mark' );
}
if ( ! term || ! html ) {
return html;
}
const root = document.createElement( 'div' );
root.innerHTML = html;
walk( root, term, wrapperNode );
return root.... | javascript | {
"resource": ""
} |
q58164 | MailingList | validation | function MailingList( category, wpcom ) {
if ( ! ( this instanceof MailingList ) ) {
return new MailingList( category, wpcom );
}
this._category = category;
this.wpcom = wpcom;
} | javascript | {
"resource": ""
} |
q58165 | embed | validation | function embed( editor ) {
let embedDialogContainer;
/**
* Open or close the EmbedDialog
*
* @param {boolean} visible `true` makes the dialog visible; `false` hides it.
*/
const render = ( visible = true ) => {
const selectedEmbedNode = editor.selection.getNode();
const store = editor.getParam( 'redux_s... | javascript | {
"resource": ""
} |
q58166 | onexit | validation | function onexit( code ) {
let changedFiles;
cssMake.stderr.removeListener( 'data', onstderr );
cssMake.stdout.removeListener( 'data', onstdout );
cssMake = null;
if ( scheduleBuild ) {
// Handle new css build request
scheduleBuild = false;
spawnMake();
} else if ( 0 === code ) {
// 'make build... | javascript | {
"resource": ""
} |
q58167 | updateChangedCssFiles | validation | function updateChangedCssFiles() {
let hash, filePath;
const changedFiles = [];
for ( filePath in publicCssFiles ) {
hash = md5File.sync( filePath );
if ( hash !== publicCssFiles[ filePath ] ) {
publicCssFiles[ filePath ] = hash;
changedFiles.push( path.basename( filePath ) );
}
}
return cha... | javascript | {
"resource": ""
} |
q58168 | updateSiteState | validation | function updateSiteState( state, siteId, attributes ) {
return Object.assign( {}, state, {
[ siteId ]: Object.assign( {}, initialSiteState, state[ siteId ], attributes ),
} );
} | javascript | {
"resource": ""
} |
q58169 | isValidCategoriesArray | validation | function isValidCategoriesArray( categories ) {
for ( let i = 0; i < categories.length; i++ ) {
if ( ! isValidProductCategory( categories[ i ] ) ) {
// Short-circuit the loop and return now.
return false;
}
}
return true;
} | javascript | {
"resource": ""
} |
q58170 | isValidProductCategory | validation | function isValidProductCategory( category ) {
return (
category &&
category.id &&
'number' === typeof category.id &&
category.name &&
'string' === typeof category.name &&
category.slug &&
'string' === typeof category.slug
);
} | javascript | {
"resource": ""
} |
q58171 | hasLanguageChanged | validation | function hasLanguageChanged( languageSettingValue, settings = {} ) {
if ( ! languageSettingValue ) {
return false;
}
// if there is a saved variant we know that the user is changing back to the root language === setting hasn't changed
// but if settings.locale_variant is not empty then we assume the user is tryin... | javascript | {
"resource": ""
} |
q58172 | UserSettings | validation | function UserSettings() {
if ( ! ( this instanceof UserSettings ) ) {
return new UserSettings();
}
this.settings = false;
this.initialized = false;
this.reAuthRequired = false;
this.fetchingSettings = false;
this.unsavedSettings = {};
} | javascript | {
"resource": ""
} |
q58173 | getDomainNameFromReceiptOrCart | validation | function getDomainNameFromReceiptOrCart( receipt, cart ) {
let domainRegistration;
if ( receipt && ! isEmpty( receipt.purchases ) ) {
domainRegistration = find( values( receipt.purchases ), isDomainRegistration );
}
if ( cartItems.hasDomainRegistration( cart ) ) {
domainRegistration = cartItems.getDomainRegis... | javascript | {
"resource": ""
} |
q58174 | bustHashForHrefs | validation | function bustHashForHrefs( { name, oldValue } ) {
// http://some.site.com/and/a/path?with=a&query -> http://some.site.com/and/a/path?v=13508135781
const value =
'href' === name ? `${ oldValue.split( '?' ).shift() }?v=${ new Date().getTime() }` : oldValue;
return { name, value };
} | javascript | {
"resource": ""
} |
q58175 | updateCachedProduct | validation | function updateCachedProduct( products, product ) {
let found = false;
const updatedProduct = { ...product, name: decodeEntities( product.name ) };
const newProducts = products.map( p => {
if ( p.id === product.id ) {
found = true;
return updatedProduct;
}
return p;
} );
if ( ! found ) {
newProducts... | javascript | {
"resource": ""
} |
q58176 | setLoading | validation | function setLoading( state, params, newStatus ) {
const queries = ( state.queries && { ...state.queries } ) || {};
const key = getSerializedProductsQuery( params );
queries[ key ] = { ...( queries[ key ] || {} ), isLoading: newStatus };
return queries;
} | javascript | {
"resource": ""
} |
q58177 | generateStaticUrls | validation | function generateStaticUrls( target ) {
const urls = { ...staticFilesUrls };
const assets = getAssets( target ).assetsByChunkName;
forEach( assets, ( asset, name ) => {
urls[ name ] = asset;
} );
return urls;
} | javascript | {
"resource": ""
} |
q58178 | getAcceptedLanguagesFromHeader | validation | function getAcceptedLanguagesFromHeader( header ) {
if ( ! header ) {
return [];
}
return header
.split( ',' )
.map( lang => {
const match = lang.match( /^[A-Z]{2,3}(-[A-Z]{2,3})?/i );
if ( ! match ) {
return false;
}
return match[ 0 ].toLowerCase();
} )
.filter( lang => lang );
} | javascript | {
"resource": ""
} |
q58179 | setUpCSP | validation | function setUpCSP( req, res, next ) {
const originalUrlPathname = req.originalUrl.split( '?' )[ 0 ];
// We only setup CSP for /log-in* for now
if ( ! /^\/log-in/.test( originalUrlPathname ) ) {
next();
return;
}
// This is calculated by taking the contents of the script text from between the tags,
// and ca... | javascript | {
"resource": ""
} |
q58180 | validation | function( post ) {
let latitude, longitude;
if ( ! post ) {
return;
}
latitude = parseFloat( getValueByKey( post.metadata, 'geo_latitude' ) );
longitude = parseFloat( getValueByKey( post.metadata, 'geo_longitude' ) );
if ( latitude && longitude ) {
return [ latitude, longitude ];
}
} | javascript | {
"resource": ""
} | |
q58181 | validation | function( post ) {
if ( ! post ) {
return null;
}
const isSharedPublicly = getValueByKey( post.metadata, 'geo_public' );
if ( parseInt( isSharedPublicly, 10 ) ) {
return true;
}
if ( undefined === isSharedPublicly ) {
// If they have no geo_public value but they do have a lat/long, then we assum... | javascript | {
"resource": ""
} | |
q58182 | sanitizeExtra | validation | function sanitizeExtra( data ) {
const path = data._contactDetailsCache ? [ '_contactDetailsCache', 'extra' ] : 'extra';
return data && isArray( get( data, path ) ) ? omit( data, path ) : data;
} | javascript | {
"resource": ""
} |
q58183 | transmitDraftId | validation | function transmitDraftId( calypsoPort ) {
// Bail if we are not writing a new post.
if ( ! /wp-admin\/post-new.php/.test( location.href ) ) {
return;
}
const unsubscribe = subscribe( () => {
const currentPost = select( 'core/editor' ).getCurrentPost();
if ( currentPost && currentPost.id && currentPost.statu... | javascript | {
"resource": ""
} |
q58184 | handlePostLocked | validation | function handlePostLocked( calypsoPort ) {
const unsubscribe = subscribe( () => {
const isLocked = select( 'core/editor' ).isPostLocked();
const isLockTakeover = select( 'core/editor' ).isPostLockTakeover();
const lockedDialogButtons = document.querySelectorAll(
'div.editor-post-locked-modal__buttons > a'
)... | javascript | {
"resource": ""
} |
q58185 | handlePostLockTakeover | validation | function handlePostLockTakeover( calypsoPort ) {
const unsubscribe = subscribe( () => {
const isLocked = select( 'core/editor' ).isPostLocked();
const isLockTakeover = select( 'core/editor' ).isPostLockTakeover();
const allPostsButton = document.querySelector( 'div.editor-post-locked-modal__buttons > a' );
co... | javascript | {
"resource": ""
} |
q58186 | updateImageBlocks | validation | function updateImageBlocks( blocks, image ) {
forEach( blocks, block => {
if ( imageBlocks[ block.name ] ) {
imageBlocks[ block.name ]( block, image );
}
if ( block.innerBlocks.length ) {
updateImageBlocks( block.innerBlocks, image );
}
} );
} | javascript | {
"resource": ""
} |
q58187 | updateFeaturedImagePreview | validation | function updateFeaturedImagePreview( image ) {
const currentImageId = select( 'core/editor' ).getEditedPostAttribute( 'featured_media' );
if ( currentImageId !== image.id ) {
return;
}
preloadImage( image.url ).then( () => {
const currentImage = select( 'core' ).getMedia( currentImageId );
const update... | javascript | {
"resource": ""
} |
q58188 | handlePreview | validation | function handlePreview( calypsoPort ) {
$( '#editor' ).on( 'click', '.editor-post-preview', e => {
e.preventDefault();
e.stopPropagation();
const postUrl = select( 'core/editor' ).getCurrentPostAttribute( 'link' );
const previewChannel = new MessageChannel();
calypsoPort.postMessage(
{
action: 'prev... | javascript | {
"resource": ""
} |
q58189 | handleInsertClassicBlockMedia | validation | function handleInsertClassicBlockMedia( calypsoPort ) {
calypsoPort.addEventListener( 'message', onInsertClassicBlockMedia, false );
calypsoPort.start();
function onInsertClassicBlockMedia( message ) {
const action = get( message, 'data.action' );
if ( action !== 'insertClassicBlockMedia' ) {
return;
}
c... | javascript | {
"resource": ""
} |
q58190 | handleGoToAllPosts | validation | function handleGoToAllPosts( calypsoPort ) {
$( '#editor' ).on( 'click', '.edit-post-fullscreen-mode-close__toolbar a', e => {
e.preventDefault();
calypsoPort.postMessage( {
action: 'goToAllPosts',
payload: {
unsavedChanges: select( 'core/editor' ).isEditedPostDirty(),
},
} );
} );
} | javascript | {
"resource": ""
} |
q58191 | openLinksInParentFrame | validation | function openLinksInParentFrame() {
const viewPostLinkSelectors = [
'.components-notice-list .is-success .components-notice__action.is-link', // View Post link in success notice
'.post-publish-panel__postpublish .components-panel__body.is-opened a', // Post title link in publish panel
'.components-panel__body.is... | javascript | {
"resource": ""
} |
q58192 | toolbarPin | validation | function toolbarPin( editor ) {
let isMonitoringScroll = false,
isPinned = false,
container;
/**
* Assigns the container top-level variable to the current container.
*/
function setContainer() {
container = editor.getContainer();
}
/**
* Updates the pinned state, toggling the container class as appro... | javascript | {
"resource": ""
} |
q58193 | _initStorage | validation | function _initStorage( options ) {
const dbInfo = {};
if ( options ) {
for ( const i in options ) {
dbInfo[ i ] = options[ i ];
}
}
dbInfo.db = {};
dummyStorage[ dbInfo.name ] = dbInfo.db;
this._dbInfo = dbInfo;
return Promise.resolve();
} | javascript | {
"resource": ""
} |
q58194 | finish | validation | function finish() {
let node,
regex = new RegExp( 'mceItemHidden|hidden(((Grammar|Spell)Error)|Suggestion)' ),
nodes = editor.dom.select( 'span' ),
i = nodes.length;
while ( i-- ) {
// reversed
node = nodes[ i ];
if ( node.className && regex.test( node.className ) ) {
editor.dom.remove( node... | javascript | {
"resource": ""
} |
q58195 | build_chunks | validation | function build_chunks( sub_text, sub_ranges, range_data, container, options ) {
let text_start = null,
text_stop = null,
i,
remove_r_id,
r_id,
sr_id,
range_id,
range_info,
new_i,
new_sub_text,
new_sub_range;
// We use sub_ranges and not sub_text because we *can* have an empty string with a range
... | javascript | {
"resource": ""
} |
q58196 | find_largest_range | validation | function find_largest_range( rs ) {
let r_id = -1,
r_size = 0,
i;
if ( rs.length < 1 ) {
return null;
}
for ( i = 0; i < rs.length; i++ ) {
if ( null === rs[ i ] ) {
continue;
}
// Set on first valid range and subsequently larger ranges
if ( -1 === r_id || rs[ i ].indices[ 1 ] - rs[ i ].indices[... | javascript | {
"resource": ""
} |
q58197 | setUpLocale | validation | function setUpLocale( context, next ) {
const language = getLanguage( context.params.lang );
if ( language ) {
context.lang = context.params.lang;
if ( language.rtl ) {
context.isRTL = true;
}
}
next();
} | javascript | {
"resource": ""
} |
q58198 | customPostMetadataToProductAttributes | validation | function customPostMetadataToProductAttributes( metadata ) {
const productAttributes = {};
metadata.forEach( ( { key, value } ) => {
const schemaKey = metaKeyToSchemaKeyMap[ key ];
if ( ! schemaKey ) {
return;
}
// If the property's type is marked as boolean in the schema,
// convert the value from PHP... | javascript | {
"resource": ""
} |
q58199 | parseAsShortcode | validation | function parseAsShortcode( node, _parsed ) {
// Attempt to convert string element into DOM node. If successful, recurse
// to trigger the shortcode strategy
const shortcode = parse( node );
if ( shortcode ) {
return _recurse( shortcode, _parsed );
}
return _parsed;
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.