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