Jump to content

User:Yair rand/NECV2.js

From Wiktionary, the free dictionary

Note: You may have to bypass your browser’s cache to see the changes. In addition, after saving a sitewide CSS file such as MediaWiki:Common.css, it will take 5-10 minutes before the changes take effect, even if you clear your cache.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.


// New Entry Creator version 2.
// Requires TabbedLanguages.js, YR/Editor.js, Adddefinition.js, and possibly some of my other scripts too.

function newEntry()
{
var bodyContent=document.getElementById('bodyContent')
while(bodyContent.firstChild.className!="printfooter"){bodyContent.removeChild(bodyContent.firstChild)}
editor=new Editor();
new AdderWrapper(editor, {
  createForm:function(){return newNode('form','Language name: ',newNode('input',{'style':'font-size:150%','name':'language'}),newNode('input',{'type':'submit'}))},
  fields:{language:function(txt){return txt}},
  onsubmit:function(values,render){
    render("\n=="+values.language+"==\n",function(newhtml){
      var temp=newNode('span');temp.innerHTML=newhtml;
      bodyContent.insertBefore(temp.firstChild,bodyContent.firstChild);
      document.getElementById('catlinks').appendChild(newNode('span'));
      makeLanguageTabs();
      addPOSHeader(true);
      mw.util.addPortletLink('p-tb', 'javascript:addDefinition()', 'Add definition');
      currentBoxToBeAdded.style.display='none';
      newsection = languageContainers[0];
      newsection.removeChild(newsection.firstChild);
      newsection.insertBefore(currentBoxToBeAdded.firstChild, newsection.lastChild).firstChild.focus()
      editor.addEdit({
        edit:function(){return "=="+values.language+"==\n"},
        redo:function(){},
        undo:function(){window.location=window.location},
        summary:"+section "+values.language
        }, newsection)
      })
    }
  },bodyContent,bodyContent.firstChild)

}

$(function(){
  if(mw.config.get('wgPageName') == "Special:Search" && document.getElementById("searchMenuNecLink")){
    document.getElementById("searchMenuNecLink").firstChild.href = document.getElementById("searchMenuNecLink").firstChild.href.split("&action=edit")[0]+"&startingnewentry=true"
    }
  location.search.indexOf("startingnewentry=true") != -1 && newEntry()
  })