Annotation of rat/client/ratcode.js, revision 1.7
1.1 raeburn 1: <!--
2: The LearningOnline Network
3: Resource Assembly Tool
1.7 ! albertel 4: // $Id: ratcode.js,v 1.6 2006/06/19 09:43:02 www Exp $
1.1 raeburn 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 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);
1.3 www 99: var data6=new Array(1024);
1.1 raeburn 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
1.7 ! albertel 247: function newresource(rid,cid,text,url,ext,type,oldidx) {
1.1 raeburn 248: stored=0;
1.7 ! albertel 249: var newidx=addobj(rid,'b&'+rid+'&'+cid+':0:0:0',url,oldidx);
! 250:
1.3 www 251: objcont[newidx]=
1.1 raeburn 252: text+':'+url+':'+ext+':'+type+':res';
1.3 www 253: return newidx;
1.1 raeburn 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
1.7 ! albertel 472: function addobj(kjid,objs,url,oldindex) {
1.1 raeburn 473: stored=0;
474: expense++;
475: if ((rowcont[kjid]!='') && (typeof(rowcont[kjid])!="undefined")) {
476: rowcont[kjid]+=':';
477: }
1.3 www 478: var newindex=obj.length;
479: if ((url!='') && (typeof(url)!="undefined")) {
1.7 ! albertel 480: // see if we have a zombie with that url and possibly oldindex
1.3 www 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) {
1.7 ! albertel 486: if (typeof(oldindex) == "undefined") {
! 487: newindex=oidx;
! 488: } else {
! 489: if (oidx == oldindex) {
! 490: newindex=oidx;
! 491: }
! 492: }
1.3 www 493: }
494: }
495: }
496: }
497: }
498: rowcont[kjid]+=newindex;
499: obj[newindex]=objs;
500: return newindex;
1.1 raeburn 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);
1.2 www 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
1.1 raeburn 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 src="'+iconpath+
1008: 'meta.gif"><a target="preview" href="'+url+
1009: '"><img border=0 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 src="'+iconpath+
1048: 'meta.gif"><a target="preview" href="'+url+
1049: '"><img border=0 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 src="'+iconpath+
1084: 'meta.gif"><a target="preview" href="'+url+
1085: '"><img border=0 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.clear();
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.clear();
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 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.clear();
1626: }
1627:
1628: // --------------------------------------------------------- Clears copy window
1629: function copydxclear() {
1630: copydx.document.clear();
1631: }
1632: // ------------------------------------------------------- Clears search window
1633: function srchclear() {
1634: srch.document.clear();
1635: }
1636:
1637: // --------------------------------------------------------- Clears parm window
1638: function parmclear() {
1639: parm.document.clear();
1640: }
1641:
1642: // ------------------------------------------------------ Closes indexer window
1643: function idxclose() {
1644: if (idx && !idx.closed) {
1645: idxflag=0;
1646: idx.close();
1647: }
1648: }
1649:
1650: // --------------------------------------------------------- Closes copy window
1651: function copydxclose() {
1652: if (copydx && !copydx.closed) {
1653: copydxflag=0;
1654: copydx.close();
1655: }
1656: }
1657:
1658: // ------------------------------------------------------- Closes search window
1659: function srchclose() {
1660: if (srch && !srch.closed) {
1661: srchflag=0;
1662: srch.close();
1663: }
1664: }
1665:
1666: // ------------------------------------------------------- Closes search window
1667: function parmclose() {
1668: if (parm && !parm.closed) {
1669: parmflag=0;
1670: parm.close();
1671: }
1672: }
1673:
1674: // -------------------------------------------------------- Open indexer window
1675: function idxopen(mode) {
1676: var options="scrollbars=1,resizable=1,menubar=0";
1677: idxmode=mode;
1678: idxflag=1;
1679: idx=open("/res/?launch=1&mode=rat&catalogmode="+mode,"idxout",options);
1680: idx.focus();
1681: }
1.4 www 1682: // -------------------------------------------------------- Open zombie window
1683: function groupopen(url) {
1684: var options="scrollbars=1,resizable=1,menubar=0";
1685: idxmode=mode;
1686: idxflag=1;
1687: idx=open("/adm/groupsort?mode=rat&recover=1&readfile="+url,"idxout",options);
1688: idx.focus();
1689: }
1.6 www 1690: // ------------------------------------------------------- Open bookmark window
1691: function bookmarkopen() {
1692: var options="scrollbars=1,resizable=1,menubar=0";
1693: idxmode=mode;
1694: idxflag=1;
1695: idx=open("/adm/groupsort?mode=rat&bookmarks=1","idxout",options);
1696: idx.focus();
1697: }
1.1 raeburn 1698: // ------------------------------------------------- Open browser to select map
1699: var editbrowser;
1700: function openbrowser(formname,elementname,only,omit) {
1701: var url = '/res/?';
1702: if (editbrowser == null) {
1703: url += 'launch=1&';
1704: }
1705: url += 'catalogmode=interactive&';
1706: url += 'mode=edit&';
1707: url += 'form=' + formname + '&';
1708: if (only != null) {
1709: url += 'only=' + only + '&';
1710: }
1711: if (omit != null) {
1712: url += 'omit=' + omit + '&';
1713: }
1714: url += 'element=' + elementname + '';
1715: var title = 'Browser';
1716: var options = 'scrollbars=1,resizable=1,menubar=0';
1717: options += ',width=700,height=600';
1718: editbrowser = copydx.open(url,title,options,'1');
1719: editbrowser.focus();
1720: }
1721: // ----------------------------------------------------------- Open copy window
1722: function copydxopen(mode) {
1723: var options="scrollbars=1,resizable=1,menubar=0";
1724: copydxmode=mode;
1725: copydxflag=1;
1726: copydx=open("",'copydxout',options);
1727: copydx.document.clear('');
1728: copydx.document.writeln(
1729: '<html><body bgcolor="#FFFFFF"><h1>Copy from Map</h1>'+
1730: '<form name="mapload"><input type=text size=40 name=importmap>'+
1731: '<input type=button onClick="javascript:opener.openbrowser'+
1732: "('mapload','importmap','sequence,page','')"+
1733: '" value="Browse"><input type=button value="Load Map" '+
1734: 'onClick="window.location=document.mapload.importmap.value+'+
1735: "'?launch=1&forceselect=1'"+'"></form>');
1736:
1737: copydx.document.writeln('</body></html>');
1738: copydx.focus();
1739: }
1740:
1741: // --------------------------------------------------------- Open search window
1742: function srchopen(mode) {
1743: var options="scrollbars=1,resizable=1,menubar=0";
1744: srchmode=mode;
1745: srchflag=1;
1746: srch=open("/adm/searchcat?launch=1&mode=rat&catalogmode="+mode,"srchout",options);
1747: srch.focus();
1748: }
1749:
1750: // -------------------------------------------- Interface function to searching
1751: function search() {
1752: alert("Searching not yet implemented");
1753: }
1754:
1755: // ------------------------------------------------------- Do srch status check
1756: function srchcheck(mode) {
1757: if (!srch || srch.closed || srchmode!=mode) {
1758: srchopen(mode);
1759: }
1760: srch.focus();
1761: }
1762:
1763: // -------------------------------------------------------- Do idx status check
1764: function idxcheck(mode) {
1765: if (!idx || idx.closed || idxmode!=mode) {
1766: idxopen(mode);
1767: }
1768: idx.focus();
1769: }
1770:
1771: // -------------------------------------------------------- Do idx status check
1772: function copydxcheck(mode) {
1773: if (!copydx || copydx.closed || copydxmode!=mode) {
1774: copydxopen(mode);
1775: }
1776: copydx.focus();
1777: }
1778:
1779: // ---------------------------------------------------- Handles "click to edit"
1780: function handler(infostr) {
1781: var k;
1782: editmode=1;
1783: notclear=1;
1784: infcheck();
1785: inf.document.clear();
1786: inf.document.writeln(
1787: '<html><body bgcolor="#FFFFFF">'+
1788: '<table><tr><td width=32><img src="'+raticons+'edit.gif"></td><td bgcolor="#AAFFAA">');
1789: data1=infostr.split('&');
1790: if (data1[0]=='c') {
1791: inf.document.writeln('<b>Condition</b><hr>');
1792: linkmode=0;
1793: if (data1[4]=='-') {
1794: data2[0]=''; data2[1]='normal';
1795: } else {
1796: data2=objcont[data1[4]].split(':');
1797: }
1798: inf.document.writeln(
1799: '<form name=condinfo><textarea name=c cols=30 rows=3>'
1800: +data2[0]+'</textarea><br><input type=radio name=s value=normal '+
1801: 'onClick="self.document.forms.condinfo.elements.h.value='+"'normal'"+'"');
1802: if (data2[1]=='normal') { inf.document.write(' checked'); }
1803: inf.document.write(
1804: '> Recommendation if true<br><input type=radio name=s value=stop '+
1805: 'onClick="self.document.forms.condinfo.elements.h.value='+"'stop'"+'"');
1806: if (data2[1]=='stop') { inf.document.write(' checked'); }
1807: inf.document.write(
1808: '> Blocking this link if false<br><input type=radio name=s value=force '+
1809: 'onClick="self.document.forms.condinfo.elements.h.value='+"'force'"+'"');
1810: if (data2[1]=='force') { inf.document.write(' checked'); }
1811: inf.document.write(
1812: '> Blocking other links if true<br><a href="javascript:opener.editmode=0;'
1813: +'opener.notclear=0;');
1814: if (data1[4]=='-') {
1815: inf.document.write('opener.crecond('+data1[2]+','+data1[1]+','
1816: +'opener.escape(self.document.forms.condinfo.elements.c.value),'
1817: +'self.document.forms.condinfo.elements.h.value);');
1818: } else {
1819: inf.document.write('opener.objcont['+data1[4]+']='
1820: +'opener.escape(self.document.forms.condinfo.elements.c.value)+'+"':'"
1821: +'+self.document.forms.condinfo.elements.h.value+'+"':cond';");
1822: }
1823: inf.document.writeln(
1824: 'opener.infoclear();opener.editmode=0;opener.draw('
1825: +');"><b>Save Changes</b></a> '
1826: +' <a href="javascript:self.document.forms.condinfo.reset()">Reset</a><br>'
1827: +'<input type=hidden name=h value='+data2[1]+'>');
1828:
1829: inf.document.writeln(
1830: '<a href="javascript:opener.notclear=0;opener.infoclear();'
1831: +'opener.delcond('+data1[2]+','+data1[1]+');opener.editmode=0;opener.draw('
1832: +');">Delete Condition</a><br>');
1833: inf.document.writeln(
1834: '<a href="javascript:opener.notclear=0;opener.infoclear();'
1835: +'opener.dellink('+data1[3]+');opener.editmode=0;opener.draw('
1836: +');">Delete Link</a>');
1837:
1838: inf.document.writeln('<br><a href="javascript:'+
1839: 'opener.insertcondlink('+data1[1]+','+data1[3]+');'+
1840: 'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1841: +');">Insert Resource Into Link</a>');
1842: } else {
1843: if (data1[0]=='r') {
1844: if (linkmode!=0) {
1845: joinres(linkmode,data1[1],0);
1846: editmode=0;
1847: notclear=0;
1848: linkmode=0;
1849: inf.document.writeln('<b>Linked Resources</b>');
1850: draw();
1851: } else {
1852: data2=objcont[data1[1]].split(':');
1853: if (data2[3]=='start') {
1854: inf.document.writeln('<b>Start</b>');
1855: } else {
1856: if (data2[3]=='finish') {
1857: inf.document.writeln('<b>Finish</b>');
1858: } else {
1859: inf.document.writeln('<b>Resource</b>');
1860: }
1861: }
1862: inf.document.write(
1863: '<form name=resinfo><table><tr><td>Title:</td><td colspan=2>'
1864: +'<input type=text name=t size=30 value="'
1865: +escape(data2[0])+'"><input type=hidden name=h value='+data2[3]+'></td></tr>');
1866: inf.document.write('<tr><td>URL:</td><td colspan=2>'
1867: +'<input type=text name=u size=30 value="'+data2[1]+'"></td></tr>'
1868: +'<tr><td>External:</td><td><input type=checkbox name=e');
1869: if (data2[2]=='true') { inf.document.write(' checked'); }
1870: inf.document.write('></td><td align=right>'
1871: +'<a href="javascript:opener.idxcheck(\'interactive\')">Browse</a> '
1872: +'<a href="javascript:opener'
1873: +'.srchcheck(\'interactive\')">Search</a></td></tr>');
1874: if ((data2[3]!='start') && (data2[3]!='finish')) {
1875: inf.document.write('<tr><td colspan=3>'
1876: +'<input type=radio name=y value=normal '+
1877: 'onClick="self.document.forms.resinfo.elements.h.value='+"'normal'"+'"');
1878: if (data2[3]=='normal') { inf.document.write(' checked'); }
1879: inf.document.write(
1880: '> Regular <input type=radio name=y value=mandatory '+
1881: 'onClick="self.document.forms.resinfo.elements.h.value='+"'mandatory'"+'"');
1882: if (data2[3]=='mandatory') { inf.document.write(' checked'); }
1883: inf.document.write(
1884: '> Mandatory <input type=radio name=y value=optional '+
1885: 'onClick="self.document.forms.resinfo.elements.h.value='+"'optional'"+'"');
1886: if (data2[3]=='optional') { inf.document.write(' checked'); }
1887: inf.document.write('> Optional</td></tr>');
1888: }
1889: inf.document.writeln(
1890: '<tr><td colspan=3><a href="javascript:opener.editmode=0;'
1891: +'opener.notclear=0;opener.objcont['+data1[1]
1892: +']=opener.escape(self.document.forms.resinfo.elements.t.value)+'+"':'"
1893: +'+opener.escape(self.document.forms.resinfo.elements.u.value)+'+"':'"
1894: +'+self.document.forms.resinfo.elements.e.checked+'+"':'"
1895: +'+self.document.forms.resinfo.elements.h.value+'+"':res'"
1896: +';opener.infoclear();opener.editmode=0;opener.draw();">'
1897: +'<b>Save Changes</b></a> '
1898: +' <a href="javascript:self.document.forms.resinfo.reset()">Reset</a>'
1899: +'</td></tr></table>');
1900: if ((data2[3]!='start') && (data2[3]!='finish')) {
1901: inf.document.writeln(
1902: '<a href="javascript:opener.notclear=0;opener.infoclear();'
1903: +'opener.delres('+data1[1]+',0);opener.editmode=0;opener.draw('
1904: +');">Delete Resource (cutting links)</a>');
1905: inf.document.writeln(
1906: '<br><a href="javascript:opener.notclear=0;opener.infoclear();'
1907: +'opener.delres('+data1[1]+',1);opener.editmode=0;opener.draw('
1908: +');">Delete Resource (preserving links)</a>');
1909: }
1910: if (data2[3]!='finish') {
1911: inf.document.writeln(
1912: '<br><a href="javascript:opener.editmode=0;opener.notclear=0;'
1913: +'opener.linkmode='+data1[1]+';'
1914: +'opener.infoclear();">Link Resource</a>');
1915: }
1916: inf.document.writeln(
1917: '<br><a href="javascript:'
1918: +'opener.setparms('+data1[1]+');'
1919: +'opener.infoclear();">Set Parameters</a>');
1920:
1921: }
1922: } else {
1923: linkmode=0;
1924: inf.document.writeln('<b>Link</b><hr><form>');
1925: data2=obj[data1[0]].split('&');
1926: k=data2[data2.length-2];
1927: data3=objlinks[k].split(':');
1928: inf.document.writeln('From <b>'+objcont[data3[0]].split(':')[0]+
1929: '</b><br>to <b>'+objcont[data3[1]].split(':')[0]+'</b>');
1930: inf.document.writeln('<br><a href="javascript:opener.dellink('+
1931: k+');opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1932: +');">Delete Link</a>');
1933: inf.document.writeln('<br><a href="javascript:'+
1934: "opener.insertreslink('"+infostr+"');"+
1935: 'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1936: +');">Insert Resource Into Link</a>');
1937: }
1938: }
1939: inf.document.writeln(
1940: '<br><a href="javascript:opener.editmode=0;opener.notclear=0;'
1941: +'opener.infoclear();">Cancel</a>');
1942: inf.document.writeln('</form></td></tr></table></body></html>');
1943: inf.document.close();
1944: inf.focus();
1945: }
1946:
1947: // ----------------------------------------------------- Clicks on empty fields
1948: function empty(rid,k) {
1949: var cid=findcol(k);
1950: var lcol=k-1;
1951: trow=row[rid];
1952: lrow=trow-1;
1953: editmode=1;
1954: notclear=1;
1955: linkmode=0;
1956: infcheck();
1957: inf.document.clear();
1958: inf.document.writeln(
1959: '<html><body bgcolor="#FFFFFF">'+
1960: '<table><tr><td width=32><img src="'+raticons+'edit.gif"></td><td bgcolor="#AAFFAA">'+
1961: '<b>Empty Field</b><hr>');
1962:
1963: inf.document.writeln('<br><a href="javascript:opener.newresource('+
1964: rid+','+cid+",'','','false','normal');"+
1965: 'opener.mostrecent=opener.obj.length-1;'+
1966: 'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1967: +');">Insert resource</a>');
1968:
1969: if ((mostrecent!=0) && (objcont[mostrecent]!='') &&
1970: (typeof(objcont[mostrecent])!="undefined")) {
1971:
1972: inf.document.writeln('<br><a href="javascript:opener.newresource('+
1973: rid+','+cid+",'','','false','normal');"+
1974: 'opener.mostrecent=opener.obj.length-1;'+
1975: 'opener.joinres('+mostrecent+',opener.obj.length-1,0);'+
1976: 'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1977: +');">Insert resource linked to from most recent one</a>');
1978:
1979: inf.document.writeln('<br><a href="javascript:opener.newresource('+
1980: rid+','+cid+",'','','false','normal');"+
1981: 'opener.mostrecent=opener.obj.length-1;'+
1982: 'opener.joinres(opener.obj.length-1,'+mostrecent+',0);'+
1983: 'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1984: +');">Insert resource linking to most recent one</a>');
1985: }
1986:
1987:
1988: inf.document.writeln('<hr>Insert column:');
1989: inf.document.writeln('<a href="javascript:opener.insertcol('+
1990: lcol+');opener.addobj('+rid+",'e&'+opener.maxcol);"
1991: +'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1992: +');">left</a>');
1993: inf.document.writeln('<a href="javascript:opener.insertcol('+
1994: k+');opener.addobj('+rid+",'e&'+opener.maxcol);"
1995: +'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1996: +');">right</a> ');
1997: inf.document.writeln('<br>Insert row:');
1998: inf.document.writeln('<a href="javascript:opener.insertrow('+
1999: trow+');opener.addobj(opener.maxrow'+",'e&"+cid+"');"
2000: +'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
2001: +');">below</a>');
2002: inf.document.writeln('<a href="javascript:opener.insertrow('+
2003: lrow+');opener.addobj(opener.maxrow'+",'e&"+cid+"');"
2004: +'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
2005: +');">above</a> ');
2006:
2007:
2008: inf.document.writeln(
2009: '<br><a href="javascript:opener.editmode=0;opener.notclear=0;'
2010: +'opener.infoclear();">Cancel</a>');
2011: inf.document.writeln('</td></tr></table></body></html>');
2012: inf.document.close();
2013: inf.focus();
2014: }
2015:
2016: // ---------------------------------------------------- Save into hidden fields
2017: function save() {
2018: var k;
2019: if (graphdef=='yes') {
2020: parent.server.document.forms.storage.output.value='graphdef<:>yes';
2021: for (k=1;k<obj.length;k++) {
2022: parent.server.document.forms.storage.output.value+=
2023: '<&>obj<:>'+k+'<:>'+obj[k];
2024: }
2025: for (k=0;k<row.length;k++) {
2026: parent.server.document.forms.storage.output.value+=
2027: '<&>row<:>'+k+'<:>'+row[k];
2028: }
2029: for (k=0;k<col.length;k++) {
2030: parent.server.document.forms.storage.output.value+=
2031: '<&>col<:>'+k+'<:>'+col[k];
2032: }
2033: for (k=0;k<rowcont.length;k++) {
2034: if (rowcont[k]) {
2035: parent.server.document.forms.storage.output.value+=
2036: '<&>rowcont<:>'+k+'<:>'+rowcont[k];
2037: }
2038: }
2039: parent.server.document.forms.storage.output.value+=
2040: '<&>maxcol<:>'+maxcol;
2041: parent.server.document.forms.storage.output.value+=
2042: '<&>maxrow<:>'+maxrow;
2043: parent.server.document.forms.storage.output.value+=
2044: '<&>zscale<:>'+zscale;
2045: } else {
2046: parent.server.document.forms.storage.output.value='graphdef<:>no';
2047: }
2048: parent.server.document.forms.storage.output.value+=
2049: '<&>tablemode<:>'+tablemode;
2050:
2051: for (k=0;k<objparms.length;k++) {
2052: if (objparms[k]) {
2053: parent.server.document.forms.storage.output.value+=
2054: '<&>objparms<:>'+k+'<:>'+objparms[k];
2055: }
2056: }
2057: for (k=0;k<objcont.length;k++) {
2058: if (objcont[k]) {
2059: parent.server.document.forms.storage.output.value+=
2060: '<&>objcont<:>'+k+'<:>'+objcont[k];
2061: }
2062: }
2063: for (k=0;k<objlinks.length;k++) {
2064: if (objlinks[k]) {
2065: parent.server.document.forms.storage.output.value+=
2066: '<&>objlinks<:>'+k+'<:>'+objlinks[k];
2067: }
2068: }
2069: undopointer++;
2070: undostack[undopointer]=
2071: parent.server.document.forms.storage.output.value;
2072: }
2073:
2074: // ----------------------------------------------- Reset all layout information
2075: function graphreset() {
2076:
2077: var k;
2078:
2079: for (k=0;k<obj.length;k++) { obj[k]=''; }
2080: obj.length=0;
2081: obj[0]='';
2082:
2083: rowcont.length=0;
2084: rowcont[0]='';
2085:
2086: row.length=0;
2087: row[0]=0;
2088: maxrow=0;
2089:
2090: col.length=0;
2091: colmap.length=0;
2092: maxcol=-1;
2093: insertcol(-1);
2094:
2095: objcont[0]='';
2096: objlinks[0]='';
2097:
2098: graphdef='no';
2099:
2100: }
2101:
2102: // --------------------- Compare two resources with each other for "straighten"
2103: function rescompare(a,b) {
2104: data1=a.split(':');
2105: data2=b.split(':');
2106: var rvalue=0;
2107: var k;
2108: for (k=1;k<data1.length;k++) {
2109: if (data1[k]==data2[0]) { rvalue--; }
2110: }
2111: for (k=1;k<data2.length;k++) {
2112: if (data2[k]==data1[0]) { rvalue++; }
2113: }
2114: if (rvalue==0) { rvalue=data2.length-data1.length; }
2115: return rvalue;
2116: }
2117:
2118: // -------------------------------------------- Draw the table instead of graph
2119: function tabledraw() {
2120: var objsorted=new Array();
2121: var robjs=new Array();
2122: var iobjs=new Array();
2123: var k;
2124: var i;
2125: var j;
2126: var nr;
2127: var ck;
2128: var cck;
2129: var condid;
2130: var url='';
2131: var mime='';
2132: var ext='';
2133: var urlparts=new Array;
2134: var sortstr=sortobjs();
2135: insrestab(1,-1,-1,'');
2136: if ((sortstr!='') && (typeof(sortstr)!="undefined")) {
2137: objsorted=sortstr.split('&');
2138: for (k=0;k<objsorted.length;k++) {
2139: i=(objsorted[k].split(':'))[0];
2140: iobjs[k]=i;
2141: robjs[i]=k;
2142: }
2143: for (k=0;k<iobjs.length;k++) {
2144: i=iobjs[k];
2145: if (k<objsorted.length-1) {
2146: nr=iobjs[k+1];
2147: } else {
2148: nr=-1;
2149: }
2150: data1=objcont[i].split(':');
2151: ck=rescolor(data1[2],data1[3]);
2152: parent.mapout.document.write('<tr><td bgcolor="'+ck+'">');
2153: url=data1[1];
2154: ext=data1[2];
2155: urlparts=url.split('.');
2156: mime=urlparts[urlparts.length-1];
2157: if (typeof(mime)=="undefined") { mime=''; }
2158: if ((mime!='') && (ext!='true')) {
2159: parent.mapout.document.write
2160: ('<a target="preview" align="right" href="'+url+'.meta'+
2161: '"><img src="'+iconpath+'meta.gif"></a><p>'+
2162: '<a target="preview" align="right"href="'+url+
2163: '"><img src="'+iconpath+mime+'.gif"></a><p>');
2164: }
2165: parent.mapout.document.write(
2166: '<b><a href="javascript:if (parent.code.linkmode!=0) { '
2167: +'parent.code.joinres(parent.code.linkmode,'+i+',0);'
2168: +'parent.code.linkmode=0;parent.code.editmode=0;'
2169: +'parent.code.notclear=0;parent.code.infoclear();'
2170: +'parent.code.draw(); }">'+k+'</a></b></td><td bgcolor="'+ck
2171: +'"><form name=r'+i+' method=post>');
2172: data2=obj[i].split('&');
2173: parent.mapout.document.write('<table bgcolor="#CCCCCC">');
2174:
2175: if (data1[3]=='start') {
2176: parent.mapout.document.writeln('<tr><td><b>Start</b></td></tr>');
2177: }
2178: if (data1[3]=='finish') {
2179: parent.mapout.document.writeln('<tr><td><b>Finish</b></td></tr>');
2180: }
2181: parent.mapout.document.write(
2182: '<tr><td>Title:</td><td><input type=text name=t size=50 value="'
2183: +data1[0]+'"><input type=hidden name=h value='+data1[3]
2184: +'></td></tr>');
2185: parent.mapout.document.write(
2186: '<tr><td>URL:</td><td><input type=text name=u size=50 value="'
2187: +data1[1]+'"></td></tr>'
2188: +'<tr><td>External:</td><td><input type=checkbox name=e');
2189: if (data1[2]=='true') { parent.mapout.document.write(' checked'); }
2190: parent.mapout.document.write('></td></tr>');
2191: if ((data1[3]!='start') && (data1[3]!='finish')) {
2192: parent.mapout.document.write(
2193: '<tr><td colspan=2><input type=radio name=y value=normal '+
2194: 'onClick="parent.mapout.document.forms.r'+i+'.elements.h.value='+
2195: "'normal'"+'"');
2196: if (data1[3]=='normal') { parent.mapout.document.write(' checked'); }
2197: parent.mapout.document.write(
2198: '> Regular <input type=radio name=y value=mandatory '+
2199: 'onClick="parent.mapout.document.forms.r'+i+'.elements.h.value='+
2200: "'mandatory'"+'"');
2201: if (data1[3]=='mandatory') { parent.mapout.document.write(' checked'); }
2202: parent.mapout.document.write(
2203: '> Mandatory <input type=radio name=y value=optional '+
2204: 'onClick="parent.mapout.document.forms.r'+i+'.elements.h.value='+
2205: "'optional'"+'"');
2206: if (data1[3]=='optional') { parent.mapout.document.write(' checked'); }
2207: parent.mapout.document.write('> Optional</td></tr>');
2208: }
2209: parent.mapout.document.write(
2210: '<tr><td colspan=2><a href="javascript:parent.code.objcont['+i
2211: +']=parent.code.escape(parent.mapout.document.forms.r'+i
2212: +'.elements.t.value)+'+"':'"
2213: +'+parent.code.escape(parent.mapout.document.forms.r'+i
2214: +'.elements.u.value)+'+"':'"
2215: +'+parent.mapout.document.forms.r'+i+'.elements.e.checked+'+"':'"
2216: +'+parent.mapout.document.forms.r'+i+'.elements.h.value+'+"':res'"
2217: +';parent.code.draw();">'
2218: +'<b>Save Changes</b></a> '
2219: +' <a href="javascript:parent.mapout.document.forms.r'+i
2220: +'.reset()">Reset</a></td></tr><tr><td colspan=2>');
2221: if ((data1[3]!='start') && (data1[3]!='finish')) {
2222: parent.mapout.document.writeln(
2223: '<A href="javascript:parent.code.notclear=0;parent.code.infoclear();'
2224: +'parent.code.delres('+i+',0);parent.code.editmode=0;parent.code.draw();">'
2225: +'Delete Resource (cutting links)</A><br>'
2226: +'<A href="javascript:parent.code.notclear=0;parent.code.infoclear();'
2227: +'parent.code.delres('+i+',1);parent.code.editmode=0;parent.code.draw();">'
2228: +'Delete Resource (preserving links)</A><br>');
2229: }
2230: if (data1[3]!='finish') {
2231: parent.mapout.document.writeln(
2232: '<a href="javascript:parent.code.linkmode='+i+
2233: ';parent.code.notclear=0;parent.code.infoclear();">'+
2234: 'Link resource</a>');
2235: }
2236: parent.mapout.document.writeln(
2237: '<br><a href="javascript:'
2238: +'parent.code.setparms('+i+');">Set Parameters</a>');
2239:
2240: parent.mapout.document.writeln('</td></tr>');
2241: parent.mapout.document.writeln('<tr><td colspan=2><table><tr>');
2242: for (j=2;j<data2.length;j++) {
2243: data4=data2[j].split(':');
2244: data3=objlinks[data4[2]].split(':');
2245: if (data3.length>1) {
2246: if (data3[1]==nr) {
2247: cck='#AAAAAA';
2248: if (data3[2]!=0) {
2249: cck=condcolor((objcont[data3[2]].split(':'))[1]);
2250: condid=data3[2];
2251: } else {
2252: condid='-';
2253: }
2254: parent.mapout.document.writeln(
2255: '<td bgcolor='+cck+'>Next<br>');
2256: parent.mapout.document.writeln(
2257: '<a href="javascript:parent.code.handler('+
2258: "'c&"+data4[0]+'&'+i+'&'+data4[2]+'&'+condid+"');"
2259: +'">Edit</a>');
2260: parent.mapout.document.writeln('</td>');
2261: }
2262: }
2263: }
2264: for (j=2;j<data2.length;j++) {
2265: data4=data2[j].split(':');
2266: data3=objlinks[data4[2]].split(':');
2267: if (data3.length>1) {
2268: if ((data3[1]!=nr) && (data3[1]!=0)) {
2269: cck='#AAAAAA';
2270: if (data3[2]!=0) {
2271: cck=condcolor((objcont[data3[2]].split(':'))[1]);
2272: condid=data3[2];
2273: } else {
2274: condid='-';
2275: }
2276: parent.mapout.document.writeln(
2277: '<td bgcolor='+cck+'>To: '+robjs[data3[1]]+'<br>');
2278: parent.mapout.document.writeln(
2279: '<a href="javascript:parent.code.handler('+
2280: "'c&"+data4[0]+'&'+i+'&'+data4[2]+'&'+condid+"');"
2281: +'">Edit</a>');
2282: parent.mapout.document.writeln('</td>');
2283: }
2284: }
2285: }
2286: parent.mapout.document.writeln(
2287: '</tr></table></td></tr></table></form>');
2288: insrestab(rrow[data2[1]],i,nr,data1[3]);
2289:
2290: }
2291: }
2292: }
2293:
2294: // ----------------------------------------------------- Insert Resource Output
2295: function insrestab(irow,be,af,typ) {
2296: parent.mapout.document.writeln('<tr><td colspan=2>'+
2297: '<table><tr><td><a href="javascript:parent.code.insertrow('
2298: +irow+');parent.code.newresource(parent.code.maxrow,'+rcol[1]
2299: +",'','','false','normal');parent.code.mostrecent=parent.code.obj.length-1;"
2300: +'parent.code.draw();">'
2301: +'Insert resource</a></td><td>');
2302: if ((be!=-1) && (typ!='finish')) {
2303: parent.mapout.document.writeln(
2304: '<a href="javascript:parent.code.insertrow('
2305: +irow+');parent.code.newresource(parent.code.maxrow,'+rcol[0]
2306: +",'','','false','normal');parent.code.mostrecent=parent.code.obj.length-1;"
2307: +"parent.code.save();"
2308: +'parent.code.joinres('+be+',parent.code.mostrecent,0);'
2309: +'parent.code.draw();">'
2310: +'Insert resource linked to from above</a><br>');
2311: }
2312: if ((be!=-1) && (af!=-1) && (typ!='finish')) {
2313: parent.mapout.document.writeln(
2314: '<a href="javascript:parent.code.insertrow('
2315: +irow+');parent.code.newresource(parent.code.maxrow,'+rcol[0]
2316: +",'','','false','normal');parent.code.mostrecent=parent.code.obj.length-1;"
2317: +"parent.code.save();"
2318: +'parent.code.joinres('+be+',parent.code.mostrecent,0);'
2319: +"parent.code.save();"
2320: +'parent.code.joinres(parent.code.mostrecent,'+af+',0);'
2321: +'parent.code.draw();">'
2322: +'Insert resource linked to from above and linking to below</a><br>');
2323: }
2324: if (af!=-1) {
2325: parent.mapout.document.writeln(
2326: '<a href="javascript:parent.code.insertrow('
2327: +irow+');parent.code.newresource(parent.code.maxrow,'+rcol[0]
2328: +",'','','false','normal');parent.code.mostrecent=parent.code.obj.length-1;"
2329: +"parent.code.save();"
2330: +'parent.code.joinres(parent.code.mostrecent,'+af+',0);'
2331: +'parent.code.draw();">'
2332: +'Insert resource linking to below</a><br>');
2333: }
2334: parent.mapout.document.writeln('</td></tr></table></tr>');
2335: }
2336:
2337: // ---------------------------------------- Draw simple table instead of graph
2338: function simpletabledraw() {
2339: var objsorted=new Array();
2340: var robjs=new Array();
2341: var iobjs=new Array();
2342: var k;
2343: var i;
2344: var j;
2345: var nr;
2346: var ck;
2347: var cck;
2348: var mime;
2349: var ext;
2350: var url;
2351: var urlparts=new Array;
2352: var condid;
2353: var sortstr=sortobjs();
2354: if ((sortstr!='') && (typeof(sortstr)!="undefined")) {
2355: objsorted=sortstr.split('&');
2356: for (k=0;k<objsorted.length;k++) {
2357: i=(objsorted[k].split(':'))[0];
2358: iobjs[k]=i;
2359: robjs[i]=k;
2360: }
2361: for (k=0;k<iobjs.length;k++) {
2362: i=iobjs[k];
2363: if (k<objsorted.length-1) {
2364: nr=iobjs[k+1];
2365: } else {
2366: nr=-1;
2367: }
2368: data1=objcont[i].split(':');
2369: ck=rescolor(data1[2],data1[3]);
2370: parent.mapout.document.write('<tr><td bgcolor="'+ck+'">');
2371: url=data1[1];
2372: ext=data1[2];
2373: urlparts=url.split('.');
2374: mime=urlparts[urlparts.length-1];
2375: if (typeof(mime)=="undefined") { mime=''; }
2376: if ((mime!='') && (ext!='true')) {
2377: parent.mapout.document.write
2378: ('<a target="preview" align="right" href="'+url+'.meta'+
2379: '"><img src="'+iconpath+'meta.gif"></a><p>'+
2380: '<a target="preview" align="right"href="'+url+
2381: '"><img src="'+iconpath+mime+'.gif"></a><p>');
2382: }
2383: parent.mapout.document.write('<b>'+k+'</b></td><td bgcolor="'+ck+'">');
2384: data2=obj[i].split('&');
2385: parent.mapout.document.write('<table>');
2386:
2387: if (data1[3]=='start') {
2388: parent.mapout.document.writeln('<tr><td><b>Start</b></td></tr>');
2389: }
2390: if (data1[3]=='finish') {
2391: parent.mapout.document.writeln('<tr><td><b>Finish</b></td></tr>');
2392: }
2393: parent.mapout.document.write(
2394: '<tr><td>Title:</td><td>'+data1[0]+'</td></tr>');
2395: parent.mapout.document.write(
2396: '<tr><td>URL:</td><td>'+data1[1]+'</td></tr>'
2397: +'<tr><td colspan=2><table><tr>');
2398: for (j=2;j<data2.length;j++) {
2399: data4=data2[j].split(':');
2400: data3=objlinks[data4[2]].split(':');
2401: if (data3.length>1) {
2402: if (data3[1]==nr) {
2403: cck='#AAAAAA';
2404: if (data3[2]!=0) {
2405: cck=condcolor((objcont[data3[2]].split(':'))[1]);
2406: condid=data3[2];
2407: } else {
2408: condid='-';
2409: }
2410: parent.mapout.document.writeln(
2411: '<td bgcolor='+cck+'>Next<br>');
2412: parent.mapout.document.writeln('</td>');
2413: }
2414: }
2415: }
2416: for (j=2;j<data2.length;j++) {
2417: data4=data2[j].split(':');
2418: data3=objlinks[data4[2]].split(':');
2419: if (data3.length>1) {
2420: if ((data3[1]!=nr) && (data3[1]!=0)) {
2421: cck='#AAAAAA';
2422: if (data3[2]!=0) {
2423: cck=condcolor((objcont[data3[2]].split(':'))[1]);
2424: condid=data3[2];
2425: } else {
2426: condid='-';
2427: }
2428: parent.mapout.document.writeln(
2429: '<td bgcolor='+cck+'>To: '+robjs[data3[1]]+'<br>');
2430: parent.mapout.document.writeln('</td>');
2431: }
2432: }
2433: }
2434: parent.mapout.document.writeln('</tr></table></td></tr></table></tr>');
2435: }
2436: } else {
2437: parent.mapout.document.writeln('<tr><td>No Resources</td></tr>');
2438: }
2439: }
2440:
2441: // ---------------------------------- Sort objects to straighten graph or table
2442: function sortobjs() {
2443: message("Sorting Resources: "+funny);
2444: var k;
2445: var ij;
2446: var dol;
2447: var dtl;
2448: var kj;
2449: var sortthis=0;
2450: var objsort=new Array();
2451: for (k=1;k<objcont.length;k++) {
2452: if (objcont[k]) {
2453: data1=objcont[k].split(':');
2454: if (data1[data1.length-1]=='res') {
2455: objsort[objsort.length]=''+k;
2456: }
2457: }
2458: }
2459: if (objsort.length==0) { return ''; }
2460: for (k=1;k<objlinks.length;k++) {
2461: wheelswitch();
2462: message("Sorting Resources: "+funny);
2463: if ((typeof(objlinks[k])!="undefined") && (objlinks[k]!='')) {
2464: sortthis=1;
2465: data1=objlinks[k].split(':');
2466: kj=-1;
2467: for (j=0;j<objsort.length;j++) {
2468: if ((objsort[j].split(':'))[0]==data1[0]) {
2469: kj=j;
2470: }
2471: }
2472: if (kj!=-1) { objsort[kj]+=':'+data1[1]; }
2473: }
2474: }
2475: if (sortthis!=0) {
2476: for (k=0;k<objsort.length;k++) {
2477: wheelswitch();
2478: message("Sorting Resources: "+funny);
2479: for (j=0;j<objsort.length;j++) {
2480: if (k!=j) {
2481: data1=objsort[k].split(':');
2482: data2=objsort[j].split(':');
2483: dol=data1.length;
2484: dtl=data2.length;
2485: if (dol+dtl<200) {
2486: for (kj=1;kj<dol;kj++) {
2487: if (data1[kj]==data2[0]) {
2488: for (ij=1;ij<dtl;ij++) {
2489: data1[data1.length]=data2[ij];
2490: }
2491: }
2492: }
2493: for (kj=1;kj<dtl;kj++) {
2494: if (data2[kj]==data1[0]) {
2495: for (ij=1;ij<dol;ij++) {
2496: data2[data2.length]=data1[ij];
2497: }
2498: }
2499: }
2500: objsort[k]=data1.join(':');
2501: objsort[j]=data2.join(':');
2502: }
2503: }
2504: }
2505: }
2506: message("Sorting Resources: finishing up.");
2507: return objsort.sort(rescompare).join('&');
2508: } else {
2509: return objsort.join('&');
2510: }
2511: }
2512:
2513: // ----------------------------------------------------------- Straighten graph
2514: function graphopt() {
2515: var k;
2516: var kj;
2517: var ij;
2518: var objsorted=new Array();
2519: condense();
2520: graphreset();
2521: objsorted=(sortobjs()).split('&');
2522: if (objsorted.length==0) { return; }
2523: message("Creating Optimized Graph");
2524: var thisnewobj=''+(objsorted[0].split(':'))[0];
2525: rowcont[1]=thisnewobj;
2526: var thiscolmax=1;
2527: obj[thisnewobj]='b&1&'+thiscolmax+':0:0:0';
2528: var allcolmax=0;
2529: for (k=1;k<objsorted.length;k++) {
2530: thisnewobj=(objsorted[k].split(':'))[0];
2531: if (rescompare(objsorted[k-1],objsorted[k])==0) {
2532: rowcont[rowcont.length-1]+=':'+thisnewobj;
2533: thiscolmax++;
2534: } else {
2535: rowcont[rowcont.length]=thisnewobj;
2536: thiscolmax=1;
2537: }
2538: kj=rowcont.length-1;
2539: obj[thisnewobj]='b&'+kj+'&'+thiscolmax+':0:0:0';
2540: if (thiscolmax>allcolmax) { allcolmax=thiscolmax; }
2541: }
2542: for (k=0;k<obj.length;k++) {
2543: if (!obj[k]) { obj[k]=''; }
2544: }
2545: for (k=0;k<=allcolmax;k++) { insertcol(0); }
2546: for (k=0;k<rowcont.length;k++) {
2547: row[k]=k;
2548: }
2549: maxrow=rowcont.length-1;
2550: var oldlinks=new Array();
2551: for (k=0;k<objlinks.length;k++) {
2552: oldlinks[k]=objlinks[k];
2553: objlinks[k]='';
2554: }
2555: objlinks.length=0;
2556: objlinks[0]='';
2557: graphdef='yes';
2558: save();
2559:
2560: for (k=0;k<objsorted.length;k++) {
2561: wheelswitch();
2562: message("Connecting Resources: "+funny);
2563: kj=(objsorted[k].split(':'))[0];
2564: for (ij=1;ij<oldlinks.length;ij++) {
2565: if (oldlinks[ij]) {
2566: data1=oldlinks[ij].split(':');
2567: if (data1[0]==kj) {
2568: joinres(data1[0],data1[1],data1[2]);
2569: save();
2570: }
2571: }
2572: }
2573: }
2574: }
2575:
2576: // ----------------------------------------------------------- Remove e-objects
2577: function condense() {
2578: message("Condensing");
2579: var j;
2580: for (j=0;j<=maxrow;j++) {
2581: if ((rowcont[j]!='') && (typeof(rowcont[j])!="undefined")) {
2582: data1=rowcont[j].split(':');
2583: rowcont[j]='';
2584: for (k=0;k<data1.length;k++) {
2585: if (obj[data1[k]].substring(0,2)!='e&') {
2586: if ((rowcont[j]!='') && (typeof(rowcont[j])!="undefined")) {
2587: rowcont[j]+=':';
2588: }
2589: rowcont[j]+=data1[k];
2590: }
2591: }
2592: }
2593: }
2594: }
2595:
2596: // ---------------------------------------------------- Load from hidden fields
2597: function load() {
2598: message("Loading");
2599: schedule('load');
2600: }
2601:
2602: function finishload() {
2603: var k;
2604: for (k=0;k<objcont.length;k++) { objcont[k]=''; }
2605: objcont.length=0;
2606: for (k=0;k<objlinks.length;k++) { objlinks[k]=''; }
2607: objlinks.length=0;
2608: for (k=0;k<objparms.length;k++) { objparms[k]=''; }
2609: objparms.length=0;
2610: objlinks[0]='';
2611: objcont[0]='';
2612: editmode=0;
2613: notclear=0;
2614: lastinfo='';
2615: graphreset();
2616: var inputstr=parent.server.document.forms.storage.output.value;
2617: if ((inputstr!='') && (typeof(inputstr)!="undefined")) {
2618: data1=inputstr.split('<&>');
2619: var k;
2620: for (k=0;k<data1.length;k++) {
2621: data2=data1[k].split(':').join(':').split('<:>');
2622: if (data2[0]=='graphdef') { graphdef=data2[1]; }
2623: if (data2[0]=='maxcol') { maxcol=1*data2[1]; }
2624: if (data2[0]=='maxrow') { maxrow=1*data2[1]; }
2625: if (data2[0]=='obj') { obj[data2[1]]=data2[2]; }
2626: if (data2[0]=='objcont') { objcont[data2[1]]=data2[2]; }
2627: if (data2[0]=='objlinks') { objlinks[data2[1]]=data2[2]; }
2628: if (data2[0]=='objparms') {
2629: if (typeof(objparms[data2[1]])=="undefined") {
2630: objparms[data2[1]]=data2[2];
2631: } else {
2632: if (objparms[data2[2]]=='') {
2633: objparms[data2[1]]=data2[2];
2634: } else {
2635: objparms[data2[1]]+=':'+data2[2];
2636: }
2637: }
2638: }
2639: if (data2[0]=='rowcont') { rowcont[data2[1]]=data2[2]; }
2640: if (data2[0]=='row') { row[data2[1]]=1*data2[2]; }
2641: if (data2[0]=='col') { col[data2[1]]=1*data2[2]; }
2642: if (data2[0]=='mode') { mode=data2[1]; }
2643: if (data2[0]=='tablemode') { tablemode=1*data2[1]; }
2644: if (data2[0]=='zscale') { zscale=1*data2[1]; }
2645: }
2646: }
2647: if (graphdef=='yes') {
2648: for (k=1;k<=maxrow;k++) {
2649: if (typeof(rowcont[k])=="undefined") { rowcont[k]=''; }
2650: }
2651: } else {
2652: var hasstart=0;
2653: var hasfinish=0;
2654: for (k=0;k<objcont.length;k++) {
2655: if (typeof(objcont[k])!="undefined") {
2656: var objfunctype=(objcont[k].split(':'))[3];
2657: if (objfunctype=='start') { hasstart=1; }
2658: if (objfunctype=='finish') { hasfinish=1; }
2659: }
2660: }
2661: if (!hasstart) {
2662: if ((typeof(objcont[1])=="undefined") || (objcont[1]=='')) {
2663: objcont[1]='Start::false:start:res';
2664: }
2665: }
2666: if (!hasfinish) {
2667: if ((typeof(objcont[2])=="undefined") || (objcont[2]=='')) {
2668: objcont[2]='Finish::false:finish:res';
2669: }
2670: }
2671: }
2672: }
2673:
2674: // -------------------------------------------------------------- Parameter set
2675: function setparms(resid) {
2676: var options="scrollbars=1,resizable=1,menubar=0";
2677: parmflag=1;
2678: data1=objcont[resid].split(':');
2679: parm=open("/adm/ratparms?url="+data1[1]+"&parms="+objparms[resid]+
2680: "&resid="+resid,"parmout",options);
2681: parm.focus();
2682: }
2683:
2684: // -------------------------------------------------------------- Undo function
2685: function undo() {
2686: if (undopointer>1) {
2687: undopointer--;
2688: parent.server.document.forms.storage.output.value
2689: =undostack[undopointer];
2690: finishload();
2691: undopointer--;
2692: draw();
2693: stored=0;
2694: } else {
2695: alert("Cannot undo: reached beginning of edit session");
2696: }
2697: }
2698:
2699: // -------------------------------------------------------------- Redo function
2700: function redo() {
2701: if (undopointer<undostack.length-1) {
2702: undopointer++;
2703: parent.server.document.forms.storage.output.value
2704: =undostack[undopointer];
2705: finishload();
2706: undopointer--;
2707: draw();
2708: stored=0;
2709: } else {
2710: alert("Cannot redo: reached end of edit session");
2711: }
2712: }
2713:
2714: // ------------------------------------------------------------ Revert function
2715: function revert() {
2716: if (confirm("Revert to beginning of edit session?")) {
2717: undopointer=2;
2718: undo();
2719: }
2720: }
2721:
2722: // ---------------------------------------------------------------- Wheelswitch
2723: function wheelswitch() {
2724: if (funny=='|') {
2725: funny='/';
2726: } else {
2727: if (funny=='/') {
2728: funny='-';
2729: } else {
2730: if (funny=='-') {
2731: funny='\\';
2732: } else {
2733: if (funny=='\\') { funny='|'; }
2734: }
2735: }
2736: }
2737: }
2738:
2739: // --------------------------------------------- Checks if server frame defined
2740: function checkdef() {
2741: if (parent.flag==1) {
2742: srvloaded();
2743: }
2744: if ((finishdone==0) && (tim==0)) { setTimeout('checkdef()',100); }
2745: }
2746:
2747: // ---------------------------------------------------------- The wait function
2748: function wait() {
2749: if ((finishdone==1) || (tim==1)) {
2750: if (tim==0) {
2751: clearTimeout(canceltim);
2752: if (reqaction=='save') { finishsave(); }
2753: if (reqaction=='load') { finishload(); draw(); }
2754: } else {
2755: alert("Server Communication Timed Out.");
2756: }
2757: } else {
2758: wheelswitch();
2759: message('Waiting for server reply: '+funny);
2760: setTimeout('wait();',100);
2761: }
2762: }
2763:
2764: // ---------------------------------------------------------- Schedule function
2765: function schedule(action) {
2766: reqaction=action;
2767: tim=0;
2768: finishdone=0;
2769: canceltim=setTimeout('tim=1;',20000);
2770: checkdef();
2771: wait();
2772: }
2773:
2774: // ----------------------------------------------------- launch indexer browser
2775: function groupsearch() {
1.5 www 2776: srchcheck('import');
1.1 raeburn 2777: }
2778:
2779: function groupimport() {
1.5 www 2780: idxcheck('import');
1.1 raeburn 2781: }
2782:
2783: function groupcopy() {
1.5 www 2784: copydxcheck('import');
1.1 raeburn 2785: }
2786:
2787: // -------------------------------------------------------------- Store changes
2788: function storechange() {
2789: var k;
2790: parent.flag=0;
2791: parent.server.document.forms.storage.submit();
2792: schedule('save');
2793: }
2794:
2795: function finishsave() {
2796: finishload();
2797: draw();
2798: stored=1;
2799: }
2800:
2801: // --------------------------------------- Gets called when submission finished
2802: function srvloaded() {
2803: finishdone=1;
2804: message("Server replied.");
2805: }
2806:
2807: // ---------------------------------------------------------------- Toggle Mode
2808: function togglemode() {
2809: if (tablemode==0) {
2810: tablemode=1;
2811: } else {
2812: if (tablemode==1) {
2813: tablemode=2;
2814: } else {
2815: tablemode=0;
2816: }
2817: }
2818: notclear=0;
2819: infoclear();
2820: draw();
2821: }
2822:
2823: // -------------------------------------------------------- Main program onLoad
2824: function main() {
2825: if (mainrun==0) {
2826: infopen();
2827: infoclear();
2828: load();
2829: stored=1;
2830: mainrun=1;
2831: }
2832: }
2833:
2834: // ---------------------------------------------------------- Close the window?
2835: function leave() {
2836: if (!inf.closed) {
2837: inf.close();
2838: }
2839: if (srch && !srch.closed) {
2840: srchclose();
2841: }
2842: if (idx && !idx.closed) {
2843: idxclose();
2844: }
2845: if (copydx && !copydx.closed) {
2846: copydxclose();
2847: }
2848: }
2849:
2850: </script>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>