Annotation of rat/client/code.html, revision 1.2
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,
! 11: 5/2,5/3,5/4 Gerd Kortemeyer with Scott Harrison
1.1 www 12: -->
13:
14:
15: <head>
16: <script language="JavaScript">
17:
18: var row=new Array();
19: var maxrow=-1;
20: var col=new Array();
21: var maxcol=-1;
22: var colmap=new Array();
23: var colmap2=new Array();
24: var colmap3=new Array();
25: var colmap4=new Array();
26: var colmap5=new Array();
27: var colmap6=new Array();
28: var obj=new Array();
29: var objcont=new Array();
30: var objlinks=new Array();
31: var rowcont=new Array();
32: var rowtype=new Array();
33: var coltype=new Array();
34: var rcol=new Array();
35: var rrow=new Array();
36: var cw=new Array();
37: var rh=new Array();
38:
1.2 ! www 39: var undostack=new Array();
! 40: var undopointer=0;
! 41: var stored=0;
1.1 www 42: var editmode=0;
43: var notclear=0;
44: var linkmode=0;
45: var lastinfo='';
46: var graphdef='no';
47: var mainrun=0;
1.2 ! www 48: var tablemode=0;
1.1 www 49:
50: var data1=new Array(1024);
51: var data2=new Array(1024);
52: var data3=new Array(1024);
53: var data4=new Array(1024);
54: var data5=new Array(1024);
55:
56:
57: // ------------------------------------------------ Insert a row into the table
58:
59: function insertrow(j,ex1,ex2) {
60: var kj;
1.2 ! www 61: stored=0;
1.1 www 62: objects1='';
63: objects2='';
64: for (kj=0;kj<=maxrow;kj++) {
65: if ( row[kj]==j ) { objects1=rowcont[kj]; }
66: if ( row[kj]==j+1 ) { objects2=rowcont[kj]; }
67: if ( row[kj]>j ) { row[kj]++; }
68: }
69: maxrow++;
70: row[maxrow]=j+1;
71: rowcont[maxrow]=':';
72: colcover=':'+ex1+':'+ex2+':';
73: objects=objects1+':'+objects2;
74: data1=objects.split(':');
75: for (kj=0;kj<data1.length;kj++) {
76: if (data1[kj]!='') {
77: thisisobj=obj[data1[kj]];
78: thisobjtype=thisisobj.split('&')[0];
79: if (thisobjtype=='v') {
80: if (rowcont[maxrow].indexOf(':'+data1[kj]+':',0)==-1) {
81: thisobjcol=thisisobj.split('&')[1];
82: if (colcover.indexOf(':'+thisobjcol+':',0)==-1) {
83: colcover+=thisobjcol+':';
84: rowcont[maxrow]+=data1[kj]+':';
85: }
86: }
87: }
88: if (thisobjtype=='h') {
89: updown=thisisobj.split('&')[4];
90: leftupdown=updown.split(':')[0];
91: rightupdown=updown.split(':')[1];
92: thisobjdest=thisisobj.split('&')[3];
93: thisobjtofrom=thisisobj.split('&')[2];
94: thisobjfrom=thisobjtofrom.split(':')[0];
95: thisobjto=thisobjtofrom.split(':')[1];
96: thisobjdir=col[thisobjto]-col[thisobjfrom];
97: thisobjrow=row[thisisobj.split('&')[1]];
98: topbottom=thisobjrow-j-1;
99: newobj='';
100: if (leftupdown==-1) {
101: if (topbottom<0) {
102: if (thisobjdir<0) {
103: newobj='v&'+thisobjto+'&'+thisobjdest+'&-1';
104: } else {
105: newobj='v&'+thisobjfrom+'&'+thisobjdest+'&1';
106: }
107: }
108: } else {
109: if (topbottom>0) {
110: if (thisobjdir<0) {
111: newobj='v&'+thisobjto+'&'+thisobjdest+'&1';
112: } else {
113: newobj='v&'+thisobjfrom+'&'+thisobjdest+'&-1';
114: }
115: }
116: }
117: if (newobj!='') {
118: thisobjcol=newobj.split('&')[1];
119: if (colcover.indexOf(':'+thisobjcol+':',0)==-1) {
120: colcover+=thisobjcol+':';
121: rowcont[maxrow]+=obj.length+':';
122: obj[obj.length]=newobj;
123: }
124: }
125: newobj='';
126: if (rightupdown==-1) {
127: if (topbottom<0) {
128: if (thisobjdir<0) {
129: newobj='v&'+thisobjfrom+'&'+thisobjdest+'&1';
130: } else {
131: newobj='v&'+thisobjto+'&'+thisobjdest+'&-1';
132: }
133: }
134: } else {
135: if (topbottom>0) {
136: if (thisobjdir<0) {
137: newobj='v&'+thisobjfrom+'&'+thisobjdest+'&-1';
138: } else {
139: newobj='v&'+thisobjto+'&'+thisobjdest+'&1';
140: }
141: }
142: }
143: if (newobj!='') {
144: thisobjcol=newobj.split('&')[1];
145: if (colcover.indexOf(':'+thisobjcol+':',0)==-1) {
146: colcover+=thisobjcol+':';
147: rowcont[maxrow]+=obj.length+':';
148: obj[obj.length]=newobj;
149: }
150: }
151: }
152: }
153: }
154: if (rowcont[maxrow]!=':') {
155: rowcont[maxrow]=rowcont[maxrow].substring(1,rowcont[maxrow].length-1);
156: } else {
157: rowcont[maxrow]='';
158: }
159: }
160:
161: // --------------------------------------------- Creates a new condition object
162:
163: function newcondition(content,type) {
164: var ko;
1.2 ! www 165: stored=0;
1.1 www 166: ko=obj.length;
167: obj[ko]='c';
168: objcont[ko]=content+':'+type+':cond';
169: return ko;
170: }
171:
172: // ---------------------------------------------- Creates a new resource object
173:
174: function newresource(rid,cid,text,url) {
1.2 ! www 175: stored=0;
1.1 www 176: objcont[addobj(rid,'b&'+rid+'&'+cid+':0:0:0')]=text+':'+url+':res';
177: }
178:
179:
180: // -------------------------------- Insert a condition into a port of an object
181:
182: function insertcond(obj1,portnr,cond) {
183: var k;
1.2 ! www 184: stored=0;
1.1 www 185: data1=obj[obj1].split('&');
186: for (k=2;k<data1.length;k++) {
187: data2=data1[k].split(':');
188: if (data2[0]==portnr) {
189: data2[3]=cond;
190: data1[k]=data2.join(':');
191: }
192: }
193: obj[obj1]=data1.join('&');
194: }
195:
196: // --------------------------------------------- Insert a column into the table
197: // Inserts a new table column after table column j
198:
199: function insertcol(j) {
200: var kj;
1.2 ! www 201: stored=0;
1.1 www 202: for (kj=0;kj<=maxcol;kj++) {
203: if ( col[kj]>j ) { col[kj]++; }
204: }
205: maxcol++;
206: col[maxcol]=j+1;
207: }
208:
209: // --------------------------------------------------------------- Find the row
210:
211: function findrow(jid) {
212: var j;
213: for (j=0;j<=maxrow;j++) { if (row[j]==jid) { return j; } }
214: return -1;
215: }
216:
217: // --------------------------------------------------------------- Find the col
218:
219: function findcol(jid) {
220: var j;
221: for (j=0;j<=maxcol;j++) { if (col[j]==jid) { return j; } }
222: return -1;
223: }
224:
225: // -------------------------------------------------------------- Map out a row
226: //
227: // b&rowID&colID:inObj:outObj:outCond&...
228: // h&rowID&incolID:outcolID&inObj:outObj&inupdown:outupdown
229: // v&colID&inObj:outObj&updown
230: //
231: // returns middle (col number of middle of obj1)
232: // sets colmap (map of cols with object numbers)
233:
234: function maprow (jid,obj1,ign) {
235: var j; var k; var left; var right; var middle;
236: middle=-1;
237: for (j=0;j<=maxcol;j++) { colmap[j]=0; }
238: if (rowcont[jid]!='') {
239: data2=rowcont[jid].split(':');
240: for (j=0;j<data2.length;j++) {
241: data3=obj[data2[j]].split('&');
242: if (data3[0]=='b') {
243: left=maxcol;
244: right=0;
245: for (k=2;k<data3.length;k++) {
246: thiscol=col[data3[k].split(':')[0]];
247: if (thiscol<left) { left=thiscol; }
248: if (thiscol>right) { right=thiscol; }
249: }
250: }
251: if (data3[0]=='h') {
252: data4=data3[2].split(':');
253: if (col[data4[1]]>col[data4[0]]) {
254: left=col[data4[0]];
255: right=col[data4[1]];
256: } else {
257: right=col[data4[0]];
258: left=col[data4[1]];
259: }
260: }
261: if (data3[0]=='v') { left=col[data3[1]]; right=left; }
262: if (data2[j]==obj1) { middle=Math.round((left+right)/2); }
263: if ((data3[0]!='h') || (ign!=1)) {
264: for (k=left;k<=right;k++) { colmap[k]=data2[j]; }
265: } else {
266: colmap[left]=data2[j];
267: colmap[right]=data2[j];
268: }
269: }
270: }
271: return middle;
272: }
273:
274: // --------------------------------------------------------- Find hole in a row
275: // jid: rowID
276: // kid: colID, find point close to this
277: // dkid: destination colID
278: // returns colID
279:
280: function comingthru (jid,kid,dkid) {
281: var k;
282: maprow(jid,-1,1);
283: knum=col[kid];
284: if (colmap[knum]==0) { return kid; }
285: right=-1;
286: for (k=knum+1;(k<colmap.length) && (right==-1);k++) {
287: if ((right==-1) && (colmap[k]!=colmap[knum])) { right=k; }
288: }
289: left=-1;
290: for (k=knum-1;(k>=0) && (left==-1);k--) {
291: if ((left==-1) && (colmap[k]!=colmap[knum])) { left=k; }
292: }
293: kup=-1;
294:
295: if ((left==-1) && (right==-1)) { right=colmap.length; }
296:
297: dknum=col[dkid];
298: dleft=left-dknum;
299: dright=right-dknum;
300:
301: if (dleft<0) { dleft=-dleft; }
302: if (dright<0) { dright=-dright; }
303: if ((dright<=dleft) && (right!=-1)) { kup=right; }
304: if ((dright>=dleft) && (left!=-1)) { kup=left; }
305: if (colmap[kup]==0) { return findcol(kup); }
306:
307: if (kup==right) { kup--; }
308:
309: if (kup<0) {
310: insertcol(-1);
311: insertcol(0);
312: } else {
313: insertcol(kup);
314: }
315: return maxcol;
316: }
317:
318: // ----------------------------------------------------- Insert port into block
319: // obj1: object number
320: // d: direction from middle (>0: right, <0 left)
321: // inout: in or out port (1: in, 2: out)
322: // linkobj: object that the link goes to/comes from
323: // sets inrow or outrow
324: // return column
325:
326:
327: function insertport (obj1,d,inout,linkobj) {
328:
329:
330: var k; var port; var revport;
1.2 ! www 331: stored=0;
1.1 www 332: data1=obj[obj1].split('&');
333: middle=maprow(data1[1],obj1,0);
334: if (inout==1) {
335: inrow=data1[1];
336: } else {
337: outrow=data1[1];
338: }
339: if (d>0) {
340: for (k=middle;(colmap[k]==obj1) && (k<colmap.length);k++) { data3[k]=0; }
341: } else {
342: for (k=middle;(colmap[k]==obj1) && (k>=0);k--) { data3[k]=0; }
343: }
344: for (k=2;k<data1.length;k++) {
345: data2=data1[k].split(':');
346: data3[col[data2[0]]]=data2[inout];
347: }
348: port=-1;
349: if (d>0) {
350: for (k=middle;(colmap[k]==obj1) && (k<colmap.length);k++) {
351: if ((data3[k]==0) && (colmap[k]==obj1) && (port==-1)) { port=k; }
352: }
353: } else {
354: for (k=middle;(colmap[k]==obj1) && (k>=0);k--) {
355: if ((data3[k]==0) && (colmap[k]==obj1) && (port==-1)) { port=k; }
356: }
357: }
358:
359: if (port==-1) {
360: if (colmap[k]==0) {
361: revport=findcol(k);
362: if (inout==1) {
363: data1[data1.length]=revport+":"+linkobj+":0:0";
364: } else {
365: data1[data1.length]=revport+":0:"+linkobj+":0";
366: }
367: } else {
368: if (d>0) {
369: insertcol(k-1);
370: } else {
371: insertcol(k);
372: }
373: revport=maxcol;
374: if (inout==1) {
375: data1[data1.length]=revport+":"+linkobj+":0:0";
376: } else {
377: data1[data1.length]=revport+":0:"+linkobj+":0";
378: }
379: }
380: } else {
381: portfound=-1;
382: for (k=2;k<data1.length;k++) {
383: data2=data1[k].split(':');
384: if (col[data2[0]]==port) {
385: data2[inout]=linkobj;
386: data1[k]=data2.join(':');
387: portfound=1;
388: }
389: }
390: revport=findcol(port);
391: if (portfound==-1) {
392: if (inout==1) {
393: data1[data1.length]=revport+":"+linkobj+":0:0";
394: } else {
395: data1[data1.length]=revport+":0:"+linkobj+":0";
396: }
397: }
398: }
399: obj[obj1]=data1.join('&');
400: return revport;
401: }
402:
403: // ---------------------------- Make a new object and add it to the row content
404: // returns object number of generated object
405:
406: function addobj(kjid,objs) {
1.2 ! www 407: stored=0;
1.1 www 408: if (rowcont[kjid]!='') { rowcont[kjid]+=':'; }
409: rowcont[kjid]+=obj.length;
410: obj[obj.length]=objs;
411: return obj.length-1;
412: }
413:
414: // ---------------------------------------- Make horizontal connection for hrid
415: // hoffs=-1: this line goes on top of hrid
416:
417: function horizontal(hrid,hoffs,hfcol,htcol,hdest,hends) {
418: hcrid=-1;
419: if (hoffs==-1) {
420: hbrid=findrow(row[hrid]-1);
421: } else {
422: hbrid=findrow(row[hrid]+1);
423: }
424: if (hbrid!=-1) {
425: maprow(hbrid,-1,0);
426: hcrid=hbrid;
427: if (col[hfcol]>col[htcol]) { left=col[htcol]; right=col[hfcol]; }
428: else { right=col[htcol]; left=col[hfcol]; }
429: if (colmap[left]!=0) {
430: hcrid=-1;
431: } else {
432: if (colmap[right]!=0) {
433: hcrid=-1;
434: } else {
435: for (kh=left+1;kh<right;kh++) {
436: if (colmap[kh]!=0) {
437: if (obj[colmap[kh]].split('&')[0]!='v') { hcrid=-1; }
438: }
439: }
440: }
441: }
442: }
443:
444: if (hcrid==-1) {
445: insertrow(row[hrid]+hoffs,hfcol,htcol);
446: addobj(maxrow,'h&'+maxrow+'&'+hfcol+':'+htcol+'&'+hdest+'&'+hends);
447: } else {
448: addobj(hcrid,'h&'+hcrid+'&'+hfcol+':'+htcol+'&'+hdest+'&'+hends);
449: }
450: }
451:
452: // --------------------------------------- Deletes all references to object obj
453:
454: function delobj(obj1) {
455: var k;
1.2 ! www 456: stored=0;
1.1 www 457: for (k=0;k<rowcont.length;k++) {
458: data4=rowcont[k].split(':');
459: rowcont[k]='';
460: for (k2=0;k2<data4.length;k2++) {
461: if (data4[k2]!=obj1) {
462: if (rowcont[k]!='') { rowcont[k]+=':'; }
463: rowcont[k]+=data4[k2];
464: }
465: }
466: }
467: }
468:
469: // --------------------------------------------------------- Garbage collection
470:
471: function cleanup () {
472: var j,kj,i;
473: insertrow(maxrow);
474: insertcol(maxcol);
475: addobj(maxrow,'e&'+maxcol);
476: for (kj=0;kj<=maxcol;kj++) { data1[kj]=0; }
477: for (kj=0;kj<=maxrow;kj++) {
478: rowtype[kj]=0;
479: if (rowcont[kj]!='') {
480: data2=rowcont[kj].split(':');
481: for (j=0;j<data2.length;j++) {
482: if (obj[data2[j]].substring(0,2)=='e&') {
483: rowtype[kj]=2;
484: data1[(obj[data2[j]].split('&'))[1]]=2;
485: }
486: }
487: maprow(kj,-1,1);
488: for (j=0;j<=maxcol;j++) {
489: if (colmap[j]!=0) {
490: if (data1[j]==0) { data1[j]=1; }
491: if (rowtype[kj]==0) {
492: if (obj[colmap[j]].substring(0,2)!='v&') {
493: rowtype[kj]=1;
494: }
495: }
496: if (obj[colmap[j]].substring(0,2)=='b&') {
497: data1[j]=2;
498: rowtype[kj]=2;
499: }
500: }
501: }
502: }
503: }
504: for (j=0;j<=maxcol;j++) {
505: coltype[j]=data1[col[j]];
506: }
507: }
508:
509: // -------------------------------------------- Delete a condition from a block
510:
511: function delcond(obj1,colid) {
512: var k;
1.2 ! www 513: stored=0;
1.1 www 514: data3=obj[obj1].split('&');
515: obj[obj1]=data3[0]+'&'+data3[1];
516: for (k=2;k<data3.length;k++) {
517: data4=data3[k].split(':');
518: if (data4[0]==colid) { data4[3]=0; }
519: if ((data4[1]!=0) || (data4[2]!=0) || (data3.length==3)) {
520: obj[obj1]+='&'+data4[0]+':'+data4[1]+':'+data4[2]+':'+data4[3];
521: }
522: }
523: }
524:
525: // ----------------------------------------- Creates a new condition in a block
526:
527: function crecond(obj1,colid,condtext,condtype) {
528: var k;
529: data3=obj[obj1].split('&');
530: obj[obj1]=data3[0]+'&'+data3[1];
531: for (k=2;k<data3.length;k++) {
532: data4=data3[k].split(':');
533: if (data4[0]==colid) {
534: data4[3]=newcondition(condtext,condtype);
535: data2=objlinks[data4[2]].split(':');
536: objlinks[data4[2]]=data2[0]+':'+data2[1]+':'+data4[3];
537: }
538: if ((data4[1]!=0) || (data4[2]!=0) || (data3.length==3)) {
539: obj[obj1]+='&'+data4[0]+':'+data4[1]+':'+data4[2]+':'+data4[3];
540: }
541: }
542: }
543:
544: // ---------------------------------------- Delete the path between two objects
545: // deletes the link linknr
546: // h&rowID&incolID:outcolID&inObj:outObj&inupdown:outupdown
547: // v&colID&inObj:outObj&updown
548:
549: function dellink (linknr) {
550: var k; var obj1; var obj2;
1.2 ! www 551: stored=0;
1.1 www 552: if (objlinks[linknr]!='') {
553: data3=objlinks[linknr].split(':');
554: obj1=data3[0];
555: obj2=data3[1];
556: data3=obj[obj1].split('&');
557: obj[obj1]=data3[0]+'&'+data3[1];
558: for (k=2;k<data3.length;k++) {
559: data4=data3[k].split(':');
560: if (data4[2]==linknr) { data4[2]=0; data4[3]==0; }
561: if ((data4[1]!=0) || (data4[2]!=0) || (data3.length==3)) {
562: obj[obj1]+='&'+data4[0]+':'+data4[1]+':'+data4[2]+':'+data4[3];
563: }
564: }
565: data3=obj[obj2].split('&');
566: obj[obj2]=data3[0]+'&'+data3[1];
567: for (k=2;k<data3.length;k++) {
568: data4=data3[k].split(':');
569: if (data4[1]==linknr) { data4[1]=0; }
570: if ((data4[1]!=0) || (data4[2]!=0) || (data3.length==3)) {
571: obj[obj2]+='&'+data4[0]+':'+data4[1]+':'+data4[2]+':'+data4[3];
572: }
573: }
574: for (k=0;k<obj.length;k++) {
575: if (obj[k]!='') {
576: data3=obj[k].split('&');
577: if (((data3[0]=='v') || (data3[0]=='h')) &&
578: (data3[data3.length-2]==linknr)) {
579: delobj(k);
580: }
581: }
582: }
583: objlinks[linknr]='';
584: }
585: }
586:
587: // ----------------------------------------------------------- Join two objects
588: // Links obj1 with obj2, creates new objlink, marks all elements with number
589:
590: function joinres (obj1,obj2,cond) {
591: var k; var kr; var outcol; var incol; var d;
1.2 ! www 592: stored=0;
1.1 www 593: dest=objlinks.length;
594: objlinks[dest]=obj1+':'+obj2+':'+cond;
595: data3=obj[obj1].split('&');
596: sum=0;
597: for (k=2;k<data3.length;k++) { sum+=col[data3[k].split(':')[0]]; }
598: outmiddle=sum/(data3.length-2);
599: data3=obj[obj2].split('&');
600: sum=0;
601: for (k=2;k<data3.length;k++) { sum+=col[data3[k].split(':')[0]]; }
602: inmiddle=sum/(data3.length-2);
603: d=inmiddle-outmiddle;
604: outcol=insertport(obj1,d,2,dest);
605: insertcond(obj1,outcol,cond);
606: incol=insertport(obj2,-d,1,dest);
607: if (row[inrow]==(row[outrow]+1)) {
608: insertrow(row[outrow],-1,-1);
609: }
610: if (row[inrow]<row[outrow]) {
611: updown=1;
612: tcol=comingthru(inrow,incol,outcol);
613: horizontal(inrow,-1,tcol,incol,dest,'-1:-1');
614: addobj(inrow,'v&'+tcol+'&'+dest+'&1');
615: incol=tcol;
616: tcol=comingthru(outrow,outcol,incol);
617: horizontal(outrow,0,outcol,tcol,dest,'1:1');
618: addobj(outrow,'v&'+tcol+'&'+dest+'&1');
619: outcol=tcol;
620: } else {
621: updown=-1;
622: }
623:
624: if (inrow==outrow) {
625: tcol=comingthru(inrow,incol,outcol);
626: horizontal(inrow,-1,tcol,incol,dest,'-1:-1');
627: addobj(inrow,'v&'+tcol+'&'+dest+'&1');
628: horizontal(outrow,0,outcol,tcol,dest,'1:1');
629: } else {
630:
631: if (updown==-1) {
632: for (kr=row[outrow]+1;kr<row[inrow];kr++) {
633: rid=findrow(kr);
634: ncol=comingthru(rid,outcol,incol);
635:
636: if (ncol!=outcol) {
637: insertrow(kr-1,outcol,ncol);
638: kr++;
639: if (col[outcol]>col[ncol]) {
640: addobj(maxrow,
641: 'h&'+maxrow+'&'+outcol+':'+ncol+'&'+dest+'&-1:1');
642: } else {
643: addobj(maxrow,
644: 'h&'+maxrow+'&'+outcol+':'+ncol+'&'+dest+'&1:-1');
645: }
646: }
647: addobj(rid,'v&'+ncol+'&'+dest+'&-1');
648: outcol=ncol;
649: }
650:
651: if (incol!=outcol) {
652: insertrow(row[inrow]-1,outcol,incol);
653: if (col[outcol]>col[incol]) {
654: addobj(maxrow,
655: 'h&'+maxrow+'&'+outcol+':'+incol+'&'+dest+'&-1:1');
656: } else {
657: addobj(maxrow,
658: 'h&'+maxrow+'&'+outcol+':'+incol+'&'+dest+'&1:-1');
659: }
660: }
661:
662: } else {
663: for (kr=row[outrow]-1;kr>row[inrow];kr--) {
664: rid=findrow(kr);
665: ncol=comingthru(rid,outcol,incol);
666: if (ncol!=outcol) {
667: insertrow(kr,outcol,ncol);
668: if (col[outcol]>col[ncol]) {
669: addobj(maxrow,
670: 'h&'+maxrow+'&'+outcol+':'+ncol+'&'+dest+'&1:-1');
671: } else {
672: addobj(maxrow,
673: 'h&'+maxrow+'&'+outcol+':'+ncol+'&'+dest+'&-1:1');
674: }
675: }
676: addobj(rid,'v&'+ncol+'&'+dest+'&1');
677: outcol=ncol;
678: }
679: if (incol!=outcol) {
680: insertrow(row[inrow],outcol,incol);
681: if (col[outcol]>col[incol]) {
682: addobj(maxrow,
683: 'h&'+maxrow+'&'+outcol+':'+incol+'&'+dest+'&1:-1');
684: } else {
685: addobj(maxrow,
686: 'h&'+maxrow+'&'+outcol+':'+incol+'&'+dest+'&-1:1');
687: }
688: }
689: }
690: }
691: }
692:
693: // ---------------------------------------------------------- Delete a resource
694: // Deletes resource obj1
695: // Reconnects resources going thru this one if recon=1
696:
697: function delres (obj1,recon) {
698: var infromobj=new Array();
699: var inwithcon=new Array();
700: var inwithlink=new Array();
701: var outtoobj=new Array();
702: var outwithcon=new Array();
703: var outwithlink=new Array();
704: var inobjs=new Array();
705: var inobjscond=new Array();
706: var outobjs=new Array();
707: var outobjscond=new Array();
708:
709: var k; var k1; var k2; var found;
710:
1.2 ! www 711: stored=0;
! 712:
1.1 www 713: data1=obj[obj1].split('&');
714: for (k=2;k<data1.length;k++) {
715: data2=data1[k].split(':');
716: if (data2[1]!=0) {
717: k2=inwithlink.length;
718: inwithlink[k2]=data2[1];
719: data3=objlinks[data2[1]].split(':');
720: infromobj[k2]=data3[0];
721: inwithcon[k2]=data3[2];
722: }
723: if (data2[2]!=0) {
724: k2=outwithlink.length;
725: outwithlink[k2]=data2[2];
726: data3=objlinks[data2[2]].split(':');
727: outtoobj[k2]=data3[1];
728: outwithcon[k2]=data3[2];
729: }
730: }
731: for (k=0;k<inwithlink.length;k++) { dellink(inwithlink[k]); }
732: for (k=0;k<outwithlink.length;k++) { dellink(outwithlink[k]); }
733: delobj(obj1);
734: if (recon==1) {
735:
736: for (k=0;k<inwithlink.length;k++) {
737: if (infromobj[k]!=obj1) {
738: found=0;
739: for (k2=0;k2<inobjs.length;k2++) {
740: if (inobjs[k2]==infromobj[k]) {
741: if (inwithcon[k]!=0) {
742: if (inobjscond[k2]!='') { inobjscond[k2]+='||'; }
743: inobjscond[k2]+=
744: '('+(objcont[inwithcon[k]].split(':'))[0]+')';
745: }
746: found=1;
747: }
748: }
749: if (found==0) {
750: k2=inobjs.length;
751: inobjs[k2]=infromobj[k];
752: if (inwithcon[k]==0) {
753: inobjscond[k2]='';
754: } else {
755: inobjscond[k2]=
756: '('+(objcont[inwithcon[k]].split(':'))[0]+')';
757: }
758: }
759: }
760: }
761:
762: for (k=0;k<outwithlink.length;k++) {
763: if (outtoobj[k]!=obj1) {
764: found=0;
765: for (k2=0;k2<outobjs.length;k2++) {
766: if (outobjs[k2]==outtoobj[k]) {
767: if (outwithcon[k]!=0) {
768: if (outobjscond[k2]!='') { outobjscond[k2]+='||'; }
769: outobjscond[k2]+=
770: '('+(objcont[outwithcon[k]].split(':'))[0]+')';
771: }
772: found=1;
773: }
774: }
775: if (found==0) {
776: k2=outobjs.length;
777: outobjs[k2]=outtoobj[k];
778: if (outwithcon[k]==0) {
779: outobjscond[k2]='';
780: } else {
781: outobjscond[k2]=
782: '('+(objcont[outwithcon[k]].split(':'))[0]+')';
783: }
784: }
785: }
786: }
787:
788: for (k=0;k<inobjs.length;k++) {
789: cond='';
790: if (inobjscond[k]!='') { cond='('+inobjscond[k]+')'; }
791: for (k2=0;k2<outobjs.length;k2++) {
792: thiscond=cond;
793: if (outobjscond[k2]!='') {
794: if (thiscond!='') { thiscond+='&&'; }
795: thiscond+='('+outobjscond[k2]+')';
796: }
797: condnr=0;
798: if (thiscond!='') { condnr=newcondition(thiscond,'normal'); }
799: joinres(inobjs[k],outobjs[k2],condnr);
800: }
801: }
802: }
803: }
804:
805: // -------------------------------------------------------------- Draw an entry
806:
1.2 ! www 807: function drawcell (rtype,ctype,what,cm,obj1,ej,ek,ne) {
1.1 www 808: var bgcolor;
809: if (ctype!=0) {
810: parent.mapout.document.write('<td bgcolor='+cm+' width='+cw[ctype]+'>');
811: if (what!='') {
812: if (obj1!='') {
813: obj1="'"+obj1+"'";
814: parent.mapout.document.write
815: ('<a href="javascript:parent.code.handler('+obj1
816: +');" onMouseOver="parent.code.info('+obj1+');">');
817: }
818: if (what=='r:') {
819: parent.mapout.document.write
820: ('<img border=0 src="resource.gif">');
821: } else {
822: if (what=='c:') {
823: parent.mapout.document.write
824: ('<img border=0 src="condition.gif">');
825: } else {
826: parent.mapout.document.write
827: ('<img border=0 src="'+rtype+'.'+ctype+'.'+what+'.gif">');
828: }
829: }
830: if (obj1!='') {
831: parent.mapout.document.write('</a>');
832: }
833: } else {
834: if (ne!=1) {
835: parent.mapout.document.write
836: ('<a href="javascript:parent.code.empty('+ej+','+ek+');" ');
837: } else {
838: parent.mapout.document.write
839: ('<a href="javascript:parent.code.infoclear();" ');
840: }
841: parent.mapout.document.write
842: ('onMouseOver="parent.code.infoclear();">');
843: parent.mapout.document.write
844: ('<img border=0 src="'+rtype+'.'+ctype+'.empty.gif"></a>');
845: }
846: parent.mapout.document.write('</td>');
847: }
848: }
849:
850: // ----------------------------------------------------------------- Draw a row
851:
1.2 ! www 852: function drawrow (jid) {
1.1 www 853: var j; var jk; var k; var rc; var gc; var bc; var ck;
854: var objd1=new Array();
855: var objd2=new Array();
856: var notempty=new Array();
857: var condtype;
858: if (rowtype[jid]!=0) {
859: for (j=0;j<=maxcol;j++) {
860: colmap[j]=''; colmap2[j]=''; colmap3[j]=''; colmap4[j]='';
861: colmap5[j]='#FFFFFF'; colmap6[j]='#FFFFFF';
862: objd1[j]=''; objd2[j]=''; notempty[j]=0;
863: }
864: parent.mapout.document.writeln('<tr height='+rh[rowtype[jid]]+'>');
865: if (rowcont[jid]!='') {
866: data2=rowcont[jid].split(':');
867: for (jk=0;jk<data2.length;jk++) {
868: data3=obj[data2[jk]].split('&');
869: if (data3[0]=='b') {
870: rc=(data2[jk]+'F').substr(0,2);
871: gc=('9'+data2[jk]).substr(0,2);
872: bc=(data2[jk]+data2[jk]).substr(0,2);
873: ck='#'+rc+gc+bc;
874: left=maxcol;
875: leftin=maxcol;
876: leftout=maxcol;
877: right=0;
878: rightin=0;
879: rightout=0;
880: anyout=0;
881: for (k=2;k<data3.length;k++) {
882: data1=data3[k].split(':');
883: thiscol=col[data1[0]];
884: if (thiscol<left) { left=thiscol; }
885: if (thiscol>right) { right=thiscol; }
886: if (data1[1]!=0) {
887: if (thiscol<leftin) { leftin=thiscol; }
888: if (thiscol>rightin) { rightin=thiscol; }
889: colmap4[thiscol]=data1[1];
890: }
891: if (data1[2]!=0) {
892: if (thiscol<leftout) { anyout=1; leftout=thiscol; }
893: if (thiscol>rightout) { anyout=1; rightout=thiscol; }
894: if (data1[3]!=0) {
895: colmap3[thiscol]='c:';
896: condtype=(objcont[data1[3]].split(':'))[1];
897: colmap6[thiscol]='#FFFFAA';
898: if (condtype=='stop') { colmap6[thiscol]='#FFAAAA'; }
899: if (condtype=='force') { colmap6[thiscol]='#AAAAFF'; }
900: objd2[thiscol]='c&'
901: +data1[0]+'&'+data2[jk]+'&'+data1[2]+'&'+data1[3];
902: } else {
903: colmap3[thiscol]='ctd';
904: colmap6[thiscol]=ck;
905: objd2[thiscol]='c&'
906: +data1[0]+'&'+data2[jk]+'&'+data1[2]+'&-';
907: }
908: }
909: }
910: for (k=left;k<=right;k++) { notempty[k]=1; colmap5[k]=ck; }
911: middle=Math.round((left+right)/2);
912: colmap[middle]='r:';
913: objd1[middle]+='r&'+data2[jk];
914:
915: if (rightin>middle) {
916: for (k=middle+1;k<rightin;k++) {
917: if (colmap4[k]!='') {
918: colmap[k]='rlt';
919: } else {
920: colmap[k]='rl';
921: }
922: }
923: colmap[rightin]='tl';
924: }
925: if (leftin<middle) {
926: for (k=middle-1;k>leftin;k--) {
927: if (colmap4[k]!='') {
928: colmap[k]='lrt';
929: } else {
930: colmap[k]='lr';
931: }
932: }
933: colmap[leftin]='tr';
934: }
935:
936: if ((leftout>middle) && (anyout)) {
937: colmap2[middle]='tr';
938: }
939: if (leftout==middle) {
940: if (rightout==middle) { colmap2[middle]='td'; }
941: if (rightout>middle) { colmap2[middle]='rtd'; }
942: }
943: if (leftout<middle) {
944: if (rightout<middle) { colmap2[middle]='tl'; }
945: if (rightout==middle) { colmap2[middle]='tdl'; }
946: if (rightout>middle) {
947: if (colmap3[middle]!='') {
948: colmap2[middle]='rtdl';
949: } else {
950: colmap2[middle]='rtl';
951: }
952: }
953: }
954: if (leftout<middle) {
955: for (k=middle-1;k>leftout;k--) {
956: if (colmap3[k]!='') {
957: colmap2[k]='rld';
958: } else {
959: colmap2[k]='rl';
960: }
961: }
962: colmap2[leftout]='rd';
963: }
964: if (rightout>middle) {
965: for (k=middle+1;k<rightout;k++) {
966: if (colmap3[k]!='') {
967: colmap2[k]='lrd';
968: } else {
969: colmap2[k]='lr';
970: }
971: }
972: colmap2[rightout]='ld';
973: }
974: }
975: if (data3[0]=='h') {
976: data4=data3[2].split(':');
977: if (col[data4[1]]>col[data4[0]]) {
978: left=col[data4[0]];
979: right=col[data4[1]];
980: thisarrow='lr';
981: } else {
982: right=col[data4[0]];
983: left=col[data4[1]];
984: thisarrow='rl';
985: }
986: if (data3[4].split(':')[0]==1) {
987: colmap[left]='tr';
988: } else {
989: colmap[left]='rd'; colmap2[left]='utd'; colmap3[left]='utd';
990: }
991: for (k=left+1;k<right;k++) {
992: if (colmap[k]=='') {
993: colmap[k]=thisarrow;
994: objd1[k]=data2[jk];
995: } else {
996: colmap[k]='tdrl';
997: objd1[k]='';
998: }
999: }
1000: if (data3[4].split(':')[1]==1) {
1001: colmap[right]='tl';
1002: } else {
1003: colmap[right]='ld'; colmap2[right]='utd'; colmap3[right]='utd';
1004: }
1005: objd1[left]=data2[jk];
1006: objd1[right]=data2[jk];
1007: }
1008: if (data3[0]=='v') {
1009: left=col[data3[1]];
1010: if (colmap[left]=='') {
1011: if (data3[3]==1) { colmap[left]='dt'; } else { colmap[left]='td'; }
1012: objd1[left]=data2[jk];
1013: objd2[left]=objd1[left];
1014: } else {
1015: colmap[left]='tdrl';
1016: objd1[left]='';
1017: }
1018: colmap2[left]='utd'; colmap3[left]='utd';
1019: }
1020: }
1021: rtype=rowtype[jid];
1022: for (k=0;k<=maxcol;k++) {
1.2 ! www 1023: drawcell(rtype,coltype[rcol[k]],colmap[k],colmap5[k],objd1[k],jid,k,
1.1 www 1024: notempty[k]);
1025: }
1026: if (rowtype[jid]==2) {
1027: parent.mapout.document.writeln('</tr><tr>');
1028: for (k=0;k<=maxcol;k++) {
1.2 ! www 1029: drawcell(1,coltype[rcol[k]],colmap2[k],colmap5[k],objd2[k],jid,k,1);
1.1 www 1030: }
1031: parent.mapout.document.writeln('</tr><tr>');
1032: for (k=0;k<=maxcol;k++) {
1.2 ! www 1033: drawcell(1,coltype[rcol[k]],colmap3[k],colmap6[k],objd2[k],jid,k,1);
1.1 www 1034: }
1035: }
1036: }
1037: parent.mapout.document.writeln('</tr>');
1038: }
1039: }
1040:
1041: // ------------------------------------------------------------- Draw the table
1042:
1.2 ! www 1043: function draw () {
1.1 www 1044: var k; var kr;
1045:
1046: cleanup();
1.2 ! www 1047: save();
1.1 www 1048:
1049: for (k=0;k<=maxrow;k++) { rrow[row[k]]=k; }
1050: for (k=0;k<=maxcol;k++) { rcol[col[k]]=k; }
1051: rh[0]=0;
1052: rh[1]=30;
1053: rh[2]=60;
1054: cw[0]=0;
1055: cw[1]=30;
1056: cw[2]=60;
1057: parent.mapout.document.open('text/html','replace');
1058: parent.mapout.document.writeln('<html><body bgcolor="#FFFFFF">');
1059: parent.mapout.document.writeln(
1060: '<table cellpadding=0 cellspacing=0 border=0>');
1061:
1.2 ! www 1062: if (tablemode==0) {
! 1063: for (kr=0;kr<=maxrow;kr++) { drawrow(rrow[kr]); }
! 1064: } else {
! 1065: tabledraw();
! 1066: }
1.1 www 1067:
1068: parent.mapout.document.writeln('</table>');
1069: parent.mapout.document.writeln('</body></html>');
1070: parent.mapout.document.close();
1071: parent.focus();
1072: parent.mapout.focus();
1073: }
1074:
1075: // --------------------------------------------------------- Clears info window
1076:
1077: function infoclear() {
1078: if (notclear!=1) {
1079: var options="scrollbars=1,resizable=1,menubar=0,width=400,height=300";
1080: var inf=open("","infout",options);
1081: inf.document.clear();
1082: inf.document.writeln
1083: ('<html><body bgcolor="#FFFFFF"><table><tr><td>'+
1084: '<img src="/adm/lonIcons/lonlogos.gif"></td>');
1085: if (linkmode!=0) {
1086: inf.document.writeln(
1087: '<td><b>Link Mode</b><hr>Click on a resource to link it with<br><b>'+
1088: (objcont[linkmode].split(':'))[0]+
1089: '</b><br>click anywhere else to cancel.</td>');
1090: }
1091: inf.document.writeln('</tr></table></body></html>');
1092: inf.document.close();
1093: parent.focus();
1094: parent.mapout.focus();
1095: notclear=1;
1096: lastinfo='';
1097: }
1098: }
1099:
1100: // --------------------------------------------------- Prints out resource info
1101:
1102: function info(infostr) {
1103: if ((editmode!=1) && (infostr!=lastinfo)) {
1104: notclear=1;
1105: var options="scrollbars=1,resizable=1,menubar=0,width=400,height=300";
1106: var inf=open("","infout",options);
1107: inf.document.clear();
1108: inf.document.writeln(
1109: '<html><body bgcolor="#FFFFFF">'+
1110: '<table><tr><td width=32><img src="info.gif"></td><td bgcolor="#AAFFAA">');
1111: data1=infostr.split('&');
1112: if (data1[0]=='c') {
1113: inf.document.write('<b>Condition (');
1114: data3=objlinks[data1[3]].split(':');
1115: if (data1[4]=='-') {
1116: inf.document.write('not set');
1117: } else {
1118: data2=objcont[data1[4]].split(':');
1119: if (data2[1]=='force') {
1120: inf.document.write('Blocking Other Links');
1121: } else {
1122: if (data2[1]=='stop') {
1123: inf.document.write('Blocking This Link');
1124: } else {
1125: inf.document.write('Recommendation');
1126: }
1127: }
1128: }
1129: inf.document.writeln(')</b><hr>From <b>'+objcont[data3[0]].split(':')[0]+
1130: '</b><br>to <b>'+objcont[data3[1]].split(':')[0]+'</b>');
1131: } else {
1132: if (data1[0]=='r') {
1133: inf.document.writeln('<b>Resource</b><hr>');
1134: data2=objcont[data1[1]].split(':');
1135: inf.document.writeln('<b>'+data2[0]+'</b><br>');
1136: inf.document.writeln((data2[1].split('/')).join(' / '));
1137: } else {
1138: inf.document.writeln('<b>Link</b><hr>');
1139: data2=obj[data1[0]].split('&');
1140: data3=objlinks[data2[data2.length-2]].split(':');
1141: inf.document.writeln('From <b>'+objcont[data3[0]].split(':')[0]+
1142: '</b><br>to <b>'+objcont[data3[1]].split(':')[0]+'</b>');
1143: }
1144: }
1145: if (linkmode==0) {
1146: inf.document.writeln('<p>(click to edit)');
1147: } else {
1148: if (data1[0]=='r') {
1149: inf.document.writeln('<p>(click to link)');
1150: } else {
1151: inf.document.writeln('<p>(click to cancel linking and edit)');
1152: }
1153: }
1154: inf.document.writeln('</td></tr></table></body></html>');
1155: inf.document.close();
1156: parent.focus();
1157: parent.mapout.focus();
1158: notclear=0;
1159: lastinfo=infostr;
1160: }
1161: }
1162:
1163: // ------------------------------------------------ "Escapes" out special chars
1164:
1165: function escape(instring) {
1166: var outstring='';
1167: var thischar;
1168: var k;
1169: for (k=0;k<instring.length;k++) {
1170: thischar=instring.charAt(k);
1171: if (thischar==':') { thischar=':'; }
1172: if (thischar=='"') { thischar='"'; }
1173: if (thischar=="'") { thischar='''; }
1174: if (thischar==',') { thischar=','; }
1175: outstring+=thischar;
1176: }
1177: return outstring;
1178: }
1179:
1.2 ! www 1180: // -------------------------------------------------- Insert resource into link
! 1181:
! 1182: function insertreslink(infostr) {
! 1183: alert(infostr);
! 1184: }
! 1185:
1.1 www 1186: // ---------------------------------------------------- Handles "click to edit"
1187:
1188: function handler(infostr) {
1189: var k;
1190: editmode=1;
1191: notclear=1;
1192: var options="scrollbars=1,resizable=1,menubar=0,width=400,height=300";
1193: var inf=open("","infout",options);
1194: inf.document.clear();
1195: inf.document.writeln(
1196: '<html><body bgcolor="#FFFFFF">'+
1197: '<table><tr><td width=32><img src="edit.gif"></td><td bgcolor="#AAFFAA">');
1198: data1=infostr.split('&');
1199: if (data1[0]=='c') {
1200: inf.document.writeln('<b>Condition</b><hr>');
1201: linkmode=0;
1202: if (data1[4]=='-') {
1203: data2[0]=''; data2[1]='normal';
1204: } else {
1205: data2=objcont[data1[4]].split(':');
1206: }
1207: inf.document.writeln(
1208: '<form name=condinfo><textarea name=c cols=40 rows=4>'
1209: +data2[0]+'</textarea><br><input type=radio name=s value=normal '+
1210: 'onClick="self.document.forms.condinfo.elements.h.value='+"'normal'"+'"');
1211: if (data2[1]=='normal') { inf.document.write(' checked'); }
1212: inf.document.write(
1213: '> Recommendation if true<br><input type=radio name=s value=stop '+
1214: 'onClick="self.document.forms.condinfo.elements.h.value='+"'stop'"+'"');
1215: if (data2[1]=='stop') { inf.document.write(' checked'); }
1216: inf.document.write(
1217: '> Blocking this link if false<br><input type=radio name=s value=force '+
1218: 'onClick="self.document.forms.condinfo.elements.h.value='+"'force'"+'"');
1219: if (data2[1]=='force') { inf.document.write(' checked'); }
1220: inf.document.write(
1221: '> Blocking other links if true<br><a href="javascript:opener.editmode=0;'
1222: +'opener.notclear=0;');
1223: if (data1[4]=='-') {
1224: inf.document.write('opener.crecond('+data1[2]+','+data1[1]+','
1225: +'opener.escape(self.document.forms.condinfo.elements.c.value),'
1226: +'self.document.forms.condinfo.elements.h.value);');
1227: } else {
1228: inf.document.write('opener.objcont['+data1[4]+']='
1229: +'opener.escape(self.document.forms.condinfo.elements.c.value)+'+"':'"
1230: +'+self.document.forms.condinfo.elements.h.value+'+"':cond';");
1231: }
1232: inf.document.writeln(
1233: 'opener.infoclear();opener.editmode=0;opener.draw('
1.2 ! www 1234: +');">Change to above values</a> '
1.1 www 1235: +' <a href="javascript:self.document.forms.condinfo.reset()">Reset</a>'
1236: +'<input type=hidden name=h value='+data2[1]
1237: +'></form>');
1238:
1239: inf.document.writeln(
1240: '<a href="javascript:opener.notclear=0;opener.infoclear();'
1241: +'opener.delcond('+data1[2]+','+data1[1]+');opener.editmode=0;opener.draw('
1.2 ! www 1242: +');">Delete Condition</a>');
1.1 www 1243: } else {
1244: if (data1[0]=='r') {
1245: if (linkmode!=0) {
1246: joinres(linkmode,data1[1],0);
1247: editmode=0;
1248: notclear=0;
1249: linkmode=0;
1250: inf.document.writeln('<b>Linked Resources</b>');
1.2 ! www 1251: draw();
1.1 www 1252: } else {
1253: inf.document.writeln('<b>Resource</b>');
1254: data2=objcont[data1[1]].split(':');
1255: inf.document.write(
1256: '<form name=resinfo><table><tr><td>Title:</td><td>'
1257: +'<input type=text name=t size=40 value="'
1258: +data2[0]+'"></td></tr><tr><td>URL:</td><td>'
1259: +'<input type=text name=u size=40 value="'+data2[1]+'"></td></tr>'
1260: +'<tr><td>External:</td><td><input type=checkbox name=e');
1261: if (data2[2]=='true') { inf.document.write(' checked'); }
1262: inf.document.writeln('></td></tr>'
1263: +'<tr><td colspan=2><a href="javascript:opener.editmode=0;'
1264: +'opener.notclear=0;opener.objcont['+data1[1]
1265: +']=opener.escape(self.document.forms.resinfo.elements.t.value)+'+"':'"
1266: +'+opener.escape(self.document.forms.resinfo.elements.u.value)+'+"':'"
1267: +'+self.document.forms.resinfo.elements.e.checked+'+"':res'"
1268: +';opener.infoclear();">'
1269: +'Change to above values</a> '
1270: +' <a href="javascript:self.document.forms.resinfo.reset()">Reset</a>'
1271: +'</td></tr></table></form>');
1272: inf.document.writeln(
1273: '<a href="javascript:opener.notclear=0;opener.infoclear();'
1274: +'opener.delres('+data1[1]+',0);opener.editmode=0;opener.draw('
1.2 ! www 1275: +');">Delete Resource (cutting links)</a>');
1.1 www 1276: inf.document.writeln(
1277: '<br><a href="javascript:opener.notclear=0;opener.infoclear();'
1278: +'opener.delres('+data1[1]+',1);opener.editmode=0;opener.draw('
1.2 ! www 1279: +');">Delete Resource (preserving links)</a>');
1.1 www 1280: inf.document.writeln(
1281: '<br><a href="javascript:opener.editmode=0;opener.notclear=0;'
1282: +'opener.linkmode='+data1[1]+';'
1283: +'opener.infoclear();">Link Resource</a>');
1284: }
1285: } else {
1286: linkmode=0;
1287: inf.document.writeln('<b>Link</b><hr>');
1288: data2=obj[data1[0]].split('&');
1289: k=data2[data2.length-2];
1290: data3=objlinks[k].split(':');
1291: inf.document.writeln('From <b>'+objcont[data3[0]].split(':')[0]+
1292: '</b><br>to <b>'+objcont[data3[1]].split(':')[0]+'</b>');
1293: inf.document.writeln('<br><a href="javascript:opener.dellink('+
1294: k+');opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1.2 ! www 1295: +');">Delete Link</a>');
! 1296: inf.document.writeln('<br><a href="javascript:'+
! 1297: 'opener.insertreslink('+infostr+');'+
! 1298: 'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
! 1299: +');">Insert Resource Into Link</a>');
1.1 www 1300: }
1301: }
1302: inf.document.writeln(
1303: '<br><a href="javascript:opener.editmode=0;opener.notclear=0;'
1304: +'opener.infoclear();">Done</a>');
1305: inf.document.writeln('</td></tr></table></body></html>');
1306: inf.document.close();
1307: inf.focus();
1308: }
1309:
1310: // ----------------------------------------------------- Clicks on empty fields
1311:
1312: function empty(rid,k) {
1313: var cid=findcol(k);
1314: var lcol=k-1;
1315: trow=row[rid];
1316: lrow=trow-1;
1317: editmode=1;
1318: notclear=1;
1319: linkmode=0;
1320: var options="scrollbars=1,resizable=1,menubar=0,width=400,height=300";
1321: var inf=open("","infout",options);
1322: inf.document.clear();
1323: inf.document.writeln(
1324: '<html><body bgcolor="#FFFFFF">'+
1325: '<table><tr><td width=32><img src="edit.gif"></td><td bgcolor="#AAFFAA">'+
1326: '<b>Empty Field</b><hr>');
1327:
1328: inf.document.writeln('<br><a href="javascript:opener.newresource('+
1329: rid+','+cid+",'','');"+
1330: 'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1.2 ! www 1331: +');">Insert Resource</a>');
1.1 www 1332: inf.document.writeln('<hr>Insert column:');
1333: inf.document.writeln('<a href="javascript:opener.insertcol('+
1334: lcol+');opener.addobj('+rid+",'e&'+opener.maxcol);"
1335: +'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1.2 ! www 1336: +');">left</a>');
1.1 www 1337: inf.document.writeln('<a href="javascript:opener.insertcol('+
1338: k+');opener.addobj('+rid+",'e&'+opener.maxcol);"
1339: +'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1.2 ! www 1340: +');">right</a> ');
1.1 www 1341: inf.document.writeln('<br>Insert row:');
1342: inf.document.writeln('<a href="javascript:opener.insertrow('+
1343: trow+');opener.addobj(opener.maxrow'+",'e&"+cid+"');"
1344: +'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1.2 ! www 1345: +');">below</a>');
1.1 www 1346: inf.document.writeln('<a href="javascript:opener.insertrow('+
1347: lrow+');opener.addobj(opener.maxrow'+",'e&"+cid+"');"
1348: +'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
1.2 ! www 1349: +');">above</a> ');
1.1 www 1350:
1351:
1352: inf.document.writeln(
1353: '<br><a href="javascript:opener.editmode=0;opener.notclear=0;'
1354: +'opener.infoclear();">Done</a>');
1355: inf.document.writeln('</td></tr></table></body></html>');
1356: inf.document.close();
1357: inf.focus();
1358: }
1359:
1360: // ---------------------------------------------------- Save into hidden fields
1361:
1362: function save() {
1363: var k;
1.2 ! www 1364: parent.server.document.forms.storage.output.value='graphdef<:>yes';
1.1 www 1365: for (k=0;k<obj.length;k++) {
1.2 ! www 1366: parent.server.document.forms.storage.output.value+=
1.1 www 1367: '<&>obj<:>'+k+'<:>'+obj[k];
1368: }
1369: for (k=0;k<row.length;k++) {
1.2 ! www 1370: parent.server.document.forms.storage.output.value+=
1.1 www 1371: '<&>row<:>'+k+'<:>'+row[k];
1372: }
1373: for (k=0;k<col.length;k++) {
1.2 ! www 1374: parent.server.document.forms.storage.output.value+=
1.1 www 1375: '<&>col<:>'+k+'<:>'+col[k];
1376: }
1377: for (k=0;k<rowcont.length;k++) {
1378: if (rowcont[k]) {
1.2 ! www 1379: parent.server.document.forms.storage.output.value+=
1.1 www 1380: '<&>rowcont<:>'+k+'<:>'+rowcont[k];
1381: }
1382: }
1.2 ! www 1383: parent.server.document.forms.storage.output.value+=
1.1 www 1384: '<&>maxcol<:>'+maxcol;
1.2 ! www 1385: parent.server.document.forms.storage.output.value+=
1.1 www 1386: '<&>maxrow<:>'+maxrow;
1387:
1388: for (k=0;k<objcont.length;k++) {
1389: if (objcont[k]) {
1.2 ! www 1390: parent.server.document.forms.storage.output.value+=
1.1 www 1391: '<&>objcont<:>'+k+'<:>'+objcont[k];
1392: }
1393: }
1394: for (k=0;k<objlinks.length;k++) {
1395: if (objlinks[k]) {
1.2 ! www 1396: parent.server.document.forms.storage.output.value+=
1.1 www 1397: '<&>objlinks<:>'+k+'<:>'+objlinks[k];
1398: }
1399: }
1.2 ! www 1400: undopointer++;
! 1401: undostack[undopointer]=
! 1402: parent.server.document.forms.storage.output.value;
1.1 www 1403: }
1404:
1405: // ----------------------------------------------- Reset all layout information
1406:
1407: function graphreset() {
1408:
1409: obj.length=0;
1410: obj[0]='';
1411: obj[1]='e&1';
1412:
1413: rowcont.length=0;
1414: rowcont[0]='';
1415: rowcont[1]='1';
1416: row.length=0;
1417: row[0]=0;
1418: row[1]=1;
1419: maxrow=1;
1420:
1421: col.length=0;
1422: colmap.length=0;
1423: maxcol=-1;
1424: insertcol(-1);
1425: insertcol(0);
1426:
1427: graphdef='no';
1428:
1429: }
1430:
1431: // --------------------- Compare two resources with each other for "straighten"
1432:
1433: function rescompare(a,b) {
1434: data1=a.split(':');
1435: data2=b.split(':');
1436: var rvalue=0;
1437: var k;
1438: for (k=1;k<data1.length;k++) {
1439: if (data1[k]==data2[0]) { rvalue--; }
1440: }
1441: for (k=1;k<data3.length;k++) {
1442: if (data2[k]==data1[0]) { rvalue++; }
1443: }
1444: if (rvalue==0) { rvalue=data2.length-data1.length; }
1445:
1446: return rvalue;
1447: }
1448:
1.2 ! www 1449: // -------------------------------------------- Draw the table instead of graph
! 1450:
! 1451: function tabledraw() {
! 1452: var k;
! 1453: var ij;
! 1454: var kj;
! 1455: var objsort=new Array();
! 1456: var objsorted=new Array();
! 1457: for (k=1;k<objcont.length;k++) {
! 1458: if (objcont[k]) {
! 1459: data1=objcont[k].split(':');
! 1460: if (data1[data1.length-1]=='res') {
! 1461: objsort[objsort.length]=''+k;
! 1462: }
! 1463: }
! 1464: }
! 1465: for (k=1;k<objlinks.length;k++) {
! 1466: data1=objlinks[k].split(':');
! 1467: kj=-1;
! 1468: for (j=0;j<objsort.length;j++) {
! 1469: if ((objsort[j].split(':'))[0]==data1[0]) {
! 1470: kj=j;
! 1471: }
! 1472: }
! 1473: objsort[kj]+=':'+data1[1];
! 1474: }
! 1475: objsorted=objsort.sort(rescompare);
! 1476: for (ij=0;ij<objsorted.length;ij++) {
! 1477:
! 1478: }
! 1479: alert("Table mode not yet implemented");
! 1480: }
! 1481:
1.1 www 1482: // ------------------------------------------- Sort objects to straighten graph
1483:
1484: function graphopt() {
1485: var k;
1486: var ij;
1487: var kj;
1488: var objsort=new Array();
1489: var objsorted=new Array();
1490: condense();
1491: graphreset();
1492: for (k=1;k<objcont.length;k++) {
1493: if (objcont[k]) {
1494: data1=objcont[k].split(':');
1495: if (data1[data1.length-1]=='res') {
1496: objsort[objsort.length]=''+k;
1497: }
1498: }
1499: }
1500: for (k=1;k<objlinks.length;k++) {
1501: data1=objlinks[k].split(':');
1502: kj=-1;
1503: for (j=0;j<objsort.length;j++) {
1504: if ((objsort[j].split(':'))[0]==data1[0]) {
1505: kj=j;
1506: }
1507: }
1508: objsort[kj]+=':'+data1[1];
1509: }
1510: objsorted=objsort.sort(rescompare);
1511: var thisnewobj=''+(objsorted[0].split(':'))[0];
1512: rowcont[1]=thisnewobj;
1513: var thiscolmax=1;
1514: obj[thisnewobj]='b&1&'+thiscolmax+':0:0:0';
1515: var allcolmax=0;
1516: for (k=1;k<objsorted.length;k++) {
1517: thisnewobj=(objsorted[k].split(':'))[0];
1518: if (rescompare(objsorted[k-1],objsorted[k])==0) {
1519: rowcont[rowcont.length-1]+=':'+thisnewobj;
1520: thiscolmax++;
1521: } else {
1522: rowcont[rowcont.length]=thisnewobj;
1523: if (thiscolmax>allcolmax) { allcolmax=thiscolmax; }
1524: thiscolmax=1;
1525: }
1526: kj=rowcont.length-1;
1527: obj[thisnewobj]='b&'+kj+'&'+thiscolmax+':0:0:0';
1528: }
1529: for (k=0;k<obj.length;k++) {
1530: if (!obj[k]) { obj[k]=''; }
1531: }
1532: for (k=0;k<=allcolmax;k++) { insertcol(0); }
1533: for (k=0;k<rowcont.length;k++) {
1534: row[k]=k;
1535: }
1536: maxrow=rowcont.length-1;
1537:
1538: var oldlinks=new Array();
1539: for (k=0;k<objlinks.length;k++) { oldlinks[k]=objlinks[k]; }
1540: objlinks.length=0;
1541: objlinks[0]='';
1542: for (k=0;k<objsorted.length;k++) {
1543: kj=(objsorted[k].split(':'))[0];
1544: for (ij=1;ij<oldlinks.length;ij++) {
1545: if (oldlinks[ij]) {
1546: data1=oldlinks[ij].split(':');
1547: if (data1[0]==kj) {
1548: joinres(data1[0],data1[1],data1[2]);
1549: }
1550: }
1551: }
1552: }
1553: }
1554:
1555: // ----------------------------------------------------------- Remove e-objects
1556:
1557: function condense() {
1558: var j;
1559: for (j=0;j<=maxrow;j++) {
1560: if (rowcont[j]!='') {
1561: data1=rowcont[j].split(':');
1562: rowcont[j]='';
1563: for (k=0;k<data1.length;k++) {
1564: if (obj[data1[k]].substring(0,2)!='e&') {
1565: if (rowcont[j]!='') { rowcont[j]+=':'; }
1566: rowcont[j]+=data1[k];
1567: }
1568: }
1569: }
1570: }
1571: }
1572:
1573: // ---------------------------------------------------- Load from hidden fields
1574:
1575: function load() {
1576: objcont.length=0;
1577: objlinks.length=0;
1578: objlinks[0]='';
1579: objcont[0]='';
1580: editmode=0;
1581: notclear=0;
1582: lastinfo='';
1583: graphreset();
1.2 ! www 1584: var inputstr=parent.server.document.forms.storage.output.value;
1.1 www 1585: data1=inputstr.split('<&>');
1586: var k;
1587: for (k=0;k<data1.length;k++) {
1588: data2=data1[k].split('<:>');
1589: if (data2[0]=='graphdef') { graphdef=data2[1]; }
1590: if (data2[0]=='maxcol') { maxcol=1*data2[1]; }
1591: if (data2[0]=='maxrow') { maxrow=1*data2[1]; }
1592: if (data2[0]=='obj') { obj[data2[1]]=data2[2]; }
1593: if (data2[0]=='objcont') { objcont[data2[1]]=data2[2]; }
1594: if (data2[0]=='objlinks') { objlinks[data2[1]]=data2[2]; }
1595: if (data2[0]=='rowcont') { rowcont[data2[1]]=data2[2]; }
1596: if (data2[0]=='row') { row[data2[1]]=1*data2[2]; }
1597: if (data2[0]=='col') { col[data2[1]]=1*data2[2]; }
1598: }
1599: }
1600:
1.2 ! www 1601: // -------------------------------------------------------------- Undo function
! 1602:
! 1603: function undo() {
! 1604: if (undopointer>1) {
! 1605: undopointer--;
! 1606: parent.server.document.forms.storage.output.value
! 1607: =undostack[undopointer];
! 1608: load();
! 1609: undopointer--;
! 1610: draw();
! 1611: stored=0;
! 1612: } else {
! 1613: alert("Cannot undo: reached beginning of edit session");
! 1614: }
! 1615: }
! 1616:
! 1617: // -------------------------------------------------------------- Redo function
! 1618:
! 1619: function redo() {
! 1620: if (undopointer<undostack.length-1) {
! 1621: undopointer++;
! 1622: parent.server.document.forms.storage.output.value
! 1623: =undostack[undopointer];
! 1624: load();
! 1625: undopointer--;
! 1626: draw();
! 1627: stored=0;
! 1628: } else {
! 1629: alert("Cannot redo: reached end of edit session");
! 1630: }
! 1631: }
! 1632:
! 1633: // ------------------------------------------------------------ Revert function
! 1634:
! 1635: function revert() {
! 1636: if (confirm("Revert to beginning of edit session?")) {
! 1637: undopointer=2;
! 1638: undo();
! 1639: }
! 1640: }
! 1641:
! 1642: // -------------------------------------------------------------- Store changes
! 1643:
! 1644: function storechange() {
! 1645: parent.server.document.forms.storage.submit();
! 1646: stored=1;
! 1647: alert("Stored changes");
! 1648: }
! 1649:
! 1650: // ---------------------------------------------------------------- Toggle Mode
! 1651:
! 1652: function togglemode() {
! 1653: if (tablemode==0) { tablemode=1; } else { tablemode=0; }
! 1654: draw();
! 1655: }
! 1656:
1.1 www 1657: // -------------------------------------------------------- Main program onLoad
1658:
1659: function main() {
1660:
1661: if (mainrun==0) {
1662: load();
1.2 ! www 1663: draw();
! 1664: stored=1;
1.1 www 1665: mainrun=1;
1666: }
1667:
1668: }
1669:
1.2 ! www 1670: // ------------------------------------------------------------- Save on leave?
! 1671:
! 1672: function leave() {
! 1673: if (stored==0) {
! 1674: if (confirm('Store changes?')) {
! 1675: storechange();
! 1676: }
! 1677: }
! 1678: }
! 1679:
1.1 www 1680: </script>
1681: </head>
1682:
1.2 ! www 1683: <body bgcolor="#FFFFFF" onLoad="main();" onUnload="leave();">
! 1684: <a href="javascript:togglemode();">Toggle Display Mode</a>
! 1685: <a href="javascript:condense();draw();">Condense</a>
! 1686: <a href="javascript:graphopt();draw();">Straighten</a>
! 1687: <a href="javascript:revert();">Revert</a>
! 1688: <a href="javascript:undo();">Undo</a>
! 1689: <a href="javascript:redo();">Redo</a>
! 1690: <a href="javascript:storechange();">Store</a>
1.1 www 1691: </body>
1.2 ! www 1692: </html>
! 1693:
! 1694:
! 1695:
! 1696:
! 1697:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>