/* * addonUploader() * Extends fileUploader() * Also, this can only be used once per page. Or you'll have lots of issues with closures and scope :) */ (function ($) { /* Normalize results */ function getErrors(results) { var errors = []; if (results.validation.messages) { $.each(results.validation.messages, function (i, v) { if (v.type == 'error') { errors.push(v.message); } }); } return errors; } function checkTimeout(validation) { var timeout_id = [ 'validator', 'unexpected_exception', 'validation_timeout', ]; return _.some(validation.messages, function (message) { return _.isEqual(message.id, timeout_id); }); } $.fn.addonUploader = function (options) { var settings = { filetypes: ['zip', 'xpi', 'crx'], getErrors: getErrors, cancel: $(), maxSize: null, // Dynamically set by devhub.js submissionsDisabled: false, }; if (options) { $.extend(settings, options); } function parseErrorsFromJson(response, statusCode) { var json, errors = []; try { json = JSON.parse(response); } catch (err) { errors = [gettext('There was a problem contacting the server.')]; } if (!errors.length) { errors = settings.getErrors(json); } return { errors: errors, json: json, }; } return $(this).each(function () { var $upload_field = $(this), file = {}; /* Add some UI */ var ui_parent = $('
').html(item).appendTo(mv3CompatibilityBox); }); } } } if (messageCount > 0) { // Validation checklist should be displayed if there is at least // one message coming from the linter. let checklist_box = $('
') .text( gettext( 'Please verify the following points before finalizing your submission. This will minimize delays or misunderstanding during the review process:', ), ) .appendTo(checklist_box); if (results.validation.metadata.contains_binary_extension) { checklistMessages.push( gettext( 'Minified, concatenated or otherwise machine-generated scripts (excluding known libraries) need to have their sources submitted separately for review. Make sure that you use the source code upload field to avoid having your submission rejected.', ), ); } var checklist_ul = $('