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