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