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