?? wiki.js
字號:
var http_request=false;
var reobj=null;
var thwmlist={all:false,ked:false,wil:false};
var $ = function(id) {return document.getElementById(id);};
function send_request(url){//初始化,指定處理函數,發送請求的函數
createXMLHttpRequest();
http_request.onreadystatechange=processrequest;
http_request.open("GET",url,true);
http_request.send(null);
}
//處理返回信息的函數
function processrequest(){
if(http_request.readyState==4){//判斷對象狀態
if(http_request.status==200){//信息已成功返回,開始處理信息
var arr = http_request.responseText.split("~~");
$("tabs").value=arr[0];
$(reobj).innerHTML=arr[1];
}
else{//頁面不正常
alert("您所請求的頁面不正常!");
}
}
}
function dopage(obj,url){
$(obj).innerHTML="正在讀取數據...";
reobj=obj;
send_request(url);
}
function createXMLHttpRequest() {
http_request=false;
//開始初始化XMLHttpRequest對象
if(window.XMLHttpRequest){//Mozilla瀏覽器
http_request=new XMLHttpRequest();
if(http_request.overrideMimeType){//設置MIME類別
http_request.overrideMimeType("text/xml");
}
}else if(window.ActiveXObject){//IE瀏覽器
try{
http_request=new ActiveXObject("Msxml2.XMLHttp");
}catch(e){
try{
http_request=new ActiveXobject("Microsoft.XMLHttp");
}catch(e){}
}
}
if(!http_request){//異常,創建對象實例失敗
window.alert("創建XMLHttp對象失敗!");
return false;
}
}
function thwm(divid,url,tip){
div=$(divid);
if(!thwmlist[divid]){
div.innerHTML = tip;
createXMLHttpRequest();
http_request.open("GET",url,true);
http_request.onreadystatechange =function(){
if (http_request.readyState == 4) {
if (http_request.status == 200) {
div.innerHTML= http_request.responseText;
showdiv(divid);
thwmlist[divid]=true;
}
}
}
http_request.send(null);
}else{
showdiv(divid);
}
}
function thwmpage(divid,url,tip){
div=$(divid);
div.innerHTML = tip;
createXMLHttpRequest();
http_request.open("GET",url,true);
http_request.onreadystatechange =function(){
if (http_request.readyState == 4) {
if (http_request.status == 200) {
div.innerHTML= http_request.responseText;
showdiv(divid);
}
}
}
http_request.send(null);
}
function showdiv(divid){
div=$("allctrl");
div1=$("all");
div1.style.display="none";
div.className="top top_off";
div=$("kedctrl");
div1=$("ked");
div1.style.display="none";
div.className="top top_off";
div=$("wilctrl");
div1=$("wil");
div1.style.display="none";
div.className="top top_off";
div=$(divid);
divctrl=$(divid+"ctrl");
divctrl.className="top top_on";
if(div.style.display=="block"){
div.style.display="none";
}else{
div.style.display="block";
}
}
function subcmt(){
var COMMENT = $('COMMENT').value;
var ONLINE_ID = $('ONLINE_ID').value;
if(COMMENT == "")
{alert("評論內容不能為空");return false;}
var httpReq=getXMLHttpObj();
httpReq.open("GET","comment.php?COMMENT="+COMMENT+"&ONLINE_ID="+ONLINE_ID,true);
httpReq.onreadystatechange=function(){
if(httpReq.readyState==4){
if(httpReq.responseText=="ok"){
alert("評論提交成功");
window.location.reload();
dialogclose();
}
}
};
httpReq.send(null);
}
function getXMLHttpObj()
{
var v=null;
if(window.ActiveXObject)
{
v=new ActiveXObject("Msxml2.XMLHTTP");
if(!v)
{
v=new ActiveXObject("Microsoft.XMLHTTP");
}
}
else if(window.XMLHttpRequest)
{
v=new XMLHttpRequest();
}
return v;
}
function comment(){
alert;
$("commentBlock").style.left = (parseInt(document.body.clientWidth) - parseInt($("commentBlock").style.width))/2;
$("commentBlock").style.top = 150;
$("overlay").style.width = document.body.clientWidth;
if(parseInt(document.body.scrollHeight) < parseInt(document.body.clientHeight) )
$("overlay").style.height = document.body.clientHeight;
else
$("overlay").style.height = document.body.scrollHeight;
$("overlay").style.display = 'block';
$("commentBlock").style.display = 'block';
window.scroll(0,0);
}
function dialogclose()
{
$("overlay").style.display = 'none';
$("commentBlock").style.display = 'none';
}
function answer(){
$("answerBlock").style.left = (parseInt(document.body.clientWidth) - parseInt($("answerBlock").style.width))/2;
$("answerBlock").style.top = 140;
$("overlay").style.width = document.body.clientWidth;
if(parseInt(document.body.scrollHeight) < parseInt(document.body.clientHeight) )
$("overlay").style.height = document.body.clientHeight;
else
$("overlay").style.height = document.body.scrollHeight;
$("overlay").style.display = 'block';
$("answerBlock").style.display = 'block';
window.scroll(0,0);
}
function asrclose()
{
$("overlay").style.display = 'none';
$("answerBlock").style.display = 'none';
}
function subasr(){
var ANSWER_CONTENT = $('ANSWER').value;
var ONLINE_ID = $('ONLINE_ID').value;
if(ANSWER_CONTENT == "")
{alert("回答內容不能為空");return false;}
var httpReq=getXMLHttpObj();
httpReq.open("GET","answer.php?ANSWER_CONTENT="+ANSWER_CONTENT+"&ONLINE_ID="+ONLINE_ID,true);
httpReq.onreadystatechange=function(){
if(httpReq.readyState==4){
if(httpReq.responseText=="ok"){
alert("答案提交成功");
window.location.reload();
asrclose();
}
}
};
httpReq.send(null);
}
function adsubasr(){
var ANSWER_CONTENT = $('ANSWER').value;
var ONLINE_ID = $('ONLINE_ID').value;
if(ANSWER_CONTENT == "")
{alert("回答內容不能為空");return false;}
var httpReq=getXMLHttpObj();
httpReq.open("GET","answer.php?ANSWER_CONTENT="+ANSWER_CONTENT+"&ONLINE_ID="+ONLINE_ID,true);
httpReq.onreadystatechange=function(){
if(httpReq.readyState==4){
if(httpReq.responseText=="ok"){
alert("答案提交成功");
window.location.reload();
asrclose();
}
}
};
httpReq.send(null);
}
var login_str =
'<div style="text-align: center;"'+
'<div class="logintopBar">'+
'<table class="topBarTable" cellspacing="0" cellpadding="0" border="0">'+
'<tr>'+
'<td style="color:#fff; font-size: 14px; font-weight: bold;">登錄</td>'+
'<td align="right">'+
'<a class="dialogclosecss" onclick="loginclose()" width="16" height="16" border="0" align="absmiddle" title="關閉" /></a>'+
'</td>'+
'</tr>'+
'</table>'+
'</div>'+
'<div>'+
'<br />'+
'<div style="text-align: center;"><b style="font-size:15px;">用戶登錄</b></div><br />'+
'<div style="text-align: center;color:red;display:none;" id="login_error">dd</div>'+
'<div style="padding-left:80px;">'+
'<table border="0" width="250">'+
'<tr>'+
'<td align="right" style="font-size:12px;">用戶名:</td>'+
'<td>'+
'<input type="text" name="MEMBER" id="IDMEMBER" class="upcss" tabindex="1"> <a href="register.php" style="font-size:12px;">注冊</a>'+
'</td>'+
'</tr>'+
'<tr>'+
'<td align="right" style="font-size:12px;">密 碼:</td>'+
'<td>'+
'<input type="Password" name="LOGIN_PWORD" id="IDPWORD" class="upcss" tabindex="2" onkeydown="javascript:if(event.keyCode==13) sublogin();">'+
'</td>'+
'</tr>'+
'</table><br />'+
'</div>'+
'<div style="text-align: center;">'+
'<input type="button" onclick="sublogin();" value="登錄" class="subbcss" tabindex="3">'+
'</div>'+
'</div>'+
'</div>';
function userLogin(preUrl,regUrl){
if(preUrl!="")
$('REMINDACT').value = preUrl;
$("p").style.left = (parseInt(document.body.clientWidth) - parseInt($("p").style.width))/2;
$("p").style.top = 140;
$("overlay").style.width = document.body.clientWidth;
if(parseInt(document.body.scrollHeight) < parseInt(document.body.clientHeight) )
$("overlay").style.height = document.body.clientHeight;
else
$("overlay").style.height = document.body.scrollHeight;
$("overlay").style.display = 'block';
$("p").style.display = 'block';
if(regUrl!='')
login_str = login_str.replace('register.php',regUrl);
//alert(login_str);
$("p").innerHTML=login_str;
$('IDMEMBER').focus();
window.scroll(0,0);
}
function loginclose()
{
$("overlay").style.display = 'none';
$("p").style.display = 'none';
}
function sublogin(){
var IDMEMBER = $('IDMEMBER').value;
var IDPWORD = $('IDPWORD').value;
if(IDMEMBER == "")
{alert("用戶名不能為空!");return false;}
if(IDPWORD == "")
{alert("密碼不能為空!");return false;}
var httpReq=getXMLHttpObj();
httpReq.open("GET","login.php?MEMBER="+IDMEMBER+"&LOGIN_PWORD="+IDPWORD,true);
httpReq.onreadystatechange=function(){
if(httpReq.readyState==4){
if(httpReq.responseText=="ok"){
var REMINDACT = $('REMINDACT').value;
if(REMINDACT!="")
{
loginclose();
var pos = REMINDACT.lastIndexOf("()");
if(parseInt(pos) > 1)
{
if(parseInt(REMINDACT.lastIndexOf("wer")) > 0)
{
answer();
}
if(parseInt(REMINDACT.lastIndexOf("ment")) > 0)
{
comment();
}
}
else
window.location.href = REMINDACT;
}
else
{
window.location.reload();
loginclose();
}
}
if(httpReq.responseText=="error"){
$("login_error").style.display = 'block';
$('login_error').innerHTML = "用戶名或密碼不對,請重新登錄!";
$('IDPWORD').value = "";
$('IDPWORD').focus();
}
}
};
httpReq.send(null);
}
function goHome(goUrl){
window.location=goUrl;
}
function trim(s){
return s.replace(/(^\s*)|(\s*$)/g, "");
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -