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