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