Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function buildDocumentAndInsertEntities(doc) {
var dfd = new $.Deferred();
buildEditorStringDeferred(doc.documentElement)
.then(function(editorString) {
w.editor.setContent(editorString, {format: 'raw'}); // format is raw to prevent html parser and serializer from messing up whitespace
return insertEntities();
})
.then(function() {
w.tagger.addNoteWrappersForEntities();
if (w.entitiesManager.doEntitiesOverlap()) {
w.allowOverlap = true;
} else {
w.allowOverlap = false;
}
return $.ajax({
url: `/api/presets/${selectedPreset.id}/`,
contentType: 'application/json',
type: 'DELETE'
}).done(() => {
presets.splice(presets.indexOf(selectedPreset), 1);
// Select first by default
this.setState({presets, selectedPreset: presets[0], editingPreset: false});
}).fail(() => {
this.setState({presetError: "Could not delete the preset. Please try to refresh the page."});
}).always(() => {
this.setState({presetActionPerforming: false});
});
}else{
return $.Deferred().resolve();
}
}
}
if (pathParts[0] === 'metastore') {
pathParts.shift();
}
const loadedDeferred = $.Deferred();
if (!this.loading()) {
loadedDeferred.resolve();
} else {
const loadSub = this.loading.subscribe(() => {
loadSub.dispose();
loadedDeferred.resolve();
});
}
const sourceAndNamespaceDeferred = $.Deferred();
loadedDeferred.done(() => {
let search = location.search;
let namespaceId;
let sourceType;
if (search) {
search = search.replace('?', '');
search.split('&').forEach(param => {
if (param.indexOf('namespace=') === 0) {
namespaceId = param.replace('namespace=', '');
}
if (param.indexOf('source_type=') === 0) {
sourceType = param.replace('source_type=', '');
}
});
}
validate: function (item) {
if (!item.has('largeImage')) {
return $.Deferred().reject('Please select a "large image" item.').promise();
}
return $.Deferred().resolve().promise();
}
});
activeLocations.activeStatementLocations.forEach(location => {
if (
location.type === 'table' &&
(location.identifierChain.length !== 1 ||
!ctes[location.identifierChain[0].name.toLowerCase()])
) {
const tableDeferred = $.Deferred();
const dbDeferred = $.Deferred();
runningPromises.push(tableDeferred);
runningPromises.push(dbDeferred);
const qid = createQualifiedIdentifier(
location.identifierChain,
activeLocations.defaultDatabase
);
if (activeTableIndex[qid]) {
tableQidIndex[qid] = true;
tableDeferred.resolve(activeTableIndex[qid]);
dbDeferred.resolve(activeTableIndex[qid].parent);
} else {
let database =
location.identifierChain.length === 2
? location.identifierChain[0].name
: activeLocations.defaultDatabase;
__initApiDeferred() {
var notify, reject, resolve
this.__apiDf = $.Deferred()
this.__progressState = 'uploading'
reject = err => {
return this.__buildInfo(info => {
return this.__apiDf.reject(err, info)
})
}
resolve = info => {
return this.__apiDf.resolve(info)
}
notify = () => {
return this.__apiDf.notify(this.__progressInfo())
}
notify()
this.__fileColl.onAnyProgress(notify)
this.__allFilesDf
.done(() => {
deleteNavigatorTags(tags) {
const self = this;
const deferred = $.Deferred();
if (self.canHaveNavigatorMetadata()) {
self
.getNavigatorMeta()
.done(navMeta => {
if (navMeta && typeof navMeta.identity !== 'undefined') {
apiHelper
.deleteNavTags(navMeta.identity, tags)
.done(entity => {
if (entity) {
self.navigatorMeta = entity;
self.navigatorMetaPromise = $.Deferred()
.resolve(self.navigatorMeta)
.promise();
self.saveLater();
} else {
deferred.reject();
function makeRequest({method, url, apiVersion, type, timeout = mrequest.timeout, payload, etag, contentType = false} = {}) {
return $.Deferred(function () {
const deferred = this;
const jqXHR = $.ajax({
method,
url,
data: JSON.stringify(payload),
timeout,
beforeSend: (xhr) => {
xhr.setRequestHeader("GET" === method.toUpperCase() ? 'If-None-Match' : 'If-Match', etag);
mrequest.xhrConfig.forVersion(apiVersion)(xhr);
},
contentType
});
const didFulfill = (data, _textStatus, jqXHR) => {
const NOT_MODIFIED = 304 === jqXHR.status;
get purchaseModal() {
this._purchaseModalDeferred =
this._purchaseModalDeferred || $.Deferred();
if (this._purchaseModal) {
this._purchaseModalDeferred.notify({
type: this.constructor.PURCHASE_MODAL_CREATE,
view: this._purchaseModal,
});
}
return this._purchaseModalDeferred.promise();
}
createGist(options) {
const self = this;
const deferred = $.Deferred();
const request = self.simplePost(
GIST_API + 'create',
{
statement: options.statement,
doc_type: options.doc_type,
name: options.name,
description: options.description
},
{
silenceErrors: options.silenceErrors,
successCallback: deferred.resolve,
errorCallback: deferred.reject
}
);