Jump to content

User:Lupin/addlicense.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// <nowiki>
var addlicenseVersion="Tue Sep 13 09:55:04 EDT 2005";

function addLicense_sourceJS(url) {
  var str='<script type="text/javascript" src="';
  str += url;
  str += '"></script>';
  return document.write(str);
};

function addLicense_sourceWikipediaJS(wiki, name) {
  var url='http://' + wiki + '/w/index.php?title=';
  url += name;
  url += '&action=raw&ctype=text/javascript&dontcountme=s';
  return sourceJS(url);
};

function addLicense_sourceLupinJS(name) {
  return sourceWikipediaJS('en.wikipedia.org', 'User:Lupin/'+name + '.js');
};

if (!autoEdit){
  addLicense_sourceLupinJS('autoedit');
}

var licenseBoxHTML='		<select id="wpLicense" name="wpLicense">\\n			<option value="">None selected</option>\\n			<option value="" disabled="disabled">GNU Free Documentation Licenses:</option>\\n	<option value="GFDL" title="GFDL">&nbsp;&nbsp;#redirect [[Template:GFDL]]</option>\\n	<option value="GFDL-self" title="GFDL-self">&nbsp;&nbsp;GFDL (self made)</option>\\n<option value="" disabled="disabled">Creative Commons licenses:</option>\\n\\n	<option value="cc-by-sa-2.5" title="cc-by-sa-2.5">&nbsp;&nbsp;Attribution ShareAlike 2.5</option>\\n	<option value="cc-by-2.5" title="cc-by-2.5">&nbsp;&nbsp;Attribution 2.5</option>\\n<option value="" disabled="disabled">No rights reserved (must be explicitly stated by author):</option>\\n	<option value="NoRightsReserved" title="NoRightsReserved">&nbsp;&nbsp;No rights reserved, author releases all rights</option>\\n	<option value="CopyrightedFreeUse" title="CopyrightedFreeUse">&nbsp;&nbsp;Copyrighted, free to use for any purpose</option>\\n<option value="" disabled="disabled">Public Domain / not copyrighted:</option>\\n	<option value="PD-self" title="PD-self">&nbsp;&nbsp;PD (self made): donate to public domain / release all rights</option>\\n\\n	<option value="PD-old" title="PD-old">&nbsp;&nbsp;PD (old): author died more than 100 years ago</option>\\n	<option value="PD-US" title="PD-US">&nbsp;&nbsp;PD (United States): first published in the United States before 1923</option>\\n	<option value="PD-USGov" title="PD-USGov">&nbsp;&nbsp;Work of a US Government agency - public domain</option>\\n	<option value="PD-Soviet" title="PD-Soviet">&nbsp;&nbsp;Work published in the Soviet Union before May 27, 1973 - public domain</option>\\n	<option value="PD-BY-exempt" title="PD-BY-exempt">&nbsp;&nbsp;Work published by the Government of Belarus</option>\\n	<option value="patent" title="patent">&nbsp;&nbsp;Patent material - public domain</option>\\n\\n	<option value="PD-stamp" title="PD-stamp">&nbsp;&nbsp;Postage stamps known to be in public domain (US before 1978, others)</option>\\n	<option value="PD" title="PD">&nbsp;&nbsp;Public domain (generic)</option>\\n<option value="" disabled="disabled">Non-free licenses:</option>\\n	<option value="CopyrightByWikimedia" title="CopyrightByWikimedia">&nbsp;&nbsp;Images copyrighted by Wikimedia</option>\\n<option value="" disabled="disabled">Fair use / copyrighted:</option>\\n	<option value="Coatofarms" title="Coatofarms">&nbsp;&nbsp;Coat of arms, seal, emblem, or crest</option>\\n	<option value="logo" title="logo">&nbsp;&nbsp;Logo</option>\\n\\n	<option value="Promotional" title="Promotional">&nbsp;&nbsp;Press release photo</option>\\n	<option value="smithsonian" title="smithsonian">&nbsp;&nbsp;Image from the Smithsonian Institution</option>\\n	<option value="Stamp" title="Stamp">&nbsp;&nbsp;Fair use postage stamp, where copyright depends on country</option>\\n	<option value="USPSstamp" title="USPSstamp">&nbsp;&nbsp;- U.S. postage stamp after 1978</option>\\n<option value="" disabled="disabled">Covers:</option>\\n	<option value="albumcover" title="albumcover">&nbsp;&nbsp;Album cover</option>\\n\\n	<option value="boardgamecover" title="boardgamecover">&nbsp;&nbsp;Board game cover</option>\\n	<option value="bookcover" title="bookcover">&nbsp;&nbsp;Book cover</option>\\n	<option value="Comiccover" title="Comiccover">&nbsp;&nbsp;Comic book cover</option>\\n	<option value="Comicpanel" title="Comicpanel">&nbsp;&nbsp;- Single comic book panel</option>\\n	<option value="Comicscene" title="Comicscene">&nbsp;&nbsp;- Series of panels from a comic strip</option>\\n	<option value="DVDcover" title="DVDcover">&nbsp;&nbsp;DVD cover</option>\\n\\n	<option value="Gamecover" title="Gamecover">&nbsp;&nbsp;Video game cover</option>\\n	<option value="Magazinecover" title="Magazinecover">&nbsp;&nbsp;Magazine cover</option>\\n	<option value="TIME" title="TIME">&nbsp;&nbsp;- TIME Magazine cover</option>\\n	<option value="Newspapercover" title="Newspapercover">&nbsp;&nbsp;Newspaper cover</option>\\n	<option value="Video tape cover" title="Video tape cover">&nbsp;&nbsp;Video tape cover</option>\\n<option value="" disabled="disabled">Posters (must be reduced quality images):</option>\\n\\n	<option value="Movieposter" title="Movieposter">&nbsp;&nbsp;Movie poster</option>\\n	<option value="Sportsposter" title="Sportsposter">&nbsp;&nbsp;Sports event poster</option>\\n	<option value="Eventposter" title="Eventposter">&nbsp;&nbsp;Generic event poster</option>\\n	<option value="Politicalposter" title="Politicalposter">&nbsp;&nbsp;Politcal event poster</option>\\n<option value="" disabled="disabled">Screenshots (one per article):</option>\\n	<option value="film-screenshot" title="film-screenshot">&nbsp;&nbsp;Movie or TV screenshot</option>\\n\\n	<option value="game-screenshot" title="game-screenshot">&nbsp;&nbsp;Computer game or video game screenshot</option>\\n	<option value="musicpromo-screenshot" title="musicpromo-screenshot">&nbsp;&nbsp;Music video or music promo screenshot</option>\\n	<option value="software-screenshot" title="software-screenshot">&nbsp;&nbsp;Software screenshot</option>\\n	<option value="mac-software-screenshot" title="mac-software-screenshot">&nbsp;&nbsp;- Macintosh software screenshot</option>\\n	<option value="windows-software-screenshot" title="windows-software-screenshot">&nbsp;&nbsp;- Windows software screenshot</option>\\n	<option value="web-screenshot" title="web-screenshot">&nbsp;&nbsp;Web page screenshot</option>\\n\\n	<option value="wikipedia-screenshot" title="wikipedia-screenshot">&nbsp;&nbsp;Wikipedia web page screenshot</option>\\n	<option value="otherlicence" title="otherlicence">  Other: this placeholder must be replaced by a proper tag</option>\\n\\n		</select><br><a id="doLicenseLink"></a>';

