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

📄 ajax_content.js

📁 很好的一套PHP树形论坛程序
💻 JS
字号:

var Editor       = null;
var obj          = null;
var linkobj      = null;
var container    = null;
var editobj      = null;
var tid          = '';
var origsubject  = '';
var responsetext     ='';
var editor_state = false;

function AJAX_Init(threadtableid){
	var tds = get_tags(get_object(threadtableid), 'td');
	for (var i = 0; i < tds.length; i++){
		if (tds[i].hasChildNodes() && tds[i].id && tds[i].id.substr(0, 3) == 'td_'){
			tds[i].ondblclick = content_doubleclick;
		}
	}
}
function content_doubleclick(){
	if(editor_state == true){
		return;
	}
	Editor = new AJAX_Editor(this);
}
function AJAX_Editor(obj){
	obj          = obj;
	tid          = obj.id.substr(obj.id.lastIndexOf('_') + 1);
	linkobj      = get_object('a_ajax_' + tid);
	container    = linkobj.parentNode;
	editobj      = null;
	editor_state = false;
	AJAX_edit();
}
function AJAX_edit(){
	if (editor_state == false){
		Ajaxobj = AJAX_creat();
		editobj = container.insertBefore(Ajaxobj,linkobj);
		editobj.select();
		linkobj.style.display = 'none';
		editor_state = true;
	}
}
function AJAX_creat(){
	Ajaxobj        = document.createElement('textarea');
	Ajaxobj.rows   = 8;
	Ajaxobj.cols   = 100;
	AJAX_save('','fetchcode');
	Ajaxobj.onblur = AJAX_store;
	return Ajaxobj;
}
function AJAX_save(ajaxtext,action){
	document.AjaxForm.tid.value = tid;
	document.AjaxForm.atc_content.value = ajaxtext;
	document.AjaxForm.action.value = action;
	document.AjaxForm.submit();
}
function AJAX_store(){
	if (editor_state == true){
		AJAX_save(editobj.value,'content');
		container.removeChild(editobj);
		linkobj.style.display = '';
		editor_state = false;
		obj = null;
	}
}
function AJAX_response(action,text){
	if(action == 'fetchcode'){
		editobj.value = text;
		origsubject   = text;
	}else if(action == 'showcode'){
		linkobj.innerHTML = text;
	}
}

⌨️ 快捷键说明

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