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