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