Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private processMessages(payload) {
for (const msg of payload.messages) {
const message = this.loadMessage(msg);
// only add if not seen already; a message could arrive after it was
// dismissed *in this window* but it will already have a key with null value
if (!contains(this.messages, message.uuid)) {
this.messages[message.uuid] = message;
}
// notify listeners for specific tags
for (const tag of message.tags) {
$.map(this.tagActions[tag] || [], (callback) => callback(message));
}
}
this.count = payload.unread;
}
$("body").on("click", "a[data-show-more]", function() {
// get json from data-items attribute
var raw_data_items = $(this).data('items');
var data_items = $.map(raw_data_items, function(e) { return ({item: e})});
var modal_id = Date.now();
var page_size = $(this).data('page-size');
var modalContext = {
'modal_id': modal_id,
'list_items': data_items,
'title': $(this).data('title'),
'close': $(this).data('close-button'),
'paginate': data_items.length > page_size
};
var modal_reference = "#" + modal_id;
var modal_instance = tpl_list_modal(modalContext);
$("body").append(modal_instance);
fillForm: function fillForm(dataMapping) {
var that = this;
if ($.isEmptyObject(dataMapping)) {
return;
}
var authorsWidget = $('#submitForm .dynamic-field-list.authors')
.dynamicFieldList()[0];
$.map(dataMapping, function(value, field_id) {
var $field = $('#' + field_id);
if ($field) {
// highlight the imported fields except for the authors with the Bootstrap's success alert box
if (field_id !== 'authors') {
$field.css('background-color', '#dff0d8');
}
var setter = this.setters[$field.attr('id')];
// FIXME: workaround for
// https://github.com/twitter/typeahead.js/issues/1015
if (setter) {
setter(value);
} else {
$field.val(value);
}
}
}.bind(this));
function getFieldNamesFromTypeMapping(typeMapping) {
const fieldList =
$.map(typeMapping.properties || {}, function (fieldMapping, fieldName) {
return getFieldNamesFromFieldMapping(fieldName, fieldMapping);
});
// deduping
return _.uniq(fieldList, function (f) {
return f.name + ':' + f.type;
});
}
if (fieldMapping.properties) {
// derived object type
nestedFields = getFieldNamesFromProperties(fieldMapping.properties);
return applyPathSettings(nestedFields);
}
const fieldType = fieldMapping.type;
const ret = { name: fieldName, type: fieldType };
if (fieldMapping.index_name) {
ret.name = fieldMapping.index_name;
}
if (fieldMapping.fields) {
nestedFields = $.map(fieldMapping.fields, function (fieldMapping, fieldName) {
return getFieldNamesFromFieldMapping(fieldName, fieldMapping);
});
nestedFields = applyPathSettings(nestedFields);
nestedFields.unshift(ret);
return nestedFields;
}
return [ret];
}
function postscribeResults(...def) {
const HELPER_CLASS_NAME = 'ps-writer';
const el = $('<div id="postscribe-write-target">').get(0);
$(document.body).append(el);
return $.when(...$.map(def, (d) => {
const dfd = $.Deferred();
const opts = {
error(err) {
console.error(JSON.stringify(err));
},
done() {
removeHiddenElements(el);
dfd.resolve();
}
};
if (d instanceof Uri) {
postscribe(el, ``, opts);
} else if (d instanceof Js) {
postscribe(el, ``, opts);</div>
!function(){"use strict";function a(a){var b=this;this._text=a.text||{},this._onFileChange=a.onFileChange||function(){},this._onFileError=a.onFileError||function(){},this._onURLSubmit=a.onURLSubmit||function(){},this._onURLError=a.onURLError||function(){},this._dragover=a.onDragover||function(){},this._dragleave=a.onDragleave||function(){},this.element=this._setupElement(a.element),this._setupMouseEvents(),$(this.element).find('input[type="file"]').change(function(){b._reactToFile(this)}),$(this.element).find(".ext-input-field input").on("submit",function(){b._reactToURL($(this).val())}).keypress(function(a){return 13===a.which?(b._reactToURL($(this).val()),!1):void 0})}a.prototype.getSupportedFormats=function(){var b=["mp3","ogg","webm","wav"],c=["mp4","ogg","webm"],d=this.isFormatSupported||a.isFormatSupported,e=$.map(b,function(a,b){return d(a)?a:void 0}),f=$.map(c,function(a,b){return d(a)?a:void 0});return{audio:e,video:f}},a.prototype.isFormatSupported=function(a){var b;if("string"!=typeof a){var c=a.type.split("/")[0];return b=document.createElement(c),!(!b.canPlayType||!b.canPlayType(a.type).replace(/no/,""))}return b=document.createElement("audio"),!(!b.canPlayType||!b.canPlayType("audio/"+a+";").replace(/no/,""))},a.getSupportedFormats=a.prototype.getSupportedFormats,a.isFormatSupported=a.prototype.isFormatSupported,a.prototype.parseYoutubeURL=function(a){if(a.match){var b=/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/,c=a.match(b);if(c&&11===c[2].length)return c[2]}return!1},a.parseYoutubeURL=a.prototype.parseYoutubeURL,window.oTinput=a,a.prototype._setupElement=function(a){if("undefined"==typeof a)throw"must specify container element";var b=this._text.button||"Choose audio (or video) file",c='<button style="width: 100%;" class="btn-file-input">'+b+"</button>",d=["position: absolute","top: 0","left: 0","opacity: 0","width: 100%"].join(";"),e='<input style="'+d+'" accept="audio/*, video/*" type="file">',f="position: relative; overflow: hidden;",g='<div style="'+f+'" class="file-input-wrapper">'+c+e+"</div>",h=this._text.altButton||"Enter file URL",i='<button class="alt-input-button">'+h+"</button>",j=this._text.altInputText||"Enter URL of audio or video file, or YouTube video:",k=this._text.closeAlt||"close",l='<div style="display: none;" class="ext-input-field"><div class="close-ext-input">'+k+"</div><label>"+j+'<input type="text"></label><div class="ext-input-warning"></div></div>';return $(a).html(g+i+l),$(a)[0]},a.prototype._setupMouseEvents=function(){var a=this,b=this.element,c=$(b).find(".file-input-wrapper")[0];c.addEventListener("dragover",function(){a._dragover()},!1),c.addEventListener("dragleave",function(){a._dragleave()},!1),$(b).find(".alt-input-button").click(function(){a.showURLInput()}),$(b).find(".close-ext-input").click(function(){a.showFileInput()})},a.prototype._reactToFile=function(a){var b=a.files[0];if(this.isFormatSupported(b))this._onFileChange(b);else{var c=new Error("Filetype "+b.type+" not supported by this browser");this._onFileError(c,b)}},a.prototype._reactToURL=function(a){var b=a.replace(/\s/g,"");if(this.parseYoutubeURL(b))return this._onURLSubmit(b);var c=b.split("."),d=c[c.length-1];if(this.isFormatSupported(d))this._onURLSubmit(b);else{var e=new Error("Filetype "+d+" not supported by this browser");this._onURLError(e,a)}},a.prototype.showURLInput=function(){$(this.element).find(".ext-input-field").show().find("input").focus(),$(this.element).addClass("ext-input-active")},a.prototype.showFileInput=function(){$(this.element).find(".ext-input-field").hide(),$(this.element).removeClass("ext-input-active")}}();
private sortMessages(): Message[] {
const msgList: Message[] = $.map(this.messages, (v) => v);
msgList.sort((a, b) => a.time.getTime() - b.time.getTime());
return msgList;
}
render() {
var outputTypes = $.map(this.props.types, this._formatOutputType);
return (
<div>
<div>
<select value="{this.state.typeName}" id="input-type">
<option disabled="" value="{this.PLACEHOLDER}">Select Output Type</option>
{outputTypes}
</select>
<button disabled="{this.state.typeName">Launch new output</button>
</div>
</div>
sortColumns.push(sortOpts);
}
}
setSortColumns(sortColumns);
if (!options.multiColumnSort){
trigger(self.onSort, {
multiColumnSort: false,
sortCol: column,
sortAsc: sortOpts.sortAsc
}, e);
} else {
trigger(self.onSort, {
multiColumnSort: true,
sortCols: $.map(sortColumns, function(col){
return {
sortCol: columns[getColumnIndex(col.columnId)],
sortAsc: col.sortAsc
};
})
}, e);
}
}
});
}