Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* BROKEN -- infinite loop weirdness at the moment. */
- for (var i = 0; i < fromdata.length; i++) {
- var mainid = fromdata[i].id;
- var sub_m = afcHelper_Submissions[mainid];
- sub_m.action=afcHelper_Submissions[i].action;
- console.log(sub_m.action)
- if (sub_m.action == 'accept'){
- //create local file description talkpage?
- if((sub_m.talkpage==true)&&(sub_m.to!='')){
- afcHelper_editPage('File talk\:'+sub_m.to, '\{\{subst:WPAFCF\}\}\n'+sub_m.append, token, 'Placing [[WP:AFC|WPAFC]] project banner', true);
- }
- //First notify the user so we don't have to process yet another signature
- //todo list: if more files in one request were handled
- if(sub_m.notify==true){
- //assuming the first User/IP is the requester
- var requestinguser=/\[\[(User[_ ]talk:|User:|Special:Contributions\/)([^\||\]\]]*)([^\]]*?)\]\]/i.exec(text)[2];
- var userpagetext = afcHelper_getPageText('User talk:'+requestinguser, true);
- if (sub_m.to === '')
- userpagetext += '\n== Your request at \[\[WP:FFU|Files for upload\]\] ==\n\{\{subst:ffu talk\}\} \~\~\~\~\n';
- else
- userpagetext += '\n== Your request at \[\[WP:FFU|Files for upload\]\] ==\n\{\{subst:ffu talk|file=' + sub_m.to + '\}\} \~\~\~\~\n';
- afcHelper_editPage('User talk:'+requestinguser, userpagetext, token, 'Notifying about the [[WP:FFU|FFU]] request', true);
- }
- //update text of the FFU page
- var header = text.match(/==[^=]*==/)[0];
- text = header + "\n\{\{subst:ffu a\}\}\n" + text.substring(header.length);
- if (sub_m.to === '')
- text += '\n*\{\{subst:ffu|a\}\} \~\~\~\~\n';
- else
- text += '\n*\{\{subst:ffu|file=' + sub_m.to + '\}\} \~\~\~\~\n';
- text += '\{\{subst:ffu b\}\}\n';
- totalaccept++;
- // update [[Wikipedia:Files for upload/recent]]
- if(sub_m.recent==true){
- recenttext = afcHelper_getPageText('Wikipedia:Files_for_upload/recent',true)
- var newentry = "\|File:" + sub_m.to + "|" + ( typeof sub_m.filedescription !== "undefined" ? sub_m.filedescription : "" ) + "\n";
- var lastentry = recenttext.toLowerCase().lastIndexOf("| file:");
- var firstentry = recenttext.toLowerCase().indexOf("| file:");
- recenttext = recenttext.substring(0, lastentry);
- recenttext = recenttext.substring(0, firstentry) + newentry + recenttext.substring(firstentry) + '\n}}';
- afcHelper_editPage("Wikipedia:Files for upload/recent", recenttext, token, 'Updating recently uploaded FFUs');
- }
- } else if (sub_m.action == 'decline') {
- var header = text.match(/==[^=]*==/)[0];
- var reason = sub_m.reason;
- console.log('Reason: '+reason)
- if (reason == '')
- reason = sub_m.comment;
- else if (sub_m.comment != '')
- reason = reason + ': ' + sub_m.comment;
- if (reason == '') {
- document.getElementById('afcHelper_status').innerHTML += '<li>Skipping ' + sub_m.title + ': No decline reason specified.</li>';
- continue;
- }
- text = header + "\n\{\{subst:ffu d\}\}\n" + text.substring(header.length);
- if (sub_m.comment == '')
- text += '\n*\{\{subst:ffu|' + sub_m.reason + '\}\} \~\~\~\~\n';
- else
- text += '\n*\{\{subst:ffu|' + sub_m.reason + '\}\} ' + sub_m.comment + ' \~\~\~\~\n';
- text += '\{\{subst:ffu b\}\}\n';
- console.log('Text: '+text)
- totaldecline++;
- } else if (sub_m.action == 'comment') {
- if (sub_m.comment != '')
- text += '\n\{\{subst:ffu|c\}\} ' + sub_m.comment + '\~\~\~\~\n';
- totalcomment++;
- }
- pagetext = pagetext.substring(0, startindex) + text + pagetext.substring(endindex);
- } /**/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement