User:Malo/FlickrPicasareview.js

Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
//<nowiki>


// addPicasaOK tagger stolen from Flickr script (initially developed by Patstuart)
function picasaOK (autosave){
  var needAppend=document.editform.wpTextbox1.value;
  document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(/({{User:Picasa?Review?Bot.*}})|({{(P|p)icasa??eview??ot}})/g, '{{picasareview|' + wgUserName + '|{{subst:#time:Y-m-d}}}}');
  if (needAppend==document.editform.wpTextbox1.value)
    document.editform.wpTextbox1.value+='{{picasareview|' + wgUserName + '|{{subst:#time:Y-m-d}}}}'    
  document.editform.wpSummary.value = '[[Commons:Picasa Web Albums files|picasareview]] passed (using malo's picasa review script)';
  document.editform.wpMinoredit.checked = true;
  
  if (autosave)
    document.editform.submit();
}

// picasa_copyvio tagger stolen and modified from the flickr_copyvio tagger (initially developed by Patstuart)
function picasa_copyvio(autosave){
  document.editform.wpTextbox1.value = "{{Copyvio|Picasa review NOT passed: Author is using NC, ND, or all rights reserved.}} ~~~~\n" + document.editform.wpTextbox1.value.replace(/({{User:Picasa?Review?Bot.*}})|({{(P|p)icasa??eview??ot}})/g, "");
  document.editform.wpSummary.value = '[[Commons:Picasa Web Albums files|picasareview]] failed; marked as copyvio (using malo's picasa review script)';
  document.editform.wpMinoredit.checked = false;
  
  if (autosave)
    document.editform.submit();
}


//stolen shamelessly and modified from the add {{information}} template text
function add_toolbox_button(text, _href) 
{
  var toolbox = document.getElementById ( "p-tb" ) ;
  if ( !toolbox )
    return ;
  var ul = toolbox.getElementsByTagName ( "UL" ) [0] ;
  var li = document.createElement ( "LI" ) ;
  var a = document.createElement ( "A" ) ;
  a.appendChild (document.createTextNode(text));
  a.href = _href;
  a.className = "external" ;
  li.appendChild ( a ) ;
  ul.appendChild ( li ) ;
}


//stolen shamelessly and modified from the add {{information}} template text
function add_topbar_button(text, _href) 
{
  mw.util.addPortletLink("p-cactions", _href, text, "");
}
function addFunction(functionNameString, buttonDisplayName, checkNameSpaceFlag, whereAdd)
{
  checkNameSpaceFlag|= (wgPageName=="Commons:Sandbox");
  if (!checkNameSpaceFlag)
    return;

  if (getParamValue('functionName')==functionNameString)
  {
    addOnloadHook
    (
      function ()
      {
        eval(functionNameString+"(true)")
      }
    );
  }

  var _href;
  if (wgAction=="edit") 
    _href = "javascript:"+functionNameString+"(true)";
  else
    _href = wgScript + "?title="+encodeURIComponent(mw.config.get('wgPageName'))+ "&action=edit&functionName="+functionNameString;

  if (whereAdd=="top")
    addOnloadHook(function (){add_topbar_button(buttonDisplayName, _href);})
  else if (whereAdd=="toolbox")
    addOnloadHook(function (){add_toolbox_button(buttonDisplayName, _href);})
}

function addImageFunction(functionNameString, buttonDisplayName, buttonLocation)
{
  addFunction(functionNameString, buttonDisplayName, wgNamespaceNumber == 7, buttonLocation);
}

addImageFunction("picasaOK", "picasa passed", "top");
addImageFunction("picasa_copyvio", "picasa cv", "top");


//</nowiki>