Advertisement
Guest User

Untitled

a guest
Jul 18th, 2013
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     /* BROKEN -- infinite loop weirdness at the moment. */
  2.     for (var i = 0; i < fromdata.length; i++) {
  3.         var mainid = fromdata[i].id;
  4.         var sub_m = afcHelper_Submissions[mainid];
  5.  
  6.         sub_m.action=afcHelper_Submissions[i].action;
  7.        
  8.         console.log(sub_m.action)
  9.             if (sub_m.action == 'accept'){
  10.                 //create local file description talkpage?
  11.                 if((sub_m.talkpage==true)&&(sub_m.to!='')){
  12.                     afcHelper_editPage('File talk\:'+sub_m.to, '\{\{subst:WPAFCF\}\}\n'+sub_m.append, token, 'Placing [[WP:AFC|WPAFC]] project banner', true);
  13.                         }
  14.  
  15.                 //First notify the user so we don't have to process yet another signature
  16.                 //todo list: if more files in one request were handled
  17.                 if(sub_m.notify==true){
  18.                     //assuming the first User/IP is the requester
  19.                     var requestinguser=/\[\[(User[_ ]talk:|User:|Special:Contributions\/)([^\||\]\]]*)([^\]]*?)\]\]/i.exec(text)[2];
  20.                     var userpagetext = afcHelper_getPageText('User talk:'+requestinguser, true);
  21.                     if (sub_m.to === '')
  22.                         userpagetext += '\n== Your request at \[\[WP:FFU|Files for upload\]\] ==\n\{\{subst:ffu talk\}\} \~\~\~\~\n';
  23.                     else
  24.                         userpagetext += '\n== Your request at \[\[WP:FFU|Files for upload\]\] ==\n\{\{subst:ffu talk|file=' + sub_m.to + '\}\} \~\~\~\~\n';
  25.                     afcHelper_editPage('User talk:'+requestinguser, userpagetext, token, 'Notifying about the [[WP:FFU|FFU]] request', true);
  26.                         }
  27.      
  28.                 //update text of the FFU page
  29.                 var header = text.match(/==[^=]*==/)[0];
  30.                 text = header + "\n\{\{subst:ffu a\}\}\n" + text.substring(header.length);
  31.                 if (sub_m.to === '')
  32.                     text += '\n*\{\{subst:ffu|a\}\} \~\~\~\~\n';
  33.                 else
  34.                     text += '\n*\{\{subst:ffu|file=' + sub_m.to + '\}\} \~\~\~\~\n';
  35.                 text += '\{\{subst:ffu b\}\}\n';
  36.                         totalaccept++;                 
  37.      
  38.                 // update [[Wikipedia:Files for upload/recent]]
  39.                 if(sub_m.recent==true){
  40.                     recenttext = afcHelper_getPageText('Wikipedia:Files_for_upload/recent',true)
  41.                     var newentry = "\|File:" + sub_m.to + "|" + ( typeof sub_m.filedescription  !== "undefined" ? sub_m.filedescription : "" ) + "\n";
  42.                     var lastentry = recenttext.toLowerCase().lastIndexOf("| file:");
  43.                     var firstentry = recenttext.toLowerCase().indexOf("| file:");
  44.                     recenttext = recenttext.substring(0, lastentry);
  45.                     recenttext = recenttext.substring(0, firstentry) + newentry + recenttext.substring(firstentry) + '\n}}';
  46.                     afcHelper_editPage("Wikipedia:Files for upload/recent", recenttext, token, 'Updating recently uploaded FFUs');
  47.                 }
  48.             } else if (sub_m.action == 'decline') {
  49.                 var header = text.match(/==[^=]*==/)[0];
  50.                 var reason = sub_m.reason;
  51.                 console.log('Reason: '+reason)
  52.                 if (reason == '')
  53.                     reason = sub_m.comment;
  54.                 else if (sub_m.comment != '')
  55.                     reason = reason + ': ' + sub_m.comment;
  56.                 if (reason == '') {
  57.                     document.getElementById('afcHelper_status').innerHTML += '<li>Skipping ' + sub_m.title + ': No decline reason specified.</li>';
  58.                     continue;
  59.                 }
  60.                 text = header + "\n\{\{subst:ffu d\}\}\n" + text.substring(header.length);
  61.                 if (sub_m.comment == '')
  62.                     text += '\n*\{\{subst:ffu|' + sub_m.reason + '\}\} \~\~\~\~\n';
  63.                 else
  64.                     text += '\n*\{\{subst:ffu|' + sub_m.reason + '\}\} ' + sub_m.comment + ' \~\~\~\~\n';
  65.                 text += '\{\{subst:ffu b\}\}\n';
  66.                 console.log('Text: '+text)
  67.                 totaldecline++;
  68.  
  69.             } else if (sub_m.action == 'comment') {
  70.                 if (sub_m.comment != '')
  71.                     text += '\n\{\{subst:ffu|c\}\} ' + sub_m.comment + '\~\~\~\~\n';
  72.                         totalcomment++;
  73.                     }
  74.                 pagetext = pagetext.substring(0, startindex) + text + pagetext.substring(endindex);
  75.             } /**/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement