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

📄 inspectortrigger.js

📁 SQLiteDBMS是SQLite数据库的管理服务器软件
💻 JS
字号:
/* create */function inspectorTriggerNew(data) {	var tableName='';	if (data && (data.type == 'table' || data.type == 'view')) tableName=data.name;	lGo('newTriggerWin');	_inspectorData=data;	var form=document.forms['form_triggernew'];	if (form) {		try{			form['name'].value='new_trigger';			form['temp'].checked=form['temp'].defaultChecked=false;			while (form['table'].options.length > 0)				form['table'].remove(0);			while (form['table'].childNodes.length > 0)				form['table'].removeChild(form['table'].childNodes[0]);			var option=new Option('Select table or view', '');			option.style.backgroundColor='#eee';			form['table'].options.add(option, form['table'].options.length);			var grp=appendNew(form['table'], 'OPTGROUP');			grp.label='Tables';			for (var i=_tables.length; i--;) {				var option=new Option(_tables[i].name, _tables[i].name);				form['table'].options.add(option, form['table'].options.length);			}			var grp=appendNew(form['table'], 'OPTGROUP');			grp.label='Views';			for (var i=_view.length; i--;) {				var option=new Option(_view[i].name, _view[i].name);				form['table'].options.add(option, form['table'].options.length);			}			if (tableName)				form['table'].value=tableName;			form['event'].value='';			form['action'].value='';			form['name'].focus();			form['name'].select();			var ifm=document.getElementById('trigger_new_step');			if (!ifm || !ifm.contentWindow || !ifm.contentWindow.document || !ifm.contentWindow.document.body) return;			ifm.contentWindow.document.body.innerHTML='';		}catch(e){}	}}function inspectorTriggerNewSubmit(showSql) {	var form=document.forms['form_triggernew'];	if (!form) return false;	if (!trim(form['name'].value)) {		alert('Insert new trigger\'s name.');		form['name'].focus();		return;	}	if (!form['table'].value) {		alert('Select table or view.');		form['table'].focus();		return;	}	if (form['event'].value == 'UPDATE OF') {		alert('UPDATE OF event is not support');		form['event'].focus();		return;	}	var ifm=document.getElementById('trigger_new_step');	if (!ifm || !ifm.contentWindow || !ifm.contentWindow.document || !ifm.contentWindow.document.body) return;	var step=trim(innerText(ifm.contentWindow.document.body));	if (!step) {		alert('Insert trigger step.');		ifm.contentWindow.focus();		return;	}	syntaxSQL(ifm.contentWindow.document.body);	if (!showSql && !confirm('Create new trigger?')) return false;	var newName=form['name'].value;	var temp=(form['temp'].checked == true)?'TEMP ':'';	var table=form['table'].value;	var sql='CREATE '+temp+'TRIGGER "'+newName+'" '+(form['event'].value?form['event'].value+' ':'')+'ON "'+table+'" '+(form['action'].value?form['action'].value+' ':'')+'BEGIN\n'+step+'\nEND';	if (showSql) return dbShowSQL(sql);	dbExecCommand(sql, inspectorTriggerNewResponse);	return false;}function inspectorTriggerNewResponse(dbRes) {	if (dbRes) {		inspectorDdlClear();		dbExecCommand('show trigger', inspectorTriggerListDraw);		lHide();	}}/* modify */function inspectorTriggerModify(data) {	if (!data || data.type != 'trigger') return;	lGo('editTriggerWin');	_inspectorData=data;	var form=document.forms['form_triggeredit'];	if (form) {		try{			form['name'].value=form['curname'].value=data.name;			form['temp'].checked=form['temp'].defaultChecked=(data.ddl.match(/^\s*CREATE\s+TEMP/i)?true:false);			while (form['table'].options.length > 0)				form['table'].remove(0);			while (form['table'].childNodes.length > 0)				form['table'].removeChild(form['table'].childNodes[0]);			var option=new Option('Select table or view', '');			option.style.backgroundColor='#eee';			form['table'].options.add(option, form['table'].options.length);			var grp=appendNew(form['table'], 'OPTGROUP');			grp.label='Tables';			for (var i=_tables.length; i--;) {				var option=new Option(_tables[i].name, _tables[i].name);				form['table'].options.add(option, form['table'].options.length);			}			var grp=appendNew(form['table'], 'OPTGROUP');			grp.label='Views';			for (var i=_view.length; i--;) {				var option=new Option(_view[i].name, _view[i].name);				form['table'].options.add(option, form['table'].options.length);			}			form['table'].value=data.table;			match=data.ddl.match(/(BEFORE|AFTER|INSTEAD\s+OF|)\s+(DELETE|INSERT|UPDATE)\s+/i);			if (match)				form['event'].value=(match[1]+(match[2]?' '+match[2]:'')).toUpperCase();			else				form['event'].value='';			match=data.ddl.match(/\s+FOR\s+EACH\s+(ROW|STATEMENT)\s+/i);			if (match)				form['action'].value='FOR EACH '+(match[1].toUpperCase());			else				form['action'].value='';			form['name'].focus();			form['name'].select();			if (_isIE) inspectorTriggerModify2();			else setTimeout('inspectorTriggerModify2()', 100);		}catch(e){}	}}function inspectorTriggerModify2() {	var ifm=document.getElementById('trigger_edit_step');	if (!ifm || !ifm.contentWindow || !ifm.contentWindow.document || !ifm.contentWindow.document.body) return;	var match=_inspectorData.ddl.match(/BEGIN\s*(.*)\s*END\s*[;]?$/);	if (match && match[1])		ifm.contentWindow.document.body.innerHTML=match[1];	else		ifm.contentWindow.document.body.innerHTML='';	syntaxSQL(ifm.contentWindow.document.body);}function inspectorTriggerEditSubmit(showSql) {	var form=document.forms['form_triggeredit'];	if (!form) return false;	if (!trim(form['name'].value)) {		alert('Insert new trigger\'s name.');		form['name'].focus();		return;	}	if (!form['table'].value) {		alert('Select table or view.');		form['table'].focus();		return;	}	if (form['event'].value == 'UPDATE OF') {		alert('UPDATE OF event is not support');		form['event'].focus();		return;	}	var ifm=document.getElementById('trigger_edit_step');	if (!ifm || !ifm.contentWindow || !ifm.contentWindow.document || !ifm.contentWindow.document.body) return;	var step=trim(innerText(ifm.contentWindow.document.body));	if (!step) {		alert('Insert trigger step.');		ifm.contentWindow.focus();		return;	}	syntaxSQL(ifm.contentWindow.document.body);	if (!showSql && !confirm('Create new trigger?')) return false;	var newName=form['name'].value;	var temp=(form['temp'].checked == true)?'TEMP ':'';	var table=form['table'].value;	var sql='DROP TRIGGER "'+form['curname'].value+'";\nCREATE '+temp+'TRIGGER "'+newName+'" '+(form['event'].value?form['event'].value+' ':'')+'ON "'+table+'" '+(form['action'].value?form['action'].value+' ':'')+'BEGIN\n'+step+'\nEND';	if (showSql) {		_dbShowSQL_FFBug=ifm.contentWindow.document.body.innerHTML;		return dbShowSQL(sql);	}	dbExecCommand(sql, inspectorTriggerNewResponse);	return false;}

⌨️ 快捷键说明

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