User:DannyS712/import.js

// /* globals $, mw, OO, Set, Promise */ $( => { const FakeImport = {}; window.FakeImport = FakeImport;

FakeImport.start = function { console.log( 'Started' ); var $div = $(" "); $('#mw-content-text').empty.append( $div ); var $upload = $(" "); $div.append( $upload ); var uploadFL = FakeImport.getUpload; $upload.append( uploadFL.$element ); $div.append( $(' ' ) ); var $interwiki = $(" "); $div.append( $interwiki ); var transwikiFL = FakeImport.getTranswiki; $interwiki.append( transwikiFL.$element ); };

FakeImport.getUpload = function { var uploadFS = new OO.ui.FieldsetLayout( {       label: 'Upload XML data (import-upload)'    } );

var uploadIntro = new OO.ui.LabelWidget( {		label: "Please export the file from the source wiki using the export utility. Save it to your computer and upload it here. (importtext)"	}); var uploadFile = new OO.ui.LabelWidget( {		label: "placeholder for file upload"	}); var uploadPrefix = new OO.ui.TextInputWidget; var uploadAssign = new OO.ui.CheckboxMultioptionWidget( {		label: 'Assign edits to local users where the named user exists locally (import-assign-known-users)'	} ); var uploadComment = new OO.ui.TextInputWidget;

var uploadTargetDefault = new OO.ui.RadioOptionWidget( {		data: 'default',		label: 'Import to default locations (import-mapping-default)',	} ); var uploadTargetNamespace = new OO.ui.RadioOptionWidget( {		data: 'namespace',		label: 'Import to a namespace: (import-mapping-namespace)',	} ); var uploadTargetSubpage = new OO.ui.RadioOptionWidget( {		data: 'subpage',		label: 'Import as subpages of the following page: (import-mapping-subpage)',	} ); var uploadTargetOptions = new OO.ui.RadioSelectWidget( { 		items: [ uploadTargetDefault, uploadTargetNamespace, uploadTargetSubpage ] 	} ); uploadTargetOptions.selectItem( uploadTargetDefault );

var uploadSubmit = new OO.ui.ButtonInputWidget( {       label: 'Upload file (uploadbt)'    } );

uploadFS.addItems( [   	new OO.ui.FieldLayout( uploadIntro ),    	new OO.ui.FieldLayout( uploadFile, { label: 'Filename: (import-upload-filename)', align: 'top' } ),   	new OO.ui.FieldLayout( uploadPrefix, { label: 'Interwiki prefix: (import-upload-username-prefix)', align: 'top' } ),   	new OO.ui.FieldLayout( uploadAssign ),    	new OO.ui.FieldLayout( uploadComment, { label: 'Comment: (import-comment)', align: 'top' } ),   	new OO.ui.FieldLayout( uploadTargetOptions ),    	new OO.ui.FieldLayout( uploadSubmit ),    ] ); var uploadFL = new OO.ui.FormLayout( {   	items: [ uploadFS ],	} ); return uploadFL; }; FakeImport.getTranswiki = function { var transwikiFS = new OO.ui.FieldsetLayout( {       label: 'Import from another wiki (importinterwiki)'    } );

var transwikiIntro = new OO.ui.LabelWidget( {		label: "Select a wiki and page title to import. Revision dates and editors' names will be preserved. All imports from other wikis are logged at the import log. (import-interwiki-text)"	}); var transwikiSources = new OO.ui.DropdownInputWidget( {		options: [			{ data: 'meta', label: 'meta' } ,			{ data: 'commons', label: 'commons'} ,			{ data: 'wikipedia', label: 'wikipedia' }		]	} ); var transwikiTitle = new OO.ui.TextInputWidget; var transwikiOptions = new OO.ui.CheckboxMultiselectInputWidget( {		options: [			{ data: 'history', label: 'Copy all history revisions for this page (import-interwiki-history)', selected: true },			{ data: 'templates', label: 'Include all templates (import-interwiki-templates)' },			{ data: 'assign', label: 'Assign edits to local users where the named user exists locally (import-assign-known-users)' }		]	} ); var transwikiComment = new OO.ui.TextInputWidget;

var transwikiTargetDefault = new OO.ui.RadioOptionWidget( {		data: 'default',		label: 'Import to default locations (import-mapping-default)',	} ); var transwikiTargetNamespace = new OO.ui.RadioOptionWidget( {		data: 'namespace',		label: 'Import to a namespace: (import-mapping-namespace)',	} ); var transwikiTargetSubpage = new OO.ui.RadioOptionWidget( {		data: 'subpage',		label: 'Import as subpages of the following page: (import-mapping-subpage)',	} ); var transwikiTargetOptions = new OO.ui.RadioSelectWidget( { 		items: [ transwikiTargetDefault, transwikiTargetNamespace, transwikiTargetSubpage ] 	} ); transwikiTargetOptions.selectItem( transwikiTargetDefault );

var transwikiSubmit = new OO.ui.ButtonInputWidget( {       label: 'Import (import-interwiki-submit)'    } );

transwikiFS.addItems( [   	new OO.ui.FieldLayout( transwikiIntro ),    	new OO.ui.FieldLayout( transwikiSources, { label: 'Source wiki: (import-interwiki-sourcewiki)', align: 'top' } ),   	new OO.ui.FieldLayout( transwikiTitle, { label: 'Source page: (import-interwiki-sourcepage)', align: 'top' } ),   	new OO.ui.FieldLayout( transwikiOptions ),    	new OO.ui.FieldLayout( transwikiComment, { label: 'Comment: (import-comment)', align: 'top' } ),   	new OO.ui.FieldLayout( transwikiTargetOptions ),    	new OO.ui.FieldLayout( transwikiSubmit ),    ] ); var transwikiFL = new OO.ui.FormLayout( {   	items: [ transwikiFS ],	} ); return transwikiFL; }; });

mw.loader.using([ 'oojs-ui-core', 'oojs-ui-widgets' ], => {	$(document).ready( => { if (mw.config.get('wgNamespaceNumber') === -1) { if (mw.config.get('wgCanonicalSpecialPageName') === 'Blankpage') { const page2 = mw.config.get('wgTitle').split('/'); if (page2[1] && page2[1] === 'FakeImport') { FakeImport.start; }			}		}	}); });

//