📄 thesaurus.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
function passToXopus( ) {
var i=0;
var txt='';
var selectedList = document.termsform.termslist;
for (i=0; i<selectedList.options.length; i++){
txt+=selectedList.options.item(i).value;
if (i!=selectedList.options.length-1) txt+=',';
}
if (window.top.choose != null)
window.top.choose(txt, txt, "");
else
opener.document.getElementById('cms-keywords').value=txt;
window.close();
}
function passTermToXopus(term) {
window.top.choose(term, term, "");
window.close();
}
function passFirstTermToXopus(){
if (document.forms['Form1']['lists'].options.length!=0)
passTermToXopus(document.forms['Form1']['lists'].options[0].value);
}
function addTerm(useParentWindow,term){
/*
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
*/
var selectedList;
if (useParentWindow)
selectedList = parent.document.getElementById('termslist');
else
selectedList = document.getElementById('termslist');
var numItems=selectedList.length;
var addOption = new Option(term,term);
var found=false;
var i=0;
while((!found) && (i < numItems)){
if (selectedList.options[i].text==term) found=true;
i++;
}
if (found==false)
selectedList.options[numItems]=addOption;
}
function submitTerms(){
var selectedList = document.getElementById('termslist');
var i=0;
var targetURL="/editing/dialogs/thesaurus/result.html";
while (i<selectedList.length){
if (i==1)
targetURL=targetURL+'?';
else targetURL=targetURL+'&';
targetURL=targetURL+'term'+i+"="+selectedList.options[i].text;
i++;
}
window.location.href=targetURL;
}
/* START Moving items in a selection list
Ref: http://javascript.internet.com/forms/selection-order.html
FIX: not only the value but also the key is moved
*/
function move(index,to) {
var list = document.termsform.termslist;
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 */
/*
START Selection list narrowing as you type.
*/
var links = new Array();
var categories = new Array();
var searchFilter = "Any";
//var selectHeight;
var allHTML;
var MAXCRUMBS = 10;
var breadcrumbs = new Array();
var crumbIndex = 9;
var dialogsize = {width:800, height:600 };
var myHistory = new Array();
function initSelectedTerms(){
var termslist=parent.document.getElementById('termslist');
if (termslist != 'null'){
var terms=window.top.dialogArguments.value;
var terms_arr=terms.split(/\s*,\s*/);
for (i=0; i<terms_arr.length;i++)
if (terms_arr[i] != '')
addTerm(false,terms_arr[i]);
}
}
function initMyIframe(){
entry=listframe.window.location.href;
if (myHistory.length==0){
myHistory[0]=entry;
}
else
if (myHistory[myHistory.length-1].toLowerCase() != entry.toLowerCase())
myHistory[myHistory.length]=entry;
}
function goBack(){
if (myHistory.length > 1){
listframe.window.location.href=myHistory[myHistory.length-2];
myHistory.length-=1;
}
}
function init() {
var i;
for (i=0; i<MAXCRUMBS; i++) breadcrumbs[i]=null;
initSelectedTerms();
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-20;
// mastertable.style.height=parent.document.body.clientHeight-header.offsetHeight-3;
mastertable.style.width='100%';
myIframe=document.getElementById('listframe');
myIframe.style.height=parent.document.body.clientHeight-header.offsetHeight-25;
}
selectHeight = 10;
document.getElementById('Text1').focus();
}
function showCrumbs(){
var index=crumbIndex;
var txt = '';
var cnt=0;
while ( cnt<MAXCRUMBS ){
if (breadcrumbs[index] != null){
if (index!=crumbIndex) txt+=' › '
txt+=breadcrumbs[index];
}
cnt++;
index=(index+1)%MAXCRUMBS;
}
var div= document.getElementById('breadcrumb');
div.innerHTML=txt;
}
function addCrumb(term){
var index=-1;
var i;
for (i=0; i<MAXCRUMBS; i++) if (breadcrumbs[i]==term){ index=i; break; }
breadcrumbs[crumbIndex]=term;
if (index>-1 && index!=crumbIndex) breadcrumbs[index]=null;
showCrumbs();
crumbIndex>0 ? crumbIndex-- : crumbIndex=MAXCRUMBS-1;
}
function selectTerm(useParentWindow,term){
if (useParentWindow){
parent.document.getElementById('searchText').value=term;
parent.narrowList(term,useParentWindow);
} else {
document.getElementById('searchText').value=term;
narrowList(term,useParentWindow);
}
}
function selectFirst(){
document.forms['Form1']['lists'].options[0].selected = true;
showAssociatedTerms(document.forms['Form1']['lists'].options[0].value);
document.forms['Form1']['lists'].focus();
}
function getFirst(){
if (document.forms['Form1']['lists'].options.length!=0){
addTerm(false,document.forms['Form1']['lists'].options[0].value);
}
document.getElementById('Text1').focus();
}
function getSelected(){
addTerm(false,document.forms['Form1']['lists'].value);
// document.getElementById('searchText').focus();
}
function showAssociatedTerms(term){
listframe.window.location.href='associated-terms?term='+escape(term);
}
function drawSelect() {
mHTML = '';
for(i=0;i<links.length;i++) {
mHTML+="<option title=\"test\" value=\"" + links[i] + "\">" + links[i] + "</option>";
}
mHTML+="</select>";
document.getElementById("mContainer").innerHTML = mHTML;
}
function narrowList(searchString,useParentWindow) {
resultsFound = 0;
searchString = searchString.toLowerCase();
// if beneden zorgt ervoor dat niet hele select opnieuw wordt gevuld, dit veroorzaakt nl vertraging!
if (searchString.length != 0)
{
mHTML = '';
found=false;
list=document.getElementById("mContainer");
list.options.length=0;
var addOption;
for(i=0;i<links.length;i++) {
zLink = links[i].toLowerCase();
if( (zLink.indexOf(searchString) == 0 )) {
found=true;
resultsFound++;
addOption = new Option(links[i],links[i]);
list.options[list.options.length]=addOption;
// mHTML+="<option value=\"" + links[i] + "\">" + links[i] + "</option>";
}
}
//mHTML+="</select>";
//if(found)document.getElementById("mContainer").innerHTML = mHTML
}
}
/*
END Selection list narrowing as you type.
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -