User:Yair rand/NECV2.js

// 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  })