pixmicat

Subversion Repositories:
Compare Path: Rev
With Path: Rev
/PMC2Prototype/ @ 374  →  /PMC2Prototype/ @ 375
/PMC2Prototype/resource/mainscript.js
@@ -1 +1,161 @@
var preset_sensor=0;var previous_replyhlno=0;var msgs=['在沒有附加檔案的情況下,請寫入內文','附加檔案為系統不支援的格式','偵測到您有輸入櫻花日文假名的可能性,將自動為您轉換'];var arrtbl_1=[63223,12353,82],arrtbl_2=[63306,12449,85],arrtbl_3=[63486,12535,4],arrtbl_4=[[63216,63219],[12293,12540],1],arrtbl_5=[[63210,63212],[12541,12445],1];function $(i){return document.getElementById(i);}function l1(){var N=getCookie("namec"),E=getCookie("emailc"),obj;if((obj=$("fname"))){obj.value=N;}if((obj=$("femail"))){obj.value=E;}}function l2(){var P=getCookie("pwdc"),d=document,forms_length=d.forms.length;for(var i=0;i<forms_length;i++){if(d.forms[i].pwd){d.forms[i].pwd.value=P;}}}function getCookie(key){var tmp1,tmp2,xx1=0,xx2=0,xx3;tmp1=' '+document.cookie+';';var len=tmp1.length;while(xx1<len){xx2=tmp1.indexOf(';',xx1);tmp2=tmp1.substring(xx1+1,xx2);xx3=tmp2.indexOf('=');if(tmp2.substring(0,xx3)==key){return unescape(tmp2.substring(xx3+1,xx2-xx1-1));}xx1=xx2+1;}return'';}function setCookie(name,value){var exp=new Date();exp.setTime(exp.getTime()+1000*60*60*24*7);document.cookie=name+"="+escape(value)+"; expires="+exp.toGMTString();}function c(){try{if(!$("fupfile")){return true;}var upfilevalue=$("fupfile").value;if(!upfilevalue&&!$("fcom").value){alert(msgs[0]);return false;}if(upfilevalue){var ext_allowed=0,ext_length=ext.length;for(var j=0;j<ext_length;j++){if(upfilevalue.substr(upfilevalue.length-3,3).toUpperCase()==ext[j]){ext_allowed=1;break;}}if(!ext_allowed){alert(msgs[1]);return false;}}check_sakura('fcom');check_sakura('fname');check_sakura('fsub');if(window.clipboardData){document.forms[0].upfile_path.value=upfilevalue;}document.forms[0].sendbtn.disabled=true;}catch(e){}if($("fname").value){setCookie("namec",$("fname").value);}}function fixalllinks(){if(!document.getElementsByTagName){return;}var anchors=document.getElementsByTagName("a");var anchors_length=anchors.length;for(var i=0;i<anchors_length;i++){var anchor=anchors[i];if(anchor.getAttribute("href")&&anchor.getAttribute("rel")=="_blank"){anchor.target="_blank";}if(anchor.getAttribute("href")&&anchor.getAttribute("rel")=="_top"){anchor.target="_top";}}}function showform(){var d=document;d.getElementById("postform").className="";d.getElementById("postform_tbl").className="";d.getElementById("hide").className="show";d.getElementById("show").className="hide";}function hideform(){var d=document;d.getElementById("postform").className="hide_btn";d.getElementById("postform_tbl").className="hide";d.getElementById("hide").className="hide";d.getElementById("show").className="show";}function quote(text){try{$("fcom").focus();}catch(e){}$("fcom").value+='>>No.'+text+"\r\n";}function replyhl(id,isrecover){var rpydiv=$('r'+id);if(rpydiv){if(isrecover){rpydiv.className=rpydiv.className.replace(' reply_hl','');}else{if(previous_replyhlno){replyhl(previous_replyhlno,true);}previous_replyhlno=id;rpydiv.className+=' reply_hl';}}}function check_sakura(field){var tar_obj=$(field);var checktext=escape(tar_obj.value).toLowerCase();var regular_exp=/%uf(6[ef]|7[0-9a-f]|80)[0-9a-f]/;if(checktext.match(regular_exp)!==null){alert(msgs[2]);replace_sakura(tar_obj);}}function replace_sakura(tar_obj){var temp=tar_obj.value,i=0;for(i=0;i<=arrtbl_1[2];i++){temp=replaceDX(temp,arrtbl_1[0]+i,arrtbl_1[1]+i);}for(i=0;i<=arrtbl_2[2];i++){temp=replaceDX(temp,arrtbl_2[0]+i,arrtbl_2[1]+i);}for(i=0;i<=arrtbl_3[2];i++){temp=replaceDX(temp,arrtbl_3[0]+i,arrtbl_3[1]+i);}for(i=0;i<=arrtbl_4[2];i++){temp=replaceDX(temp,arrtbl_4[0][i],arrtbl_4[1][i]);}for(i=0;i<=arrtbl_5[2];i++){temp=replaceDX(temp,arrtbl_5[0][0]+i,arrtbl_5[1][0]+i);temp=replaceDX(temp,arrtbl_5[0][1]+i,arrtbl_5[1][1]+i);}tar_obj.value=temp;}function replaceDX(txt,target,retxt){if(txt.indexOf(String.fromCharCode(target))!=-1){txt=txt.split(String.fromCharCode(target));txt=txt.join(String.fromCharCode(retxt));}return txt;}function preset(){if(preset_sensor){return;}preset_sensor++;fixalllinks();var url=location.href;if(url.indexOf('?res=')){if(url.match(/#[rq]([0-9]+)$/)){replyhl(RegExp.$1);}if(url.match(/#q([0-9]+)$/)){quote(RegExp.$1);}}}window.onload=preset;
var preset_sensor = 0;
var previous_replyhlno = 0;
var msgs = ['在沒有附加檔案的情況下,請寫入內文', '附加檔案為系統不支援的格式', '偵測到您有輸入櫻花日文假名的可能性,將自動為您轉換'];
var arrtbl_1 = [63223, 12353, 82], arrtbl_2 = [63306, 12449, 85], arrtbl_3 = [63486, 12535, 4], arrtbl_4 = [[63216, 63219], [12293, 12540], 1], arrtbl_5 = [[63210, 63212], [12541, 12445], 1];
 
/* getElementById */
function $(i){ return document.getElementById(i); }
 
/* 取出Cookies的值並填入表單 */
function l1(){
var N = getCookie("namec"), E = getCookie("emailc"), obj;
if((obj=$("fname"))){ obj.value = N; }
if((obj=$("femail"))){ obj.value = E; }
}
 
/* 填入表單密碼 */
function l2(){
var P = getCookie("pwdc"), d = document, forms_length = d.forms.length;
for(var i = 0; i < forms_length; i++){
if(d.forms[i].pwd){ d.forms[i].pwd.value = P; }
}
}
 
/* 讀取Cookies值 */
function getCookie(key){
var tmp1, tmp2, xx1 = 0, xx2 = 0, xx3;
tmp1 = ' '+document.cookie+';';
var len = tmp1.length;
while(xx1 < len){
xx2 = tmp1.indexOf(';', xx1);
tmp2 = tmp1.substring(xx1 + 1, xx2);
xx3 = tmp2.indexOf('=');
if(tmp2.substring(0, xx3)==key){ return unescape(tmp2.substring(xx3 + 1, xx2 - xx1 - 1)); }
xx1 = xx2 + 1;
}
return '';
}
 
/* 寫入Cookies值 */
function setCookie(name,value){
var exp = new Date();
exp.setTime(exp.getTime() + 1000*60*60*24*7);
document.cookie = name+"="+escape(value)+"; expires="+exp.toGMTString();
}
 
/* 前端檢查表單機制 */
function c(){
try{
if(!$("fupfile")){ return true; }
var upfilevalue = $("fupfile").value;
if(!upfilevalue && !$("fcom").value){ alert(msgs[0]); return false; }
if(upfilevalue){
var ext_allowed = 0, ext_length = ext.length;
for(var j = 0; j < ext_length; j++){
if(upfilevalue.substr(upfilevalue.length - 3, 3).toUpperCase()==ext[j]){
ext_allowed = 1;
break;
}
}
if(!ext_allowed){ alert(msgs[1]); return false; }
}
check_sakura('fcom'); check_sakura('fname'); check_sakura('fsub'); // 檢查櫻花日文
if(window.clipboardData){ document.forms[0].upfile_path.value = upfilevalue; } // IE的Senddata為完整路徑名稱
document.forms[0].sendbtn.disabled = true;
}catch(e){ }
if($("fname").value){ setCookie("namec", $("fname").value); } // Cookies寫入名稱
}
 
/* 動態改變超連結的視窗目標 */
function fixalllinks(){
if(!document.getElementsByTagName){ return; }
var anchors = document.getElementsByTagName("a");
var anchors_length = anchors.length;
for(var i = 0; i < anchors_length; i++){
var anchor = anchors[i];
if(anchor.getAttribute("href") && anchor.getAttribute("rel") == "_blank"){ anchor.target = "_blank"; }
if(anchor.getAttribute("href") && anchor.getAttribute("rel") == "_top"){ anchor.target = "_top"; }
}
}
 
/* 顯示發文表單 */
function showform(){
var d = document;
d.getElementById("postform").className = "";
d.getElementById("postform_tbl").className = "";
d.getElementById("hide").className = "show";
d.getElementById("show").className = "hide";
}
 
/* 隱藏發文表單 */
function hideform(){
var d = document;
d.getElementById("postform").className = "hide_btn";
d.getElementById("postform_tbl").className = "hide";
d.getElementById("hide").className = "hide";
d.getElementById("show").className = "show";
}
 
/* 內文引用編號 */
function quote(text){
try{ $("fcom").focus(); }catch(e){ }
$("fcom").value += '>>No.' + text + "\r\n";
}
 
/* 回應背景標亮 / 取消 */
function replyhl(id, isrecover){
var rpydiv = $('r'+id);
if(rpydiv){
if(isrecover){
rpydiv.className = rpydiv.className.replace(' reply_hl', '');
}else{
if(previous_replyhlno){ replyhl(previous_replyhlno, true); }
previous_replyhlno = id;
rpydiv.className += ' reply_hl';
}
}
}
 
/* 檢查使用者是否輸入了Unicode使用者造字區字集 (多為櫻花日文假名) */
function check_sakura(field){
var tar_obj = $(field);
var checktext = escape(tar_obj.value).toLowerCase(); // %uxxxx形式 (全部小寫)
var regular_exp = /%uf(6[ef]|7[0-9a-f]|80)[0-9a-f]/; // U+F6Ex~F80x為櫻花日文的概略位置 (比對時用小寫)
if(checktext.match(regular_exp)!==null){
alert(msgs[2]);
replace_sakura(tar_obj); // 代轉
}
}
 
/* 將Unicode使用者造字區字集之日文對應至Unicode日文假名區 */
function replace_sakura(tar_obj){
var temp = tar_obj.value, i = 0;
for(i = 0; i <= arrtbl_1[2]; i++){ temp = replaceDX(temp, arrtbl_1[0]+i, arrtbl_1[1]+i); }
for(i = 0; i <= arrtbl_2[2]; i++){ temp = replaceDX(temp, arrtbl_2[0]+i, arrtbl_2[1]+i); }
for(i = 0; i <= arrtbl_3[2]; i++){ temp = replaceDX(temp, arrtbl_3[0]+i, arrtbl_3[1]+i); }
for(i = 0; i <= arrtbl_4[2]; i++){ temp = replaceDX(temp, arrtbl_4[0][i], arrtbl_4[1][i]); }
for(i = 0; i <= arrtbl_5[2]; i++){ temp = replaceDX(temp, arrtbl_5[0][0]+i, arrtbl_5[1][0]+i); temp = replaceDX(temp, arrtbl_5[0][1]+i, arrtbl_5[1][1]+i); }
tar_obj.value = temp;
}
 
/* 強力字元取代函式 */
function replaceDX(txt, target, retxt){
if(txt.indexOf(String.fromCharCode(target))!=-1){
txt = txt.split(String.fromCharCode(target));
txt = txt.join(String.fromCharCode(retxt));
}
return txt;
}
 
/* 載入後執行的函式 */
function preset(){
if(preset_sensor){ return; } // 執行一遍即可
preset_sensor++; // 設定執行旗標
fixalllinks(); // 修正連結目標
var url = location.href;
if(url.indexOf('?res=')){
if(url.match(/#[rq]([0-9]+)$/)){ replyhl(RegExp.$1); } // 回應標亮
if(url.match(/#q([0-9]+)$/)){ quote(RegExp.$1); } // 回應引用
}
}
window.onload = preset;
/PMC2Prototype/resource/xmlhttp.js
@@ -54,9 +54,64 @@
T.style.display = (showDIVs.indexOf(','+T.id+',')!=-1) ? '' : 'none';
}
}
window.scroll(0, 0); // To the top
},
PTE : function(){
PTE : {
template : '',
cache : {
MAIN : '', REPLY : '', SEPARATE : ''
},
_cacheTemplate : function(template){
if(template.match(/<!--&MAIN-->([\s\S]*)<!--\/&MAIN-->/)){ Trender.PTE.cache.MAIN = RegExp.$1.replace(/&nbsp;/g, '&#160;'); }
if(template.match(/<!--&REPLY-->([\s\S]*)<!--\/&REPLY-->/)){ Trender.PTE.cache.REPLY = RegExp.$1.replace(/&nbsp;/g, '&#160;'); }
if(template.match(/<!--&SEPARATE-->([\s\S]*)<!--\/&SEPARATE-->/)){ Trender.PTE.cache.SEPARATE = RegExp.$1.replace(/&nbsp;/g, '&#160;'); }
},
_replaceMain : function(obj){
var arrLabels = {'{$NO}' : obj.no, '{$SUB}' : obj.sub, '{$NAME}' : obj.name, '{$NOW}' : obj.now, '{$COM}' : obj.com} //, '{$CATEGORY}' : $category, '{$QUOTEBTN}' : $QUOTEBTN, '{$IMG_BAR}' : $IMG_BAR, '{$IMG_SRC}' : $imgsrc, '{$WARN_BEKILL}' : $WARN_BEKILL, '{$QUOTEBTN}' : $QUOTEBTN};
var dat = Trender.PTE._evalIf(Trender.PTE.cache.MAIN, arrLabels);
for(l in arrLabels){
dat = dat.replace(new RegExp(l.replace('$', '\\$'), 'g'), arrLabels[l]);
}
return dat;
},
_replaceReply : function(obj){
var arrLabels = {'{$NO}' : obj.no, '{$SUB}' : obj.sub, '{$NAME}' : obj.name, '{$NOW}' : obj.now, '{$COM}' : obj.com} //, '{$CATEGORY}' : $category, '{$QUOTEBTN}' : $QUOTEBTN, '{$IMG_BAR}' : $IMG_BAR, '{$IMG_SRC}' : $imgsrc, '{$WARN_BEKILL}' : $WARN_BEKILL, '{$QUOTEBTN}' : $QUOTEBTN};
var dat = Trender.PTE._evalIf(Trender.PTE.cache.REPLY, arrLabels);
for(l in arrLabels){
dat = dat.replace(new RegExp(l.replace('$', '\\$'), 'g'), arrLabels[l]);
}
return dat;
},
_replaceSeparate : function(){
return Trender.PTE.cache.SEPARATE;
},
_evalIf : function(dat, arrLabels){
return dat;
},
init : function(){
Txmlhttp.get(Taction.resource+'/'+Trender.PTE.template, Trender.PTE._cacheTemplate);
Taction.flag['PTE'] = true;
},
renderThreads : function(jsonResult){
var icount = jsonResult.threads.length; var pcount;
var dat = ''; var thread = '';
for(var i = 0; i < icount; i++){
// ThreadPost
thread = jsonResult.threads[i];
dat += Trender.PTE._replaceMain(thread);
// Replies
pcount = thread.replies.length;
for(var p = 0; p < pcount; p++){
dat += Trender.PTE._replaceReply(thread.replies[p]);
}
// Horizon line (if needed)
if(i != icount - 1){ dat += Trender.PTE._replaceSeparate(); }
}
return dat;
},
renderReplies : function(jsonResult){
}
},
PageNavi : function(pMax, pCurrent){
var TableTxt = '<ul>';
@@ -71,7 +126,7 @@
show : function(txt){
var result = Trender.parseJSON(txt);
if(result.status!="OK"){ alert(result.status); return; }
$('TrenderShow').innerHTML = txt;
$('TrenderShow').innerHTML = Trender.PTE.renderThreads(result); // PTE Client
Trender.PageNavi(result.pageMax, result.pageCurrent);
Trender.__show('TrenderShow', 'TrenderPageNavi');
},
@@ -89,6 +144,7 @@
var Taction = {
flag : {}, // 執行旗標
self : '', // PHP URL
resource : '', // 資源資料夾
main : function(hash){
//var hash_ori = hash;
hash = hash.split(';');
@@ -108,6 +164,7 @@
case 'page':
case '':
if(typeof hash[1]=='undefined' || hash[1]==''){ hash[1] = 1; }
if(typeof Taction.flag['PTE']=='undefined'){ Trender.PTE.init(); }
Txmlhttp.get(Taction.self+'/show_ajax/'+hash[1], Trender.show);
break;
default:
/PMC2Prototype/resource/pixmicat_ajax.tmpl
@@ -10,6 +10,8 @@
<script type="text/javascript">
// <![CDATA[
Taction.self = '<?php echo PMCCore_getConfig('ENV.PHP_SELF');?>';
Taction.resource = '<?php echo PMCCore_getConfig('ENV.FOLDER.RESOURCE');?>';
Trender.PTE.template = '<?php echo PMCCore_getConfig('TEMPLATE.THREAD');?>';
// ]]>
</script>
</head>
@@ -68,14 +70,12 @@
<input type="submit" value=" 搜尋 " />
</li>
</ul>
<hr />
</div>
</form>
 
<div id="TrenderStatus" style="display: none;">
[<a href="#" onclick="Thistory.register(this)">回到版面</a>]
<div class="bar_admin">系統資訊</div>
 
<div style="text-align: center;">
<table border="1" style="margin: 0px auto; text-align: left;">
<tr><td align="center" colspan="3">基本設定</td></tr>
@@ -107,24 +107,18 @@
<tr align="center"><td colspan="2">GD函式庫 $info_gd_verinfo$</td><td> $info_gd_func$ </td></tr>
</table>
</div>
<hr />
</div>
 
<div id="TrenderShow">
TEST<br />
show form &amp; thread structure here. using <a href="<?php echo PMCCore_getConfig('ENV.PHP_SELF');?>/show_ajax/1">ajax</a> to load thread.
<hr />
Now Loading...
</div>
 
<hr />
<div id="TrenderPageNavi">
<ul>
<li>第一頁</li>
<li>[<b>1</b>]</li>
<li>[<a href="#page;2" rel="ajaxlink">2</a>]</li>
<li>[<a href="#page;3" rel="ajaxlink">3</a>]</li>
<li>[<a href="#page;4" rel="ajaxlink">4</a>]</li>
<li>[<a href="#page;5" rel="ajaxlink">5</a>]</li>
<li>下一頁</li>
<li>最後一頁</li>
</ul>
</div>