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