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