User:Magnus Manske/newbiehelp.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.
addOnloadHook(newbiehelp_init);

function newbiehelp_run () {
  newbiehelp_box = document.createElement ( 'div' ) ;
  newbiehelp_box.id = 'newbiehelp_box' ;
  newbiehelp_box.style.zIndex = 99 ;
  newbiehelp_box.style.position = 'absolute' ;
  newbiehelp_box.style.left = '100px' ;
  newbiehelp_box.style.top = '30px' ;
  newbiehelp_box.style.width = '600px' ;
  newbiehelp_box.style.height = '400px' ;
  newbiehelp_box.style.border = '2px solid black' ;
  newbiehelp_box.style.background = '#99CCFF' ;
  newbiehelp_box.style.padding = '3px' ;

  var close = document.createElement ( 'input' ) ;
  close.type = 'button' ;
  close.style.cssFloat = 'right' ;
  close.value = 'Close help' ;
  close.onclick = function () { var n = document.getElementById('newbiehelp_box') ; n.parentNode.removeChild ( n ) ; return false ; } ;

  var h2 = document.createElement ( 'h2' ) ;
  h2.appendChild ( document.createTextNode ( 'How to edit Wikipedia?' ) ) ;

  var p1 = document.createElement ( 'p' ) ;
  p1.appendChild ( document.createTextNode ( 'Anyone (yes, that means YOU!) can edit Wikipedia! Here are a few hints so work can be done as smoothly as possible:' ) ) ;

  var ul = document.createElement ( 'ul' ) ;

  var li1 = document.createElement ( 'li' ) ;
  li1.appendChild ( document.createTextNode ( 'This is an encyclopedia. Please write only texts helpful and appropriate in that context.' ) ) ;
  ul.appendChild ( li1 ) ;

  var li2 = document.createElement ( 'li' ) ;
  li2.appendChild ( document.createTextNode ( 'Wikipedia is written from a ' ) ) ;
  var a2 = document.createElement ( 'a' ) ;
  a2.appendChild ( document.createTextNode ( 'Neutral Point of View' ) ) ;
  a2.href = 'http://en.wikipedia.org/wiki/Wikipedia:Neutral_point_of_view' ;
  li2.appendChild ( a2 ) ;
  li2.appendChild ( document.createTextNode ( '. Please try to follow that ideal.' ) ) ;
  ul.appendChild ( li2 ) ;

  var li5 = document.createElement ( 'li' ) ;
  li5.appendChild ( document.createTextNode ( 'When adding new text, cite your sources. This is especially important in biographies of living people!' ) ) ;
  ul.appendChild ( li5 ) ;

  var li3 = document.createElement ( 'li' ) ;
  li3.appendChild ( document.createTextNode ( 'Wiki markup (all these "[[" and "{{" things) can be confusing at first. Don\'t worry, you\'ll get used to it in time. When in doubt, ignore them and just write text; someone more experienced will probably clean it up. And, you can always have a look at the ' ) ) ;
  var a3 = document.createElement ( 'a' ) ;
  a3.appendChild ( document.createTextNode ( 'editing help' ) ) ;
  a3.href = 'http://en.wikipedia.org/wiki/Wikipedia:Cheatsheet' ;
  li3.appendChild ( a3 ) ;
  li3.appendChild ( document.createTextNode ( ' (also linked from every edit page). You can try out Wiki markup in the ' ) ) ;
  var a4 = document.createElement ( 'a' ) ;
  a4.appendChild ( document.createTextNode ( 'sandbox' ) ) ;
  a4.href = 'http://en.wikipedia.org/wiki/Wikipedia:Sandbox' ;
  li3.appendChild ( a4 ) ;
  li3.appendChild ( document.createTextNode ( '.' ) ) ;
  ul.appendChild ( li3 ) ;

  var li4 = document.createElement ( 'li' ) ;
  li4.appendChild ( document.createTextNode ( 'Have a look at the ' ) ) ;
  var a5 = document.createElement ( 'a' ) ;
  a5.appendChild ( document.createTextNode ( 'help pages' ) ) ;
  a5.href = 'http://en.wikipedia.org/wiki/Help:Contents' ;
  li4.appendChild ( a5 ) ;
  li4.appendChild ( document.createTextNode ( ' for more information. To discuss an article, or to contact a user, please use the respective "discussion" page.' ) ) ;
  ul.appendChild ( li4 ) ;

  var li6 = document.createElement ( 'li' ) ;
  li6.appendChild ( document.createTextNode ( 'Finally, Wikipedia lives from YOUR contributions! So, ' ) ) ;
  var b1 = document.createElement ( 'b' ) ;
  b1.appendChild ( document.createTextNode ( 'be bold' ) ) ;
  li6.appendChild ( b1 ) ;
  li6.appendChild ( document.createTextNode ( ' in editing pages.' ) ) ;
  ul.appendChild ( li6 ) ;

  newbiehelp_box.appendChild ( close ) ;
  newbiehelp_box.appendChild ( h2 ) ;
  newbiehelp_box.appendChild ( p1 ) ;
  newbiehelp_box.appendChild ( ul ) ;

  document.getElementById('bodyContent').appendChild ( newbiehelp_box ) ;
  return false ;
}

function newbiehelp_init () {
  edit_tab = document.getElementById('ca-edit');

  var a = document.createElement ( 'a' ) ;
  a.appendChild ( document.createTextNode ( "how?" ) ) ;
  a.title = "Some help for first-time editors" ;
  a.href = '#' ;
  a.onclick = newbiehelp_run ;
  a.style.margin = '0px' ;
  a.style.padding = '0px' ;
  a.className = 'internal' ;
  
  t1 = document.createTextNode ( " (" ) ;
  t2 = document.createTextNode ( ")" ) ;

  var span = document.createElement ( 'span' ) ;
  span.style.margin = '0px' ;
  span.style.padding = '0px' ;
  span.appendChild ( t1 ) ;
  span.appendChild ( a ) ;
  span.appendChild ( t2 ) ;

  edit_tab.appendChild ( span ) ;
}