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