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