File:
[LON-CAPA] /
rat /
client /
ratcode.js
Revision
1.13.10.2:
download - view:
text,
annotated -
select for diffs
Sun Dec 16 16:34:23 2012 UTC (11 years, 8 months ago) by
raeburn
Branches:
version_2_11_X
CVS tags:
version_2_11_5_msu,
version_2_11_5,
version_2_11_4_uiuc,
version_2_11_4_msu,
version_2_11_4,
version_2_11_3_uiuc,
version_2_11_3_msu,
version_2_11_3,
version_2_11_2_uiuc,
version_2_11_2_msu,
version_2_11_2_educog,
version_2_11_2,
version_2_11_1,
version_2_11_0_RC3,
version_2_11_0_RC2,
version_2_11_0_RC1,
version_2_11_0
Diff to branchpoint 1.13:
preferred,
unified
- For 2.11
- Reverse change in 1.13.10.1. Bookmarks not in use in 2.11
1: <!--
2: The LearningOnline Network
3: Resource Assembly Tool
4: // $Id: ratcode.js,v 1.13.10.2 2012/12/16 16:34:23 raeburn Exp $
5: //
6: // Copyright Michigan State University Board of Trustees
7: //
8: // This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: //
10: // LON-CAPA is free software; you can redistribute it and/or modify
11: // it under the terms of the GNU General Public License as published by
12: // the Free Software Foundation; either version 2 of the License, or
13: // (at your option) any later version.
14: //
15: // LON-CAPA is distributed in the hope that it will be useful,
16: // but WITHOUT ANY WARRANTY; without even the implied warranty of
17: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: // GNU General Public License for more details.
19: //
20: // You should have received a copy of the GNU General Public License
21: // along with LON-CAPA; if not, write to the Free Software
22: // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: //
24: // /home/httpd/html/adm/gpl.txt
25: //
26: // http://www.lon-capa.org/
27: //
28: YEAR 2000
29: 7/23,7/24,7/26,
30: 8/11,8/14,8/18,8/19,8/20,8/21,8/22,8/25,8/26,8/28,8/30,8/31,
31: 9/1,9/2,9/4,9/5,9/6,
32: 1/7,1/8,1/10,1/14,1/15,1/16,1/21,1/22,1/29,1/30,1/31,
33: 2/2,2/3,2/10,2/12,2/13,2/14,2/15,2/17,2/18,2/19,2/20,2/21,2/22,
34: 5/2,5/3,5/4,5/5,5/6,5/8,5/9,5/13,5/18,5/20,5/22,5/24,5/25,
35: 6/7,6/8,6/9,6/10,6/12,6/15,7/4,7/26,7/28,7/31,8/5,8/19,8/24,
36: YEAR 2001
37: 01/17/01,03/03,03/05 Gerd Kortemeyer
38: 04/20 Gerd Kortemeyer
39: 06/11,06/25,06/27,06/28,06/29,07/04 Gerd Kortemeyer
40: 03/01/02 Matthew Hall
41: -->
42:
43:
44: <script type="text/javascript" language="JavaScript">
45:
46: var row=new Array();
47: var maxrow=-1;
48: var col=new Array();
49: var maxcol=-1;
50:
51: var colmap=new Array();
52: var colmap2=new Array();
53: var colmap3=new Array();
54: var colmap4=new Array();
55: var colmap5=new Array();
56: var colmap6=new Array();
57: var obj=new Array();
58: var objcont=new Array();
59: var objparms=new Array();
60: var objlinks=new Array();
61: var rowcont=new Array();
62: var rowtype=new Array();
63: var coltype=new Array();
64: var rcol=new Array();
65: var rrow=new Array();
66: var cw=new Array();
67: var rh=new Array();
68:
69: var undostack=new Array();
70: var undopointer=0;
71: var stored=0;
72: var editmode=0;
73: var notclear=0;
74: var linkmode=0;
75: var lastinfo='';
76: var graphdef='no';
77: var mode='';
78: var mainrun=0;
79: var tablemode=0;
80: var mostrecent=0;
81: var zscale=3;
82:
83: var disrows=0;
84: var discols=0;
85:
86: var finishdone=0;
87: var tim=0;
88: var funny='|';
89: var reqaction='';
90: var canceltim;
91:
92: var expense=0;
93:
94: var data1=new Array(1024);
95: var data2=new Array(1024);
96: var data3=new Array(1024);
97: var data4=new Array(1024);
98: var data5=new Array(1024);
99: var data6=new Array(1024);
100:
101: var inf;
102: var srch;
103: var srchflag=-1; // 1 means currently open
104: // 0 means closed (but has been open)
105: // -1 means never yet opened/defined
106: var srchmode='';
107:
108: var idx;
109: var idxflag=-1; // 1 means currently open
110: // 0 means closed (but has been open)
111: // -1 means never yet opened/defined
112: var idxmode='';
113:
114: var copydx;
115: var copydxflag=-1; // 1 means currently open
116: // 0 means closed (but has been open)
117: // -1 means never yet opened/defined
118: var copydxmode='';
119:
120: var parm;
121: var parmflag=-1; // 1 means currently open
122: // 0 means closed (but has been open)
123: // -1 means never yet opened/defined
124:
125: var iconpath='/adm/lonIcons/';
126: var raticons='/adm/rat/';
127:
128: function testfunction() {
129: inf.document.forms.resinfo.elements.t.value="ABC";
130: }
131:
132: // ------------------------------------------------ Insert a row into the table
133: function insertrow(j,ex1,ex2) {
134: var kj;
135: stored=0;
136: expense++; expense++;
137: objects1='';
138: objects2='';
139: for (kj=0;kj<=maxrow;kj++) {
140: if ( row[kj]==j ) { objects1=rowcont[kj]; }
141: if ( row[kj]==j+1 ) { objects2=rowcont[kj]; }
142: if ( row[kj]>j ) { row[kj]++; }
143: }
144: maxrow++;
145: row[maxrow]=j+1;
146: rowcont[maxrow]=':';
147: colcover=':'+ex1+':'+ex2+':';
148: objects=objects1+':'+objects2;
149: data1=objects.split(':');
150: for (kj=0;kj<data1.length;kj++) {
151: if ((data1[kj]!='') && (typeof(data1[kj])!="undefined")) {
152: thisisobj=obj[data1[kj]];
153: thisobjtype=thisisobj.split('&')[0];
154: if (thisobjtype=='v') {
155: if (rowcont[maxrow].indexOf(':'+data1[kj]+':',0)==-1) {
156: thisobjcol=thisisobj.split('&')[1];
157: if (colcover.indexOf(':'+thisobjcol+':',0)==-1) {
158: colcover+=thisobjcol+':';
159: rowcont[maxrow]+=data1[kj]+':';
160: }
161: }
162: }
163: if (thisobjtype=='h') {
164: updown=thisisobj.split('&')[4];
165: leftupdown=updown.split(':')[0];
166: rightupdown=updown.split(':')[1];
167: thisobjdest=thisisobj.split('&')[3];
168: thisobjtofrom=thisisobj.split('&')[2];
169: thisobjfrom=thisobjtofrom.split(':')[0];
170: thisobjto=thisobjtofrom.split(':')[1];
171: thisobjdir=col[thisobjto]-col[thisobjfrom];
172: thisobjrow=row[thisisobj.split('&')[1]];
173: topbottom=thisobjrow-j-1;
174: newobj='';
175: if (leftupdown==-1) {
176: if (topbottom<0) {
177: if (thisobjdir<0) {
178: newobj='v&'+thisobjto+'&'+thisobjdest+'&-1';
179: } else {
180: newobj='v&'+thisobjfrom+'&'+thisobjdest+'&1';
181: }
182: }
183: } else {
184: if (topbottom>0) {
185: if (thisobjdir<0) {
186: newobj='v&'+thisobjto+'&'+thisobjdest+'&1';
187: } else {
188: newobj='v&'+thisobjfrom+'&'+thisobjdest+'&-1';
189: }
190: }
191: }
192: if ((newobj!='') && (typeof(newobj)!="undefined")) {
193: thisobjcol=newobj.split('&')[1];
194: if (colcover.indexOf(':'+thisobjcol+':',0)==-1) {
195: colcover+=thisobjcol+':';
196: rowcont[maxrow]+=obj.length+':';
197: obj[obj.length]=newobj;
198: }
199: }
200: newobj='';
201: if (rightupdown==-1) {
202: if (topbottom<0) {
203: if (thisobjdir<0) {
204: newobj='v&'+thisobjfrom+'&'+thisobjdest+'&1';
205: } else {
206: newobj='v&'+thisobjto+'&'+thisobjdest+'&-1';
207: }
208: }
209: } else {
210: if (topbottom>0) {
211: if (thisobjdir<0) {
212: newobj='v&'+thisobjfrom+'&'+thisobjdest+'&-1';
213: } else {
214: newobj='v&'+thisobjto+'&'+thisobjdest+'&1';
215: }
216: }
217: }
218: if ((newobj!='') && (typeof(newobj)!="undefined")) {
219: thisobjcol=newobj.split('&')[1];
220: if (colcover.indexOf(':'+thisobjcol+':',0)==-1) {
221: colcover+=thisobjcol+':';
222: rowcont[maxrow]+=obj.length+':';
223: obj[obj.length]=newobj;
224: }
225: }
226: }
227: }
228: }
229: if (rowcont[maxrow]!=':') {
230: rowcont[maxrow]=rowcont[maxrow].substring(1,rowcont[maxrow].length-1);
231: } else {
232: rowcont[maxrow]='';
233: }
234: }
235:
236: // --------------------------------------------- Creates a new condition object
237: function newcondition(content,type) {
238: var ko;
239: stored=0;
240: ko=obj.length;
241: obj[ko]='c';
242: objcont[ko]=content+':'+type+':cond';
243: return ko;
244: }
245:
246: // ---------------------------------------------- Creates a new resource object
247: function newresource(rid,cid,text,url,ext,type,oldidx) {
248: stored=0;
249: var newidx=addobj(rid,'b&'+rid+'&'+cid+':0:0:0',url,oldidx);
250:
251: objcont[newidx]=
252: text+':'+url+':'+ext+':'+type+':res';
253: return newidx;
254: }
255:
256:
257: // -------------------------------- Insert a condition into a port of an object
258: function insertcond(obj1,portnr,cond) {
259: var k;
260: stored=0;
261: data1=obj[obj1].split('&');
262: for (k=2;k<data1.length;k++) {
263: data2=data1[k].split(':');
264: if (data2[0]==portnr) {
265: data2[3]=cond;
266: data1[k]=data2.join(':');
267: }
268: }
269: obj[obj1]=data1.join('&');
270: }
271:
272: // --------------------------------------------- Insert a column into the table
273: // Inserts a new table column after table column j
274: function insertcol(j) {
275: var kj;
276: stored=0;
277: for (kj=0;kj<=maxcol;kj++) {
278: if ( col[kj]>j ) { col[kj]++; }
279: }
280: maxcol++;
281: expense++; expense++;
282: col[maxcol]=j+1;
283: }
284:
285: // --------------------------------------------------------------- Find the row
286: function findrow(jid) {
287: var j;
288: for (j=0;j<=maxrow;j++) { if (row[j]==jid) { return j; } }
289: return -1;
290: }
291:
292: // --------------------------------------------------------------- Find the col
293: function findcol(jid) {
294: var j;
295: for (j=0;j<=maxcol;j++) { if (col[j]==jid) { return j; } }
296: return -1;
297: }
298:
299: // -------------------------------------------------------------- Map out a row
300: //
301: // b&rowID&colID:inObj:outObj:outCond&...
302: // h&rowID&incolID:outcolID&inObj:outObj&inupdown:outupdown
303: // v&colID&inObj:outObj&updown
304: //
305: // returns middle (col number of middle of obj1)
306: // sets colmap (map of cols with object numbers)
307: function maprow (jid,obj1,ign) {
308: var j; var k; var left; var right; var middle;
309: middle=-1;
310: for (j=0;j<=maxcol;j++) { colmap[j]=0; }
311: if ((rowcont[jid]!='') && (typeof(rowcont[jid])!="undefined")) {
312: data2=rowcont[jid].split(':');
313: for (j=0;j<data2.length;j++) {
314: data3=obj[data2[j]].split('&');
315: if (data3[0]=='b') {
316: left=maxcol;
317: right=0;
318: for (k=2;k<data3.length;k++) {
319: thiscol=col[data3[k].split(':')[0]];
320: if (thiscol<left) { left=thiscol; }
321: if (thiscol>right) { right=thiscol; }
322: }
323: }
324: if (data3[0]=='h') {
325: data4=data3[2].split(':');
326: if (col[data4[1]]>col[data4[0]]) {
327: left=col[data4[0]];
328: right=col[data4[1]];
329: } else {
330: right=col[data4[0]];
331: left=col[data4[1]];
332: }
333: }
334: if (data3[0]=='v') { left=col[data3[1]]; right=left; }
335: if (data2[j]==obj1) { middle=Math.round((left+right)/2); }
336: if ((data3[0]!='h') || (ign!=1)) {
337: for (k=left;k<=right;k++) { colmap[k]=data2[j]; }
338: } else {
339: colmap[left]=data2[j];
340: colmap[right]=data2[j];
341: }
342: }
343: }
344: return middle;
345: }
346:
347: // --------------------------------------------------------- Find hole in a row
348: // jid: rowID
349: // kid: colID, find point close to this
350: // dkid: destination colID
351: // returns colID
352: function comingthru (jid,kid,dkid) {
353: var k;
354: maprow(jid,-1,1);
355: knum=col[kid];
356: if (colmap[knum]==0) { return kid; }
357: right=-1;
358: for (k=knum+1;(k<colmap.length) && (right==-1);k++) {
359: if ((right==-1) && (colmap[k]!=colmap[knum])) { right=k; }
360: }
361: left=-1;
362: for (k=knum-1;(k>=0) && (left==-1);k--) {
363: if ((left==-1) && (colmap[k]!=colmap[knum])) { left=k; }
364: }
365: kup=-1;
366:
367: if ((left==-1) && (right==-1)) { right=colmap.length; }
368:
369: dknum=col[dkid];
370: dleft=left-dknum;
371: dright=right-dknum;
372:
373: if (dleft<0) { dleft=-dleft; }
374: if (dright<0) { dright=-dright; }
375: if ((dright<=dleft) && (right!=-1)) { kup=right; }
376: if ((dright>=dleft) && (left!=-1)) { kup=left; }
377: if (colmap[kup]==0) { return findcol(kup); }
378:
379: if (kup==right) { kup--; }
380:
381: if (kup<0) {
382: insertcol(-1);
383: insertcol(0);
384: } else {
385: insertcol(kup);
386: }
387: return maxcol;
388: }
389:
390: // ----------------------------------------------------- Insert port into block
391: // obj1: object number
392: // d: direction from middle (>0: right, <0 left)
393: // inout: in or out port (1: in, 2: out)
394: // linkobj: object that the link goes to/comes from
395: // sets inrow or outrow
396: // return column
397: function insertport (obj1,d,inout,linkobj) {
398: var k; var port; var revport;
399: stored=0;
400: data1=obj[obj1].split('&');
401: middle=maprow(data1[1],obj1,0);
402: if (inout==1) {
403: inrow=data1[1];
404: } else {
405: outrow=data1[1];
406: }
407: if (d>0) {
408: for (k=middle;(colmap[k]==obj1) && (k<colmap.length);k++) { data3[k]=0; }
409: } else {
410: for (k=middle;(colmap[k]==obj1) && (k>=0);k--) { data3[k]=0; }
411: }
412: for (k=2;k<data1.length;k++) {
413: data2=data1[k].split(':');
414: data3[col[data2[0]]]=data2[inout];
415: }
416: port=-1;
417: if (d>0) {
418: for (k=middle;(colmap[k]==obj1) && (k<colmap.length);k++) {
419: if ((data3[k]==0) && (colmap[k]==obj1) && (port==-1)) { port=k; }
420: }
421: } else {
422: for (k=middle;(colmap[k]==obj1) && (k>=0);k--) {
423: if ((data3[k]==0) && (colmap[k]==obj1) && (port==-1)) { port=k; }
424: }
425: }
426: if (port==-1) {
427: if (colmap[k]==0) {
428: revport=findcol(k);
429: if (inout==1) {
430: data1[data1.length]=revport+":"+linkobj+":0:0";
431: } else {
432: data1[data1.length]=revport+":0:"+linkobj+":0";
433: }
434: } else {
435: if (d>0) {
436: insertcol(k-1);
437: } else {
438: insertcol(k);
439: }
440: revport=maxcol;
441: if (inout==1) {
442: data1[data1.length]=revport+":"+linkobj+":0:0";
443: } else {
444: data1[data1.length]=revport+":0:"+linkobj+":0";
445: }
446: }
447: } else {
448: portfound=-1;
449: for (k=2;k<data1.length;k++) {
450: data2=data1[k].split(':');
451: if (col[data2[0]]==port) {
452: data2[inout]=linkobj;
453: data1[k]=data2.join(':');
454: portfound=1;
455: }
456: }
457: revport=findcol(port);
458: if (portfound==-1) {
459: if (inout==1) {
460: data1[data1.length]=revport+":"+linkobj+":0:0";
461: } else {
462: data1[data1.length]=revport+":0:"+linkobj+":0";
463: }
464: }
465: }
466: obj[obj1]=data1.join('&');
467: return revport;
468: }
469:
470: // ---------------------------- Make a new object and add it to the row content
471: // returns object number of generated object
472: function addobj(kjid,objs,url,oldindex) {
473: stored=0;
474: expense++;
475: if ((rowcont[kjid]!='') && (typeof(rowcont[kjid])!="undefined")) {
476: rowcont[kjid]+=':';
477: }
478: var newindex=obj.length;
479: if ((url!='') && (typeof(url)!="undefined")) {
480: // see if we have a zombie with that url and possibly oldindex
481: for (oidx=0;oidx<objcont.length;oidx++) {
482: if (typeof(objcont[oidx])!="undefined") {
483: data6=objcont[oidx].split(':');
484: if (data6[4]=='zombie') {
485: if (data6[1]==url) {
486: if (typeof(oldindex) == "undefined") {
487: newindex=oidx;
488: } else {
489: if (oidx == oldindex) {
490: newindex=oidx;
491: }
492: }
493: }
494: }
495: }
496: }
497: }
498: rowcont[kjid]+=newindex;
499: obj[newindex]=objs;
500: return newindex;
501: }
502:
503: // ---------------------------------------- Make horizontal connection for hrid
504: // hoffs=-1: this line goes on top of hrid
505: function horizontal(hrid,hoffs,hfcol,htcol,hdest,hends) {
506: hcrid=-1;
507: if (hoffs==-1) {
508: hbrid=findrow(row[hrid]-1);
509: } else {
510: hbrid=findrow(row[hrid]+1);
511: }
512: if (hbrid!=-1) {
513: maprow(hbrid,-1,0);
514: hcrid=hbrid;
515: if (col[hfcol]>col[htcol]) { left=col[htcol]; right=col[hfcol]; }
516: else { right=col[htcol]; left=col[hfcol]; }
517: if (colmap[left]!=0) {
518: hcrid=-1;
519: } else {
520: if (colmap[right]!=0) {
521: hcrid=-1;
522: } else {
523: for (kh=left+1;kh<right;kh++) {
524: if (colmap[kh]!=0) {
525: if (obj[colmap[kh]].split('&')[0]!='v') { hcrid=-1; }
526: }
527: }
528: }
529: }
530: }
531: if (hcrid==-1) {
532: insertrow(row[hrid]+hoffs,hfcol,htcol);
533: addobj(maxrow,'h&'+maxrow+'&'+hfcol+':'+htcol+'&'+hdest+'&'+hends);
534: } else {
535: addobj(hcrid,'h&'+hcrid+'&'+hfcol+':'+htcol+'&'+hdest+'&'+hends);
536: }
537: }
538:
539: // --------------------------------------- Deletes all references to object obj
540: function delobj(obj1) {
541: var k;
542: stored=0;
543: for (k=0;k<rowcont.length;k++) {
544: data4=rowcont[k].split(':');
545: rowcont[k]='';
546: for (k2=0;k2<data4.length;k2++) {
547: if (data4[k2]!=obj1) {
548: if ((rowcont[k]!='') && (typeof(rowcont[k])!="undefined")) {
549: rowcont[k]+=':';
550: }
551: rowcont[k]+=data4[k2];
552: }
553: }
554: }
555: obj[obj1]='';
556: }
557:
558: // --------------------------------------------------------- Garbage collection
559: function cleanup () {
560: message("Garbage Collection");
561: var j,kj,i;
562: disrows=0;
563: discols=0;
564: var emptyspots=0;
565:
566: for (kj=0;kj<=maxcol;kj++) { data1[kj]=0; }
567: for (kj=0;kj<=maxrow;kj++) {
568: rowtype[kj]=0;
569: if ((rowcont[kj]!='') && (typeof(rowcont[kj])!="undefined")) {
570: data2=rowcont[kj].split(':');
571: for (j=0;j<data2.length;j++) {
572: if (obj[data2[j]].substring(0,2)=='e&') {
573: rowtype[kj]=2;
574: data1[(obj[data2[j]].split('&'))[1]]=2;
575: }
576: }
577: maprow(kj,-1,1);
578: for (j=0;j<=maxcol;j++) {
579: if (colmap[j]!=0) {
580: if (data1[j]==0) { data1[j]=1; }
581: if (rowtype[kj]==0) {
582: if (obj[colmap[j]].substring(0,2)!='v&') {
583: rowtype[kj]=1;
584: }
585: }
586: if (obj[colmap[j]].substring(0,2)=='b&') {
587: data1[j]=2;
588: if (colmap[maxcol]==0) { emptyspots++; }
589: rowtype[kj]=2;
590: }
591: }
592: }
593: }
594: }
595: for (j=0;j<=maxcol;j++) {
596: coltype[j]=data1[col[j]];
597: if (coltype[j]!=0) { discols+=1; }
598: }
599: for (j=0;j<=maxrow;j++) {
600: if (rowtype[j]==2) { disrows+=3; }
601: if (rowtype[j]==1) { disrows+=1; }
602: }
603: if (emptyspots==0) {
604: insertrow(maxrow);
605: insertcol(maxcol);
606: addobj(maxrow,'e&'+maxcol);
607: discols++;
608: disrows++;
609: rowtype[maxrow]=2;
610: coltype[maxcol]=2;
611: }
612: }
613:
614: // -------------------------------------------- Delete a condition from a block
615: function delcond(obj1,colid) {
616: var k;
617: stored=0;
618: data3=obj[obj1].split('&');
619: obj[obj1]=data3[0]+'&'+data3[1];
620: for (k=2;k<data3.length;k++) {
621: data4=data3[k].split(':');
622: if (data4[0]==colid) {
623: data4[3]=0;
624: objlinks[data4[2]]=(objlinks[data4[2]].split(':'))[0]+':'+
625: (objlinks[data4[2]].split(':'))[1]+':0';
626: }
627: if ((data4[1]!=0) || (data4[2]!=0) || (data3.length==3)) {
628: obj[obj1]+='&'+data4[0]+':'+data4[1]+':'+data4[2]+':'+data4[3];
629: }
630: }
631: }
632:
633: // ----------------------------------------- Creates a new condition in a block
634: function crecond(obj1,colid,condtext,condtype) {
635: var k;
636: data3=obj[obj1].split('&');
637: obj[obj1]=data3[0]+'&'+data3[1];
638: for (k=2;k<data3.length;k++) {
639: data4=data3[k].split(':');
640: if (data4[0]==colid) {
641: data4[3]=newcondition(condtext,condtype);
642: data2=objlinks[data4[2]].split(':');
643: objlinks[data4[2]]=data2[0]+':'+data2[1]+':'+data4[3];
644: }
645: if ((data4[1]!=0) || (data4[2]!=0) || (data3.length==3)) {
646: obj[obj1]+='&'+data4[0]+':'+data4[1]+':'+data4[2]+':'+data4[3];
647: }
648: }
649: }
650:
651: // ---------------------------------------- Delete the path between two objects
652: // deletes the link linknr
653: // h&rowID&incolID:outcolID&inObj:outObj&inupdown:outupdown
654: // v&colID&inObj:outObj&updown
655: function dellink (linknr) {
656: var k; var obj1; var obj2;
657: stored=0;
658: if ((objlinks[linknr]!='') && (typeof(objlinks[linknr])!="undefined")) {
659: data3=objlinks[linknr].split(':');
660: obj1=data3[0];
661: obj2=data3[1];
662: data3=obj[obj1].split('&');
663: obj[obj1]=data3[0]+'&'+data3[1];
664: for (k=2;k<data3.length;k++) {
665: data4=data3[k].split(':');
666: if (data4[2]==linknr) { data4[2]=0; data4[3]==0; }
667: if ((data4[1]!=0) || (data4[2]!=0) || (data3.length==3)) {
668: obj[obj1]+='&'+data4[0]+':'+data4[1]+':'+data4[2]+':'+data4[3];
669: }
670: }
671: data3=obj[obj2].split('&');
672: obj[obj2]=data3[0]+'&'+data3[1];
673: for (k=2;k<data3.length;k++) {
674: data4=data3[k].split(':');
675: if (data4[1]==linknr) { data4[1]=0; }
676: if ((data4[1]!=0) || (data4[2]!=0) || (data3.length==3)) {
677: obj[obj2]+='&'+data4[0]+':'+data4[1]+':'+data4[2]+':'+data4[3];
678: }
679: }
680: for (k=0;k<obj.length;k++) {
681: if ((obj[k]!='') && (typeof(obj[k])!="undefined")) {
682: data3=obj[k].split('&');
683: if (((data3[0]=='v') || (data3[0]=='h')) &&
684: (data3[data3.length-2]==linknr)) {
685: delobj(k);
686: }
687: }
688: }
689: objlinks[linknr]='';
690: }
691: }
692:
693: // ----------------------------------------------------------- Join two objects
694: // Links obj1 with obj2, creates new objlink, marks all elements with number
695: function joinres (obj1,obj2,cond) {
696: stored=0;
697: var minexpense;
698: var best;
699:
700: expense=0;
701: tryjoin(obj1,obj2,cond,1,1);
702: minexpense=expense;
703: best=0;
704: finishload();
705:
706: expense=0;
707: tryjoin(obj1,obj2,cond,1,-1);
708: if (expense<minexpense) {
709: best=1;
710: minexpense=expense;
711: }
712: finishload();
713:
714: expense=0;
715: tryjoin(obj1,obj2,cond,-1,1);
716: if (expense<minexpense) {
717: best=2;
718: minexpense=expense;
719: }
720: finishload();
721:
722: expense=0;
723: tryjoin(obj1,obj2,cond,-1,-1);
724: if (expense<minexpense) {
725: best=3;
726: minexpense=expense;
727: }
728:
729: if (best==0) {
730: finishload();
731: tryjoin(obj1,obj2,cond,1,1);
732: }
733: if (best==1) {
734: finishload();
735: tryjoin(obj1,obj2,cond,1,-1);
736: }
737: if (best==2) {
738: finishload();
739: tryjoin(obj1,obj2,cond,-1,1);
740: }
741: }
742:
743: function tryjoin(obj1,obj2,cond,d1,d2) {
744: var k; var kr; var outcol; var incol; var d; var dest;
745:
746: dest=objlinks.length;
747: objlinks[dest]=obj1+':'+obj2+':'+cond;
748:
749: outcol=insertport(obj1,d1,2,dest);
750: insertcond(obj1,outcol,cond);
751: incol=insertport(obj2,d2,1,dest);
752: if (row[inrow]==(row[outrow]+1)) {
753: insertrow(row[outrow],-1,-1);
754: }
755: if (row[inrow]<row[outrow]) {
756: updown=1;
757: tcol=comingthru(inrow,incol,outcol);
758: horizontal(inrow,-1,tcol,incol,dest,'-1:-1');
759: addobj(inrow,'v&'+tcol+'&'+dest+'&1');
760: incol=tcol;
761: tcol=comingthru(outrow,outcol,incol);
762: horizontal(outrow,0,outcol,tcol,dest,'1:1');
763: addobj(outrow,'v&'+tcol+'&'+dest+'&1');
764: outcol=tcol;
765: } else {
766: updown=-1;
767: }
768:
769: if (inrow==outrow) {
770: tcol=comingthru(inrow,incol,outcol);
771: horizontal(inrow,-1,tcol,incol,dest,'-1:-1');
772: addobj(inrow,'v&'+tcol+'&'+dest+'&1');
773: horizontal(outrow,0,outcol,tcol,dest,'1:1');
774: } else {
775:
776: if (updown==-1) {
777: for (kr=row[outrow]+1;kr<row[inrow];kr++) {
778: rid=findrow(kr);
779: ncol=comingthru(rid,outcol,incol);
780:
781: if (ncol!=outcol) {
782: insertrow(kr-1,outcol,ncol);
783: kr++;
784: if (col[outcol]>col[ncol]) {
785: addobj(maxrow,
786: 'h&'+maxrow+'&'+outcol+':'+ncol+'&'+dest+'&-1:1');
787: } else {
788: addobj(maxrow,
789: 'h&'+maxrow+'&'+outcol+':'+ncol+'&'+dest+'&1:-1');
790: }
791: }
792: addobj(rid,'v&'+ncol+'&'+dest+'&-1');
793: outcol=ncol;
794: }
795:
796: if (incol!=outcol) {
797: insertrow(row[inrow]-1,outcol,incol);
798: if (col[outcol]>col[incol]) {
799: addobj(maxrow,
800: 'h&'+maxrow+'&'+outcol+':'+incol+'&'+dest+'&-1:1');
801: } else {
802: addobj(maxrow,
803: 'h&'+maxrow+'&'+outcol+':'+incol+'&'+dest+'&1:-1');
804: }
805: }
806:
807: } else {
808: for (kr=row[outrow]-1;kr>row[inrow];kr--) {
809: rid=findrow(kr);
810: ncol=comingthru(rid,outcol,incol);
811: if (ncol!=outcol) {
812: insertrow(kr,outcol,ncol);
813: if (col[outcol]>col[ncol]) {
814: addobj(maxrow,
815: 'h&'+maxrow+'&'+outcol+':'+ncol+'&'+dest+'&1:-1');
816: } else {
817: addobj(maxrow,
818: 'h&'+maxrow+'&'+outcol+':'+ncol+'&'+dest+'&-1:1');
819: }
820: }
821: addobj(rid,'v&'+ncol+'&'+dest+'&1');
822: outcol=ncol;
823: }
824: if (incol!=outcol) {
825: insertrow(row[inrow],outcol,incol);
826: if (col[outcol]>col[incol]) {
827: addobj(maxrow,
828: 'h&'+maxrow+'&'+outcol+':'+incol+'&'+dest+'&1:-1');
829: } else {
830: addobj(maxrow,
831: 'h&'+maxrow+'&'+outcol+':'+incol+'&'+dest+'&-1:1');
832: }
833: }
834: }
835: }
836: }
837:
838: // ---------------------------------------------------------- Delete a resource
839: // Deletes resource obj1
840: // Reconnects resources going thru this one if recon=1
841: function delres (obj1,recon) {
842: var infromobj=new Array();
843: var inwithcon=new Array();
844: var inwithlink=new Array();
845: var outtoobj=new Array();
846: var outwithcon=new Array();
847: var outwithlink=new Array();
848: var inobjs=new Array();
849: var inobjscond=new Array();
850: var outobjs=new Array();
851: var outobjscond=new Array();
852:
853: var k; var k1; var k2; var found;
854:
855: stored=0;
856:
857: data1=obj[obj1].split('&');
858: for (k=2;k<data1.length;k++) {
859: data2=data1[k].split(':');
860: if (data2[1]!=0) {
861: k2=inwithlink.length;
862: inwithlink[k2]=data2[1];
863: data3=objlinks[data2[1]].split(':');
864: infromobj[k2]=data3[0];
865: inwithcon[k2]=data3[2];
866: }
867: if (data2[2]!=0) {
868: k2=outwithlink.length;
869: outwithlink[k2]=data2[2];
870: data3=objlinks[data2[2]].split(':');
871: outtoobj[k2]=data3[1];
872: outwithcon[k2]=data3[2];
873: }
874: }
875: for (k=0;k<inwithlink.length;k++) { dellink(inwithlink[k]); }
876: for (k=0;k<outwithlink.length;k++) { dellink(outwithlink[k]); }
877: delobj(obj1);
878: // turn into a zombie
879: data2=objcont[obj1].split(':');
880: data2[3]='zombie';
881: data2[4]='zombie';
882: objcont[obj1]=data2.join(':');
883: // reconnect
884: if (recon==1) {
885: message("Reconnecting");
886: for (k=0;k<inwithlink.length;k++) {
887: if (infromobj[k]!=obj1) {
888: found=0;
889: for (k2=0;k2<inobjs.length;k2++) {
890: if (inobjs[k2]==infromobj[k]) {
891: if (inwithcon[k]!=0) {
892: if ((inobjscond[k2]!='') &&
893: (typeof(inobjscond[k2])!="undefined")) {
894: inobjscond[k2]+='||';
895: }
896: inobjscond[k2]+=
897: '('+(objcont[inwithcon[k]].split(':'))[0]+')';
898: }
899: found=1;
900: }
901: }
902: if (found==0) {
903: k2=inobjs.length;
904: inobjs[k2]=infromobj[k];
905: if (inwithcon[k]==0) {
906: inobjscond[k2]='';
907: } else {
908: inobjscond[k2]=
909: '('+(objcont[inwithcon[k]].split(':'))[0]+')';
910: }
911: }
912: }
913: }
914:
915: for (k=0;k<outwithlink.length;k++) {
916: if (outtoobj[k]!=obj1) {
917: found=0;
918: for (k2=0;k2<outobjs.length;k2++) {
919: if (outobjs[k2]==outtoobj[k]) {
920: if (outwithcon[k]!=0) {
921: if ((outobjscond[k2]!='') &&
922: (typeof(outobjscond[k2])!="undefined")) {
923: outobjscond[k2]+='||';
924: }
925: outobjscond[k2]+=
926: '('+(objcont[outwithcon[k]].split(':'))[0]+')';
927: }
928: found=1;
929: }
930: }
931: if (found==0) {
932: k2=outobjs.length;
933: outobjs[k2]=outtoobj[k];
934: if (outwithcon[k]==0) {
935: outobjscond[k2]='';
936: } else {
937: outobjscond[k2]=
938: '('+(objcont[outwithcon[k]].split(':'))[0]+')';
939: }
940: }
941: }
942: }
943:
944: for (k=0;k<inobjs.length;k++) {
945: cond='';
946: if ((inobjscond[k]!='') && (typeof(inobjscond[k])!="undefined")) {
947: cond='('+inobjscond[k]+')';
948: }
949: for (k2=0;k2<outobjs.length;k2++) {
950: thiscond=cond;
951: if ((outobjscond[k2]!='') && (typeof(outobjscond[k2])!="undefined")) {
952: if ((thiscond!='') && (typeof(thiscond)!="undefined")) {
953: thiscond+='&&';
954: }
955: thiscond+='('+outobjscond[k2]+')';
956: }
957: condnr=0;
958: if ((thiscond!='') && (typeof(thiscond)!="undefined")) {
959: condnr=newcondition(thiscond,'normal');
960: }
961: save();
962: joinres(inobjs[k],outobjs[k2],condnr);
963: }
964: }
965: }
966: }
967:
968: // -------------------------------------------------------------- Draw an entry
969: function drawcell (rtype,ctype,what,cm,obj1,ej,ek,ne) {
970: var bgcolor;
971: var url='';
972: var urlparts=new Array;
973: var mime;
974: var ext;
975: var objref;
976: var objnum;
977:
978: if ((what=='') && (ne==0)) { cm="#DDDDDD"; }
979: if (ctype!=0) {
980: parent.mapout.document.write('<td bgcolor='+cm+' width='+cw[ctype]+'>');
981: if ((what!='') && (typeof(what)!="undefined")) {
982: if ((obj1!='') && (typeof(obj1)!="undefined")) {
983: objref="'"+obj1+"'";
984: parent.mapout.document.write
985: ('<a href="javascript:parent.code.handler('+objref
986: +');" onMouseOver="parent.code.info('+objref+');">');
987: }
988: if (what=='r:') {
989: mime='';
990: objnum=(obj1.split('&'))[1];
991: if (typeof(objcont[objnum])!="undefined") {
992: urlparts=objcont[objnum].split(':');
993: url=urlparts[1];
994: ext=urlparts[2];
995: urlparts=url.split('.');
996: mime=urlparts[urlparts.length-1];
997: if (typeof(mime)=="undefined") { mime=''; }
998: mime=mime.toLowerCase();
999: }
1000: parent.mapout.document.write
1001: ('<img border="0" width="'+cw[ctype]+'" height="'+rh[1]
1002: +'" src="'+raticons+'resource.gif" />');
1003: if (zscale==3) {
1004: if ((mime!='') && (ext!='true')) {
1005: parent.mapout.document.write
1006: ('<br /><img border="0" src="'+raticons+'left.gif" /></a><a target="preview" href="'+
1007: url+'.meta"><img border="0" width="20" src="'+iconpath+
1008: 'meta.gif" /><a target="preview" href="'+url+
1009: '"><img border="0" width="20" src="'+iconpath+mime+'.gif" />'+
1010: '<img border="0" src="'+raticons+'right.gif" />');
1011: } else {
1012: parent.mapout.document.write
1013: ('<br /><img border="0" src="'+raticons+'middle.gif" />');
1014: }
1015: parent.mapout.document.write
1016: ('<br /><img border="0" src="'+raticons+'bottom.gif" />');
1017: } else {
1018: parent.mapout.document.write
1019: ('<br /><img border="0" width="'+cw[ctype]+'" height="'+rh[1]
1020: +'" src="'+raticons+'bottom.gif" />');
1021: }
1022: } else {
1023: if (what=='c:') {
1024: parent.mapout.document.write
1025: ('<img border="0" width="'+cw[ctype]+'" height="'+rh[rtype]
1026: +'" src="'+raticons+'condition.gif" />');
1027: } else {
1028: if (what=='rs:') {
1029: mime='';
1030: objnum=(obj1.split('&'))[1];
1031: if (typeof(objcont[objnum])!="undefined") {
1032: urlparts=objcont[objnum].split(':');
1033: url=urlparts[1];
1034: ext=urlparts[2];
1035: urlparts=url.split('.');
1036: mime=urlparts[urlparts.length-1];
1037: if (typeof(mime)=="undefined") { mime=''; }
1038: mime=mime.toLowerCase();
1039: }
1040: parent.mapout.document.write
1041: ('<img border="0" width="'+cw[ctype]+'" height="'+rh[1]
1042: +'" src="'+raticons+'start.gif" />');
1043: if (zscale==3) {
1044: if ((mime!='') && (ext!='true')) {
1045: parent.mapout.document.write
1046: ('<br /><img border="0" src="'+raticons+'left.gif" /></a><a target="preview" href="'+
1047: url+'.meta"><img border="0" width="20" src="'+iconpath+
1048: 'meta.gif" /><a target="preview" href="'+url+
1049: '"><img border="0" width="20" src="'+iconpath+mime+'.gif" />'+
1050: '<img border="0" src="'+raticons+'right.gif" />');
1051: } else {
1052: parent.mapout.document.write
1053: ('<br /><img border="0" src="'+raticons+'middle.gif" />');
1054: }
1055: parent.mapout.document.write
1056: ('<br /><img border="0" src="'+raticons+'bottom.gif" />');
1057: } else {
1058: parent.mapout.document.write
1059: ('<br /><img border="0" width="'+cw[ctype]+'" height="'+rh[1]
1060: +'" src="'+raticons+'bottom.gif" />');
1061: }
1062:
1063: } else {
1064: if (what=='rf:') {
1065: mime='';
1066: objnum=(obj1.split('&'))[1];
1067: if (typeof(objcont[objnum])!="undefined") {
1068: urlparts=objcont[objnum].split(':');
1069: url=urlparts[1];
1070: ext=urlparts[2];
1071: urlparts=url.split('.');
1072: mime=urlparts[urlparts.length-1];
1073: if (typeof(mime)=="undefined") { mime=''; }
1074: mime=mime.toLowerCase();
1075: }
1076: parent.mapout.document.write
1077: ('<img border="0" width="'+cw[ctype]+'" height="'+rh[1]
1078: +'" src="'+raticons+'finish.gif" />');
1079: if (zscale==3) {
1080: if ((mime!='') && (ext!='true')) {
1081: parent.mapout.document.write
1082: ('<br /><img border="0" src="'+raticons+'left.gif" /></a><a target="preview" href="'+
1083: url+'.meta"><img border="0" width="20" src="'+iconpath+
1084: 'meta.gif" /><a target="preview" href="'+url+
1085: '"><img border="0" width="20" src="'+iconpath+mime+'.gif" />'+
1086: '<img border="0" src="'+raticons+'right.gif" />');
1087: } else {
1088: parent.mapout.document.write
1089: ('<br /><img border="0" src="'+raticons+'middle.gif" />');
1090: }
1091: parent.mapout.document.write
1092: ('<br /><img border="0" src="'+raticons+'bottom.gif" />');
1093: } else {
1094: parent.mapout.document.write
1095: ('<br /><img border="0" width="'+cw[ctype]+'" height="'+rh[1]
1096: +'" src="'+raticons+'bottom.gif" />');
1097: }
1098:
1099: } else {
1100: parent.mapout.document.write
1101: ('<img border="0" width="'+cw[ctype]+'" height="'+rh[rtype]
1102: +'" src="'+raticons+rtype+'.'+ctype+'.'+what+'.gif" />');
1103: }
1104: }
1105: }
1106: }
1107: if ((obj1!='') && (typeof(obj1)!="undefined")) {
1108: parent.mapout.document.write('</a>');
1109: }
1110: } else {
1111: if (ne!=1) {
1112: parent.mapout.document.write
1113: ('<a href="javascript:parent.code.empty('+ej+','+ek+');" ');
1114: } else {
1115: parent.mapout.document.write
1116: ('<a href="javascript:parent.code.infoclear();" ');
1117: }
1118: parent.mapout.document.write
1119: ('onMouseOver="parent.code.infoclear();">');
1120: parent.mapout.document.write
1121: (
1122: '<img border="0" width="'+cw[ctype]+'" height="'+rh[rtype]
1123: +'" src="'+raticons+rtype+'.'+ctype+'.empty.gif" /></a>');
1124: }
1125: parent.mapout.document.write('</td>');
1126: }
1127: }
1128:
1129: // --------------------------------------------------------- Color of resources
1130: function rescolor (ext,typ) {
1131: var rc; var gc; var bc;
1132: if (ext=='true') { bc='55'; } else { bc='99'; }
1133: if (typ=='mandatory') { rc='FF'; } else { rc='BB'; }
1134: if (typ=='optional') { gc='BB'; } else { gc='FF'; }
1135: if ((typ=='start') || (typ=='finish')) { rc='AA'; gc='AA'; bc='FF'; }
1136: return '#'+rc+gc+bc;
1137: }
1138:
1139: // -------------------------------------------------------- Color of conditions
1140: function condcolor(typ) {
1141: if (typ=='stop') { return '#EEAAAA'; }
1142: if (typ=='force') { return '#AAAAEE'; }
1143: return '#EEEEAA';
1144: }
1145:
1146: // ----------------------------------------------------------------- Draw a row
1147: function drawrow (jid) {
1148: var j; var jk; var k; var ck; var rtype;
1149: var objd1=new Array();
1150: var objd2=new Array();
1151: var notempty=new Array();
1152: var condtype;
1153: if (rowtype[jid]!=0) {
1154: for (j=0;j<=maxcol;j++) {
1155: colmap[j]=''; colmap2[j]=''; colmap3[j]=''; colmap4[j]='';
1156: colmap5[j]='#CCCCCC'; colmap6[j]='#CCCCCC';
1157: objd1[j]=''; objd2[j]=''; notempty[j]=0;
1158: }
1159:
1160: parent.mapout.document.writeln('<tr height='+rh[rowtype[jid]]+'>');
1161: if ((rowcont[jid]!='') && (typeof(rowcont[jid])!="undefined")) {
1162: data2=rowcont[jid].split(':');
1163: for (jk=0;jk<data2.length;jk++) {
1164: data3=obj[data2[jk]].split('&');
1165: if (data3[0]=='b') {
1166: data1=objcont[data2[jk]].split(':');
1167: rtype=data1[3];
1168: ck=rescolor(data1[2],data1[3]);
1169: left=maxcol;
1170: leftin=maxcol;
1171: leftout=maxcol;
1172: right=0;
1173: rightin=0;
1174: rightout=0;
1175: anyout=0;
1176: for (k=2;k<data3.length;k++) {
1177: data1=data3[k].split(':');
1178: thiscol=col[data1[0]];
1179: if (thiscol<left) { left=thiscol; }
1180: if (thiscol>right) { right=thiscol; }
1181: if (data1[1]!=0) {
1182: if (thiscol<leftin) { leftin=thiscol; }
1183: if (thiscol>rightin) { rightin=thiscol; }
1184: colmap4[thiscol]=data1[1];
1185: }
1186: if (data1[2]!=0) {
1187: if (thiscol<leftout) { anyout=1; leftout=thiscol; }
1188: if (thiscol>rightout) { anyout=1; rightout=thiscol; }
1189: if (data1[3]!=0) {
1190: colmap3[thiscol]='c:';
1191: condtype=(objcont[data1[3]].split(':'))[1];
1192: colmap6[thiscol]=condcolor(condtype);
1193: objd2[thiscol]='c&'
1194: +data1[0]+'&'+data2[jk]+'&'+data1[2]+'&'+data1[3];
1195: } else {
1196: colmap3[thiscol]='ctd';
1197: colmap6[thiscol]=ck;
1198: objd2[thiscol]='c&'
1199: +data1[0]+'&'+data2[jk]+'&'+data1[2]+'&-';
1200: }
1201: }
1202: }
1203: for (k=left;k<=right;k++) { notempty[k]=1; colmap5[k]=ck; }
1204: middle=Math.round((left+right)/2);
1205: if (rtype=='start') {
1206: colmap[middle]='rs:';
1207: } else {
1208: if (rtype=='finish') {
1209: colmap[middle]='rf:';
1210: } else {
1211: colmap[middle]='r:';
1212: }
1213: }
1214: objd1[middle]+='r&'+data2[jk];
1215:
1216: if (rightin>middle) {
1217: for (k=middle+1;k<rightin;k++) {
1218: if ((colmap4[k]!='') && (typeof(colmap4[k])!="undefined")) {
1219: colmap[k]='rlt';
1220: } else {
1221: colmap[k]='rl';
1222: }
1223: }
1224: colmap[rightin]='tl';
1225: }
1226: if (leftin<middle) {
1227: for (k=middle-1;k>leftin;k--) {
1228: if ((colmap4[k]!='') && (typeof(colmap4[k])!="undefined")) {
1229: colmap[k]='lrt';
1230: } else {
1231: colmap[k]='lr';
1232: }
1233: }
1234: colmap[leftin]='tr';
1235: }
1236:
1237: if ((leftout>middle) && (anyout)) {
1238: colmap2[middle]='tr';
1239: }
1240: if (leftout==middle) {
1241: if (rightout==middle) { colmap2[middle]='td'; }
1242: if (rightout>middle) { colmap2[middle]='rtd'; }
1243: }
1244: if (leftout<middle) {
1245: if (rightout<middle) { colmap2[middle]='tl'; }
1246: if (rightout==middle) { colmap2[middle]='tdl'; }
1247: if (rightout>middle) {
1248: if ((colmap3[middle]!='') && (typeof(colmap3[middle])!="undefined")) {
1249: colmap2[middle]='rtdl';
1250: } else {
1251: colmap2[middle]='rtl';
1252: }
1253: }
1254: }
1255: if (leftout<middle) {
1256: for (k=middle-1;k>leftout;k--) {
1257: if ((colmap3[k]!='') && (typeof(colmap3[k])!="undefined")) {
1258: colmap2[k]='rld';
1259: } else {
1260: colmap2[k]='rl';
1261: }
1262: }
1263: colmap2[leftout]='rd';
1264: }
1265: if (rightout>middle) {
1266: for (k=middle+1;k<rightout;k++) {
1267: if ((colmap3[k]!='') && (typeof(colmap3[k])!="undefined")) {
1268: colmap2[k]='lrd';
1269: } else {
1270: colmap2[k]='lr';
1271: }
1272: }
1273: colmap2[rightout]='ld';
1274: }
1275: }
1276: if (data3[0]=='h') {
1277: data4=data3[2].split(':');
1278: if (col[data4[1]]>col[data4[0]]) {
1279: left=col[data4[0]];
1280: right=col[data4[1]];
1281: thisarrow='lr';
1282: } else {
1283: right=col[data4[0]];
1284: left=col[data4[1]];
1285: thisarrow='rl';
1286: }
1287: if (data3[4].split(':')[0]==1) {
1288: colmap[left]='tr';
1289: } else {
1290: colmap[left]='rd'; colmap2[left]='utd'; colmap3[left]='utd';
1291: }
1292: notempty[left]=1;
1293: notempty[right]=1;
1294: for (k=left+1;k<right;k++) {
1295: notempty[k]=1;
1296: if (colmap[k]=='') {
1297: colmap[k]=thisarrow;
1298: objd1[k]=data2[jk];
1299: } else {
1300: colmap[k]='tdrl';
1301: objd1[k]='';
1302: }
1303: }
1304: if (data3[4].split(':')[1]==1) {
1305: colmap[right]='tl';
1306: } else {
1307: colmap[right]='ld'; colmap2[right]='utd'; colmap3[right]='utd';
1308: }
1309: objd1[left]=data2[jk];
1310: objd1[right]=data2[jk];
1311: }
1312: if (data3[0]=='v') {
1313: left=col[data3[1]];
1314: if (colmap[left]=='') {
1315: if (data3[3]==1) { colmap[left]='dt'; } else { colmap[left]='td'; }
1316: objd1[left]=data2[jk]+'&'+jid;
1317: objd2[left]=objd1[left];
1318: } else {
1319: colmap[left]='tdrl';
1320: objd1[left]='';
1321: }
1322: colmap2[left]='utd'; colmap3[left]='utd';
1323: }
1324: }
1325: rtype=rowtype[jid];
1326: for (k=0;k<=maxcol;k++) {
1327: drawcell(rtype,coltype[rcol[k]],colmap[k],colmap5[k],objd1[k],jid,k,
1328: notempty[k]);
1329: }
1330: if (rowtype[jid]==2) {
1331: parent.mapout.document.writeln('</tr>');
1332: parent.mapout.document.writeln('<tr height='+rh[1]+'>');
1333: for (k=0;k<=maxcol;k++) {
1334: drawcell(1,coltype[rcol[k]],colmap2[k],colmap5[k],objd2[k],jid,k,
1335: notempty[k]);
1336: }
1337: parent.mapout.document.writeln('</tr>');
1338: parent.mapout.document.writeln('<tr height='+rh[1]+'>');
1339: for (k=0;k<=maxcol;k++) {
1340: drawcell(1,coltype[rcol[k]],colmap3[k],colmap6[k],objd2[k],jid,k,
1341: notempty[k]);
1342: }
1343: }
1344: }
1345: parent.mapout.document.writeln('</tr>');
1346: }
1347: }
1348:
1349: // -------------------------------------------------------------- Print message
1350: function message(txt) {
1351: parent.window.status=txt;
1352: }
1353:
1354: // ------------------------------------------------------------- Draw the table
1355: function draw () {
1356: var k; var kr;
1357:
1358: cleanup();
1359: save();
1360:
1361: rh[0]=0;
1362: rh[1]=zscale*10;
1363: rh[2]=zscale*20;
1364: cw[0]=0;
1365: cw[1]=zscale*10;
1366: cw[2]=zscale*20;
1367:
1368: parent.mapout.document.open('text/html','replace');
1369: parent.mapout.document.writeln('<html><body bgcolor="#FFFFFF">');
1370:
1371: if (tablemode==0) {
1372: if (graphdef=='no') { graphopt(); cleanup(); }
1373: for (k=0;k<=maxrow;k++) { rrow[row[k]]=k; }
1374: for (k=0;k<=maxcol;k++) { rcol[col[k]]=k; }
1375: parent.mapout.document.writeln(
1376: '<table cellpadding="0" cellspacing="0" border="0" rows="'
1377: +disrows+'" cols="'+discols+'">');
1378: for (kr=0;kr<=maxrow;kr++) {
1379: message("Generating Output Row "+kr);
1380: drawrow(rrow[kr]);
1381: }
1382: } else {
1383: message("Generating Table Output");
1384: for (k=0;k<=maxrow;k++) { rrow[row[k]]=k; }
1385: for (k=0;k<=maxcol;k++) { rcol[col[k]]=k; }
1386:
1387: parent.mapout.document.writeln( '<table>');
1388: if (tablemode==1) {
1389: tabledraw();
1390: } else {
1391: simpletabledraw();
1392: }
1393: }
1394:
1395: parent.mapout.document.writeln('</table>');
1396: parent.mapout.document.writeln('</body></html>');
1397: parent.mapout.document.close();
1398: parent.focus();
1399: parent.mapout.focus();
1400: }
1401:
1402: // --------------------------------------------------------- Clears info window
1403: function infoclear() {
1404: if (notclear!=1) {
1405: infcheck();
1406: inf.document.open();
1407: inf.document.writeln
1408: ('<html><body bgcolor="#FFFFFF"><table><tr><td>'+
1409: '<img src="/adm/lonIcons/lonlogos.gif" /></td>');
1410: if (linkmode!=0) {
1411: if (tablemode==0) {
1412: inf.document.writeln(
1413: '<td><b>Link Mode</b><hr />Click on a resource to link it with<br /><b>'+
1414: (objcont[linkmode].split(':'))[0]+
1415: '</b><br />click anywhere else to cancel.</td>');
1416: } else {
1417: inf.document.writeln(
1418: '<td><b>Link Mode</b><hr />Click on a resource number to link it with<br /><b>'+
1419: (objcont[linkmode].split(':'))[0]+'</b><br />'+
1420: '<a href="javascript:opener.linkmode=0;opener.notclear=0;opener.infoclear();">'
1421: +'Cancel</a></td>');
1422: }
1423: } else {
1424: if (tablemode==0) {
1425: inf.document.writeln(
1426: '<td><b>Click to Edit</b><hr />Click in a light gray area<br />'
1427: +'to insert resources, columns and rows</td>'
1428: );
1429: }
1430: }
1431: inf.document.writeln('</tr></table></body></html>');
1432: inf.document.close();
1433: if (srchflag==1) {
1434: srchclose();
1435: }
1436: if (idxflag==1) {
1437: idxclose();
1438: }
1439: if (parmflag==1) {
1440: parmclose();
1441: }
1442: parent.top.focus();
1443: parent.mapout.focus();
1444: notclear=1;
1445: lastinfo='';
1446: }
1447: }
1448:
1449: // ------------------------------------------------------------ Open inf window
1450: function infopen() {
1451: var options="scrollbars=1,resizable=1,menubar=0,width=400,height=300";
1452: inf=open("","infout",options);
1453: }
1454:
1455: // -------------------------------------------------------- Do inf status check
1456: function infcheck() {
1457: if (inf.closed) {
1458: infopen();
1459: }
1460: }
1461:
1462: // --------------------------------------------------- Prints out resource info
1463: function info(infostr) {
1464: var mime='';
1465: var ext;
1466: var urlparts=new Array;
1467: var url='';
1468: if ((editmode!=1) && (infostr!=lastinfo)) {
1469: notclear=1;
1470: infcheck();
1471: inf.document.open();
1472: inf.document.writeln(
1473: '<html><body bgcolor="#FFFFFF">'+
1474: '<table><tr><td width="32"><img src="'+raticons+'info.gif" /></td><td bgcolor="#AAFFAA">');
1475: data1=infostr.split('&');
1476: if (data1[0]=='c') {
1477: inf.document.write('<b>Condition (');
1478: data3=objlinks[data1[3]].split(':');
1479: if (data1[4]=='-') {
1480: inf.document.write('not set');
1481: } else {
1482: data2=objcont[data1[4]].split(':');
1483: if (data2[1]=='force') {
1484: inf.document.write('Blocking Other Links');
1485: } else {
1486: if (data2[1]=='stop') {
1487: inf.document.write('Blocking This Link');
1488: } else {
1489: inf.document.write('Recommendation');
1490: }
1491: }
1492: }
1493: inf.document.writeln(')</b><hr />From <b>'+objcont[data3[0]].split(':')[0]+
1494: '</b><br />to <b>'+objcont[data3[1]].split(':')[0]+'</b>');
1495: } else {
1496: if (data1[0]=='r') {
1497: data2=objcont[data1[1]].split(':');
1498: url=data2[1];
1499: ext=data2[2];
1500: urlparts=url.split('.');
1501: mime=urlparts[urlparts.length-1];
1502: if (typeof(mime)=="undefined") { mime=''; }
1503: if (ext=='true') { mime=''; }
1504: if (mime!='') {
1505: inf.document.write
1506: ('<br /><a target="preview" align="right" href="'+url+
1507: '"><img border="0" width="20" src="'+iconpath+mime+'.gif" /></a> ');
1508: }
1509: inf.document.write('<b>');
1510: if (data2[2]=='true') { inf.document.write('External '); }
1511: if (data2[3]=='start') {
1512: inf.document.writeln('<b>Start</b>');
1513: } else {
1514: if (data2[3]=='finish') {
1515: inf.document.writeln('<b>Finish</b>');
1516: } else {
1517: inf.document.writeln('<b>Resource</b>');
1518: }
1519: }
1520: if (data2[3]=='mandatory') {
1521: inf.document.write(' (Mandatory)');
1522: }
1523: if (data2[3]=='optional') {
1524: inf.document.write(' (Optional)');
1525: }
1526: inf.document.writeln('</b><hr /><b>'+data2[0]+'</b><br />');
1527: inf.document.writeln((data2[1].split('/')).join(' / '));
1528: } else {
1529: inf.document.writeln('<b>Link</b><hr />');
1530: data2=obj[data1[0]].split('&');
1531: data3=objlinks[data2[data2.length-2]].split(':');
1532: inf.document.writeln('From <b>'+objcont[data3[0]].split(':')[0]+
1533: '</b><br />to <b>'+objcont[data3[1]].split(':')[0]+'</b>');
1534: }
1535: }
1536: if (linkmode==0) {
1537: inf.document.writeln('<p>(click to edit)');
1538: } else {
1539: if (data1[0]=='r') {
1540: inf.document.writeln('<p>(click to link)');
1541: } else {
1542: inf.document.writeln('<p>(click to cancel linking and edit)');
1543: }
1544: }
1545: inf.document.writeln('</td></tr></table></body></html>');
1546: inf.document.close();
1547: parent.top.focus();
1548: parent.mapout.focus();
1549: notclear=0;
1550: lastinfo=infostr;
1551: }
1552: }
1553:
1554: // ------------------------------------------------ "Escapes" out special chars
1555: function escape(instring) {
1556: var outstring='';
1557: var thischar;
1558: var k;
1559: for (k=0;k<instring.length;k++) {
1560: thischar=instring.charAt(k);
1561: if (thischar==':') { thischar=':'; }
1562: if (thischar=='"') { thischar='"'; }// "
1563: if (thischar=="'") { thischar='''; }
1564: if (thischar==',') { thischar=','; }
1565: outstring+=thischar;
1566: }
1567: return outstring;
1568: }
1569:
1570: // -------------------------------------------------- Insert resource into link
1571: function insertreslink(infostr) {
1572: var lnr;
1573: var fobj;
1574: var tobj;
1575: var nobj;
1576: var cobj;
1577: var cid;
1578: var rid;
1579: data1=infostr.split('&');
1580: data2=obj[data1[0]].split('&');
1581: lnr=data2[data2.length-2];
1582: data3=objlinks[lnr].split(':');
1583: fobj=data3[0];
1584: tobj=data3[1];
1585: cobj=data3[2];
1586: if (data2[0]=='v') {
1587: rid=data1[1];
1588: cid=data2[1];
1589: } else {
1590: rid=data2[1];
1591: cid=(data2[2].split(':'))[0];
1592: }
1593: dellink(lnr);
1594: newresource(rid,cid,'','','false','normal');
1595: nobj=obj.length-1;
1596: save();
1597: joinres(fobj,nobj,cobj);
1598: save();
1599: joinres(nobj,tobj,0);
1600: }
1601:
1602: // -------------------------------------------- Insert resource after condition
1603: function insertcondlink(cid,lnr) {
1604: var fobj;
1605: var tobj;
1606: var nobj;
1607: var cobj;
1608: data3=objlinks[lnr].split(':');
1609: fobj=data3[0];
1610: tobj=data3[1];
1611: cobj=data3[2];
1612: rid=(obj[fobj].split('&'))[1];
1613: insertrow(row[rid]);
1614: dellink(lnr);
1615: newresource(maxrow,cid,'','','false','normal');
1616: nobj=obj.length-1;
1617: save();
1618: joinres(fobj,nobj,cobj);
1619: save();
1620: joinres(nobj,tobj,0);
1621: }
1622:
1623: // ------------------------------------------------------ Clears indexer window
1624: function idxclear() {
1625: idx.document.open();
1626: idx.document.close();
1627: }
1628:
1629: // --------------------------------------------------------- Clears copy window
1630: function copydxclear() {
1631: copydx.document.open();
1632: copydx.document.close();
1633: }
1634: // ------------------------------------------------------- Clears search window
1635: function srchclear() {
1636: srch.document.open();
1637: srch.document.close();
1638: }
1639:
1640: // --------------------------------------------------------- Clears parm window
1641: function parmclear() {
1642: parm.document.open();
1643: parm.document.close();
1644: }
1645:
1646: // ------------------------------------------------------ Closes indexer window
1647: function idxclose() {
1648: if (idx && !idx.closed) {
1649: idxflag=0;
1650: idx.close();
1651: }
1652: }
1653:
1654: // --------------------------------------------------------- Closes copy window
1655: function copydxclose() {
1656: if (copydx && !copydx.closed) {
1657: copydxflag=0;
1658: copydx.close();
1659: }
1660: }
1661:
1662: // ------------------------------------------------------- Closes search window
1663: function srchclose() {
1664: if (srch && !srch.closed) {
1665: srchflag=0;
1666: srch.close();
1667: }
1668: }
1669:
1670: // ------------------------------------------------------- Closes search window
1671: function parmclose() {
1672: if (parm && !parm.closed) {
1673: parmflag=0;
1674: parm.close();
1675: }
1676: }
1677:
1678: // -------------------------------------------------------- Open indexer window
1679: function idxopen(mode) {
1680: var options="scrollbars=1,resizable=1,menubar=0";
1681: idxmode=mode;
1682: idxflag=1;
1683: idx=open("/res/?launch=1&mode=rat&catalogmode="+mode,"idxout",options);
1684: idx.focus();
1685: }
1686: // -------------------------------------------------------- Open zombie window
1687: function groupopen(url) {
1688: var options="scrollbars=1,resizable=1,menubar=0";
1689: idxmode=mode;
1690: idxflag=1;
1691: idx=open("/adm/groupsort?inhibitmenu=yes&mode=rat&recover=1&readfile="+url,"idxout",options);
1692: idx.focus();
1693: }
1694: // ------------------------------------------------- Open browser to select map
1695: var editbrowser;
1696: function openbrowser(formname,elementname,only,omit) {
1697: var url = '/res/?';
1698: if (editbrowser == null) {
1699: url += 'launch=1&';
1700: }
1701: url += 'catalogmode=interactive&';
1702: url += 'mode=edit&';
1703: url += 'form=' + formname + '&';
1704: if (only != null) {
1705: url += 'only=' + only + '&';
1706: }
1707: if (omit != null) {
1708: url += 'omit=' + omit + '&';
1709: }
1710: url += 'element=' + elementname + '';
1711: var title = 'Browser';
1712: var options = 'scrollbars=1,resizable=1,menubar=0';
1713: options += ',width=700,height=600';
1714: editbrowser = copydx.open(url,title,options,'1');
1715: editbrowser.focus();
1716: }
1717: // ----------------------------------------------------------- Open copy window
1718: function copydxopen(mode) {
1719: var options="scrollbars=1,resizable=1,menubar=0";
1720: copydxmode=mode;
1721: copydxflag=1;
1722: copydx=open("",'copydxout',options);
1723: copydx.document.open('');
1724: copydx.document.writeln(
1725: '<html><body bgcolor="#FFFFFF"><h1>Copy from Map</h1>'+
1726: '<form name="mapload"><input type="text" size="40" name="importmap">'+
1727: '<input type="button" onClick="javascript:opener.openbrowser'+
1728: "('mapload','importmap','sequence,page','')"+
1729: '" value="Browse"><input type="button" value="Load Map" '+
1730: 'onClick="window.location=document.mapload.importmap.value+'+
1731: "'?launch=1&forceselect=1'"+'"></form>');
1732:
1733: copydx.document.writeln('</body></html>');
1734: copydx.focus();
1735: }
1736:
1737: // --------------------------------------------------------- Open search window
1738: function srchopen(mode) {
1739: var options="scrollbars=1,resizable=1,menubar=0";
1740: srchmode=mode;
1741: srchflag=1;
1742: srch=open("/adm/searchcat?launch=1&mode=rat&catalogmode="+mode,"srchout",options);
1743: srch.focus();
1744: }
1745:
1746: // -------------------------------------------- Interface function to searching
1747: function search() {
1748: alert("Searching not yet implemented");
1749: }
1750:
1751: // ------------------------------------------------------- Do srch status check
1752: function srchcheck(mode) {
1753: if (!srch || srch.closed || srchmode!=mode) {
1754: srchopen(mode);
1755: }
1756: srch.focus();
1757: }
1758:
1759: // -------------------------------------------------------- Do idx status check
1760: function idxcheck(mode) {
1761: if (!idx || idx.closed || idxmode!=mode) {
1762: idxopen(mode);
1763: }
1764: idx.focus();
1765: }
1766:
1767: // -------------------------------------------------------- Do idx status check
1768: function copydxcheck(mode) {
1769: if (!copydx || copydx.closed || copydxmode!=mode) {
1770: copydxopen(mode);
1771: }
1772: copydx.focus();
1773: }
1774:
1775: // ---------------------------------------------------- Handles "click to edit"
1776: function handler(infostr) {
1777: var k;
1778: editmode=1;
1779: notclear=1;
1780: infcheck();
1781: inf.document.open();
1782: inf.document.writeln(
1783: '<html><body bgcolor="#FFFFFF">'+
1784: '<table><tr><td width="32"><img src="'+raticons+'edit.gif" /></td><td bgcolor="#AAFFAA">');
1785: data1=infostr.split('&');
1786: if (data1[0]=='c') {
1787: inf.document.writeln('<b>Condition</b><hr />');
1788: linkmode=0;
1789: if (data1[4]=='-') {
1790: data2[0]=''; data2[1]='normal';
1791: } else {
1792: data2=objcont[data1[4]].split(':');
1793: }
1794: inf.document.writeln(
1795: '<form name="condinfo"><textarea name="c" cols="30" rows="3">'
1796: +data2[0]+'</textarea><br /><input type="radio" name="s" value="normal" '+
1797: 'onClick="self.document.forms.condinfo.elements.h.value='+"'normal'"+'"');
1798: if (data2[1]=='normal') { inf.document.write(' checked'); }
1799: inf.document.write(
1800: '> Recommendation if true<br /><input type="radio" name="s" value="stop" '+
1801: 'onClick="self.document.forms.condinfo.elements.h.value='+"'stop'"+'"');
1802: if (data2[1]=='stop') { inf.document.write(' checked'); }
1803: inf.document.write(
1804: '> Blocking this link if false<br /><input type="radio" name="s" value="force" '+
1805: 'onClick="self.document.forms.condinfo.elements.h.value='+"'force'"+'"');
1806: if (data2[1]=='force') { inf.document.write(' checked'); }
1807: inf.document.write(
1808: '> Blocking other links if true<br /><a href="javascript:opener.editmode=0;'
1809: +'opener.notclear=0;');
1810: if (data1[4]=='-') {
1811: inf.document.write('opener.crecond('+data1[2]+','+data1[1]+','
1812: +'opener.escape(self.document.forms.condinfo.elements.c.value),'
1813: +'self.document.forms.condinfo.elements.h.value);');
1814: } else {
1815: inf.document.write('opener.objcont['+data1[4]+']='
1816: +'opener.escape(self.document.forms.condinfo.elements.c.value)+'+"':'"
1817: +'+self.document.forms.condinfo.elements.h.value+'+"':cond';");
1818: }
1819: inf.document.writeln(
1820: 'opener.infoclear();opener.editmode=0;opener.draw('
1821: +');"><b>Save Changes</b></a> '
1822: +' <a href="javascript:self.document.forms.condinfo.reset()">Reset</a><br />'
1823: +'<input type="hidden" name="h" value="'+data2[1]+'">');
1824:
1825: inf.document.writeln(
1826: '<a href="javascript:opener.notclear=0;opener.infoclear();'
1827: +'opener.delcond('+data1[2]+','+data1[1]+');opener.editmode=0;opener.draw('
1828: +');">Delete Condition</a><br />');
1829: inf.document.writeln(
1830: '<a href="javascript:opener.notclear=0;opener.infoclear();'
1831: +'opener.dellink('+data1[3]+');opener.editmode=0;opener.draw('
1832: +');">Delete Link</a>');
1833:
1834: inf.document.writeln('<br /><a href="javascript:'+
1835: 'opener.insertcondlink('+data1[1]+','+data1[3]+');'+
1836: 'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1837: +');">Insert Resource Into Link</a>');
1838: } else {
1839: if (data1[0]=='r') {
1840: if (linkmode!=0) {
1841: joinres(linkmode,data1[1],0);
1842: editmode=0;
1843: notclear=0;
1844: linkmode=0;
1845: inf.document.writeln('<b>Linked Resources</b>');
1846: draw();
1847: } else {
1848: data2=objcont[data1[1]].split(':');
1849: if (data2[3]=='start') {
1850: inf.document.writeln('<b>Start</b>');
1851: } else {
1852: if (data2[3]=='finish') {
1853: inf.document.writeln('<b>Finish</b>');
1854: } else {
1855: inf.document.writeln('<b>Resource</b>');
1856: }
1857: }
1858: inf.document.write(
1859: '<form name="resinfo"><table><tr><td>Title:</td><td colspan="2">'
1860: +'<input type="text" name="t" size="30" value="'
1861: +escape(data2[0])+'"><input type="hidden" name="h" value='+data2[3]+'></td></tr>');
1862: inf.document.write('<tr><td>URL:</td><td colspan="2">'
1863: +'<input type="text" name="u" size="30" value="'+data2[1]+'"></td></tr>'
1864: +'<tr><td>External:</td><td><input type="checkbox" name="e"');
1865: if (data2[2]=='true') { inf.document.write(' checked="checked"'); }
1866: inf.document.write('></td><td align="right">'
1867: +'<a href="javascript:opener.idxcheck(\'interactive\')">Browse</a> '
1868: +'<a href="javascript:opener'
1869: +'.srchcheck(\'interactive\')">Search</a></td></tr>');
1870: if ((data2[3]!='start') && (data2[3]!='finish')) {
1871: inf.document.write('<tr><td colspan="3">'
1872: +'<input type="radio" name="y" value="normal" '+
1873: 'onClick="self.document.forms.resinfo.elements.h.value='+"'normal'"+'"');
1874: if (data2[3]=='normal') { inf.document.write(' checked="checked"'); }
1875: inf.document.write(
1876: '> Regular <input type="radio" name="y" value="mandatory" '+
1877: 'onClick="self.document.forms.resinfo.elements.h.value='+"'mandatory'"+'"');
1878: if (data2[3]=='mandatory') { inf.document.write(' checked="checked"'); }
1879: inf.document.write(
1880: '> Mandatory <input type="radio" name="y" value="optional" '+
1881: 'onClick="self.document.forms.resinfo.elements.h.value='+"'optional'"+'"');
1882: if (data2[3]=='optional') { inf.document.write(' checked="checked"'); }
1883: inf.document.write('> Optional</td></tr>');
1884: }
1885: inf.document.writeln(
1886: '<tr><td colspan="3"><a href="javascript:opener.editmode=0;'
1887: +'opener.notclear=0;opener.objcont['+data1[1]
1888: +']=opener.escape(self.document.forms.resinfo.elements.t.value)+'+"':'"
1889: +'+opener.escape(self.document.forms.resinfo.elements.u.value)+'+"':'"
1890: +'+self.document.forms.resinfo.elements.e.checked+'+"':'"
1891: +'+self.document.forms.resinfo.elements.h.value+'+"':res'"
1892: +';opener.infoclear();opener.editmode=0;opener.draw();">'
1893: +'<b>Save Changes</b></a> '
1894: +' <a href="javascript:self.document.forms.resinfo.reset()">Reset</a>'
1895: +'</td></tr></table>');
1896: if ((data2[3]!='start') && (data2[3]!='finish')) {
1897: inf.document.writeln(
1898: '<a href="javascript:opener.notclear=0;opener.infoclear();'
1899: +'opener.delres('+data1[1]+',0);opener.editmode=0;opener.draw('
1900: +');">Delete Resource (cutting links)</a>');
1901: inf.document.writeln(
1902: '<br /><a href="javascript:opener.notclear=0;opener.infoclear();'
1903: +'opener.delres('+data1[1]+',1);opener.editmode=0;opener.draw('
1904: +');">Delete Resource (preserving links)</a>');
1905: }
1906: if (data2[3]!='finish') {
1907: inf.document.writeln(
1908: '<br /><a href="javascript:opener.editmode=0;opener.notclear=0;'
1909: +'opener.linkmode='+data1[1]+';'
1910: +'opener.infoclear();">Link Resource</a>');
1911: }
1912: inf.document.writeln(
1913: '<br /><a href="javascript:'
1914: +'opener.setparms('+data1[1]+');'
1915: +'opener.infoclear();">Set Parameters</a>');
1916:
1917: }
1918: } else {
1919: linkmode=0;
1920: inf.document.writeln('<b>Link</b><hr /><form>');
1921: data2=obj[data1[0]].split('&');
1922: k=data2[data2.length-2];
1923: data3=objlinks[k].split(':');
1924: inf.document.writeln('From <b>'+objcont[data3[0]].split(':')[0]+
1925: '</b><br />to <b>'+objcont[data3[1]].split(':')[0]+'</b>');
1926: inf.document.writeln('<br /><a href="javascript:opener.dellink('+
1927: k+');opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1928: +');">Delete Link</a>');
1929: inf.document.writeln('<br /><a href="javascript:'+
1930: "opener.insertreslink('"+infostr+"');"+
1931: 'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1932: +');">Insert Resource Into Link</a>');
1933: }
1934: }
1935: inf.document.writeln(
1936: '<br /><a href="javascript:opener.editmode=0;opener.notclear=0;'
1937: +'opener.infoclear();">Cancel</a>');
1938: inf.document.writeln('</form></td></tr></table></body></html>');
1939: inf.document.close();
1940: inf.focus();
1941: }
1942:
1943: // ----------------------------------------------------- Clicks on empty fields
1944: function empty(rid,k) {
1945: var cid=findcol(k);
1946: var lcol=k-1;
1947: trow=row[rid];
1948: lrow=trow-1;
1949: editmode=1;
1950: notclear=1;
1951: linkmode=0;
1952: infcheck();
1953: inf.document.open();
1954: inf.document.writeln(
1955: '<html><body bgcolor="#FFFFFF">'+
1956: '<table><tr><td width="32"><img src="'+raticons+'edit.gif" /></td><td bgcolor="#AAFFAA">'+
1957: '<b>Empty Field</b><hr />');
1958:
1959: inf.document.writeln('<br /><a href="javascript:opener.newresource('+
1960: rid+','+cid+",'','','false','normal');"+
1961: 'opener.mostrecent=opener.obj.length-1;'+
1962: 'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1963: +');">Insert resource</a>');
1964:
1965: if ((mostrecent!=0) && (objcont[mostrecent]!='') &&
1966: (typeof(objcont[mostrecent])!="undefined")) {
1967:
1968: inf.document.writeln('<br /><a href="javascript:opener.newresource('+
1969: rid+','+cid+",'','','false','normal');"+
1970: 'opener.mostrecent=opener.obj.length-1;'+
1971: 'opener.joinres('+mostrecent+',opener.obj.length-1,0);'+
1972: 'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1973: +');">Insert resource linked to from most recent one</a>');
1974:
1975: inf.document.writeln('<br /><a href="javascript:opener.newresource('+
1976: rid+','+cid+",'','','false','normal');"+
1977: 'opener.mostrecent=opener.obj.length-1;'+
1978: 'opener.joinres(opener.obj.length-1,'+mostrecent+',0);'+
1979: 'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1980: +');">Insert resource linking to most recent one</a>');
1981: }
1982:
1983:
1984: inf.document.writeln('<hr />Insert column:');
1985: inf.document.writeln('<a href="javascript:opener.insertcol('+
1986: lcol+');opener.addobj('+rid+",'e&'+opener.maxcol);"
1987: +'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1988: +');">left</a>');
1989: inf.document.writeln('<a href="javascript:opener.insertcol('+
1990: k+');opener.addobj('+rid+",'e&'+opener.maxcol);"
1991: +'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1992: +');">right</a> ');
1993: inf.document.writeln('<br />Insert row:');
1994: inf.document.writeln('<a href="javascript:opener.insertrow('+
1995: trow+');opener.addobj(opener.maxrow'+",'e&"+cid+"');"
1996: +'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1997: +');">below</a>');
1998: inf.document.writeln('<a href="javascript:opener.insertrow('+
1999: lrow+');opener.addobj(opener.maxrow'+",'e&"+cid+"');"
2000: +'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
2001: +');">above</a> ');
2002:
2003:
2004: inf.document.writeln(
2005: '<br /><a href="javascript:opener.editmode=0;opener.notclear=0;'
2006: +'opener.infoclear();">Cancel</a>');
2007: inf.document.writeln('</td></tr></table></body></html>');
2008: inf.document.close();
2009: inf.focus();
2010: }
2011:
2012: // ---------------------------------------------------- Save into hidden fields
2013: function save() {
2014: var k;
2015: if (graphdef=='yes') {
2016: parent.server.document.forms.storage.output.value='graphdef<:>yes';
2017: for (k=1;k<obj.length;k++) {
2018: parent.server.document.forms.storage.output.value+=
2019: '<&>obj<:>'+k+'<:>'+obj[k];
2020: }
2021: for (k=0;k<row.length;k++) {
2022: parent.server.document.forms.storage.output.value+=
2023: '<&>row<:>'+k+'<:>'+row[k];
2024: }
2025: for (k=0;k<col.length;k++) {
2026: parent.server.document.forms.storage.output.value+=
2027: '<&>col<:>'+k+'<:>'+col[k];
2028: }
2029: for (k=0;k<rowcont.length;k++) {
2030: if (rowcont[k]) {
2031: parent.server.document.forms.storage.output.value+=
2032: '<&>rowcont<:>'+k+'<:>'+rowcont[k];
2033: }
2034: }
2035: parent.server.document.forms.storage.output.value+=
2036: '<&>maxcol<:>'+maxcol;
2037: parent.server.document.forms.storage.output.value+=
2038: '<&>maxrow<:>'+maxrow;
2039: parent.server.document.forms.storage.output.value+=
2040: '<&>zscale<:>'+zscale;
2041: } else {
2042: parent.server.document.forms.storage.output.value='graphdef<:>no';
2043: }
2044: parent.server.document.forms.storage.output.value+=
2045: '<&>tablemode<:>'+tablemode;
2046:
2047: for (k=0;k<objparms.length;k++) {
2048: if (objparms[k]) {
2049: parent.server.document.forms.storage.output.value+=
2050: '<&>objparms<:>'+k+'<:>'+objparms[k];
2051: }
2052: }
2053: for (k=0;k<objcont.length;k++) {
2054: if (objcont[k]) {
2055: parent.server.document.forms.storage.output.value+=
2056: '<&>objcont<:>'+k+'<:>'+objcont[k];
2057: }
2058: }
2059: for (k=0;k<objlinks.length;k++) {
2060: if (objlinks[k]) {
2061: parent.server.document.forms.storage.output.value+=
2062: '<&>objlinks<:>'+k+'<:>'+objlinks[k];
2063: }
2064: }
2065: undopointer++;
2066: undostack[undopointer]=
2067: parent.server.document.forms.storage.output.value;
2068: }
2069:
2070: // ----------------------------------------------- Reset all layout information
2071: function graphreset() {
2072:
2073: var k;
2074:
2075: for (k=0;k<obj.length;k++) { obj[k]=''; }
2076: obj.length=0;
2077: obj[0]='';
2078:
2079: rowcont.length=0;
2080: rowcont[0]='';
2081:
2082: row.length=0;
2083: row[0]=0;
2084: maxrow=0;
2085:
2086: col.length=0;
2087: colmap.length=0;
2088: maxcol=-1;
2089: insertcol(-1);
2090:
2091: objcont[0]='';
2092: objlinks[0]='';
2093:
2094: graphdef='no';
2095:
2096: }
2097:
2098: // --------------------- Compare two resources with each other for "straighten"
2099: function rescompare(a,b) {
2100: data1=a.split(':');
2101: data2=b.split(':');
2102: var rvalue=0;
2103: var k;
2104: for (k=1;k<data1.length;k++) {
2105: if (data1[k]==data2[0]) { rvalue--; }
2106: }
2107: for (k=1;k<data2.length;k++) {
2108: if (data2[k]==data1[0]) { rvalue++; }
2109: }
2110: if (rvalue==0) { rvalue=data2.length-data1.length; }
2111: return rvalue;
2112: }
2113:
2114: // -------------------------------------------- Draw the table instead of graph
2115: function tabledraw() {
2116: var objsorted=new Array();
2117: var robjs=new Array();
2118: var iobjs=new Array();
2119: var k;
2120: var i;
2121: var j;
2122: var nr;
2123: var ck;
2124: var cck;
2125: var condid;
2126: var url='';
2127: var mime='';
2128: var ext='';
2129: var urlparts=new Array;
2130: var sortstr=sortobjs();
2131: insrestab(1,-1,-1,'');
2132: if ((sortstr!='') && (typeof(sortstr)!="undefined")) {
2133: objsorted=sortstr.split('&');
2134: for (k=0;k<objsorted.length;k++) {
2135: i=(objsorted[k].split(':'))[0];
2136: iobjs[k]=i;
2137: robjs[i]=k;
2138: }
2139: for (k=0;k<iobjs.length;k++) {
2140: i=iobjs[k];
2141: if (k<objsorted.length-1) {
2142: nr=iobjs[k+1];
2143: } else {
2144: nr=-1;
2145: }
2146: data1=objcont[i].split(':');
2147: ck=rescolor(data1[2],data1[3]);
2148: parent.mapout.document.write('<tr><td bgcolor="'+ck+'">');
2149: url=data1[1];
2150: ext=data1[2];
2151: urlparts=url.split('.');
2152: mime=urlparts[urlparts.length-1];
2153: if (typeof(mime)=="undefined") { mime=''; }
2154: if ((mime!='') && (ext!='true')) {
2155: parent.mapout.document.write
2156: ('<a target="preview" align="right" href="'+url+'.meta'+
2157: '"><img width="20" src="'+iconpath+'meta.gif" /></a><p>'+
2158: '<a target="preview" align="right"href="'+url+
2159: '"><img width="20" src="'+iconpath+mime+'.gif" /></a><p>');
2160: }
2161: parent.mapout.document.write(
2162: '<b><a href="javascript:if (parent.code.linkmode!=0) { '
2163: +'parent.code.joinres(parent.code.linkmode,'+i+',0);'
2164: +'parent.code.linkmode=0;parent.code.editmode=0;'
2165: +'parent.code.notclear=0;parent.code.infoclear();'
2166: +'parent.code.draw(); }">'+k+'</a></b></td><td bgcolor="'+ck
2167: +'"><form name="r'+i+'" method="post">');
2168: data2=obj[i].split('&');
2169: parent.mapout.document.write('<table bgcolor="#CCCCCC">');
2170:
2171: if (data1[3]=='start') {
2172: parent.mapout.document.writeln('<tr><td><b>Start</b></td></tr>');
2173: }
2174: if (data1[3]=='finish') {
2175: parent.mapout.document.writeln('<tr><td><b>Finish</b></td></tr>');
2176: }
2177: parent.mapout.document.write(
2178: '<tr><td>Title:</td><td><input type="text" name="t" size="50" value="'
2179: +data1[0]+'"><input type="hidden" name="h" value="'+data1[3]
2180: +'"></td></tr>');
2181: parent.mapout.document.write(
2182: '<tr><td>URL:</td><td><input type="text" name="u" size="50" value="'
2183: +data1[1]+'"></td></tr>'
2184: +'<tr><td>External:</td><td><input type="checkbox" name="e"');
2185: if (data1[2]=='true') { parent.mapout.document.write(' checked="checked"'); }
2186: parent.mapout.document.write('></td></tr>');
2187: if ((data1[3]!='start') && (data1[3]!='finish')) {
2188: parent.mapout.document.write(
2189: '<tr><td colspan="2"><input type="radio" name="y" value="normal" '+
2190: 'onClick="parent.mapout.document.forms.r'+i+'.elements.h.value='+
2191: "'normal'"+'"');
2192: if (data1[3]=='normal') { parent.mapout.document.write(' checked="checked"'); }
2193: parent.mapout.document.write(
2194: '> Regular <input type="radio" name="y" value="mandatory" '+
2195: 'onClick="parent.mapout.document.forms.r'+i+'.elements.h.value='+
2196: "'mandatory'"+'"');
2197: if (data1[3]=='mandatory') { parent.mapout.document.write(' checked="checked"'); }
2198: parent.mapout.document.write(
2199: '> Mandatory <input type="radio" name="y" value="optional" '+
2200: 'onClick="parent.mapout.document.forms.r'+i+'.elements.h.value='+
2201: "'optional'"+'"');
2202: if (data1[3]=='optional') { parent.mapout.document.write(' checked="checked"'); }
2203: parent.mapout.document.write('> Optional</td></tr>');
2204: }
2205: parent.mapout.document.write(
2206: '<tr><td colspan="2"><a href="javascript:parent.code.objcont['+i
2207: +']=parent.code.escape(parent.mapout.document.forms.r'+i
2208: +'.elements.t.value)+'+"':'"
2209: +'+parent.code.escape(parent.mapout.document.forms.r'+i
2210: +'.elements.u.value)+'+"':'"
2211: +'+parent.mapout.document.forms.r'+i+'.elements.e.checked+'+"':'"
2212: +'+parent.mapout.document.forms.r'+i+'.elements.h.value+'+"':res'"
2213: +';parent.code.draw();">'
2214: +'<b>Save Changes</b></a> '
2215: +' <a href="javascript:parent.mapout.document.forms.r'+i
2216: +'.reset()">Reset</a></td></tr><tr><td colspan="2">');
2217: if ((data1[3]!='start') && (data1[3]!='finish')) {
2218: parent.mapout.document.writeln(
2219: '<a href="javascript:parent.code.notclear=0;parent.code.infoclear();'
2220: +'parent.code.delres('+i+',0);parent.code.editmode=0;parent.code.draw();">'
2221: +'Delete Resource (cutting links)</a><br />'
2222: +'<a href="javascript:parent.code.notclear=0;parent.code.infoclear();'
2223: +'parent.code.delres('+i+',1);parent.code.editmode=0;parent.code.draw();">'
2224: +'Delete Resource (preserving links)</a><br />');
2225: }
2226: if (data1[3]!='finish') {
2227: parent.mapout.document.writeln(
2228: '<a href="javascript:parent.code.linkmode='+i+
2229: ';parent.code.notclear=0;parent.code.infoclear();">'+
2230: 'Link resource</a>');
2231: }
2232: parent.mapout.document.writeln(
2233: '<br /><a href="javascript:'
2234: +'parent.code.setparms('+i+');">Set Parameters</a>');
2235:
2236: parent.mapout.document.writeln('</td></tr>');
2237: parent.mapout.document.writeln('<tr><td colspan="2"><table><tr>');
2238: for (j=2;j<data2.length;j++) {
2239: data4=data2[j].split(':');
2240: data3=objlinks[data4[2]].split(':');
2241: if (data3.length>1) {
2242: if (data3[1]==nr) {
2243: cck='#AAAAAA';
2244: if (data3[2]!=0) {
2245: cck=condcolor((objcont[data3[2]].split(':'))[1]);
2246: condid=data3[2];
2247: } else {
2248: condid='-';
2249: }
2250: parent.mapout.document.writeln(
2251: '<td bgcolor="'+cck+'">Next<br />');
2252: parent.mapout.document.writeln(
2253: '<a href="javascript:parent.code.handler('+
2254: "'c&"+data4[0]+'&'+i+'&'+data4[2]+'&'+condid+"');"
2255: +'">Edit</a>');
2256: parent.mapout.document.writeln('</td>');
2257: }
2258: }
2259: }
2260: for (j=2;j<data2.length;j++) {
2261: data4=data2[j].split(':');
2262: data3=objlinks[data4[2]].split(':');
2263: if (data3.length>1) {
2264: if ((data3[1]!=nr) && (data3[1]!=0)) {
2265: cck='#AAAAAA';
2266: if (data3[2]!=0) {
2267: cck=condcolor((objcont[data3[2]].split(':'))[1]);
2268: condid=data3[2];
2269: } else {
2270: condid='-';
2271: }
2272: parent.mapout.document.writeln(
2273: '<td bgcolor="'+cck+'">To: '+robjs[data3[1]]+'<br />');
2274: parent.mapout.document.writeln(
2275: '<a href="javascript:parent.code.handler('+
2276: "'c&"+data4[0]+'&'+i+'&'+data4[2]+'&'+condid+"');"
2277: +'">Edit</a>');
2278: parent.mapout.document.writeln('</td>');
2279: }
2280: }
2281: }
2282: parent.mapout.document.writeln(
2283: '</tr></table></td></tr></table></form>');
2284: insrestab(rrow[data2[1]],i,nr,data1[3]);
2285:
2286: }
2287: }
2288: }
2289:
2290: // ----------------------------------------------------- Insert Resource Output
2291: function insrestab(irow,be,af,typ) {
2292: parent.mapout.document.writeln('<tr><td colspan="2">'+
2293: '<table><tr><td><a href="javascript:parent.code.insertrow('
2294: +irow+');parent.code.newresource(parent.code.maxrow,'+rcol[1]
2295: +",'','','false','normal');parent.code.mostrecent=parent.code.obj.length-1;"
2296: +'parent.code.draw();">'
2297: +'Insert resource</a></td><td>');
2298: if ((be!=-1) && (typ!='finish')) {
2299: parent.mapout.document.writeln(
2300: '<a href="javascript:parent.code.insertrow('
2301: +irow+');parent.code.newresource(parent.code.maxrow,'+rcol[0]
2302: +",'','','false','normal');parent.code.mostrecent=parent.code.obj.length-1;"
2303: +"parent.code.save();"
2304: +'parent.code.joinres('+be+',parent.code.mostrecent,0);'
2305: +'parent.code.draw();">'
2306: +'Insert resource linked to from above</a><br />');
2307: }
2308: if ((be!=-1) && (af!=-1) && (typ!='finish')) {
2309: parent.mapout.document.writeln(
2310: '<a href="javascript:parent.code.insertrow('
2311: +irow+');parent.code.newresource(parent.code.maxrow,'+rcol[0]
2312: +",'','','false','normal');parent.code.mostrecent=parent.code.obj.length-1;"
2313: +"parent.code.save();"
2314: +'parent.code.joinres('+be+',parent.code.mostrecent,0);'
2315: +"parent.code.save();"
2316: +'parent.code.joinres(parent.code.mostrecent,'+af+',0);'
2317: +'parent.code.draw();">'
2318: +'Insert resource linked to from above and linking to below</a><br />');
2319: }
2320: if (af!=-1) {
2321: parent.mapout.document.writeln(
2322: '<a href="javascript:parent.code.insertrow('
2323: +irow+');parent.code.newresource(parent.code.maxrow,'+rcol[0]
2324: +",'','','false','normal');parent.code.mostrecent=parent.code.obj.length-1;"
2325: +"parent.code.save();"
2326: +'parent.code.joinres(parent.code.mostrecent,'+af+',0);'
2327: +'parent.code.draw();">'
2328: +'Insert resource linking to below</a><br />');
2329: }
2330: parent.mapout.document.writeln('</td></tr></table></tr>');
2331: }
2332:
2333: // ---------------------------------------- Draw simple table instead of graph
2334: function simpletabledraw() {
2335: var objsorted=new Array();
2336: var robjs=new Array();
2337: var iobjs=new Array();
2338: var k;
2339: var i;
2340: var j;
2341: var nr;
2342: var ck;
2343: var cck;
2344: var mime;
2345: var ext;
2346: var url;
2347: var urlparts=new Array;
2348: var condid;
2349: var sortstr=sortobjs();
2350: if ((sortstr!='') && (typeof(sortstr)!="undefined")) {
2351: objsorted=sortstr.split('&');
2352: for (k=0;k<objsorted.length;k++) {
2353: i=(objsorted[k].split(':'))[0];
2354: iobjs[k]=i;
2355: robjs[i]=k;
2356: }
2357: for (k=0;k<iobjs.length;k++) {
2358: i=iobjs[k];
2359: if (k<objsorted.length-1) {
2360: nr=iobjs[k+1];
2361: } else {
2362: nr=-1;
2363: }
2364: data1=objcont[i].split(':');
2365: ck=rescolor(data1[2],data1[3]);
2366: parent.mapout.document.write('<tr><td bgcolor="'+ck+'">');
2367: url=data1[1];
2368: ext=data1[2];
2369: urlparts=url.split('.');
2370: mime=urlparts[urlparts.length-1];
2371: if (typeof(mime)=="undefined") { mime=''; }
2372: if ((mime!='') && (ext!='true')) {
2373: parent.mapout.document.write
2374: ('<a target="preview" align="right" href="'+url+'.meta'+
2375: '"><img width="20" src="'+iconpath+'meta.gif" /></a><p>'+
2376: '<a target="preview" align="right"href="'+url+
2377: '"><img width="20" src="'+iconpath+mime+'.gif" /></a><p>');
2378: }
2379: parent.mapout.document.write('<b>'+k+'</b></td><td bgcolor="'+ck+'">');
2380: data2=obj[i].split('&');
2381: parent.mapout.document.write('<table>');
2382:
2383: if (data1[3]=='start') {
2384: parent.mapout.document.writeln('<tr><td><b>Start</b></td></tr>');
2385: }
2386: if (data1[3]=='finish') {
2387: parent.mapout.document.writeln('<tr><td><b>Finish</b></td></tr>');
2388: }
2389: parent.mapout.document.write(
2390: '<tr><td>Title:</td><td>'+data1[0]+'</td></tr>');
2391: parent.mapout.document.write(
2392: '<tr><td>URL:</td><td>'+data1[1]+'</td></tr>'
2393: +'<tr><td colspan="2"><table><tr>');
2394: for (j=2;j<data2.length;j++) {
2395: data4=data2[j].split(':');
2396: data3=objlinks[data4[2]].split(':');
2397: if (data3.length>1) {
2398: if (data3[1]==nr) {
2399: cck='#AAAAAA';
2400: if (data3[2]!=0) {
2401: cck=condcolor((objcont[data3[2]].split(':'))[1]);
2402: condid=data3[2];
2403: } else {
2404: condid='-';
2405: }
2406: parent.mapout.document.writeln(
2407: '<td bgcolor='+cck+'>Next<br />');
2408: parent.mapout.document.writeln('</td>');
2409: }
2410: }
2411: }
2412: for (j=2;j<data2.length;j++) {
2413: data4=data2[j].split(':');
2414: data3=objlinks[data4[2]].split(':');
2415: if (data3.length>1) {
2416: if ((data3[1]!=nr) && (data3[1]!=0)) {
2417: cck='#AAAAAA';
2418: if (data3[2]!=0) {
2419: cck=condcolor((objcont[data3[2]].split(':'))[1]);
2420: condid=data3[2];
2421: } else {
2422: condid='-';
2423: }
2424: parent.mapout.document.writeln(
2425: '<td bgcolor="'+cck+'">To: '+robjs[data3[1]]+'<br />');
2426: parent.mapout.document.writeln('</td>');
2427: }
2428: }
2429: }
2430: parent.mapout.document.writeln('</tr></table></td></tr></table></tr>');
2431: }
2432: } else {
2433: parent.mapout.document.writeln('<tr><td>No Resources</td></tr>');
2434: }
2435: }
2436:
2437: // ---------------------------------- Sort objects to straighten graph or table
2438: function sortobjs() {
2439: message("Sorting Resources: "+funny);
2440: var k;
2441: var ij;
2442: var dol;
2443: var dtl;
2444: var kj;
2445: var sortthis=0;
2446: var objsort=new Array();
2447: for (k=1;k<objcont.length;k++) {
2448: if (objcont[k]) {
2449: data1=objcont[k].split(':');
2450: if (data1[data1.length-1]=='res') {
2451: objsort[objsort.length]=''+k;
2452: }
2453: }
2454: }
2455: if (objsort.length==0) { return ''; }
2456: for (k=1;k<objlinks.length;k++) {
2457: wheelswitch();
2458: message("Sorting Resources: "+funny);
2459: if ((typeof(objlinks[k])!="undefined") && (objlinks[k]!='')) {
2460: sortthis=1;
2461: data1=objlinks[k].split(':');
2462: kj=-1;
2463: for (j=0;j<objsort.length;j++) {
2464: if ((objsort[j].split(':'))[0]==data1[0]) {
2465: kj=j;
2466: }
2467: }
2468: if (kj!=-1) { objsort[kj]+=':'+data1[1]; }
2469: }
2470: }
2471: if (sortthis!=0) {
2472: for (k=0;k<objsort.length;k++) {
2473: wheelswitch();
2474: message("Sorting Resources: "+funny);
2475: for (j=0;j<objsort.length;j++) {
2476: if (k!=j) {
2477: data1=objsort[k].split(':');
2478: data2=objsort[j].split(':');
2479: dol=data1.length;
2480: dtl=data2.length;
2481: if (dol+dtl<200) {
2482: for (kj=1;kj<dol;kj++) {
2483: if (data1[kj]==data2[0]) {
2484: for (ij=1;ij<dtl;ij++) {
2485: data1[data1.length]=data2[ij];
2486: }
2487: }
2488: }
2489: for (kj=1;kj<dtl;kj++) {
2490: if (data2[kj]==data1[0]) {
2491: for (ij=1;ij<dol;ij++) {
2492: data2[data2.length]=data1[ij];
2493: }
2494: }
2495: }
2496: objsort[k]=data1.join(':');
2497: objsort[j]=data2.join(':');
2498: }
2499: }
2500: }
2501: }
2502: message("Sorting Resources: finishing up.");
2503: return objsort.sort(rescompare).join('&');
2504: } else {
2505: return objsort.join('&');
2506: }
2507: }
2508:
2509: // ----------------------------------------------------------- Straighten graph
2510: function graphopt() {
2511: var k;
2512: var kj;
2513: var ij;
2514: var objsorted=new Array();
2515: condense();
2516: graphreset();
2517: objsorted=(sortobjs()).split('&');
2518: if (objsorted.length==0) { return; }
2519: message("Creating Optimized Graph");
2520: var thisnewobj=''+(objsorted[0].split(':'))[0];
2521: rowcont[1]=thisnewobj;
2522: var thiscolmax=1;
2523: obj[thisnewobj]='b&1&'+thiscolmax+':0:0:0';
2524: var allcolmax=0;
2525: for (k=1;k<objsorted.length;k++) {
2526: thisnewobj=(objsorted[k].split(':'))[0];
2527: if (rescompare(objsorted[k-1],objsorted[k])==0) {
2528: rowcont[rowcont.length-1]+=':'+thisnewobj;
2529: thiscolmax++;
2530: } else {
2531: rowcont[rowcont.length]=thisnewobj;
2532: thiscolmax=1;
2533: }
2534: kj=rowcont.length-1;
2535: obj[thisnewobj]='b&'+kj+'&'+thiscolmax+':0:0:0';
2536: if (thiscolmax>allcolmax) { allcolmax=thiscolmax; }
2537: }
2538: for (k=0;k<obj.length;k++) {
2539: if (!obj[k]) { obj[k]=''; }
2540: }
2541: for (k=0;k<=allcolmax;k++) { insertcol(0); }
2542: for (k=0;k<rowcont.length;k++) {
2543: row[k]=k;
2544: }
2545: maxrow=rowcont.length-1;
2546: var oldlinks=new Array();
2547: for (k=0;k<objlinks.length;k++) {
2548: oldlinks[k]=objlinks[k];
2549: objlinks[k]='';
2550: }
2551: objlinks.length=0;
2552: objlinks[0]='';
2553: graphdef='yes';
2554: save();
2555:
2556: for (k=0;k<objsorted.length;k++) {
2557: wheelswitch();
2558: message("Connecting Resources: "+funny);
2559: kj=(objsorted[k].split(':'))[0];
2560: for (ij=1;ij<oldlinks.length;ij++) {
2561: if (oldlinks[ij]) {
2562: data1=oldlinks[ij].split(':');
2563: if (data1[0]==kj) {
2564: joinres(data1[0],data1[1],data1[2]);
2565: save();
2566: }
2567: }
2568: }
2569: }
2570: }
2571:
2572: // ----------------------------------------------------------- Remove e-objects
2573: function condense() {
2574: message("Condensing");
2575: var j;
2576: for (j=0;j<=maxrow;j++) {
2577: if ((rowcont[j]!='') && (typeof(rowcont[j])!="undefined")) {
2578: data1=rowcont[j].split(':');
2579: rowcont[j]='';
2580: for (k=0;k<data1.length;k++) {
2581: if (obj[data1[k]].substring(0,2)!='e&') {
2582: if ((rowcont[j]!='') && (typeof(rowcont[j])!="undefined")) {
2583: rowcont[j]+=':';
2584: }
2585: rowcont[j]+=data1[k];
2586: }
2587: }
2588: }
2589: }
2590: }
2591:
2592: // ---------------------------------------------------- Load from hidden fields
2593: function load() {
2594: message("Loading");
2595: schedule('load');
2596: }
2597:
2598: function finishload() {
2599: var k;
2600: for (k=0;k<objcont.length;k++) { objcont[k]=''; }
2601: objcont.length=0;
2602: for (k=0;k<objlinks.length;k++) { objlinks[k]=''; }
2603: objlinks.length=0;
2604: for (k=0;k<objparms.length;k++) { objparms[k]=''; }
2605: objparms.length=0;
2606: objlinks[0]='';
2607: objcont[0]='';
2608: editmode=0;
2609: notclear=0;
2610: lastinfo='';
2611: graphreset();
2612: var inputstr=parent.server.document.forms.storage.output.value;
2613: if ((inputstr!='') && (typeof(inputstr)!="undefined")) {
2614: data1=inputstr.split('<&>');
2615: var k;
2616: for (k=0;k<data1.length;k++) {
2617: data2=data1[k].split(':').join(':').split('<:>');
2618: if (data2[0]=='graphdef') { graphdef=data2[1]; }
2619: if (data2[0]=='maxcol') { maxcol=1*data2[1]; }
2620: if (data2[0]=='maxrow') { maxrow=1*data2[1]; }
2621: if (data2[0]=='obj') { obj[data2[1]]=data2[2]; }
2622: if (data2[0]=='objcont') { objcont[data2[1]]=data2[2]; }
2623: if (data2[0]=='objlinks') { objlinks[data2[1]]=data2[2]; }
2624: if (data2[0]=='objparms') {
2625: if (typeof(objparms[data2[1]])=="undefined") {
2626: objparms[data2[1]]=data2[2];
2627: } else {
2628: if (objparms[data2[2]]=='') {
2629: objparms[data2[1]]=data2[2];
2630: } else {
2631: objparms[data2[1]]+=':'+data2[2];
2632: }
2633: }
2634: }
2635: if (data2[0]=='rowcont') { rowcont[data2[1]]=data2[2]; }
2636: if (data2[0]=='row') { row[data2[1]]=1*data2[2]; }
2637: if (data2[0]=='col') { col[data2[1]]=1*data2[2]; }
2638: if (data2[0]=='mode') { mode=data2[1]; }
2639: if (data2[0]=='tablemode') { tablemode=1*data2[1]; }
2640: if (data2[0]=='zscale') { zscale=1*data2[1]; }
2641: }
2642: }
2643: if (graphdef=='yes') {
2644: for (k=1;k<=maxrow;k++) {
2645: if (typeof(rowcont[k])=="undefined") { rowcont[k]=''; }
2646: }
2647: } else {
2648: var hasstart=0;
2649: var hasfinish=0;
2650: for (k=0;k<objcont.length;k++) {
2651: if (typeof(objcont[k])!="undefined") {
2652: var objfunctype=(objcont[k].split(':'))[3];
2653: if (objfunctype=='start') { hasstart=1; }
2654: if (objfunctype=='finish') { hasfinish=1; }
2655: }
2656: }
2657: if (!hasstart) {
2658: if ((typeof(objcont[1])=="undefined") || (objcont[1]=='')) {
2659: objcont[1]='Start::false:start:res';
2660: }
2661: }
2662: if (!hasfinish) {
2663: if ((typeof(objcont[2])=="undefined") || (objcont[2]=='')) {
2664: objcont[2]='Finish::false:finish:res';
2665: }
2666: }
2667: }
2668: }
2669:
2670: // -------------------------------------------------------------- Parameter set
2671: function setparms(resid) {
2672: var options="scrollbars=1,resizable=1,menubar=0";
2673: parmflag=1;
2674: data1=objcont[resid].split(':');
2675: parm=open("/adm/ratparms?url="+data1[1]+"&parms="+objparms[resid]+
2676: "&resid="+resid,"parmout",options);
2677: parm.focus();
2678: }
2679:
2680: // -------------------------------------------------------------- Undo function
2681: function undo() {
2682: if (undopointer>1) {
2683: undopointer--;
2684: parent.server.document.forms.storage.output.value
2685: =undostack[undopointer];
2686: finishload();
2687: undopointer--;
2688: draw();
2689: stored=0;
2690: } else {
2691: alert("Cannot undo: reached beginning of edit session");
2692: }
2693: }
2694:
2695: // -------------------------------------------------------------- Redo function
2696: function redo() {
2697: if (undopointer<undostack.length-1) {
2698: undopointer++;
2699: parent.server.document.forms.storage.output.value
2700: =undostack[undopointer];
2701: finishload();
2702: undopointer--;
2703: draw();
2704: stored=0;
2705: } else {
2706: alert("Cannot redo: reached end of edit session");
2707: }
2708: }
2709:
2710: // ------------------------------------------------------------ Revert function
2711: function revert() {
2712: if (confirm("Revert to beginning of edit session?")) {
2713: undopointer=2;
2714: undo();
2715: }
2716: }
2717:
2718: // ---------------------------------------------------------------- Wheelswitch
2719: function wheelswitch() {
2720: if (funny=='|') {
2721: funny='/';
2722: } else {
2723: if (funny=='/') {
2724: funny='-';
2725: } else {
2726: if (funny=='-') {
2727: funny='\\';
2728: } else {
2729: if (funny=='\\') { funny='|'; }
2730: }
2731: }
2732: }
2733: }
2734:
2735: // --------------------------------------------- Checks if server frame defined
2736: function checkdef() {
2737: if (parent.flag==1) {
2738: srvloaded();
2739: }
2740: if ((finishdone==0) && (tim==0)) { setTimeout('checkdef()',100); }
2741: }
2742:
2743: // ---------------------------------------------------------- The wait function
2744: function wait() {
2745: if ((finishdone==1) || (tim==1)) {
2746: if (tim==0) {
2747: clearTimeout(canceltim);
2748: if (reqaction=='save') { finishsave(); }
2749: if (reqaction=='load') { finishload(); draw(); }
2750: } else {
2751: alert("Server Communication Timed Out.");
2752: }
2753: } else {
2754: wheelswitch();
2755: message('Waiting for server reply: '+funny);
2756: setTimeout('wait();',100);
2757: }
2758: }
2759:
2760: // ---------------------------------------------------------- Schedule function
2761: function schedule(action) {
2762: reqaction=action;
2763: tim=0;
2764: finishdone=0;
2765: canceltim=setTimeout('tim=1;',20000);
2766: checkdef();
2767: wait();
2768: }
2769:
2770: // ----------------------------------------------------- launch indexer browser
2771: function groupsearch() {
2772: srchcheck('import');
2773: }
2774:
2775: function groupimport() {
2776: idxcheck('import');
2777: }
2778:
2779: function groupcopy() {
2780: copydxcheck('import');
2781: }
2782:
2783: // -------------------------------------------------------------- Store changes
2784: function storechange() {
2785: var k;
2786: parent.flag=0;
2787: parent.server.document.forms.storage.submit();
2788: schedule('save');
2789: }
2790:
2791: function finishsave() {
2792: finishload();
2793: draw();
2794: stored=1;
2795: }
2796:
2797: // --------------------------------------- Gets called when submission finished
2798: function srvloaded() {
2799: finishdone=1;
2800: message("Server replied.");
2801: }
2802:
2803: // ---------------------------------------------------------------- Toggle Mode
2804: function togglemode() {
2805: if (tablemode==0) {
2806: tablemode=1;
2807: } else {
2808: if (tablemode==1) {
2809: tablemode=2;
2810: } else {
2811: tablemode=0;
2812: }
2813: }
2814: notclear=0;
2815: infoclear();
2816: draw();
2817: }
2818:
2819: // -------------------------------------------------------- Main program onLoad
2820: function main() {
2821: if (mainrun==0) {
2822: infopen();
2823: infoclear();
2824: load();
2825: stored=1;
2826: mainrun=1;
2827: }
2828: }
2829:
2830: // ---------------------------------------------------------- Close the window?
2831: function leave() {
2832: if (!inf.closed) {
2833: inf.close();
2834: }
2835: if (srch && !srch.closed) {
2836: srchclose();
2837: }
2838: if (idx && !idx.closed) {
2839: idxclose();
2840: }
2841: if (copydx && !copydx.closed) {
2842: copydxclose();
2843: }
2844: }
2845:
2846: </script>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>