User:CWii/JB2script.js: Difference between revisions

Content deleted Content added
CWii (talk | contribs)
update
m Maintenance: Replacing addPortletLink() with mw.util.addPortletLink() (mw:ResourceLoader/Migration_guide_(users)#addPortletLink)
 
(48 intermediate revisions by 3 users not shown)
Line 1:
function jb2script () {
if( mw.config.get('wgNamespaceNumber') == 6 ) {
mw.util.addPortletLink( 'p-cactions', "javascript:jb2script.callback()", "JB2", "jb2script", "Tag for moval by John Bot II", "");
}
}
Line 8:
jb2script.callback = function jb2scriptCallback() {
var Window = new SimpleWindow( 600, 300 );
Window.setTitle( "John Bot II image movalmover btool" );
var form = new QuickForm( jb2script.callback.evaluate );
var categories = form.append( {
Line 14:
name: 'movable',
label: 'Is the image movable? ',
tooltip: 'mehPlease chose the correct option.',
event: jb2script.callback.change_category
} );
Line 31:
categories.append( {
type: 'option',
label: "Not by a bot - It can'twas bealready moved by a robot",
selected: false,
value: 'notBotmoved'
} );
form.append( {
Line 68:
switch( value ) {
case 'yes':
work_area = new QuickForm.element( {
type: 'field',
label: 'Movable',
name: 'work_area'
} );
work_area.append( {
type: 'input',
name: 'newname',
label: 'New name: '
} );
work_area.append( {
type: 'input',
name: 'comCat1',
label: 'Commons Cat #1: '
} );
work_area.append( {
type: 'input',
name: 'comCat2',
label: 'Commons Cat #2: '
} );
work_area.append( {
type: 'input',
name: 'comCat3',
label: 'Commons Cat #3: '
} );
work_area.append( {
type: 'input',
name: 'comCat4',
label: 'Commons Cat #4: '
} );
work_area.append( {
type: 'input',
name: 'comCat5',
label: 'Commons Cat #5: '
} );
work_area.append( {
type: 'input',
name: 'comCat6',
label: 'Commons Cat #6: '
} );
work_area.append( {
type: 'checkbox',
name: 'keeplocal',
list: [
{ label: 'Keep local', value: 'keeplocal' }
]
 
} );
work_area.append( { type:'submit' } );
work_area = work_area.render();
old_area.parentNode.replaceChild( work_area, old_area );
break;
case 'no':
work_area = new QuickForm.element( {
type: 'field',
label: 'Cannot be moved',
name: 'work_area'
} );
work_area.append( {
type: 'textarea',
name: 'reason',
label: 'Reason:'
} );
work_area.append( { type:'submit' } );
work_area = work_area.render();
old_area.parentNode.replaceChild( work_area, old_area );
break;
case 'moved':
work_area = new QuickForm.element( {
type: 'field',
label: 'Already Moved',
name: 'work_area'
} );
work_area.append( {
type: 'input',
name: 'newname',
label: 'New name:'
} );
work_area.append( { type:'submit' } );
work_area = work_area.render();
old_area.parentNode.replaceChild( work_area, old_area );
break;
default:
work_area = new QuickForm.element( {
type: 'field',
label: 'MovableNothing for anything',
name: 'work_area'
} );
work_area = work_area.appendrender( {);
old_area.parentNode.replaceChild( work_area, old_area );
type: 'input',
name: 'newname',break;
label: 'New name: '
} );
work_area.append( {
type: 'input',
name: 'comCat1',
label: 'Commons Cat #1: '
} );
work_area.append( {
type: 'input',
name: 'comCat2',
label: 'Commons Cat #2: '
} );
work_area.append( {
type: 'input',
name: 'comCat3',
label: 'Commons Cat #3: '
} );
work_area.append( {
type: 'input',
name: 'comCat4',
label: 'Commons Cat #4: '
} );
work_area.append( { type:'submit' } );
work_area = work_area.render();
old_area.parentNode.replaceChild( work_area, old_area );
break;
default:
work_area = new QuickForm.element( {
type: 'field',
label: 'Nothing for anything',
name: 'work_area'
} );
work_area = work_area.render();
old_area.parentNode.replaceChild( work_area, old_area );
break;
}
Line 117 ⟶ 166:
jb2script.callbacks = {
yes: function ( self ) {
newname = self.params.newname;
cc1 = self.params.cc1;
cc2 = self.params.cc2;
cc3 = self.params.cc3;
cc4 = self.params.cc4;
cc5 = self.params.cc5;
cc6 = self.params.cc6;
keeplocal = self.params.keeplocal;
template = '\{\{jb2move|canMove=yes'
template += '|user=' + mw.config.get('wgUserName');
if ( cc1 != '' ) {
template += '|comCat1=' + cc1;
}
if ( cc2 != '' ) {
template += '|comCat2=' + cc2;
}
if ( cc3 != '' ) {
template += '|comCat3=' + cc3;
}
if ( cc4 != '' ) {
template += '|comCat4=' + cc4;
}
if ( cc5 != '' ) {
template += '|comCat5=' + cc5;
}
if ( cc6 != '' ) {
template += '|comCat6=' + cc6;
}
if( newname != '' ) {
template += '|newName=' + newname;
}
/*var form = e.target;
var checked = form.getChecked( 'keeplocal' );
if( checked.length == 0 ) {
template += '|keepLocal=yes';
}*/
if( keeplocal ) {
cc1 = self.params.cc1;
template += '|keepLocal=yes';
cc2 = self.params.cc2;
}
cc3 = self.params.cc3;
cc4 = self.params.cc4;
template += '\}\}\n';
template = '\{\{jb2move|canMove=yes'
var form = self.responseXML.getElementById('editform');
template += '|user=' + wgUserName;
if ( cc1 != '' if( !form ) {
self.statelem.error( 'Failed to get edit Form' );
template += '|commCat1=' + cc1;
}
}
if ( cc2 != '' ) {
var text = form.wpTextbox1.value;
template += '|commCat2=' + cc2;
}
var postData = {
if ( cc3 != '' ) {
'wpMinoredit': true,
template += '|commCat3=' + cc3;
'wpWatchthis': false,
}
'wpStarttime': form.wpStarttime.value,
if ( cc4 != '' ) {
'wpEdittime': form.wpEdittime.value,
template += '|commCat4=' + cc4;
'wpAutoSummary': form.wpAutoSummary.value,
}
'wpEditToken': form.wpEditToken.value,
'wpSummary': 'Reviewing image for [[User:John Bot II|JB-II]] (Image OK)',
template += '\}\}';
'wpTextbox1': template + text
};
var form = self.responseXML.getElementById('editorm');
self.post( postData );
if( !form ) {
},
self.statelem.error( 'Failed to get edit Form' );
no: function ( self ) {
}
var reason = self.params.reason;
template = '\{\{jb2move|canMove=no'
var text = form.wpTextbox1.value;
template += '|user=' + mw.config.get('wgUserName');
template += '|reason=' + reason;
var postData = {
template += '\}\}\n'
'wpMinoredit': TwinkleConfig.markAIVReportAsMinor ? '' : form.wpMinoredit.checked ? '' : undefined,
'wpWatchthis': form.wpWatchthis.checked ? '' : undefined,
var form = self.responseXML.getElementById('editform');
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
if( !form ) {
'wpAutoSummary': form.wpAutoSummary.value,
self.statelem.error( 'Failed to get edit Form' );
'wpEditToken': form.wpEditToken.value,
}
'wpSummary': '(TESTING) Reviewing image for [[User:John Bot|JB-II]] (Image OK)',
'wpTextbox1': template + text
var text = form.wpTextbox1.value;
};
self.post( var postData );= {
'wpMinoredit': true,
 
'wpWatchthis': false,
'wpStarttime': form.wpStarttime.value,
}
'wpEdittime': form.wpEdittime.value,
}
'wpAutoSummary': form.wpAutoSummary.value,
 
'wpEditToken': form.wpEditToken.value,
'wpSummary': 'Reviewing image for [[User:John Bot II|JB-II]] (Image NOT OK)',
'wpTextbox1': template + text
};
self.post( postData );
},
moved: function ( self ) {
var newname = self.params.newname;
var form = self.responseXML.getElementById('editform');
if( !form ) {
self.statelem.error( 'Failed to get edit Form' );
}
var text = form.wpTextbox1.value;
var fText;
var re = new RegExp( "\\{\\{jb2move" );
var myArr;
if( (myArr = re.exec( text ) ) ) {
self.statelem.error( 'Sorry, you gotta do this one manaul.' );
return;
} else {
fText = '\{\{jb2move';
fText += '|user=' + mw.config.get('wgUserName');
fText += '|canMove=moved'
if( newname != '' ) {
fText += '|newName=' + newname;
}
fText += '\}\}';
}
var text = form.wpTextbox1.value;
var postData = {
'wpMinoredit': true,
'wpWatchthis': false,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
'wpAutoSummary': form.wpAutoSummary.value,
'wpEditToken': form.wpEditToken.value,
'wpSummary': 'Reviewing image for [[User:John Bot II|JB-II]] (Image MOVED)',
'wpTextbox1': fText
};
self.post( postData );
}
}
jb2script.callback.evaluate = function(e) {
var form = e.target;
var reason = "";
switch( form.categoriesmovable.value ) {
default:
case 'yes':
case 'yes':
var query = {
var query = {
'title': wgPageName,
'title': mw.config.get('wgPageName'),
'action': 'submit',
'action': 'submit',
};
};
var newname = form.newname.value;
var cc1 = form.comCat1.value;
var cc2 = form.comCat2.value;
var cc3 = form.comCat3.value;
var cc4 = form.comCat4.value;
var cc5 = form.comCat5.value;
var cc6 = form.comCat6.value;
var keeplocal = form.keeplocal.checked;
Status.init( form );
Status.init( form );
wikipedia_wiki = new Wikipedia.wiki( 'Tagging Image', query, jb2script.callbacks.yes );
wikipedia_wiki.params = {new newname:newname,Wikipedia.wiki( cc1:cc1,'Tagging cc2:cc2Image', cc3:cc3query, cc4:cc4jb2script.callbacks.yes });
wikipedia_wiki.params = { newname:newname, cc1:cc1, cc2:cc2, cc3:cc3, cc4:cc4, cc5:cc5, cc6:cc6, keeplocal:keeplocal }
wikipedia_wiki.get();
wikipedia_wiki.get();
break;
break;
}
case 'no':
var query = {
'title': mw.config.get('wgPageName'),
'action': 'submit',
'unwatch': 'true',
};
var reason = form.reason.value;
Status.init( form );
wikipedia_wiki = new Wikipedia.wiki( 'Tagging Image', query, jb2script.callbacks.no );
wikipedia_wiki.params = { reason:reason }
wikipedia_wiki.get();
break;
case 'moved':
var query = {
'title': mw.config.get('wgPageName'),
'action': 'submit',
'unwatch': 'true',
};
var newname = form.newname.value;
Status.init( form );
wikipedia_wiki = new Wikipedia.wiki( 'Tagging Image', query, jb2script.callbacks.moved );
wikipedia_wiki.params = { newname:newname }
wikipedia_wiki.get();
break;
}
}