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

📄 harvest-view.js.svn-base

📁 由国外的一个著名的geonetwork修改而来
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
//=====================================================================================//===//=== HarvestView//=== //=== Handles all view related stuff in the MVC pattern//===//=== Needs : geonetwork-ajax.js//===//=====================================================================================var SHOW = new Object();SHOW.LIST = new Object();SHOW.ADD  = new Object();SHOW.EDIT = new Object();//TODO: aggiustare il last run//TODO: aggiornamento entry nella list a seguito di start, stop, run//TODO: mostrare le info se ci sono errori nell'harvesting (colonna Errors nella lista)//TODO: mostrare info extra (discussione con Michelle A.) //=====================================================================================function HarvestView(xmlLoader){	this.rowTransf    = new XSLTransformer('harvesting/client-row-builder.xsl',    xmlLoader);	this.searchTransf = new XSLTransformer('harvesting/client-search-builder.xsl', xmlLoader);	this.privilTransf = new XSLTransformer('harvesting/client-privil-builder.xsl', xmlLoader);		this.panelSwitcher = new TabSwitcher(['listPanel',   'addPanel',   'editPanel'], 													 ['listButtons', 'addButtons', 'editButtons']);	this.editSwitcher = new TabSwitcher(['editPanelGN','editPanelWAF']);		//--- setup validators		this.gnValid  = new Validator(xmlLoader);	this.wafValid = new Validator(xmlLoader);}//=====================================================================================HarvestView.prototype.init = function(){	this.show(SHOW.LIST);		this.gnValid.add(	[		{ id:'gn.name',     type:'length',   minSize :1,  maxSize :200 },		{ id:'gn.host',     type:'length',   minSize :1,  maxSize :200 },		{ id:'gn.host',     type:'hostname' },		{ id:'gn.port',     type:'integer',  minValue:80, maxValue:65535, empty:true },		{ id:'gn.servlet',  type:'length',   minSize :1,  maxSize :200 },		{ id:'gn.servlet',  type:'alphanum' },		{ id:'gn.username', type:'length',   minSize :0,  maxSize :200 },		{ id:'gn.password', type:'length',   minSize :0,  maxSize :200 },				{ id:'gn.every.days',   type:'integer',  minValue:0, maxValue:99 },		{ id:'gn.every.hours',  type:'integer',  minValue:0, maxValue:23 },		{ id:'gn.every.mins',   type:'integer',  minValue:0, maxValue:59 }	]);		this.wafValid.add(	[		{ id:'waf.name',        type:'length',   minSize :1,  maxSize :200 },		{ id:'waf.url',         type:'length',   minSize :1,  maxSize :200 },		{ id:'waf.url',         type:'url' },		{ id:'waf.username',    type:'length',   minSize :0,  maxSize :200 },		{ id:'waf.password',    type:'length',   minSize :0,  maxSize :200 },		{ id:'waf.every.days',  type:'integer',  minValue:0, maxValue:99 },		{ id:'waf.every.hours', type:'integer',  minValue:0, maxValue:23 },		{ id:'waf.every.mins',  type:'integer',  minValue:0, maxValue:59 }	]);		this.gnShower  = new Shower('gn.useAccount',  'gn.account');		this.wafShower = new Shower('waf.useAccount', 'waf.account');}//=====================================================================================HarvestView.prototype.show = function(obj){	if (obj == SHOW.LIST)		this.panelSwitcher.show('listPanel', 'listButtons');			else if (obj == SHOW.ADD)		this.panelSwitcher.show('addPanel', 'addButtons');			else if (obj == SHOW.EDIT)		this.panelSwitcher.show('editPanel', 'editButtons');			else		throw 'Unknown object to show : '+ obj;		}//=====================================================================================	HarvestView.prototype.getEditType = function() { return $('edit.type').value; }HarvestView.prototype.isAdding    = function() { return $('edit.id').value == ''; }//=====================================================================================HarvestView.prototype.getHostData = function() {	var data = 	{		HOST :    $('gn.host')   .value,		PORT :    $('gn.port')   .value,		SERVLET : $('gn.servlet').value	};		return data;}//=====================================================================================//=== SiteId methods//=====================================================================================HarvestView.prototype.getSiteName = function() { 	var ctrl = $('gn.siteId');		if (ctrl.options.length == 0)		return null;			return ctrl.options[ctrl.selectedIndex].textContent;}//=====================================================================================HarvestView.prototype.getSiteId = function() { 	var ctrl = $('gn.siteId');		if (ctrl.options.length == 0)		return null;			return ctrl.options[ctrl.selectedIndex].value;}//=====================================================================================HarvestView.prototype.clearSiteId = function() { return $('gn.siteId').options.length = 0; }//=====================================================================================HarvestView.prototype.addSiteId = function(id, label){	var html='<option value="'+ id +'">'+ gn.escape(label) +'</option>';	new Insertion.Bottom('gn.siteId', html);}//=====================================================================================//=== Other methods//=====================================================================================/* Enters 'add' mode showing the GN or WAF editing panel and filling it with empty data */HarvestView.prototype.add = function(){	var type = $('add.type').value;		$('edit.id')  .value= "";	$('edit.type').value= type;		if (type == 'geonetwork')	{		this.setEmpty_GN();		this.editSwitcher.show('editPanelGN');	}	else if (type == 'webFolder')	{		this.setEmpty_WAF();		this.editSwitcher.show('editPanelWAF');	}	else		throw 'Unknown type : '+ type;		//--- show edit panel	this.show(SHOW.EDIT);}	//=====================================================================================HarvestView.prototype.append = function(xmlNode){	this.rowTransf.transform(xmlNode, this.appendCallBack);}//-------------------------------------------------------------------------------------HarvestView.prototype.appendCallBack = function(xml){	var html= gn.xmlToString(xml);		//--- add the new entry in list	new Insertion.Bottom('table', html);}//=====================================================================================/* Refreshes the content of an entry on the main list  */ HarvestView.prototype.refresh = function(xmlNode){	this.rowTransf.transform(xmlNode, this.refreshCallBack);}//-------------------------------------------------------------------------------------HarvestView.prototype.refreshCallBack = function(xml){	var id   = xml.getAttribute('id');	var html = gn.xmlToString(xml);		//--- now we have to remove the <tr> </tr> root text	var from = html.indexOf('>') +1;	var to   = html.indexOf('</tr>');		$(id).innerHTML = html.substring(from, to);	}//=====================================================================================/* Enters 'edit' mode showing the GN or WAF editing panel and filling it with given data */HarvestView.prototype.edit = function(xmlEntry){	var id   = xmlEntry.getAttribute('id');	var type = xmlEntry.getAttribute('type');		$('edit.id')  .value= id;	$('edit.type').value= type;		if (type == 'geonetwork')	{		this.setEdit_GN(xmlEntry);		this.editSwitcher.show('editPanelGN');	}	else if (type == 'webFolder')	{		this.setEdit_WAF(xmlEntry);		this.editSwitcher.show('editPanelWAF');	}	else		throw 'Unknown type : '+ type;		//--- show edit panel	this.show(SHOW.EDIT);}//=====================================================================================HarvestView.prototype.getIdList = function(){	var inputs = $('table').getElementsByTagName('input');	var idList = new Array();		for (var i=0; i<inputs.length; i++)		if (inputs[i].checked)			idList[idList.length] = inputs[i].name;		return idList;}//=====================================================================================HarvestView.prototype.remove = function(id){	Element.remove(id);}//=====================================================================================HarvestView.prototype.removeAll = function(){	gui.removeAllButFirst('table');	}//=====================================================================================HarvestView.prototype.isEditDataValid = function(){	var type = $('edit.type').value;		if (type == 'geonetwork')		return this.isValid_GN();		else if (type == 'webFolder')		return this.isValid_WAF();		throw 'Unknown type : '+ type;}//=====================================================================================HarvestView.prototype.getEditData = function(){	var type = $('edit.type').value;		if (type == 'geonetwork')		return this.getEdit_GN();		else if (type == 'webFolder')		return this.getEdit_WAF();		throw 'Unknown type : '+ type;}//=====================================================================================//=== Search methods//=====================================================================================HarvestView.prototype.addEmptySearch = function(siteName, siteId){	var doc  = Sarissa.getDomDocument();		var xmlSearch = doc.createElement('search');	var xmlName   = doc.createElement('siteName');	var xmlSiteId = doc.createElement('siteId');		doc .appendChild(xmlSearch);		xmlSearch.appendChild(xmlName);		xmlSearch.appendChild(xmlSiteId);		xmlName  .appendChild(doc.createTextNode(siteName));	xmlSiteId.appendChild(doc.createTextNode(siteId));		this.addSearch(xmlSearch);}//=====================================================================================HarvestView.prototype.addSearch = function(xmlSearch){	this.searchTransf.transform(xmlSearch, gn.wrap(this, this.addSearchCallBack));}//-------------------------------------------------------------------------------------HarvestView.prototype.addSearchCallBack = function(xml){	var html= gn.xmlToString(xml);		//--- add the new search in list	new Insertion.Bottom('gn.searches', html);		var siteId = xml.getAttribute('id');	 	this.gnValid.add(	[		{ id:'gn.text',     type:'length',   minSize :0,  maxSize :200 },		{ id:'gn.title',    type:'length',   minSize :0,  maxSize :200 },		{ id:'gn.abstract', type:'length',   minSize :0,  maxSize :200 },		{ id:'gn.keywords', type:'length',   minSize :0,  maxSize :200 }	], siteId);}//=====================================================================================HarvestView.prototype.removeSearch = function(siteId){	this.gnValid.removeByParent(siteId);	Element.remove(siteId);}//=====================================================================================HarvestView.prototype.removeAllSearch = function(){	$('gn.searches').innerHTML = '';	this.gnValid.removeByParent();	}//=====================================================================================//=== Groups methods //=====================================================================================HarvestView.prototype.clearGroups = function() { return $('waf.groups').options.length = 0; }//=====================================================================================HarvestView.prototype.addGroup = function(id, label){	var html='<option value="'+ id +'">'+ gn.escape(label) +'</option>';	new Insertion.Bottom('waf.groups', html);}//=====================================================================================HarvestView.prototype.getSelectedGroups = function() { 	var ctrl = $('waf.groups');		var result = [];		for (var i=0; i<ctrl.options.length; i++)		if (ctrl.options[i].selected)			result.push(ctrl.options[i]);				return result;}//=====================================================================================HarvestView.prototype.addEmptyGroupRows = function(groups){	for (var i=0; i<groups.length; i++)	{		var option = groups[i];		var doc    = Sarissa.getDomDocument();		var group  = doc.createElement('group');		var groupId= option.value;				group.setAttribute('id', groupId);			this.addGroupRow(group);	}}//=====================================================================================HarvestView.prototype.addGroupRow = function(xmlGroup){	//--- retrieve group's name from the list of loaded groups		var id   = xmlGroup.getAttribute('id');	var name = '???';

⌨️ 快捷键说明

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