MediaWiki:AddFileToArticle/code.js

if(wgNamespaceNumber === 6 && !mw.util.$content.find('#mw-imagepage-nofile').length) { $('.page-header__contribution-buttons .wds-dropdown .wds-list').append(       $(' ').append( $('',{id: "ca-history"}).text('Add to article').click(function {               $.showCustomModal('Choose Article','    &emsp;Insert into new article',{ id: 'article-search-form', callback: function { //mw.loader.load('jquery.autocomplete'); mw.loader.using('jquery.autocomplete',function {                            el = $('#article-search').autocomplete({ serviceUrl: wgScriptPath + '/api.php?action=opensearch', appendTo: $('#article-search-form'), deferRequestBy: 250, maxHeight: 1000, queryParamName: 'search', selectedClass: 'selected', width: '270px', namespace: 0, fnPreprocessResults: function(response){ response.query = response[0]; response.suggestions = response[1]; response.data = response[1]; return response; },                               onSelect: function(value, data, event) { var valueEncoded = encodeURIComponent(value.replace(/ /g, '_')); // slashes can't be urlencoded because they break routing window.location = window.wgArticlePath.replace(/\$1/, valueEncoded + '?action=edit&&addFile=' + wgTitle).replace(encodeURIComponent('/'), '/'); }                           });                        },function(e) {                            console.error(e);                        }); $('.add-to-new').click(function(e) {							e.preventDefault;							window.location = '/wiki/Spezial:Seite_erstellen?wpTitle=' + $('#article-search').val + '&addFile=' + wgTitle;                       }); },                   buttons: [{ message: 'Cancel', handler: function { $('#article-search-form').closeModal; }, id: 'article-search-cancel', defaultButton: true, }]               });            })        )    ); }