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

📄 listpicker_xopus.js

📁 Hippo CMS是一个以信息为中心的开源内容管理系统。Hippo CMS目标是供中,大型企业来管理其发布在互连网
💻 JS
字号:
/*
* Copyright 2001-2007 Hippo (www.hippo.nl)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

//http://www.devx.com/getHelpOn/10MinuteSolution/16372/1954?pf=true

var dialogsize = {width:450, height:500 };
function passToXopus( ) {
	 var i=0;
	 var txt='';
	 var selectedList = document.getElementById('list');
	 for (i=0; i<selectedList.options.length; i++){	 	
	   if (selectedList.options[i].selected){
	    if(txt!='') txt+=',';
	    txt+=selectedList.options[i].text;
	   }
	 }
  window.top.choose(txt, txt, "");
  window.close();
}

function myEscape(str){
 var arr=str.match(",");
 if (arr!=null) str='"'+str+'"';
	return str;
}

function myUnescape(str){
//	if (str.indexOf('"')==1 && str.lastIndexOf('"')==str.length && str.length > 1) 
//	   str=str.substring(2,str.length-1);
 return str;	
}

function passSelectedItemsToXopus() {
	 var i=0;
	 var txt='';
	 var selectedList = document.getElementById('selectedlist');
	 for (i=0; i<selectedList.options.length; i++){	 	
	   txt+=myEscape(selectedList.options[i].text);	   
	   if (i!=selectedList.options.length-1) txt+=',';
	 }
  window.top.choose(txt, txt, "");
  window.close();
}

function passFirstTermToXopus(){
	if (document.forms['Form1']['list'].options.length!=0)
		passTermToXopus(document.forms['Form1']['list'].options[0].value);
}

function passTermToXopus(term) {
  window.top.choose(myEscape(term), myEscape(term), "");
  window.close();
}

function passSelectedToXopus(){
	 passTermToXopus(document.forms['Form1']['list'].value);
}

function initSelectedTerms(){
	 if (document.getElementById('selectedlist') != null){	 	
		 var terms=window.top.dialogArguments.value;
   var arr;
   var terms_arr=new Array();
		 var str=terms;
		 var i;
		 var temp;		 
		 
 	 while (str.length >0){
 	 	 if (str.indexOf('"') == 0){
 	 	 	 while(str.indexOf('"') == 0){ 
 	 	 	 	str=str.substring(1,str.length);
 	 	 	 	temp=str.substring(0,str.indexOf('"'));
 	 	 	  terms_arr[terms_arr.length]=temp;
 	 	 	  str=str.substring(temp.length,str.length);
 	 	 	 	str=str=str.substring(1,str.length); 	 	 	 		 	 	 	 	 	 	  
 	 	 	  if (str.indexOf(',')==0) str=str.substring(1,str.length);
 	 	 	 }
 	 	 } else {
	 			 	arr=str.split(/,/);
 	 			 for (i=0; i < arr.length; i++){
 	 			 	 if (arr[i].indexOf('"') == 0) 
 	 			 	   break; 
 	 			 	 else {
			   			  if (str.indexOf(',')>=0){
			   			  	 temp=str.substring(0,str.indexOf(','));
			   			  } else
			   			    temp=str;
			   			  terms_arr[terms_arr.length]=temp;
			 		   	 str=str.substring(temp.length,str.length); 
    		 			 if (str.indexOf(',')==0) str=str.substring(1,str.length);			 
 	 			 	 }
		 			 }
		 			 if (str.indexOf(',')==0) str=str.substring(1,str.length);			 
 	 	 } 	 	
		 }

	 	for (i=0; i<terms_arr.length;i++)
	 	   if (terms_arr[i] != '')
		    addItem(terms_arr[i]);
	 }
}

function init() { 
	 
 if (window.top!=null){
   window.top.dialogWidth=dialogsize.width+'px';
 	 window.top.dialogHeight=dialogsize.height+'px';
 	 var iframes=parent.document.getElementsByTagName('iframe');
 	 iframes[0].style.width="100%";
 	 iframes[0].style.height="100%";
 	 var mastertable=document.getElementById('master_table');
 	 //iframes[0].style.width=dialogsize.width+'px';
 	// iframes[0].style.height=dialogsize.height+'px';
 	 var mastertable=document.getElementById('master_table');
 	 var header=document.getElementById('header');
 	 header.style.height="20px";
 	 mastertable.style.height=iframes[0].clientHeight-header.offsetHeight-30+"px";
// 	 mastertable.style.height=parent.document.body.clientHeight-header.offsetHeight-3;
 	 mastertable.style.width='100%';
 }
	selectHeight = 10; 
	initSelectedTerms();
}

/* START Moving items in a selection list
			Ref: http://javascript.internet.com/forms/selection-order.html
 */
 
function move(index,to) {
var list = document.termsform.selectedlist;
var total = list.options.length-1;
if (index == -1) return false;
if (to == +1 && index == total) return false;
if (to == -1 && index == 0) return false;
var items = new Array;
var values = new Array;
for (i = total; i >= 0; i--) {
items[i] = list.options[i].text;
values[i] = list.options[i].value;
}
for (i = total; i >= 0; i--) {
if (index == i) {
list.options[i + to] = new Option(items[i],values[i], 0, 1);
list.options[i] = new Option(items[i + to], values[i + to]);
i--;
}
else {
list.options[i] = new Option(items[i], values[i]);
   }
}
list.focus();
}

/* END Moving items in a selection list */

function addItem(item){
/*
  Adds a thesaurus term to the selection list.
  useParentWindow => true: function is called from the iframe
																			  false: function is called from the same window as the term selection list
*/
 if (item != ''){
   selectedList = document.getElementById('selectedlist');
		 var numItems=selectedList.length;
		 var addOption = new Option(item,item); 
		 var found=false;
		 var i=0;
		 while((!found) && (i < numItems)){
		   if (selectedList.options[i].text==item) found=true;
		    i++;
		 }  
		 if (found==false)               
		    selectedList.options[numItems]=addOption;
  }
}


function getSelected(){
	addItem(document.forms['Form1']['list'].value);
 // document.getElementById('searchText').focus();
}

function selectFirst(){
document.forms['Form1']['list'].options[0].selected = true;
document.forms['Form1']['list'].focus();
}


function formatTextValue(text) {
   text = new String(text).replace(/&amp;/g,'&');
   text = new String(text).replace(/&gt;/g,'>');
   text = new String(text).replace(/&lt;/g,'<');
   return text
}


function narrowList(searchString){
 resultsFound = 0;
	searchString = searchString.toLowerCase();
	// if beneden zorgt ervoor dat niet hele select opnieuw wordt gevuld, dit veroorzaakt nl vertraging!


		var mHTML = '';
		found=false;
		
		var list=document.getElementById("list");
		list.innerHTML='';
		var addOption;
		for(i=0;i<items.length;i++) {
			zLink = items[i].toLowerCase();
			if( (zLink.indexOf(searchString) == 0 )) {
				found=true;
				resultsFound++;
		    if(ids[i]!='')
		    {
		      addOption = new Option(formatTextValue(items[i]),ids[i]);
		    }
		    else
		    {
		      addOption = new Option(formatTextValue(items[i]),formatTextValue(items[i]));
		    }		 
		 	list.options[list.options.length]=addOption;
		}
	} 
}

⌨️ 快捷键说明

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