4 function insertTab(ev,o){
11 if(ev.type=="keydown"){
12 if(o.setSelectionRange){
13 var s=o.selectionStart;
15 o.value=o.value.substring(0,s)+" "+o.value.substr(e);
16 o.setSelectionRange(s+1,s+1);
18 }else if(o.createTextRange){
19 document.selection.createRange().text=" ";
20 o.onblur=function(){this.focus();this.onblur=null;};
32 function gotoPage(page,data){
33 if(page==undefined) page=Page;
34 if(page==undefined) page='Main';
36 window.location.href='../../wiki.hml/'+encodeURIComponent(Proj)+'/'+encodeURIComponent(page)+'?'+$H(data).toQueryString();
38 window.location.href='../../wiki.hml/'+encodeURIComponent(Proj)+'/'+encodeURIComponent(page);
42 function callURL(url,data,func){
43 var relogin=function(r){
45 LoginOp=Array(url,data,func);
55 function callWiki(page,data,func){
56 callURL('../../op-wiki.hml/'+encodeURIComponent(Proj)+'/'+encodeURIComponent(page),data,func);
59 function readWiki(page,data,target){
61 // $(target).update(r.responseText);
62 showWikiPane(r.responseXML.documentElement,target);
64 callWiki(page,data,f);
66 function showWiki(xml){
67 var ctx=new ExprContext(xml);
68 var title=xpathParse('/WikiText/Title/text()').evaluate(ctx);
69 var html=xpathParse('/WikiText/Html/text()').evaluate(ctx);
70 var lu=xpathParse('/WikiText/LastUpdate/text()').evaluate(ctx);
71 if(title) document.title=title.stringValue();
72 if(html) $('WikiPane').innerHTML=html.stringValue();
73 if(lu&&lu.value.size()>0) $('LastUpdate').innerHTML=lu.stringValue();
75 function showWikiPane(xml,target){
76 var ctx=new ExprContext(xml);
77 var html=xpathParse('/WikiText/Html/text()').evaluate(ctx);
78 if(target) $(target).innerHTML=html.stringValue();
80 function showWikiHandler(r){
81 showWiki(r.responseXML.documentElement);
83 function reloadHander(r){
87 function SubmitForm(form,page,data,func){
89 callWiki(page,$H($(form).serialize(true)).update(data),func);
91 callWiki(page,$H($(form).serialize(true)).update(data),showWikiHandler);
95 Element.prototype.showDialog=function(){
96 var d=document.viewport.getDimensions();
97 var pos=this.getDimensions();
98 var h=d.height/2-pos.height/2-100;
100 this.style.top=String(h)+"px";
101 this.style.left=String(d.width/2-pos.width/2)+"px";
102 this.style.display='block';
104 Element.prototype.hideDialog=function(){
105 this.style.display='none';
107 Element.prototype.removeChildren=function(){
108 while(this.hasChildNodes()) this.removeChild(this.lastChild);
110 Element.prototype.appendText=function(txt){
111 if(txt==undefined) txt='';
112 this.appendChild(document.createTextNode(txt));
114 Element.prototype.replaceText=function(txt){
115 if(txt==undefined) txt='';
117 this.removeChildren();
118 this.appendText(txt);
122 function showLogin(){
123 var f=$('LoginForm');
124 var m=$('LoginMsgPane');
126 $(f.Password).clear();
127 while(m.hasChildNodes()) m.removeChild(m.lastChild);
128 $('LoginPane').showDialog();
129 $('Login').activate();
131 function hideLogin(){
132 $('LoginPane').hideDialog();
136 function loadURL(url,data,target,f2){
138 $(target).update(r.responseText);
143 function opLogin(form){
145 if(r.responseText=='OK'){
147 $('LoginPane').hideDialog();
149 callURL(LoginOp[0],LoginOp[1],LoginOp[2]);
153 loadURL('../../op-top.hml',undefined,'TopMenuPane',f2);
155 $('LoginMsgPane').replaceText('IDまたはパスワードが間違っています。');
158 callURL('../../op-login.hml',$(form).serialize(true),f);
162 callURL('../../op-logout.hml',null,reloadHander);
165 function opEditSel(sel){
168 $('EditWikiPane').style.display='block';
169 $('EditOprPane').style.display='none';
172 $('EditWikiPane').style.display='none';
173 $('EditOprPane').style.display='block';
176 $('EditWikiPane').style.display='none';
177 $('EditOprPane').style.display='block';
178 readWiki('special-Diff',{'Target':Page},'EditOprPane');
183 function postWiki(form,data,func){
184 callURL('../../op-post.hml',$H($(form).serialize(true)).update(data),func);
186 function opPreview(form){
187 postWiki(form,null,showWikiHandler);
189 function opSave(form){
190 postWiki(form,{'Save':'1'},showWikiHandler);
192 function opSaveClose(form){
193 postWiki(form,{'Save':'1'},reloadHander);