User:Yair rand/addquote.js

adddefsideboxbutton(function{return newNode('li', newNode('a','Add quotation',{'style':"cursor: pointer; "}))}, null, false, function(q){setupquoteadder(q)}, true);

function setupquoteadder(q) { findlang(q.parentNode, function(findlang_){    var z;    if($(".HQToggle a", q)[0]){      z = $(">ul", q)[0];      if(z.style.display='none'){        $(".HQToggle a", q)[0].onclick;        }      }    else{      z = q.appendChild(document.createElement("ul"))      }    var zz=z.appendChild(document.createElement("li")), quoteform;    var findsubdef = q.parentNode.parentNode.nodeName.toLowerCase=="li"?"#":"", editor=new Editor;    new AdderWrapper(editor, { 'createForm': function{ return quoteform = newNode('form',{'style':'display:inline;'},'Year: ',newNode('input',{'name':'year','size':4}),' Author: ',newNode('input',{'name':'author','size':20}),' Source title: ',newNode('input',{'name':'source','size':20}),' Publisher: ',newNode('input',{'name':'publisher','size':20}),' Page(s): ',newNode('input',{'name':'page','size':5}), newNode('dl', newNode('dd', 'Quotation: ', newNode('input', {'name':'quotation','size':40}),newNode('input',{'type':'submit','value':'Preview'}),newNode('input',{'type':'button','value':'Cancel','click':function{z.removeChild(zz)}}),newNode('dl',{'style':'display:'+(findlang_=="en"?"none":"block")},newNode('dd', 'Translation: ',newNode('input',{'size':40,'name':'translation'})))))) },     'fields':{ 'quotation':util.validateNoWikisyntax('quotation', true), 'year':util.validateNoWikisyntax('year', true), 'author':util.validateNoWikisyntax('author', true), 'source':util.validateNoWikisyntax('source title', true), 'publisher':util.validateNoWikisyntax('publisher', true), 'page':function(t){return t?(/\-/.test(t)?"pages "+t:"page "+t):t}, 'translation':function(t){return t}       }, 'onsubmit':function(values, render){ var topline = (values.year?""+values.year+", ":)+values.author+", "+values.source+""+(values.page?", "+values.page:) render(topline + "\n:" + values.quotation + (values.translation?"\n:"+values.translation:""), function(newhtml){         var findnumberofheaders=findnumberofheaders_(q), findnumberofdefs=findnumberofdefs_(q), quotetobeadded=newNode('span',{'style':'display:block;'});          quotetobeadded.innerHTML=newhtml.replace(/\|\<\/p\>/g,'');          editor.addEdit({ 'edit':function(wikitext){ return ccc=wikitext.replace(RegExp("(^[\\s\\S]*?((^|\n)=[\\s\\S]*?){"+findnumberofheaders+"}"+findnumberofdefs+"[\\s\\S]*?)\n(?!#"+findsubdef+"[:\*])|$"), "$1\n#"+findsubdef+"*"+topline+"\n#"+findsubdef+"*:"+values.quotation+(values.translation?"\n#"+findsubdef+"*:"+values.translation:'')+'\n') },           'redo':function{quoteform.style.display='none'; quotetobeadded.style.display='block'; zz.appendChild(quotetobeadded)}, 'undo':function{quoteform.style.display='inline';zz.removeChild(quotetobeadded)}, 'summary':'+quote: '+values.quotation },quotetobeadded)         }) }     }, zz)  }) }