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