Annotation of rat/client/code.html, revision 1.8
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.8 ! www 12: 6/7,6/8,6/9,6/10,6/12,6/15,7/4,7/26,7/28
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]='';
1698: objcont[1]='Start::false:start:res'
1.5 www 1699: objcont[2]='Finish::false:finish:res';
1.4 www 1700: objlinks[0]='';
1701: objlinks[1]='1:2:0';
1.1 www 1702:
1703: graphdef='no';
1704:
1705: }
1706:
1707: // --------------------- Compare two resources with each other for "straighten"
1708:
1709: function rescompare(a,b) {
1710: data1=a.split(':');
1711: data2=b.split(':');
1712: var rvalue=0;
1713: var k;
1714: for (k=1;k<data1.length;k++) {
1715: if (data1[k]==data2[0]) { rvalue--; }
1716: }
1717: for (k=1;k<data3.length;k++) {
1718: if (data2[k]==data1[0]) { rvalue++; }
1719: }
1720: if (rvalue==0) { rvalue=data2.length-data1.length; }
1721: return rvalue;
1722: }
1723:
1.2 www 1724: // -------------------------------------------- Draw the table instead of graph
1725:
1726: function tabledraw() {
1.3 www 1727: var objsorted=new Array();
1728: var robjs=new Array();
1.4 www 1729: var iobjs=new Array();
1.3 www 1730: var k;
1731: var i;
1732: var j;
1733: var nr;
1.4 www 1734: var ck;
1735: var cck;
1736: var condid;
1.3 www 1737: var sortstr=sortobjs();
1.5 www 1738: insrestab(1,-1,-1,'');
1.3 www 1739: if (sortstr!='') {
1740: objsorted=sortstr.split('&');
1741: for (k=0;k<objsorted.length;k++) {
1.4 www 1742: i=(objsorted[k].split(':'))[0];
1743: iobjs[k]=i;
1744: robjs[i]=k;
1.3 www 1745: }
1.4 www 1746: for (k=0;k<iobjs.length;k++) {
1747: i=iobjs[k];
1.3 www 1748: if (k<objsorted.length-1) {
1.4 www 1749: nr=iobjs[k+1];
1.3 www 1750: } else {
1751: nr=-1;
1752: }
1753: data1=objcont[i].split(':');
1.4 www 1754: ck=rescolor(data1[2],data1[3]);
1.3 www 1755: parent.mapout.document.write('<tr><td bgcolor="'+ck
1.4 www 1756: +'"><b><a href="javascript:if (parent.code.linkmode!=0) { '
1757: +'parent.code.joinres(parent.code.linkmode,'+i+',0);'
1758: +'parent.code.linkmode=0;parent.code.editmode=0;'
1759: +'parent.code.notclear=0;parent.code.infoclear();'
1760: +'parent.code.draw(); }">'+k+'</a></b></td><td bgcolor="'+ck
1.3 www 1761: +'"><form name=r'+i+' method=post>');
1762: data2=obj[i].split('&');
1763: parent.mapout.document.write('<table bgcolor="#CCCCCC">');
1.5 www 1764: if (data1[3]=='start') {
1765: parent.mapout.document.writeln('<tr><td><b>Start</b></td></tr>');
1766: }
1767: if (data1[3]=='finish') {
1768: parent.mapout.document.writeln('<tr><td><b>Finish</b></td></tr>');
1769: }
1.3 www 1770: parent.mapout.document.write(
1.4 www 1771: '<tr><td>Title:</td><td><input type=text name=t size=50 value="'
1.5 www 1772: +data1[0]+'"><input type=hidden name=h value='+data1[3]
1773: +'></td></tr>');
1774: if ((data1[3]!='start') && (data1[3]!='finish')) {
1.3 www 1775: parent.mapout.document.write(
1.4 www 1776: '<tr><td>URL:</td><td><input type=text name=u size=50 value="'
1.3 www 1777: +data1[1]+'"></td></tr>'
1778: +'<tr><td>External:</td><td><input type=checkbox name=e');
1779: if (data1[2]=='true') { parent.mapout.document.write(' checked'); }
1780: parent.mapout.document.write('></td></tr>'
1.5 www 1781: +'<tr><td colspan=2><input type=radio name=y value=normal '+
1.3 www 1782: 'onClick="parent.mapout.document.forms.r'+i+'.elements.h.value='+
1783: "'normal'"+'"');
1784: if (data1[3]=='normal') { parent.mapout.document.write(' checked'); }
1785: parent.mapout.document.write(
1786: '> Regular <input type=radio name=y value=mandatory '+
1787: 'onClick="parent.mapout.document.forms.r'+i+'.elements.h.value='+
1788: "'mandatory'"+'"');
1789: if (data1[3]=='mandatory') { parent.mapout.document.write(' checked'); }
1790: parent.mapout.document.write(
1791: '> Mandatory <input type=radio name=y value=optional '+
1792: 'onClick="parent.mapout.document.forms.r'+i+'.elements.h.value='+
1793: "'optional'"+'"');
1794: if (data1[3]=='optional') { parent.mapout.document.write(' checked'); }
1.5 www 1795: parent.mapout.document.write('> Optional</td></tr>');
1796: } else {
1797: parent.mapout.document.write(
1798: '<tr><td><input type=hidden name=u value="">'
1799: +'<input type=hidden name=e value=false></td></tr>');
1800: }
1801: parent.mapout.document.write(
1802: '<tr><td colspan=2><a href="javascript:parent.code.objcont['+i
1.3 www 1803: +']=parent.code.escape(parent.mapout.document.forms.r'+i
1804: +'.elements.t.value)+'+"':'"
1805: +'+parent.code.escape(parent.mapout.document.forms.r'+i
1806: +'.elements.u.value)+'+"':'"
1807: +'+parent.mapout.document.forms.r'+i+'.elements.e.checked+'+"':'"
1808: +'+parent.mapout.document.forms.r'+i+'.elements.h.value+'+"':res'"
1809: +';parent.code.draw();">'
1810: +'<b>Change to above values</b></a> '
1811: +' <a href="javascript:parent.mapout.document.forms.r'+i
1.5 www 1812: +'.reset()">Reset</a></td></tr><tr><td colspan=2>');
1813: if ((data1[3]!='start') && (data1[3]!='finish')) {
1814: parent.mapout.document.writeln(
1815: '<A href="javascript:parent.code.notclear=0;parent.code.infoclear();'
1.4 www 1816: +'parent.code.delres('+i+',0);parent.code.editmode=0;parent.code.draw();">'
1817: +'Delete Resource (cutting links)</A><br>'
1818: +'<A href="javascript:parent.code.notclear=0;parent.code.infoclear();'
1819: +'parent.code.delres('+i+',1);parent.code.editmode=0;parent.code.draw();">'
1.5 www 1820: +'Delete Resource (preserving links)</A><br>');
1821: }
1822: if (data1[3]!='finish') {
1823: parent.mapout.document.writeln(
1824: '<a href="javascript:parent.code.linkmode='+i+
1.4 www 1825: ';parent.code.notclear=0;parent.code.infoclear();">'+
1826: 'Link resource</a></td></tr>');
1.5 www 1827: }
1.4 www 1828: parent.mapout.document.writeln('<tr><td colspan=2><table><tr>');
1.3 www 1829: for (j=2;j<data2.length;j++) {
1.4 www 1830: data4=data2[j].split(':');
1831: data3=objlinks[data4[2]].split(':');
1.3 www 1832: if (data3.length>1) {
1833: if (data3[1]==nr) {
1.4 www 1834: cck='#AAAAAA';
1835: if (data3[2]!=0) {
1836: cck=condcolor((objcont[data3[2]].split(':'))[1]);
1837: condid=data3[2];
1838: } else {
1839: condid='-';
1840: }
1841: parent.mapout.document.writeln(
1842: '<td bgcolor='+cck+'>Next<br>');
1843: parent.mapout.document.writeln(
1844: '<a href="javascript:parent.code.handler('+
1845: "'c&"+data4[0]+'&'+i+'&'+data4[2]+'&'+condid+"');"
1846: +'">Edit</a>');
1.3 www 1847: parent.mapout.document.writeln('</td>');
1848: }
1849: }
1850: }
1851: for (j=2;j<data2.length;j++) {
1.4 www 1852: data4=data2[j].split(':');
1853: data3=objlinks[data4[2]].split(':');
1.3 www 1854: if (data3.length>1) {
1855: if ((data3[1]!=nr) && (data3[1]!=0)) {
1.4 www 1856: cck='#AAAAAA';
1857: if (data3[2]!=0) {
1858: cck=condcolor((objcont[data3[2]].split(':'))[1]);
1859: condid=data3[2];
1860: } else {
1861: condid='-';
1862: }
1.3 www 1863: parent.mapout.document.writeln(
1.4 www 1864: '<td bgcolor='+cck+'>To: '+robjs[data3[1]]+'<br>');
1865: parent.mapout.document.writeln(
1866: '<a href="javascript:parent.code.handler('+
1867: "'c&"+data4[0]+'&'+i+'&'+data4[2]+'&'+condid+"');"
1868: +'">Edit</a>');
1.3 www 1869: parent.mapout.document.writeln('</td>');
1870: }
1871: }
1872: }
1873: parent.mapout.document.writeln(
1.4 www 1874: '</tr></table></td></tr></table></form>');
1.5 www 1875: insrestab(rrow[data2[1]],i,nr,data1[3]);
1.4 www 1876:
1.3 www 1877: }
1878: }
1879: }
1880:
1.4 www 1881: // ----------------------------------------------------- Insert Resource Output
1882:
1.5 www 1883: function insrestab(irow,be,af,typ) {
1.4 www 1884: parent.mapout.document.writeln('<tr><td colspan=2>'+
1885: '<table><tr><td><a href="javascript:parent.code.insertrow('
1886: +irow+');parent.code.newresource(parent.code.maxrow,'+rcol[1]
1887: +",'','','false','normal');parent.code.mostrecent=parent.code.obj.length-1;"
1888: +'parent.code.draw();">'
1889: +'Insert resource</a></td><td>');
1.5 www 1890: if ((be!=-1) && (typ!='finish')) {
1.4 www 1891: parent.mapout.document.writeln(
1892: '<a href="javascript:parent.code.insertrow('
1893: +irow+');parent.code.newresource(parent.code.maxrow,'+rcol[0]
1894: +",'','','false','normal');parent.code.mostrecent=parent.code.obj.length-1;"
1895: +'parent.code.joinres('+be+',parent.code.mostrecent,0);'
1896: +'parent.code.draw();">'
1897: +'Insert resource linked to from above</a><br>');
1898: }
1.5 www 1899: if ((be!=-1) && (af!=-1) && (typ!='finish')) {
1.4 www 1900: parent.mapout.document.writeln(
1901: '<a href="javascript:parent.code.insertrow('
1902: +irow+');parent.code.newresource(parent.code.maxrow,'+rcol[0]
1903: +",'','','false','normal');parent.code.mostrecent=parent.code.obj.length-1;"
1904: +'parent.code.joinres('+be+',parent.code.mostrecent,0);'
1905: +'parent.code.joinres(parent.code.mostrecent,'+af+',0);'
1906: +'parent.code.draw();">'
1907: +'Insert resource linked to from above and linking to below</a><br>');
1908: }
1909: if (af!=-1) {
1910: parent.mapout.document.writeln(
1911: '<a href="javascript:parent.code.insertrow('
1912: +irow+');parent.code.newresource(parent.code.maxrow,'+rcol[0]
1913: +",'','','false','normal');parent.code.mostrecent=parent.code.obj.length-1;"
1914: +'parent.code.joinres(parent.code.mostrecent,'+af+',0);'
1915: +'parent.code.draw();">'
1916: +'Insert resource linking to below</a><br>');
1917: }
1918: parent.mapout.document.writeln('</td></tr></table></tr>');
1919: }
1920: // ---------------------------------------- Draw simple table instead of graph
1921:
1922: function simpletabledraw() {
1923: var objsorted=new Array();
1924: var robjs=new Array();
1925: var iobjs=new Array();
1926: var k;
1927: var i;
1928: var j;
1929: var nr;
1930: var ck;
1931: var cck;
1932: var condid;
1933: var sortstr=sortobjs();
1934: if (sortstr!='') {
1935: objsorted=sortstr.split('&');
1936: for (k=0;k<objsorted.length;k++) {
1937: i=(objsorted[k].split(':'))[0];
1938: iobjs[k]=i;
1939: robjs[i]=k;
1940: }
1941: for (k=0;k<iobjs.length;k++) {
1942: i=iobjs[k];
1943: if (k<objsorted.length-1) {
1944: nr=iobjs[k+1];
1945: } else {
1946: nr=-1;
1947: }
1948: data1=objcont[i].split(':');
1949: ck=rescolor(data1[2],data1[3]);
1950: parent.mapout.document.write('<tr><td bgcolor="'+ck
1951: +'"><b>'+k+'</b></td><td bgcolor="'+ck
1952: +'">');
1953: data2=obj[i].split('&');
1954: parent.mapout.document.write('<table>');
1.5 www 1955: if (data1[3]=='start') {
1956: parent.mapout.document.writeln('<tr><td><b>Start</b></td></tr>');
1957: }
1958: if (data1[3]=='finish') {
1959: parent.mapout.document.writeln('<tr><td><b>Finish</b></td></tr>');
1960: }
1.4 www 1961: parent.mapout.document.write(
1962: '<tr><td>Title:</td><td>'+data1[0]+'</td></tr>');
1963: parent.mapout.document.write(
1964: '<tr><td>URL:</td><td>'+data1[1]+'</td></tr>'
1965: +'<tr><td colspan=2><table><tr>');
1966: for (j=2;j<data2.length;j++) {
1967: data4=data2[j].split(':');
1968: data3=objlinks[data4[2]].split(':');
1969: if (data3.length>1) {
1970: if (data3[1]==nr) {
1971: cck='#AAAAAA';
1972: if (data3[2]!=0) {
1973: cck=condcolor((objcont[data3[2]].split(':'))[1]);
1974: condid=data3[2];
1975: } else {
1976: condid='-';
1977: }
1978: parent.mapout.document.writeln(
1979: '<td bgcolor='+cck+'>Next<br>');
1980: parent.mapout.document.writeln('</td>');
1981: }
1982: }
1983: }
1984: for (j=2;j<data2.length;j++) {
1985: data4=data2[j].split(':');
1986: data3=objlinks[data4[2]].split(':');
1987: if (data3.length>1) {
1988: if ((data3[1]!=nr) && (data3[1]!=0)) {
1989: cck='#AAAAAA';
1990: if (data3[2]!=0) {
1991: cck=condcolor((objcont[data3[2]].split(':'))[1]);
1992: condid=data3[2];
1993: } else {
1994: condid='-';
1995: }
1996: parent.mapout.document.writeln(
1997: '<td bgcolor='+cck+'>To: '+robjs[data3[1]]+'<br>');
1998: parent.mapout.document.writeln('</td>');
1999: }
2000: }
2001: }
2002: parent.mapout.document.writeln('</tr></table></td></tr></table></tr>');
2003: }
2004: } else {
2005: parent.mapout.document.writeln('<tr><td>No Resources</td></tr>');
2006: }
2007: }
2008:
1.3 www 2009: // ---------------------------------- Sort objects to straighten graph or table
2010:
2011: function sortobjs() {
1.8 ! www 2012: message("Sorting Resources: "+funny);
1.2 www 2013: var k;
2014: var ij;
1.3 www 2015: var dol;
2016: var dtl;
1.2 www 2017: var kj;
1.3 www 2018: var sortthis=0;
1.2 www 2019: var objsort=new Array();
2020: for (k=1;k<objcont.length;k++) {
2021: if (objcont[k]) {
2022: data1=objcont[k].split(':');
2023: if (data1[data1.length-1]=='res') {
2024: objsort[objsort.length]=''+k;
2025: }
2026: }
2027: }
1.3 www 2028: if (objsort.length==0) { return ''; }
1.2 www 2029: for (k=1;k<objlinks.length;k++) {
1.8 ! www 2030: wheelswitch();
! 2031: message("Sorting Resources: "+funny);
1.3 www 2032: if (objlinks[k]!='') {
2033: sortthis=1;
1.2 www 2034: data1=objlinks[k].split(':');
2035: kj=-1;
2036: for (j=0;j<objsort.length;j++) {
2037: if ((objsort[j].split(':'))[0]==data1[0]) {
2038: kj=j;
2039: }
2040: }
1.8 ! www 2041: if (kj!=-1) { objsort[kj]+=':'+data1[1]; }
1.3 www 2042: }
1.2 www 2043: }
1.3 www 2044: if (sortthis!=0) {
2045: for (k=0;k<objsort.length;k++) {
1.8 ! www 2046: wheelswitch();
! 2047: message("Sorting Resources: "+funny);
1.3 www 2048: for (j=0;j<objsort.length;j++) {
2049: if (k!=j) {
2050: data1=objsort[k].split(':');
2051: data2=objsort[j].split(':');
2052: dol=data1.length;
2053: dtl=data2.length;
1.8 ! www 2054: if (dol+dtl<200) {
! 2055: for (kj=1;kj<dol;kj++) {
1.3 www 2056: if (data1[kj]==data2[0]) {
2057: for (ij=1;ij<dtl;ij++) {
2058: data1[data1.length]=data2[ij];
2059: }
2060: }
1.8 ! www 2061: }
! 2062: for (kj=1;kj<dtl;kj++) {
1.3 www 2063: if (data2[kj]==data1[0]) {
2064: for (ij=1;ij<dol;ij++) {
1.8 ! www 2065: data2[data2.length]=data1[ij];
! 2066: }
! 2067: }
! 2068: }
! 2069: objsort[k]=data1.join(':');
! 2070: objsort[j]=data2.join(':');
1.3 www 2071: }
2072: }
2073: }
1.2 www 2074: }
1.8 ! www 2075: message("Sorting Resources: finishing up.");
1.3 www 2076: return objsort.sort(rescompare).join('&');
2077: } else {
2078: return objsort.join('&');
2079: }
1.2 www 2080: }
2081:
1.3 www 2082: // ----------------------------------------------------------- Straighten graph
1.1 www 2083:
2084: function graphopt() {
1.3 www 2085: var k;
2086: var kj;
2087: var ij;
2088:
2089: var objsorted=new Array();
2090: condense();
2091: graphreset();
2092: objsorted=(sortobjs()).split('&');
2093: if (objsorted.length==0) { return; }
2094: message("Creating Optimized Graph");
1.1 www 2095: var thisnewobj=''+(objsorted[0].split(':'))[0];
2096: rowcont[1]=thisnewobj;
2097: var thiscolmax=1;
2098: obj[thisnewobj]='b&1&'+thiscolmax+':0:0:0';
2099: var allcolmax=0;
2100: for (k=1;k<objsorted.length;k++) {
2101: thisnewobj=(objsorted[k].split(':'))[0];
2102: if (rescompare(objsorted[k-1],objsorted[k])==0) {
2103: rowcont[rowcont.length-1]+=':'+thisnewobj;
2104: thiscolmax++;
2105: } else {
2106: rowcont[rowcont.length]=thisnewobj;
2107: thiscolmax=1;
2108: }
2109: kj=rowcont.length-1;
1.5 www 2110: obj[thisnewobj]='b&'+kj+'&'+thiscolmax+':0:0:0';
2111: if (thiscolmax>allcolmax) { allcolmax=thiscolmax; }
1.1 www 2112: }
2113: for (k=0;k<obj.length;k++) {
2114: if (!obj[k]) { obj[k]=''; }
2115: }
2116: for (k=0;k<=allcolmax;k++) { insertcol(0); }
2117: for (k=0;k<rowcont.length;k++) {
2118: row[k]=k;
2119: }
2120: maxrow=rowcont.length-1;
2121:
2122: var oldlinks=new Array();
2123: for (k=0;k<objlinks.length;k++) { oldlinks[k]=objlinks[k]; }
2124: objlinks.length=0;
2125: objlinks[0]='';
2126: for (k=0;k<objsorted.length;k++) {
2127: kj=(objsorted[k].split(':'))[0];
2128: for (ij=1;ij<oldlinks.length;ij++) {
2129: if (oldlinks[ij]) {
2130: data1=oldlinks[ij].split(':');
2131: if (data1[0]==kj) {
2132: joinres(data1[0],data1[1],data1[2]);
2133: }
2134: }
2135: }
2136: }
1.3 www 2137: graphdef='yes';
1.1 www 2138: }
2139:
2140: // ----------------------------------------------------------- Remove e-objects
2141:
2142: function condense() {
1.3 www 2143: message("Condensing");
1.1 www 2144: var j;
2145: for (j=0;j<=maxrow;j++) {
2146: if (rowcont[j]!='') {
2147: data1=rowcont[j].split(':');
2148: rowcont[j]='';
2149: for (k=0;k<data1.length;k++) {
2150: if (obj[data1[k]].substring(0,2)!='e&') {
2151: if (rowcont[j]!='') { rowcont[j]+=':'; }
2152: rowcont[j]+=data1[k];
2153: }
2154: }
2155: }
2156: }
2157: }
2158:
2159: // ---------------------------------------------------- Load from hidden fields
2160:
2161: function load() {
1.4 www 2162: message("Loading");
1.8 ! www 2163: schedule('load');
! 2164: checkdef();
! 2165: }
! 2166:
! 2167: function finishload() {
1.4 www 2168: var k;
2169: for (k=0;k<objcont.length;k++) { objcont[k]=''; }
1.1 www 2170: objcont.length=0;
1.4 www 2171: for (k=0;k<objlinks.length;k++) { objlinks[k]=''; }
1.1 www 2172: objlinks.length=0;
2173: objlinks[0]='';
2174: objcont[0]='';
2175: editmode=0;
2176: notclear=0;
2177: lastinfo='';
2178: graphreset();
1.2 www 2179: var inputstr=parent.server.document.forms.storage.output.value;
1.3 www 2180: if (inputstr!='') {
1.1 www 2181: data1=inputstr.split('<&>');
2182: var k;
2183: for (k=0;k<data1.length;k++) {
2184: data2=data1[k].split('<:>');
2185: if (data2[0]=='graphdef') { graphdef=data2[1]; }
2186: if (data2[0]=='maxcol') { maxcol=1*data2[1]; }
2187: if (data2[0]=='maxrow') { maxrow=1*data2[1]; }
2188: if (data2[0]=='obj') { obj[data2[1]]=data2[2]; }
2189: if (data2[0]=='objcont') { objcont[data2[1]]=data2[2]; }
2190: if (data2[0]=='objlinks') { objlinks[data2[1]]=data2[2]; }
2191: if (data2[0]=='rowcont') { rowcont[data2[1]]=data2[2]; }
2192: if (data2[0]=='row') { row[data2[1]]=1*data2[2]; }
2193: if (data2[0]=='col') { col[data2[1]]=1*data2[2]; }
1.6 www 2194: if (data2[0]=='mode') { mode=data2[1]; }
1.3 www 2195: if (data2[0]=='tablemode') { tablemode=1*data2[1]; }
1.4 www 2196: if (data2[0]=='zscale') { zscale=1*data2[1]; }
1.1 www 2197: }
1.3 www 2198: }
1.1 www 2199: }
2200:
1.2 www 2201: // -------------------------------------------------------------- Undo function
2202:
2203: function undo() {
2204: if (undopointer>1) {
2205: undopointer--;
2206: parent.server.document.forms.storage.output.value
2207: =undostack[undopointer];
1.8 ! www 2208: finishload();
1.2 www 2209: undopointer--;
2210: draw();
2211: stored=0;
2212: } else {
2213: alert("Cannot undo: reached beginning of edit session");
2214: }
2215: }
2216:
2217: // -------------------------------------------------------------- Redo function
2218:
2219: function redo() {
2220: if (undopointer<undostack.length-1) {
2221: undopointer++;
2222: parent.server.document.forms.storage.output.value
2223: =undostack[undopointer];
1.8 ! www 2224: finishload();
1.2 www 2225: undopointer--;
2226: draw();
2227: stored=0;
2228: } else {
2229: alert("Cannot redo: reached end of edit session");
2230: }
2231: }
2232:
2233: // ------------------------------------------------------------ Revert function
2234:
2235: function revert() {
2236: if (confirm("Revert to beginning of edit session?")) {
2237: undopointer=2;
2238: undo();
2239: }
2240: }
2241:
1.8 ! www 2242: // ---------------------------------------------------------------- Wheelswitch
! 2243:
! 2244: function wheelswitch() {
! 2245: if (funny=='|') {
! 2246: funny='/';
! 2247: } else {
! 2248: if (funny=='/') {
! 2249: funny='-';
! 2250: } else {
! 2251: if (funny=='-') {
! 2252: funny='\\';
! 2253: } else {
! 2254: if (funny=='\\') { funny='|'; }
! 2255: }
! 2256: }
! 2257: }
! 2258: }
! 2259:
! 2260: // --------------------------------------------- Checks if server frame defined
! 2261:
! 2262: function checkdef() {
! 2263: if (parent.server.document.forms.storage.output.value!=undefined) {
! 2264: srvloaded();
! 2265: }
! 2266: if ((finishdone==0) && (tim==0)) { setTimeout('checkdef()',100); }
! 2267: }
! 2268:
! 2269: // ---------------------------------------------------------- The wait function
! 2270:
! 2271: function wait() {
! 2272: if ((finishdone==1) || (tim==1)) {
! 2273: if (tim==0) {
! 2274: clearTimeout(canceltim);
! 2275: if (reqaction=='save') { finishsave(); }
! 2276: if (reqaction=='load') { finishload(); draw(); }
! 2277: } else {
! 2278: alert("Server Communication Timed Out.");
! 2279: }
! 2280: } else {
! 2281: wheelswitch();
! 2282: message('Waiting for server reply: '+funny);
! 2283: setTimeout('wait();',100);
! 2284: }
! 2285: }
! 2286:
! 2287: // ---------------------------------------------------------- Schedule function
! 2288:
! 2289: function schedule(action) {
! 2290: reqaction=action;
! 2291: tim=0;
! 2292: finishdone=0;
! 2293: canceltim=setTimeout('tim=1;',20000)
! 2294: wait();
! 2295: }
! 2296:
1.2 www 2297: // -------------------------------------------------------------- Store changes
2298:
2299: function storechange() {
1.8 ! www 2300: var k;
1.2 www 2301: parent.server.document.forms.storage.submit();
1.8 ! www 2302: schedule('save');
! 2303: }
! 2304:
! 2305: function finishsave() {
! 2306: finishload();
1.7 www 2307: draw();
1.2 www 2308: stored=1;
2309: }
2310:
1.8 ! www 2311: // --------------------------------------- Gets called when submission finished
! 2312:
! 2313: function srvloaded() {
! 2314: finishdone=1;
! 2315: message("Server replied.");
! 2316: }
! 2317:
1.2 www 2318: // ---------------------------------------------------------------- Toggle Mode
2319:
2320: function togglemode() {
1.4 www 2321: if (tablemode==0) {
2322: tablemode=1;
2323: } else {
2324: if (tablemode==1) {
2325: tablemode=2;
2326: } else {
2327: tablemode=0;
2328: }
2329: }
2330: notclear=0;
2331: infoclear();
1.2 www 2332: draw();
2333: }
2334:
1.1 www 2335: // -------------------------------------------------------- Main program onLoad
2336:
2337: function main() {
2338:
2339: if (mainrun==0) {
1.5 www 2340: infopen();
2341: infoclear();
1.1 www 2342: load();
1.2 www 2343: stored=1;
1.1 www 2344: mainrun=1;
2345: }
2346:
2347: }
2348:
1.2 www 2349: // ------------------------------------------------------------- Save on leave?
2350:
2351: function leave() {
1.5 www 2352: if (!inf.closed) {
2353: inf.close();
2354: }
1.2 www 2355: if (stored==0) {
2356: if (confirm('Store changes?')) {
2357: storechange();
2358: }
2359: }
2360: }
2361:
1.1 www 2362: </script>
2363: </head>
2364:
1.2 www 2365: <body bgcolor="#FFFFFF" onLoad="main();" onUnload="leave();">
2366: <a href="javascript:togglemode();">Toggle Display Mode</a>
1.4 www 2367: <a href="javascript:if (zscale>1) { zscale--; draw();}">Zoom Out</a>
2368: <a href="javascript:if (zscale<3) { zscale++; draw();}">Zoom In</a>
1.2 www 2369: <a href="javascript:condense();draw();">Condense</a>
2370: <a href="javascript:graphopt();draw();">Straighten</a>
2371: <a href="javascript:revert();">Revert</a>
2372: <a href="javascript:undo();">Undo</a>
2373: <a href="javascript:redo();">Redo</a>
2374: <a href="javascript:storechange();">Store</a>
1.1 www 2375: </body>
1.2 www 2376: </html>
2377:
2378:
2379:
2380:
2381:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>