⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index.html

📁 ajax php wiki source code
💻 HTML
字号:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="style.css" rel="Stylesheet" type="text/css" />
<script type="text/javascript" src="script/prototype.js"></script>
<script type="text/javascript" src="script/menu.js"></script>
<script type="text/javascript">

/* Save as Draft Related */
var AutoDraftSavingFrequency = 30;
var DraftSavingTask = false;

/* History Menu Related */
var MAX_SELECTION = 5;
var historyMenu;
var menuOn = false;

function get_window_size() {
	var winW;
	var winH;
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
  			winW = window.innerWidth;
  			winH = window.innerHeight;
 		}
 		if (navigator.appName.indexOf("Microsoft")!=-1) {
 		 	winW = document.body.offsetWidth;
  			winH = document.body.offsetHeight;
 		}
	}
	return [winW, winH];
}

function show(content) {
	Element.show ('ID_WIKI_BOARD');
	Element.hide ('ID_WIKI_EDIT');
	$('ID_WIKI_CONTENT').innerHTML = content;
}

function save_draft() {
	var content = $('ID_EDIT_CONTENT').value;
	if (content.length > 0) {
		Element.show('ID_SAVING');
		var req = new Ajax.Request('save.php',
					{ method: 'post',
					  postBody: 'action=draft&content=' + encodeURIComponent(content),
					  onComplete: function() { Element.hide('ID_SAVING');}
					});
	}
}

function auto_save() {
	if (DraftSavingTask) {
		save_draft();
		setTimeout (auto_save, AutoDraftSavingFrequency * 1000);
	}
}

function edit(content) {
	Element.show ('ID_WIKI_EDIT');	
	$('ID_EDIT_CONTENT').disabled = false;
	Element.hide ('ID_WIKI_BOARD');
	$('ID_EDIT_CONTENT').value = content;
	if (!DraftSavingTask) {
		setTimeout (auto_save, AutoDraftSavingFrequency * 1000);
		DraftSavingTask = true;
	}
}

function request_edit() {
	var req = new Ajax.Request('query.php', 
				  {method:'get', 
				   parameters:'action=draft', 
				   onComplete: function(r) { 
				   		if (r.responseText.length == 0)
				   			edit ('Edit Here');
				   		else
							edit (r.responseText);
					       }
			});
}

function preview() {
	Element.hide('ID_EDIT');
	Element.show('ID_CLOSE');
	Element.show ('ID_WIKI_BOARD');
	$('ID_WIKI_CONTENT').innerHTML = $('ID_EDIT_CONTENT').value;
}

function close_preview() {
	Element.hide('ID_WIKI_BOARD');
	Element.show('ID_EDIT');
	Element.hide('ID_CLOSE');
}

function save() {
	close_preview();
	var content = $('ID_EDIT_CONTENT').value;
	if (content.length > 0) {
		DraftSavingTask = false;
		$('ID_EDIT_CONTENT').disabled = true;
		var req = new Ajax.Request('save.php',
						{ method: 'post',
						  postBody: 'action=save&content=' + encodeURIComponent(content),
						  onComplete: function (r) { show(r.responseText); }
						});
	}
}

function choose_history(id) {
	var fname = historyMenu.get_content(id);
	Element.hide('ID_HISTORY');
	menuOn = false;
	var req = new Ajax.Request('query.php',
					{ method: 'get',
					  parameters: 'action=file&filename=' + fname,
					  onComplete: function (r) {
								if (r.responseText.length != 0)
									$('ID_EDIT_CONTENT').value = r.responseText;
					  	      }
					});
}

function history() {
	if (! menuOn) {
		var req = new Ajax.Request('query.php',
					{ method: 'get',
					  parameters: 'action=history',
					  onComplete: function (r) {
								var hist = r.responseText.split ('\n').without('\r', '\n', '');
								if (hist.length == 0)
									return ;
								historyMenu.clear();
								for (var l = 0; l < Math.min(hist.length, MAX_SELECTION); l++) {
									historyMenu.add_item (hist[l]);
								}
								Element.show('ID_HISTORY');
								menuOn = true;
								historyMenu.highlight(0);
						      } 
					});
	} else {
		Element.hide('ID_HISTORY');
		menuOn = false;
	}
}


</script>
<title>Wiki Sandbox</title>
</head>

<body>
<div id="ID_TITLE">
	<img src="images/title.gif"> <font size="2">Edit in place!</font>
</div>
<div style="display:none" id="ID_SAVING">Saving</div>

<div id="ID_WIKI_EDIT" style="display:none">
	<textarea id="ID_EDIT_CONTENT" rows="15" cols="120">
	</textarea><br>
	<table border="0">
	<tr><td valign="top">
		[<a href="javascript: save_draft();">儲存草稿</a>] - 
		[<a href="javascript: preview();">預覽</a>] - 
		[<a href="javascript: save();">儲存</a>] - 
		[<a href="javascript: history();">瀏覽歷史紀錄</a>]
	</td><td>
		<div id="ID_HISTORY" style="display:none; width:250"></div>
	</td></tr>
	</table>
</div>

<div id="ID_WIKI_BOARD" style="display:none">
	<div id="ID_WIKI_CONTENT"></div>
	<div align="right" id="ID_EDIT">[<a href="javascript: request_edit();">編輯</a>]</div>
	<div align="right" style="display:none" id="ID_CLOSE">[<a href="javascript: close_preview();">關閉</a>]</div>
</div>


<script type="text/javascript">
	var a;
	a = get_window_size() ;
	$('ID_SAVING').style.left=a[0] - 50;
	historyMenu = new Menu ('historyMenu', 'ID_HISTORY', 'choose_history', 'son', 'soff');

	var req = new Ajax.Request('query.php', 
			       {method:'get',
			  	onComplete: function (r) {
						if (r.responseText.length == 0) 
							request_edit();
						else
							show (r.responseText);
			 		}
			       });
</script>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -