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