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

📄 objects.js

📁 its a varypowrerfull javascript tool
💻 JS
📖 第 1 页 / 共 2 页
字号:
		remove_relation(list[i]);	}	var self = this;	var index = self.rows.find(row);	row.destroy(); 	self.rows.splice(index,1);	self.updateMini();	self.updateShadow();	self.updateWidth();	for (var i=0;i<self.rows.length;i++) {		self.rows[i].updateRelations();		self.rows[i].showRelations();	}	var last = -1;	if (this.rows.length && this.rows[this.rows.length-1] != row) { last = this.rows[this.rows.length-1]; }	if (last != -1) { this.selectRow(last); }	return (last == -1 ? false : last);}function Table_selectRow(row) {	if (this.selectedRow) {		this.selectedRow.deselect();	}	this.selectedRow = row;	this.selectedRow.select();}function Table_updateWidth() {	var index;	var orig = parseInt(this._div.style.width);	var max=this._title.innerHTML.length;	for (var i=0;i<this.rows.length;i++) {		if (this.rows[i]) {			if (this.rows[i]._title.innerHTML.length > max) {				max = this.rows[i]._title.innerHTML.length;			}		}	}	var new_ = Math.max(TABLE_WIDTH,80+max*LETTER_WIDTH);	this._div.style.width = new_ + "px";	if (new_ != orig) {		this.updateMini();		/* pokud jsme tabulce zmenili rozmery, musime aktualizovat relace */		for (var i=0;i<this.rows.length;i++) {			if (this.rows[i]) {				this.rows[i].updateRelations();			} /* if ziva relace */		} /* for vsechny relace */	} /* if hybli sme sirkou */}function Table_hideShadow() {	this.s1.className= "";	this.s2.className= "";	this.s3.className= "";}function Table_updateShadow() {	this.hideShadow();	this.s1.className= "shadow_right";	this.s2.className= "shadow_bottom";	this.s3.className = "shadow_corner";}function Table_setPK(index) {	this.rows[index].setPK();}function Table_losePK(index) {	this.rows[index].losePK();}function Table(x,y,title) {	var self=this;	this.base = abstractParent;	this.base("table");	this._div.style.width = TABLE_WIDTH + "px";	this.rows = Array();	this.selectRow = Table_selectRow;	this.moveTo = Table_moveTo;	this.addRow = Table_addRow;	this.removeRow = Table_removeRow;	this.updateWidth = Table_updateWidth;	this.updateMini = Table_updateMini;	this.updateShadow = Table_updateShadow;	this.hideShadow = Table_hideShadow;	this.setPK = Table_setPK;	this.losePK = Table_losePK;	this.markbox = OAT.Dom.create("input",{cssFloat:"left",styleFloat:"left"});	this.markbox.setAttribute("type","checkbox");	this._div.insertBefore(this.markbox,this._title);		this.setTitle(title);	this._title.className = "table_title";	this.selectedRow = null;	this._rows = OAT.Dom.create("div"); /* sem pujdou radky */	this._rows.className = "rows"		this._mini = OAT.Dom.create("div");	this._mini.className = "mini";		/* provazani do stromove struktury */	var map = $("map");	map.appendChild(this._mini);	this._div.appendChild(this._rows);		this.s1 = OAT.Dom.create("div");	this.s2 = OAT.Dom.create("div");	this.s3 = OAT.Dom.create("div");	this._div.appendChild(this.s1);	this._div.appendChild(this.s2);	this._div.appendChild(this.s3);	this.updateShadow();		this.moveTo(x,y);	this.updateWidth();		OAT.Drag.create(this._title,this._div);	var obj = this;	var ref1 = function() {		for (var i=0;i<obj.rows.length;i++) {			obj.rows[i].hideRelations();		}	} /* callback */	var ref2 = function() {		for (var i=0;i<obj.rows.length;i++) {			obj.rows[i].updateRelations();			obj.rows[i].showRelations();		}	} /* callback */	OAT.Dom.attach(this._title,"mousedown",ref1);	OAT.Dom.attach(this._title,"mouseup",ref2);		OAT.Dom.attach(this._div,"mousedown",function(){raise_table(self);});}/*	objekt TableAdmin:		cudliky na pridani a smazani tabulek, input na zmenu nazvu		changeName() - zmena nadpisu tabulky		manageTable, loseTable() - vybrani a odvybrani tabulky		addTable, delTable() - zruseni a vytvoreni tabulky	*/function TableAdmin_addTable() {	this.loseTable();	this._input.value = "[click anywhere to place table]";	document.body.style.cursor = "crosshair";	this.last_number++;	Locks.newTable = 1;	new_table_name = "table_"+this.last_number;}function TableAdmin_delTable() {	if (!this.table_ref) { return; }	var title = this.table_ref._title.innerHTML;	if (!confirm("Really delete table '"+title+"' ?")) { return; }	remove_table(this.table_ref);}function TableAdmin_changeName() {		this.table_ref.setTitle(this._input.value);	this.table_ref.updateWidth();}function TableAdmin_manageTable(table) {	this.table_ref = table;	this._input.removeAttribute("disabled");	this._input.value = table._title.innerHTML;}function TableAdmin_loseTable() {	this.table_ref = null;	this._input.setAttribute("disabled","true");	this._input.value = "[no table selected]";}function getLateFunc(obj, methodName) {	return (function() {			return obj[methodName](this);	});}function TableAdmin() {	this.manageTable = TableAdmin_manageTable;	this.loseTable = TableAdmin_loseTable;	this.changeName = TableAdmin_changeName;	this.addTable = TableAdmin_addTable;	this.delTable = TableAdmin_delTable;	this.last_number = 0; /* pro automaticke cislovani tabulek */	this.table_ref = null; /* odkaz na prave vybranou tabulku */	this._div = $("table_admin"); /* cela cast baru pro tabulky */	this._input = $("table_name");		OAT.Dom.attach("menu_tableadd","click",getLateFunc(this,"addTable"));	OAT.Dom.attach("menu_tabledel","click",getLateFunc(this,"delTable"));	OAT.Dom.attach(this._input,"keyup",getLateFunc(this,"changeName"));	OAT.Dom.attach("menu_align","click",reposition_tables);	OAT.Dom.attach("menu_clear","click",clear_tables);	this.loseTable();}/*	objekt RowAdmin:		cudliky na pridani a smazani radek, resp. budoucich sloupcu		changeName() - zmena nazvu		manageTable, loseTable() - vybrani a odvybrani tabulky		manageRow, loseRow() - vybrani a odvybrani radku		addRow, delRow() - zruseni a vytvoreni radku		upRow, downRow() - presun nahoru a dolu*/function RowAdmin_upRow() {	var div = this.row_ref._div;	var root = div.parentNode;	var prev = div.previousSibling;	if (prev) {		root.insertBefore(div,prev);		var index_upper = this.table_ref.rows.find(this.row_ref)-1;		var upperRow = this.table_ref.rows[index_upper];		this.table_ref.rows.splice(index_upper,1);		this.table_ref.rows.splice(index_upper+1,0,upperRow);		this.row_ref.updateRelations();		upperRow.updateRelations();	}}function RowAdmin_downRow() {	var div = this.row_ref._div;	var root = div.parentNode;	var next = div.nextSibling;	if (next) {		root.insertBefore(next,div);		var index = this.table_ref.rows.find(this.row_ref);		this.table_ref.rows.splice(index,1);		var lowerRow = this.table_ref.rows[index];		this.table_ref.rows.splice(index+1,0,this.row_ref);				this.row_ref.updateRelations();		lowerRow.updateRelations();	}}function RowAdmin_addRow() {	if (!this.table_ref) { return; }	var row = this.table_ref.addRow("row",SQL_DATA_TYPES[1].types[0].type);	row.setNN();	row.setSpec(32);	this.manageRow(row);	if (this.table_ref.selectedRow) {		this.table_ref.selectedRow.deselect();	}	this.table_ref.selectedRow = row;	row.select();}function RowAdmin_delRow() {	if (!this.row_ref) { return; }	var title = this.row_ref._title.innerHTML;	var title2 = this.table_ref._title.innerHTML;	if (!confirm("Really delete row '"+title+"' from table '"+title2+"' ?")) { return; }	var last_row = this.table_ref.removeRow(this.row_ref);	if (last_row) {		this.manageRow(last_row); 	} else {		this.loseRow();	}}function RowAdmin_changeName() {	this.row_ref.setTitle(this._input.value);	this.table_ref.updateWidth();	this.row_ref.updateTitle();}function RowAdmin_changeDef() {	this.row_ref.setDef(this._def.value);}function RowAdmin_changeSpec() {	this.row_ref.setSpec(this._spec.value);}function RowAdmin_manageTable(table) {	if (this.table_ref != table) {		/* pokud jsme vybrali nejakou, ktera predtim nebyla vybrana */		this.loseRow();		this.table_ref = table; /* reference na tabulku */		this._input.value = "[no row selected]";	}}function RowAdmin_loseTable(table) {	/* ztratili jsme tabulku */	this.loseRow();	this.table_ref = null;	this._input.value = "[no table selected]";}function RowAdmin_manageRow(row) {	/* nekdo klikl na radek */	var index = 0;	var total = 0;	for (var i=0;i<SQL_DATA_TYPES.length;i++) {		for (var j=0;j<SQL_DATA_TYPES[i].types.length;j++) {			if (row.type == SQL_DATA_TYPES[i].types[j].type) { index = total; }			total++;		}	}	this.row_ref = row;	this._input.removeAttribute("disabled");	this._pk.removeAttribute("disabled");	this._index.removeAttribute("disabled");	this._nn.removeAttribute("disabled");	this._def.removeAttribute("disabled");	this._type.removeAttribute("disabled");	this._input.value = row._title.innerHTML;	this._pk.checked = (row.pk ? true : false);	this._index.checked = (row.index ? true : false);	this._nn.checked = (row.nn ? true : false);	this._def.value = row.def;	this._type.selectedIndex = index;	this._spec.value = row.spec;	var type = get_data_type(row.type);	if (type.params != "") {		this._spec.removeAttribute("disabled");	} else {		this._spec.setAttribute("disabled","true");	}	if (row.pk) {		this._index.setAttribute("disabled","true");	}	}function RowAdmin_loseRow() {	this.row_ref = null;	this._input.setAttribute("disabled","true");	this._pk.setAttribute("disabled","true");	this._index.setAttribute("disabled","true");	this._nn.setAttribute("disabled","true");	this._def.setAttribute("disabled","true");	this._type.setAttribute("disabled","true");	this._spec.setAttribute("disabled","true");	this._input.value = "[no row selected]";}function RowAdmin_togglePK() {	/* primary key */	if (!this.row_ref) { return; }	var index = parseInt(this.row_ref._div.getAttribute("row_number"));	if (this._pk.checked) {		this.table_ref.setPK(index);		this._index.checked = true;		this._index.setAttribute("disabled","true");		} else {		this.table_ref.losePK(index);		this._index.removeAttribute("disabled");			this._index.checked = false;	}}function RowAdmin_changeType() {	/* zmena typu */	if (!this.row_ref) { return; }	this.row_ref.setType(this._type.selectedIndex);	this._def.value = this.row_ref.def;	var type = get_data_type(this.row_ref.type);	if (type.params != "") {		this._spec.removeAttribute("disabled");	} else {		this._spec.setAttribute("disabled","true");	}}function RowAdmin_changeIndex() {	/* zmena index on/off */	if (!this.row_ref) { return; }	if (this.row_ref.index) {		this.row_ref.loseIndex();	} else {		this.row_ref.setIndex();	}}function RowAdmin_changeNN() {	/* zmena index on/off */	if (!this.row_ref) { return; }	if (this.row_ref.nn) {		this.row_ref.loseNN();	} else {		this.row_ref.setNN();	}}function RowAdmin() {	var self = this;	this.manageRow = RowAdmin_manageRow;	this.loseRow = RowAdmin_loseRow;	this.changeName = RowAdmin_changeName;	this.changeSpec = RowAdmin_changeSpec;	this.changeDef = RowAdmin_changeDef;	this.addRow = RowAdmin_addRow;	this.delRow = RowAdmin_delRow;	this.upRow = RowAdmin_upRow;	this.downRow = RowAdmin_downRow;	this.manageTable = RowAdmin_manageTable;	this.loseTable = RowAdmin_loseTable;	this.togglePK = RowAdmin_togglePK;	this.changeType = RowAdmin_changeType;	this.changeIndex = RowAdmin_changeIndex;	this.changeNN = RowAdmin_changeNN;		this.last_number = 0; /* pro automaticke cislovani tabulek */	this.table_ref = null; /* odkaz na prave vybranou tabulku */	this.row_ref = null; /* odkaz na prave vybranou radku */	this._div = $("row_admin"); /* cela cast baru pro tabulky */	this._input = $("row_name");	this._pk = $("row_primary");	this._nn = $("row_notnull");	this._index = $("row_index");	this._def = $("row_default");	this._type = $("row_type");	this._spec = $("row_spec");		OAT.Dom.attach("menu_rowadd","click",getLateFunc(this,"addRow"));	OAT.Dom.attach("menu_rowdel","click",getLateFunc(this,"delRow"));	OAT.Dom.attach("menu_rowup","click",getLateFunc(this,"upRow"));	OAT.Dom.attach("menu_rowdown","click",getLateFunc(this,"downRow"));	OAT.Dom.attach(this._input,"keyup",getLateFunc(this,"changeName"));	OAT.Dom.attach(this._def,"keyup",getLateFunc(this,"changeDef"));	OAT.Dom.attach(this._spec,"keyup",getLateFunc(this,"changeSpec"));	OAT.Dom.attach(this._pk,"change",getLateFunc(this,"togglePK"));	OAT.Dom.attach(this._type,"change",getLateFunc(this,"changeType"));	OAT.Dom.attach(this._index,"click",getLateFunc(this,"changeIndex"));	OAT.Dom.attach(this._nn,"click",getLateFunc(this,"changeNN"));	this.loseRow();}function apply_xslt(data, xslt, callback) {	var xmlDoc = OAT.Xml.createXmlDoc(data);	var ref = function(text) {		var xslDoc = OAT.Xml.createXmlDoc(text);		var result = OAT.Xml.transformXSLT(xmlDoc,xslDoc);		result = result.documentElement.getElementsByTagName("body")[0].innerHTML;		callback(result);	}	function send() {return ""; }	OAT.Ajax.command(OAT.Ajax.GET,xslt,send,ref,OAT.Ajax.TYPE_TEXT,{});}function IOAdmin_save() {	if (IO.filename == "") {		dialogs.save.show();		return;	}		var send_ref = function() { return xml; }	var recv_ref = function(data) { alert('Saved.'); }	var callback = function() {		OAT.Ajax.command(OAT.Ajax.PUT + OAT.Ajax.AUTH_BASIC,IO.filename,send_ref,recv_ref,OAT.Ajax.TYPE_TEXT);	}	if (IO.savetype=="sql") {		var xml = export_xml("",false);		apply_xslt(xml,"zsql2sql.xsl",callback);	} else {		var xslStr = '<?xml-stylesheet type="text/xsl" href="'+$v("options_xslt")+'/designview.xsl"?>';		var xml = export_xml(xslStr,false,true);		callback();	}	}function IOAdmin_load() {	if ($("options_type_http").checked) {		var name = OAT.Dav_old.getFile("/DAV/home/"+OAT.Ajax.user,".xml");		if (!name) { return; }		IO.filename = name;		OAT.Ajax.command(OAT.Ajax.GET,name,function(){return '';},import_xml,OAT.Ajax.TYPE_TEXT);	}	if ($("options_type_dav").checked) {		var options = {			mode:'open_dialog',			user:$v("user"),			pass:$v("password"),			pathDefault:"/DAV/home/"+$v("user")+"/",			onOpenClick:function(path,fname,data){				IO.filename = path+fname;				return import_xml(data);			}		};		OAT.WebDav.open(options);	}}function IOAdmin() {	var self = this;	this.save = IOAdmin_save;	this.load = IOAdmin_load;	IO.filename = "";	IO.savetype = "";	OAT.Dom.attach("menu_markall","click",function(){for (var i=0;i<table_array.length;i++) if (table_array[i]) table_array[i].markbox.checked = true; });	OAT.Dom.attach("menu_marknone","click",function(){for (var i=0;i<table_array.length;i++) if (table_array[i]) table_array[i].markbox.checked = false; });	OAT.Dom.attach("menu_import","click",dialogs.xmla.show);	OAT.Dom.attach("menu_save","click",self.save);	OAT.Dom.attach("menu_saveas","click",dialogs.save.show);	OAT.Dom.attach("menu_load","click",self.load);	dialogs.save.ok = function() {		IO.filename = $v("save_name");		IO.savetype = $v("options_savetype");		dialogs.save.hide();		self.save();	}}

⌨️ 快捷键说明

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