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