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