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