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