function addLicense_addLicenseBox() {
  var t=document.createElement('div');
  t.innerHTML=licenseBoxHTML;

  var h=document.getElementsByTagName('h2')[0];
  if (!h) return;
  h.parentNode.insertBefore(t,h);

  // set global var licenseBox here
  window.licenseBox=document.getElementById('wpLicense');
  doLicenseLink=document.getElementById('doLicenseLink');

  licenseBox.onchange=addLicense_licenseBox_onChange;
};

function addLicense_articleFromURL(h) {
  var thisWiki='en.wikipedia.org';
  var reStart='[^:]*://';
  var preTitles='wiki/|w/index\\.php\\?title=';
  // if (!wikimediaWiki) preTitles += '|index\\.php\\?title=';
  var reEnd='/(' + preTitles + ')([^&]*)';
  var re = RegExp(reStart + thisWiki.split('.').join('\\.') + reEnd);

  var m=re.exec(h);
  if(m===null) return null;
  article=m[2];
  return article;
};

function addLicense_licenseBox_onChange () {
  var article=addLicense_articleFromURL(document.location);
  var url='http://en.wikipedia.org/w/index.php?title=' + article;
  url += '&action=edit';
  url +='&autoedit=s~$~\\n{{' + window.licenseBox.value + '}}~';
  url +='&autosummary=Added license {{'+licenseBox.value +'}}';
  if (false) url +='&autoclick=wpDiff';
  doLicenseLink.href=url;
  doLicenseLink.innerHTML='Add the selected license';
};

function addLicense_addOnloadFunction (f) {
  if (window.addEventListener) 
    window.addEventListener("load",f,false);
  else if (window.attachEvent) window.attachEvent("onload",f);
  else {
    window._old_addLicense_onload = window.onload;
    window.onload = function(){
      window._old_addLicense_onload();
      f();
    }
  }
};

function addLicense_isImagePage() {
  var h=String(document.location);
  return RegExp('(title=|wiki/):?Image:').test(h);
  return false;
};

function addLicense_onloadFunction () {
  if (addLicense_isImagePage()) 
    addLicense_addLicenseBox();
}

addLicense_addOnloadFunction(addLicense_onloadFunction);
// </nowiki>