Jump to content

User:Olcan/simple.js: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Olcan (talk | contribs)
No edit summary
Olcan (talk | contribs)
No edit summary
Line 98: Line 98:
// title="test";
// title="test";


var title=escape(location.href.match(/wiki\/(.*)/)[1].replace(/_/g, '-') + ' - Wikipedia');
var title=escape(location.href.match(/wiki\/(.*)/)[1].replace(/_/g, ' ') + ' - Wikipedia');
shortcutsAddLink ('PDFmyURL', 'http://pdfmyurl.com?-O=Portrait&--user-style-sheet=http://dl.dropbox.com/u/91246/wpcss.css&--toc-font-name=times&--header-font-name=times&--header-left='+title+'&--header-right=[page]/[toPage]&--header-line&--header-spacing=5&--filename='+title+'.pdf&url='+escape(location.href+'?useskin=simple&action=render&dummy=.pdf'));
shortcutsAddLink ('PDFmyURL', 'http://pdfmyurl.com?-O=Portrait&--user-style-sheet=http://dl.dropbox.com/u/91246/wpcss.css&--header-font-name=times&--header-left='+title+'&--header-right=[page]/[toPage]&--header-line&--header-spacing=5&--filename='+title+'.pdf&url='+escape(location.href+'?useskin=simple&action=render&dummy=.pdf'));
}
}

Revision as of 12:26, 31 May 2010

//<pre><nowiki>

 var shortcutsVersion      = "1.1.1";
 var shortcutsReleaseDate  = "2009-07-26";

 function shortcutsStartSection (name)
 {
   shortcutsLinks[shortcutsLinks.length] = { 'name': name, 'links': new Array () };
 }

 function shortcutsAddLink (name, article)
 {
   var links = shortcutsLinks[shortcutsLinks.length - 1]['links'];
   links[links.length] = { 'name': name, 'article': article };
 }

 function shortcutsMakeLink (name, url)
 {
   var ntxt = document.createTextNode (name);
   var na   = document.createElement ('a');
   var nli  = document.createElement ('li');

   na.setAttribute ('href', url); 
   nli.setAttribute ('class', 'n-shortcut');

   na.appendChild (ntxt);
   nli.appendChild (na);

   return nli;
 }

 function shortcutsMakePortlet (name, links)
 {
   var nportlet = document.createElement ('div');
   var nh5 = document.createElement ('h5');
   var ntit = document.createTextNode (name);
   var nbody = document.createElement ('div');
   var nul = document.createElement ('ul');

   if (skin == 'vector') {
       nportlet.setAttribute ('id', 'p-'+name);
       nportlet.setAttribute ('class', 'portal');
       nh5.setAttribute ('xml:lang', 'en');
       nh5.setAttribute ('lang', 'en');
       nbody.setAttribute ('class', 'body');    
   } else {
       nportlet.setAttribute ('id', 'p-'+name);
       nportlet.setAttribute ('class', 'portlet');
       nbody.setAttribute ('class', 'pBody');
       nul.setAttribute ('id', 'p-'+name);
   }

   for (var i = 0; i < links.length; i++)
     nul.appendChild (
       shortcutsMakeLink (links[i]['name'], links[i]['article'])
     );

   nh5.appendChild (ntit);
   nportlet.appendChild (nh5);
   nbody.appendChild (nul);
   nportlet.appendChild (nbody);

   return nportlet;
 }

 function shortcutsMain ()
 {
   if (skin == 'vector') {
       var sidecol = document.getElementById ('panel');
   } else {
       var sidecol = document.getElementById ('column-one');
   }

   for (var i = 0; i < shortcutsLinks.length; i++)
     if (shortcutsLinks[i]['links'].length > 0)
       sidecol.insertBefore (
         shortcutsMakePortlet (shortcutsLinks[i]['name'], shortcutsLinks[i]['links']),
         sidecol.firstChild
       );
 }

 function shortcutsInitialize ()
 {
   shortcutsInit ();
   shortcutsMain ();
 }

 var shortcutsLinks = new Array ();
 shortcutsStartSection (wgUserName ? wgUserName : 'shortcuts');

 addOnloadHook (shortcutsInitialize);

 //</nowiki></pre>

 function shortcutsInit ()
 {
//  var title=escape(location.href.match(/wiki\/(.*?)\?/)[1]);
//  title="test";

  var title=escape(location.href.match(/wiki\/(.*)/)[1].replace(/_/g, ' ') + ' - Wikipedia');
  shortcutsAddLink ('PDFmyURL', 'http://pdfmyurl.com?-O=Portrait&--user-style-sheet=http://dl.dropbox.com/u/91246/wpcss.css&--header-font-name=times&--header-left='+title+'&--header-right=[page]/[toPage]&--header-line&--header-spacing=5&--filename='+title+'.pdf&url='+escape(location.href+'?useskin=simple&action=render&dummy=.pdf'));
 }