Annotation of rat/client/code.html, revision 1.1
1.1 ! www 1: <html>
! 2:
! 3: <!--
! 4: The LearningOnline Network
! 5: Resource Assembly Tool
! 6: 7/23,7/24,7/26,
! 7: 8/11,8/14,8/18,8/19,8/20,8/21,8/22,8/25,8/26,8/28,8/30,8/31,
! 8: 9/1,9/2,9/4,9/5,9/6,
! 9: 1/7,1/8,1/10,1/14,1/15,1/16,1/21,1/22,
! 10: 1/29,1/30,1/31,
! 11: 2/2,2/3,2/10,2/12,2/13,2/14,2/15,2/17,2/18,
! 12: 2/19,2/20,2/21,2/22 Gerd Kortemeyer with Scott Harrison
! 13: -->
! 14:
! 15:
! 16: <head>
! 17: <script language="JavaScript">
! 18:
! 19: var row=new Array();
! 20: var maxrow=-1;
! 21: var col=new Array();
! 22: var maxcol=-1;
! 23: var colmap=new Array();
! 24: var colmap2=new Array();
! 25: var colmap3=new Array();
! 26: var colmap4=new Array();
! 27: var colmap5=new Array();
! 28: var colmap6=new Array();
! 29: var obj=new Array();
! 30: var objcont=new Array();
! 31: var objlinks=new Array();
! 32: var rowcont=new Array();
! 33: var rowtype=new Array();
! 34: var coltype=new Array();
! 35: var rcol=new Array();
! 36: var rrow=new Array();
! 37: var cw=new Array();
! 38: var rh=new Array();
! 39:
! 40: var editmode=0;
! 41: var notclear=0;
! 42: var linkmode=0;
! 43: var lastinfo='';
! 44: var graphdef='no';
! 45: var mainrun=0;
! 46:
! 47: var data1=new Array(1024);
! 48: var data2=new Array(1024);
! 49: var data3=new Array(1024);
! 50: var data4=new Array(1024);
! 51: var data5=new Array(1024);
! 52:
! 53:
! 54: // ------------------------------------------------ Insert a row into the table
! 55:
! 56: function insertrow(j,ex1,ex2) {
! 57: var kj;
! 58: objects1='';
! 59: objects2='';
! 60: for (kj=0;kj<=maxrow;kj++) {
! 61: if ( row[kj]==j ) { objects1=rowcont[kj]; }
! 62: if ( row[kj]==j+1 ) { objects2=rowcont[kj]; }
! 63: if ( row[kj]>j ) { row[kj]++; }
! 64: }
! 65: maxrow++;
! 66: row[maxrow]=j+1;
! 67: rowcont[maxrow]=':';
! 68: colcover=':'+ex1+':'+ex2+':';
! 69: objects=objects1+':'+objects2;
! 70: data1=objects.split(':');
! 71: for (kj=0;kj<data1.length;kj++) {
! 72: if (data1[kj]!='') {
! 73: thisisobj=obj[data1[kj]];
! 74: thisobjtype=thisisobj.split('&')[0];
! 75: if (thisobjtype=='v') {
! 76: if (rowcont[maxrow].indexOf(':'+data1[kj]+':',0)==-1) {
! 77: thisobjcol=thisisobj.split('&')[1];
! 78: if (colcover.indexOf(':'+thisobjcol+':',0)==-1) {
! 79: colcover+=thisobjcol+':';
! 80: rowcont[maxrow]+=data1[kj]+':';
! 81: }
! 82: }
! 83: }
! 84: if (thisobjtype=='h') {
! 85: updown=thisisobj.split('&')[4];
! 86: leftupdown=updown.split(':')[0];
! 87: rightupdown=updown.split(':')[1];
! 88: thisobjdest=thisisobj.split('&')[3];
! 89: thisobjtofrom=thisisobj.split('&')[2];
! 90: thisobjfrom=thisobjtofrom.split(':')[0];
! 91: thisobjto=thisobjtofrom.split(':')[1];
! 92: thisobjdir=col[thisobjto]-col[thisobjfrom];
! 93: thisobjrow=row[thisisobj.split('&')[1]];
! 94: topbottom=thisobjrow-j-1;
! 95: newobj='';
! 96: if (leftupdown==-1) {
! 97: if (topbottom<0) {
! 98: if (thisobjdir<0) {
! 99: newobj='v&'+thisobjto+'&'+thisobjdest+'&-1';
! 100: } else {
! 101: newobj='v&'+thisobjfrom+'&'+thisobjdest+'&1';
! 102: }
! 103: }
! 104: } else {
! 105: if (topbottom>0) {
! 106: if (thisobjdir<0) {
! 107: newobj='v&'+thisobjto+'&'+thisobjdest+'&1';
! 108: } else {
! 109: newobj='v&'+thisobjfrom+'&'+thisobjdest+'&-1';
! 110: }
! 111: }
! 112: }
! 113: if (newobj!='') {
! 114: thisobjcol=newobj.split('&')[1];
! 115: if (colcover.indexOf(':'+thisobjcol+':',0)==-1) {
! 116: colcover+=thisobjcol+':';
! 117: rowcont[maxrow]+=obj.length+':';
! 118: obj[obj.length]=newobj;
! 119: }
! 120: }
! 121: newobj='';
! 122: if (rightupdown==-1) {
! 123: if (topbottom<0) {
! 124: if (thisobjdir<0) {
! 125: newobj='v&'+thisobjfrom+'&'+thisobjdest+'&1';
! 126: } else {
! 127: newobj='v&'+thisobjto+'&'+thisobjdest+'&-1';
! 128: }
! 129: }
! 130: } else {
! 131: if (topbottom>0) {
! 132: if (thisobjdir<0) {
! 133: newobj='v&'+thisobjfrom+'&'+thisobjdest+'&-1';
! 134: } else {
! 135: newobj='v&'+thisobjto+'&'+thisobjdest+'&1';
! 136: }
! 137: }
! 138: }
! 139: if (newobj!='') {
! 140: thisobjcol=newobj.split('&')[1];
! 141: if (colcover.indexOf(':'+thisobjcol+':',0)==-1) {
! 142: colcover+=thisobjcol+':';
! 143: rowcont[maxrow]+=obj.length+':';
! 144: obj[obj.length]=newobj;
! 145: }
! 146: }
! 147: }
! 148: }
! 149: }
! 150: if (rowcont[maxrow]!=':') {
! 151: rowcont[maxrow]=rowcont[maxrow].substring(1,rowcont[maxrow].length-1);
! 152: } else {
! 153: rowcont[maxrow]='';
! 154: }
! 155: }
! 156:
! 157: // --------------------------------------------- Creates a new condition object
! 158:
! 159: function newcondition(content,type) {
! 160: var ko;
! 161: ko=obj.length;
! 162: obj[ko]='c';
! 163: objcont[ko]=content+':'+type+':cond';
! 164: return ko;
! 165: }
! 166:
! 167: // ---------------------------------------------- Creates a new resource object
! 168:
! 169: function newresource(rid,cid,text,url) {
! 170: objcont[addobj(rid,'b&'+rid+'&'+cid+':0:0:0')]=text+':'+url+':res';
! 171: }
! 172:
! 173:
! 174: // -------------------------------- Insert a condition into a port of an object
! 175:
! 176: function insertcond(obj1,portnr,cond) {
! 177: var k;
! 178: data1=obj[obj1].split('&');
! 179: for (k=2;k<data1.length;k++) {
! 180: data2=data1[k].split(':');
! 181: if (data2[0]==portnr) {
! 182: data2[3]=cond;
! 183: data1[k]=data2.join(':');
! 184: }
! 185: }
! 186: obj[obj1]=data1.join('&');
! 187: }
! 188:
! 189: // --------------------------------------------- Insert a column into the table
! 190: // Inserts a new table column after table column j
! 191:
! 192: function insertcol(j) {
! 193: var kj;
! 194: for (kj=0;kj<=maxcol;kj++) {
! 195: if ( col[kj]>j ) { col[kj]++; }
! 196: }
! 197: maxcol++;
! 198: col[maxcol]=j+1;
! 199: }
! 200:
! 201: // --------------------------------------------------------------- Find the row
! 202:
! 203: function findrow(jid) {
! 204: var j;
! 205: for (j=0;j<=maxrow;j++) { if (row[j]==jid) { return j; } }
! 206: return -1;
! 207: }
! 208:
! 209: // --------------------------------------------------------------- Find the col
! 210:
! 211: function findcol(jid) {
! 212: var j;
! 213: for (j=0;j<=maxcol;j++) { if (col[j]==jid) { return j; } }
! 214: return -1;
! 215: }
! 216:
! 217: // -------------------------------------------------------------- Map out a row
! 218: //
! 219: // b&rowID&colID:inObj:outObj:outCond&...
! 220: // h&rowID&incolID:outcolID&inObj:outObj&inupdown:outupdown
! 221: // v&colID&inObj:outObj&updown
! 222: //
! 223: // returns middle (col number of middle of obj1)
! 224: // sets colmap (map of cols with object numbers)
! 225:
! 226: function maprow (jid,obj1,ign) {
! 227: var j; var k; var left; var right; var middle;
! 228: middle=-1;
! 229: for (j=0;j<=maxcol;j++) { colmap[j]=0; }
! 230: if (rowcont[jid]!='') {
! 231: data2=rowcont[jid].split(':');
! 232: for (j=0;j<data2.length;j++) {
! 233: data3=obj[data2[j]].split('&');
! 234: if (data3[0]=='b') {
! 235: left=maxcol;
! 236: right=0;
! 237: for (k=2;k<data3.length;k++) {
! 238: thiscol=col[data3[k].split(':')[0]];
! 239: if (thiscol<left) { left=thiscol; }
! 240: if (thiscol>right) { right=thiscol; }
! 241: }
! 242: }
! 243: if (data3[0]=='h') {
! 244: data4=data3[2].split(':');
! 245: if (col[data4[1]]>col[data4[0]]) {
! 246: left=col[data4[0]];
! 247: right=col[data4[1]];
! 248: } else {
! 249: right=col[data4[0]];
! 250: left=col[data4[1]];
! 251: }
! 252: }
! 253: if (data3[0]=='v') { left=col[data3[1]]; right=left; }
! 254: if (data2[j]==obj1) { middle=Math.round((left+right)/2); }
! 255: if ((data3[0]!='h') || (ign!=1)) {
! 256: for (k=left;k<=right;k++) { colmap[k]=data2[j]; }
! 257: } else {
! 258: colmap[left]=data2[j];
! 259: colmap[right]=data2[j];
! 260: }
! 261: }
! 262: }
! 263: return middle;
! 264: }
! 265:
! 266: // --------------------------------------------------------- Find hole in a row
! 267: // jid: rowID
! 268: // kid: colID, find point close to this
! 269: // dkid: destination colID
! 270: // returns colID
! 271:
! 272: function comingthru (jid,kid,dkid) {
! 273: var k;
! 274: maprow(jid,-1,1);
! 275: knum=col[kid];
! 276: if (colmap[knum]==0) { return kid; }
! 277: right=-1;
! 278: for (k=knum+1;(k<colmap.length) && (right==-1);k++) {
! 279: if ((right==-1) && (colmap[k]!=colmap[knum])) { right=k; }
! 280: }
! 281: left=-1;
! 282: for (k=knum-1;(k>=0) && (left==-1);k--) {
! 283: if ((left==-1) && (colmap[k]!=colmap[knum])) { left=k; }
! 284: }
! 285: kup=-1;
! 286:
! 287: if ((left==-1) && (right==-1)) { right=colmap.length; }
! 288:
! 289: dknum=col[dkid];
! 290: dleft=left-dknum;
! 291: dright=right-dknum;
! 292:
! 293: if (dleft<0) { dleft=-dleft; }
! 294: if (dright<0) { dright=-dright; }
! 295: if ((dright<=dleft) && (right!=-1)) { kup=right; }
! 296: if ((dright>=dleft) && (left!=-1)) { kup=left; }
! 297: if (colmap[kup]==0) { return findcol(kup); }
! 298:
! 299: if (kup==right) { kup--; }
! 300:
! 301: if (kup<0) {
! 302: insertcol(-1);
! 303: insertcol(0);
! 304: } else {
! 305: insertcol(kup);
! 306: }
! 307: return maxcol;
! 308: }
! 309:
! 310: // ----------------------------------------------------- Insert port into block
! 311: // obj1: object number
! 312: // d: direction from middle (>0: right, <0 left)
! 313: // inout: in or out port (1: in, 2: out)
! 314: // linkobj: object that the link goes to/comes from
! 315: // sets inrow or outrow
! 316: // return column
! 317:
! 318:
! 319: function insertport (obj1,d,inout,linkobj) {
! 320:
! 321:
! 322: var k; var port; var revport;
! 323: data1=obj[obj1].split('&');
! 324: middle=maprow(data1[1],obj1,0);
! 325: if (inout==1) {
! 326: inrow=data1[1];
! 327: } else {
! 328: outrow=data1[1];
! 329: }
! 330: if (d>0) {
! 331: for (k=middle;(colmap[k]==obj1) && (k<colmap.length);k++) { data3[k]=0; }
! 332: } else {
! 333: for (k=middle;(colmap[k]==obj1) && (k>=0);k--) { data3[k]=0; }
! 334: }
! 335: for (k=2;k<data1.length;k++) {
! 336: data2=data1[k].split(':');
! 337: data3[col[data2[0]]]=data2[inout];
! 338: }
! 339: port=-1;
! 340: if (d>0) {
! 341: for (k=middle;(colmap[k]==obj1) && (k<colmap.length);k++) {
! 342: if ((data3[k]==0) && (colmap[k]==obj1) && (port==-1)) { port=k; }
! 343: }
! 344: } else {
! 345: for (k=middle;(colmap[k]==obj1) && (k>=0);k--) {
! 346: if ((data3[k]==0) && (colmap[k]==obj1) && (port==-1)) { port=k; }
! 347: }
! 348: }
! 349:
! 350: if (port==-1) {
! 351: if (colmap[k]==0) {
! 352: revport=findcol(k);
! 353: if (inout==1) {
! 354: data1[data1.length]=revport+":"+linkobj+":0:0";
! 355: } else {
! 356: data1[data1.length]=revport+":0:"+linkobj+":0";
! 357: }
! 358: } else {
! 359: if (d>0) {
! 360: insertcol(k-1);
! 361: } else {
! 362: insertcol(k);
! 363: }
! 364: revport=maxcol;
! 365: if (inout==1) {
! 366: data1[data1.length]=revport+":"+linkobj+":0:0";
! 367: } else {
! 368: data1[data1.length]=revport+":0:"+linkobj+":0";
! 369: }
! 370: }
! 371: } else {
! 372: portfound=-1;
! 373: for (k=2;k<data1.length;k++) {
! 374: data2=data1[k].split(':');
! 375: if (col[data2[0]]==port) {
! 376: data2[inout]=linkobj;
! 377: data1[k]=data2.join(':');
! 378: portfound=1;
! 379: }
! 380: }
! 381: revport=findcol(port);
! 382: if (portfound==-1) {
! 383: if (inout==1) {
! 384: data1[data1.length]=revport+":"+linkobj+":0:0";
! 385: } else {
! 386: data1[data1.length]=revport+":0:"+linkobj+":0";
! 387: }
! 388: }
! 389: }
! 390: obj[obj1]=data1.join('&');
! 391: return revport;
! 392: }
! 393:
! 394: // ---------------------------- Make a new object and add it to the row content
! 395: // returns object number of generated object
! 396:
! 397: function addobj(kjid,objs) {
! 398: if (rowcont[kjid]!='') { rowcont[kjid]+=':'; }
! 399: rowcont[kjid]+=obj.length;
! 400: obj[obj.length]=objs;
! 401: return obj.length-1;
! 402: }
! 403:
! 404: // ---------------------------------------- Make horizontal connection for hrid
! 405: // hoffs=-1: this line goes on top of hrid
! 406:
! 407: function horizontal(hrid,hoffs,hfcol,htcol,hdest,hends) {
! 408: hcrid=-1;
! 409: if (hoffs==-1) {
! 410: hbrid=findrow(row[hrid]-1);
! 411: } else {
! 412: hbrid=findrow(row[hrid]+1);
! 413: }
! 414: if (hbrid!=-1) {
! 415: maprow(hbrid,-1,0);
! 416: hcrid=hbrid;
! 417: if (col[hfcol]>col[htcol]) { left=col[htcol]; right=col[hfcol]; }
! 418: else { right=col[htcol]; left=col[hfcol]; }
! 419: if (colmap[left]!=0) {
! 420: hcrid=-1;
! 421: } else {
! 422: if (colmap[right]!=0) {
! 423: hcrid=-1;
! 424: } else {
! 425: for (kh=left+1;kh<right;kh++) {
! 426: if (colmap[kh]!=0) {
! 427: if (obj[colmap[kh]].split('&')[0]!='v') { hcrid=-1; }
! 428: }
! 429: }
! 430: }
! 431: }
! 432: }
! 433:
! 434: if (hcrid==-1) {
! 435: insertrow(row[hrid]+hoffs,hfcol,htcol);
! 436: addobj(maxrow,'h&'+maxrow+'&'+hfcol+':'+htcol+'&'+hdest+'&'+hends);
! 437: } else {
! 438: addobj(hcrid,'h&'+hcrid+'&'+hfcol+':'+htcol+'&'+hdest+'&'+hends);
! 439: }
! 440: }
! 441:
! 442: // --------------------------------------- Deletes all references to object obj
! 443:
! 444: function delobj(obj1) {
! 445: var k;
! 446: for (k=0;k<rowcont.length;k++) {
! 447: data4=rowcont[k].split(':');
! 448: rowcont[k]='';
! 449: for (k2=0;k2<data4.length;k2++) {
! 450: if (data4[k2]!=obj1) {
! 451: if (rowcont[k]!='') { rowcont[k]+=':'; }
! 452: rowcont[k]+=data4[k2];
! 453: }
! 454: }
! 455: }
! 456: }
! 457:
! 458: // --------------------------------------------------------- Garbage collection
! 459:
! 460: function cleanup () {
! 461: var j,kj,i;
! 462: insertrow(maxrow);
! 463: insertcol(maxcol);
! 464: addobj(maxrow,'e&'+maxcol);
! 465: for (kj=0;kj<=maxcol;kj++) { data1[kj]=0; }
! 466: for (kj=0;kj<=maxrow;kj++) {
! 467: rowtype[kj]=0;
! 468: if (rowcont[kj]!='') {
! 469: data2=rowcont[kj].split(':');
! 470: for (j=0;j<data2.length;j++) {
! 471: if (obj[data2[j]].substring(0,2)=='e&') {
! 472: rowtype[kj]=2;
! 473: data1[(obj[data2[j]].split('&'))[1]]=2;
! 474: }
! 475: }
! 476: maprow(kj,-1,1);
! 477: for (j=0;j<=maxcol;j++) {
! 478: if (colmap[j]!=0) {
! 479: if (data1[j]==0) { data1[j]=1; }
! 480: if (rowtype[kj]==0) {
! 481: if (obj[colmap[j]].substring(0,2)!='v&') {
! 482: rowtype[kj]=1;
! 483: }
! 484: }
! 485: if (obj[colmap[j]].substring(0,2)=='b&') {
! 486: data1[j]=2;
! 487: rowtype[kj]=2;
! 488: }
! 489: }
! 490: }
! 491: }
! 492: }
! 493: for (j=0;j<=maxcol;j++) {
! 494: coltype[j]=data1[col[j]];
! 495: }
! 496: }
! 497:
! 498: // -------------------------------------------- Delete a condition from a block
! 499:
! 500: function delcond(obj1,colid) {
! 501: var k;
! 502: data3=obj[obj1].split('&');
! 503: obj[obj1]=data3[0]+'&'+data3[1];
! 504: for (k=2;k<data3.length;k++) {
! 505: data4=data3[k].split(':');
! 506: if (data4[0]==colid) { data4[3]=0; }
! 507: if ((data4[1]!=0) || (data4[2]!=0) || (data3.length==3)) {
! 508: obj[obj1]+='&'+data4[0]+':'+data4[1]+':'+data4[2]+':'+data4[3];
! 509: }
! 510: }
! 511: }
! 512:
! 513: // ----------------------------------------- Creates a new condition in a block
! 514:
! 515: function crecond(obj1,colid,condtext,condtype) {
! 516: var k;
! 517: data3=obj[obj1].split('&');
! 518: obj[obj1]=data3[0]+'&'+data3[1];
! 519: for (k=2;k<data3.length;k++) {
! 520: data4=data3[k].split(':');
! 521: if (data4[0]==colid) {
! 522: data4[3]=newcondition(condtext,condtype);
! 523: data2=objlinks[data4[2]].split(':');
! 524: objlinks[data4[2]]=data2[0]+':'+data2[1]+':'+data4[3];
! 525: }
! 526: if ((data4[1]!=0) || (data4[2]!=0) || (data3.length==3)) {
! 527: obj[obj1]+='&'+data4[0]+':'+data4[1]+':'+data4[2]+':'+data4[3];
! 528: }
! 529: }
! 530: }
! 531:
! 532: // ---------------------------------------- Delete the path between two objects
! 533: // deletes the link linknr
! 534: // h&rowID&incolID:outcolID&inObj:outObj&inupdown:outupdown
! 535: // v&colID&inObj:outObj&updown
! 536:
! 537: function dellink (linknr) {
! 538: var k; var obj1; var obj2;
! 539: if (objlinks[linknr]!='') {
! 540: data3=objlinks[linknr].split(':');
! 541: obj1=data3[0];
! 542: obj2=data3[1];
! 543: data3=obj[obj1].split('&');
! 544: obj[obj1]=data3[0]+'&'+data3[1];
! 545: for (k=2;k<data3.length;k++) {
! 546: data4=data3[k].split(':');
! 547: if (data4[2]==linknr) { data4[2]=0; data4[3]==0; }
! 548: if ((data4[1]!=0) || (data4[2]!=0) || (data3.length==3)) {
! 549: obj[obj1]+='&'+data4[0]+':'+data4[1]+':'+data4[2]+':'+data4[3];
! 550: }
! 551: }
! 552: data3=obj[obj2].split('&');
! 553: obj[obj2]=data3[0]+'&'+data3[1];
! 554: for (k=2;k<data3.length;k++) {
! 555: data4=data3[k].split(':');
! 556: if (data4[1]==linknr) { data4[1]=0; }
! 557: if ((data4[1]!=0) || (data4[2]!=0) || (data3.length==3)) {
! 558: obj[obj2]+='&'+data4[0]+':'+data4[1]+':'+data4[2]+':'+data4[3];
! 559: }
! 560: }
! 561: for (k=0;k<obj.length;k++) {
! 562: if (obj[k]!='') {
! 563: data3=obj[k].split('&');
! 564: if (((data3[0]=='v') || (data3[0]=='h')) &&
! 565: (data3[data3.length-2]==linknr)) {
! 566: delobj(k);
! 567: }
! 568: }
! 569: }
! 570: objlinks[linknr]='';
! 571: }
! 572: }
! 573:
! 574: // ----------------------------------------------------------- Join two objects
! 575: // Links obj1 with obj2, creates new objlink, marks all elements with number
! 576:
! 577: function joinres (obj1,obj2,cond) {
! 578: var k; var kr; var outcol; var incol; var d;
! 579: dest=objlinks.length;
! 580: objlinks[dest]=obj1+':'+obj2+':'+cond;
! 581: data3=obj[obj1].split('&');
! 582: sum=0;
! 583: for (k=2;k<data3.length;k++) { sum+=col[data3[k].split(':')[0]]; }
! 584: outmiddle=sum/(data3.length-2);
! 585: data3=obj[obj2].split('&');
! 586: sum=0;
! 587: for (k=2;k<data3.length;k++) { sum+=col[data3[k].split(':')[0]]; }
! 588: inmiddle=sum/(data3.length-2);
! 589: d=inmiddle-outmiddle;
! 590: outcol=insertport(obj1,d,2,dest);
! 591: insertcond(obj1,outcol,cond);
! 592: incol=insertport(obj2,-d,1,dest);
! 593: if (row[inrow]==(row[outrow]+1)) {
! 594: insertrow(row[outrow],-1,-1);
! 595: }
! 596: if (row[inrow]<row[outrow]) {
! 597: updown=1;
! 598: tcol=comingthru(inrow,incol,outcol);
! 599: horizontal(inrow,-1,tcol,incol,dest,'-1:-1');
! 600: addobj(inrow,'v&'+tcol+'&'+dest+'&1');
! 601: incol=tcol;
! 602: tcol=comingthru(outrow,outcol,incol);
! 603: horizontal(outrow,0,outcol,tcol,dest,'1:1');
! 604: addobj(outrow,'v&'+tcol+'&'+dest+'&1');
! 605: outcol=tcol;
! 606: } else {
! 607: updown=-1;
! 608: }
! 609:
! 610: if (inrow==outrow) {
! 611: tcol=comingthru(inrow,incol,outcol);
! 612: horizontal(inrow,-1,tcol,incol,dest,'-1:-1');
! 613: addobj(inrow,'v&'+tcol+'&'+dest+'&1');
! 614: horizontal(outrow,0,outcol,tcol,dest,'1:1');
! 615: } else {
! 616:
! 617: if (updown==-1) {
! 618: for (kr=row[outrow]+1;kr<row[inrow];kr++) {
! 619: rid=findrow(kr);
! 620: ncol=comingthru(rid,outcol,incol);
! 621:
! 622: if (ncol!=outcol) {
! 623: insertrow(kr-1,outcol,ncol);
! 624: kr++;
! 625: if (col[outcol]>col[ncol]) {
! 626: addobj(maxrow,
! 627: 'h&'+maxrow+'&'+outcol+':'+ncol+'&'+dest+'&-1:1');
! 628: } else {
! 629: addobj(maxrow,
! 630: 'h&'+maxrow+'&'+outcol+':'+ncol+'&'+dest+'&1:-1');
! 631: }
! 632: }
! 633: addobj(rid,'v&'+ncol+'&'+dest+'&-1');
! 634: outcol=ncol;
! 635: }
! 636:
! 637: if (incol!=outcol) {
! 638: insertrow(row[inrow]-1,outcol,incol);
! 639: if (col[outcol]>col[incol]) {
! 640: addobj(maxrow,
! 641: 'h&'+maxrow+'&'+outcol+':'+incol+'&'+dest+'&-1:1');
! 642: } else {
! 643: addobj(maxrow,
! 644: 'h&'+maxrow+'&'+outcol+':'+incol+'&'+dest+'&1:-1');
! 645: }
! 646: }
! 647:
! 648: } else {
! 649: for (kr=row[outrow]-1;kr>row[inrow];kr--) {
! 650: rid=findrow(kr);
! 651: ncol=comingthru(rid,outcol,incol);
! 652: if (ncol!=outcol) {
! 653: insertrow(kr,outcol,ncol);
! 654: if (col[outcol]>col[ncol]) {
! 655: addobj(maxrow,
! 656: 'h&'+maxrow+'&'+outcol+':'+ncol+'&'+dest+'&1:-1');
! 657: } else {
! 658: addobj(maxrow,
! 659: 'h&'+maxrow+'&'+outcol+':'+ncol+'&'+dest+'&-1:1');
! 660: }
! 661: }
! 662: addobj(rid,'v&'+ncol+'&'+dest+'&1');
! 663: outcol=ncol;
! 664: }
! 665: if (incol!=outcol) {
! 666: insertrow(row[inrow],outcol,incol);
! 667: if (col[outcol]>col[incol]) {
! 668: addobj(maxrow,
! 669: 'h&'+maxrow+'&'+outcol+':'+incol+'&'+dest+'&1:-1');
! 670: } else {
! 671: addobj(maxrow,
! 672: 'h&'+maxrow+'&'+outcol+':'+incol+'&'+dest+'&-1:1');
! 673: }
! 674: }
! 675: }
! 676: }
! 677: }
! 678:
! 679: // ---------------------------------------------------------- Delete a resource
! 680: // Deletes resource obj1
! 681: // Reconnects resources going thru this one if recon=1
! 682:
! 683: function delres (obj1,recon) {
! 684: var infromobj=new Array();
! 685: var inwithcon=new Array();
! 686: var inwithlink=new Array();
! 687: var outtoobj=new Array();
! 688: var outwithcon=new Array();
! 689: var outwithlink=new Array();
! 690: var inobjs=new Array();
! 691: var inobjscond=new Array();
! 692: var outobjs=new Array();
! 693: var outobjscond=new Array();
! 694:
! 695: var k; var k1; var k2; var found;
! 696:
! 697: data1=obj[obj1].split('&');
! 698: for (k=2;k<data1.length;k++) {
! 699: data2=data1[k].split(':');
! 700: if (data2[1]!=0) {
! 701: k2=inwithlink.length;
! 702: inwithlink[k2]=data2[1];
! 703: data3=objlinks[data2[1]].split(':');
! 704: infromobj[k2]=data3[0];
! 705: inwithcon[k2]=data3[2];
! 706: }
! 707: if (data2[2]!=0) {
! 708: k2=outwithlink.length;
! 709: outwithlink[k2]=data2[2];
! 710: data3=objlinks[data2[2]].split(':');
! 711: outtoobj[k2]=data3[1];
! 712: outwithcon[k2]=data3[2];
! 713: }
! 714: }
! 715: for (k=0;k<inwithlink.length;k++) { dellink(inwithlink[k]); }
! 716: for (k=0;k<outwithlink.length;k++) { dellink(outwithlink[k]); }
! 717: delobj(obj1);
! 718: if (recon==1) {
! 719:
! 720: for (k=0;k<inwithlink.length;k++) {
! 721: if (infromobj[k]!=obj1) {
! 722: found=0;
! 723: for (k2=0;k2<inobjs.length;k2++) {
! 724: if (inobjs[k2]==infromobj[k]) {
! 725: if (inwithcon[k]!=0) {
! 726: if (inobjscond[k2]!='') { inobjscond[k2]+='||'; }
! 727: inobjscond[k2]+=
! 728: '('+(objcont[inwithcon[k]].split(':'))[0]+')';
! 729: }
! 730: found=1;
! 731: }
! 732: }
! 733: if (found==0) {
! 734: k2=inobjs.length;
! 735: inobjs[k2]=infromobj[k];
! 736: if (inwithcon[k]==0) {
! 737: inobjscond[k2]='';
! 738: } else {
! 739: inobjscond[k2]=
! 740: '('+(objcont[inwithcon[k]].split(':'))[0]+')';
! 741: }
! 742: }
! 743: }
! 744: }
! 745:
! 746: for (k=0;k<outwithlink.length;k++) {
! 747: if (outtoobj[k]!=obj1) {
! 748: found=0;
! 749: for (k2=0;k2<outobjs.length;k2++) {
! 750: if (outobjs[k2]==outtoobj[k]) {
! 751: if (outwithcon[k]!=0) {
! 752: if (outobjscond[k2]!='') { outobjscond[k2]+='||'; }
! 753: outobjscond[k2]+=
! 754: '('+(objcont[outwithcon[k]].split(':'))[0]+')';
! 755: }
! 756: found=1;
! 757: }
! 758: }
! 759: if (found==0) {
! 760: k2=outobjs.length;
! 761: outobjs[k2]=outtoobj[k];
! 762: if (outwithcon[k]==0) {
! 763: outobjscond[k2]='';
! 764: } else {
! 765: outobjscond[k2]=
! 766: '('+(objcont[outwithcon[k]].split(':'))[0]+')';
! 767: }
! 768: }
! 769: }
! 770: }
! 771:
! 772: for (k=0;k<inobjs.length;k++) {
! 773: cond='';
! 774: if (inobjscond[k]!='') { cond='('+inobjscond[k]+')'; }
! 775: for (k2=0;k2<outobjs.length;k2++) {
! 776: thiscond=cond;
! 777: if (outobjscond[k2]!='') {
! 778: if (thiscond!='') { thiscond+='&&'; }
! 779: thiscond+='('+outobjscond[k2]+')';
! 780: }
! 781: condnr=0;
! 782: if (thiscond!='') { condnr=newcondition(thiscond,'normal'); }
! 783: joinres(inobjs[k],outobjs[k2],condnr);
! 784: }
! 785: }
! 786: }
! 787: }
! 788:
! 789: // -------------------------------------------------------------- Draw an entry
! 790:
! 791: function drawcell (rtype,ctype,what,cm,obj1,mode2,ej,ek,ne) {
! 792: var bgcolor;
! 793: if (ctype!=0) {
! 794: parent.mapout.document.write('<td bgcolor='+cm+' width='+cw[ctype]+'>');
! 795: if (what!='') {
! 796: if (obj1!='') {
! 797: obj1="'"+obj1+"'";
! 798: parent.mapout.document.write
! 799: ('<a href="javascript:parent.code.handler('+obj1
! 800: +');" onMouseOver="parent.code.info('+obj1+');">');
! 801: }
! 802: if (what=='r:') {
! 803: parent.mapout.document.write
! 804: ('<img border=0 src="resource.gif">');
! 805: } else {
! 806: if (what=='c:') {
! 807: parent.mapout.document.write
! 808: ('<img border=0 src="condition.gif">');
! 809: } else {
! 810: parent.mapout.document.write
! 811: ('<img border=0 src="'+rtype+'.'+ctype+'.'+what+'.gif">');
! 812: }
! 813: }
! 814: if (obj1!='') {
! 815: parent.mapout.document.write('</a>');
! 816: }
! 817: } else {
! 818: if (ne!=1) {
! 819: parent.mapout.document.write
! 820: ('<a href="javascript:parent.code.empty('+ej+','+ek+');" ');
! 821: } else {
! 822: parent.mapout.document.write
! 823: ('<a href="javascript:parent.code.infoclear();" ');
! 824: }
! 825: parent.mapout.document.write
! 826: ('onMouseOver="parent.code.infoclear();">');
! 827: parent.mapout.document.write
! 828: ('<img border=0 src="'+rtype+'.'+ctype+'.empty.gif"></a>');
! 829: }
! 830: parent.mapout.document.write('</td>');
! 831: }
! 832: }
! 833:
! 834: // ----------------------------------------------------------------- Draw a row
! 835:
! 836: function drawrow (jid,mode2) {
! 837: var j; var jk; var k; var rc; var gc; var bc; var ck;
! 838: var objd1=new Array();
! 839: var objd2=new Array();
! 840: var notempty=new Array();
! 841: var condtype;
! 842: if (rowtype[jid]!=0) {
! 843: for (j=0;j<=maxcol;j++) {
! 844: colmap[j]=''; colmap2[j]=''; colmap3[j]=''; colmap4[j]='';
! 845: colmap5[j]='#FFFFFF'; colmap6[j]='#FFFFFF';
! 846: objd1[j]=''; objd2[j]=''; notempty[j]=0;
! 847: }
! 848: parent.mapout.document.writeln('<tr height='+rh[rowtype[jid]]+'>');
! 849: if (rowcont[jid]!='') {
! 850: data2=rowcont[jid].split(':');
! 851: for (jk=0;jk<data2.length;jk++) {
! 852: data3=obj[data2[jk]].split('&');
! 853: if (data3[0]=='b') {
! 854: rc=(data2[jk]+'F').substr(0,2);
! 855: gc=('9'+data2[jk]).substr(0,2);
! 856: bc=(data2[jk]+data2[jk]).substr(0,2);
! 857: ck='#'+rc+gc+bc;
! 858: left=maxcol;
! 859: leftin=maxcol;
! 860: leftout=maxcol;
! 861: right=0;
! 862: rightin=0;
! 863: rightout=0;
! 864: anyout=0;
! 865: for (k=2;k<data3.length;k++) {
! 866: data1=data3[k].split(':');
! 867: thiscol=col[data1[0]];
! 868: if (thiscol<left) { left=thiscol; }
! 869: if (thiscol>right) { right=thiscol; }
! 870: if (data1[1]!=0) {
! 871: if (thiscol<leftin) { leftin=thiscol; }
! 872: if (thiscol>rightin) { rightin=thiscol; }
! 873: colmap4[thiscol]=data1[1];
! 874: }
! 875: if (data1[2]!=0) {
! 876: if (thiscol<leftout) { anyout=1; leftout=thiscol; }
! 877: if (thiscol>rightout) { anyout=1; rightout=thiscol; }
! 878: if (data1[3]!=0) {
! 879: colmap3[thiscol]='c:';
! 880: condtype=(objcont[data1[3]].split(':'))[1];
! 881: colmap6[thiscol]='#FFFFAA';
! 882: if (condtype=='stop') { colmap6[thiscol]='#FFAAAA'; }
! 883: if (condtype=='force') { colmap6[thiscol]='#AAAAFF'; }
! 884: objd2[thiscol]='c&'
! 885: +data1[0]+'&'+data2[jk]+'&'+data1[2]+'&'+data1[3];
! 886: } else {
! 887: colmap3[thiscol]='ctd';
! 888: colmap6[thiscol]=ck;
! 889: objd2[thiscol]='c&'
! 890: +data1[0]+'&'+data2[jk]+'&'+data1[2]+'&-';
! 891: }
! 892: }
! 893: }
! 894: for (k=left;k<=right;k++) { notempty[k]=1; colmap5[k]=ck; }
! 895: middle=Math.round((left+right)/2);
! 896: colmap[middle]='r:';
! 897: objd1[middle]+='r&'+data2[jk];
! 898:
! 899: if (rightin>middle) {
! 900: for (k=middle+1;k<rightin;k++) {
! 901: if (colmap4[k]!='') {
! 902: colmap[k]='rlt';
! 903: } else {
! 904: colmap[k]='rl';
! 905: }
! 906: }
! 907: colmap[rightin]='tl';
! 908: }
! 909: if (leftin<middle) {
! 910: for (k=middle-1;k>leftin;k--) {
! 911: if (colmap4[k]!='') {
! 912: colmap[k]='lrt';
! 913: } else {
! 914: colmap[k]='lr';
! 915: }
! 916: }
! 917: colmap[leftin]='tr';
! 918: }
! 919:
! 920: if ((leftout>middle) && (anyout)) {
! 921: colmap2[middle]='tr';
! 922: }
! 923: if (leftout==middle) {
! 924: if (rightout==middle) { colmap2[middle]='td'; }
! 925: if (rightout>middle) { colmap2[middle]='rtd'; }
! 926: }
! 927: if (leftout<middle) {
! 928: if (rightout<middle) { colmap2[middle]='tl'; }
! 929: if (rightout==middle) { colmap2[middle]='tdl'; }
! 930: if (rightout>middle) {
! 931: if (colmap3[middle]!='') {
! 932: colmap2[middle]='rtdl';
! 933: } else {
! 934: colmap2[middle]='rtl';
! 935: }
! 936: }
! 937: }
! 938: if (leftout<middle) {
! 939: for (k=middle-1;k>leftout;k--) {
! 940: if (colmap3[k]!='') {
! 941: colmap2[k]='rld';
! 942: } else {
! 943: colmap2[k]='rl';
! 944: }
! 945: }
! 946: colmap2[leftout]='rd';
! 947: }
! 948: if (rightout>middle) {
! 949: for (k=middle+1;k<rightout;k++) {
! 950: if (colmap3[k]!='') {
! 951: colmap2[k]='lrd';
! 952: } else {
! 953: colmap2[k]='lr';
! 954: }
! 955: }
! 956: colmap2[rightout]='ld';
! 957: }
! 958: }
! 959: if (data3[0]=='h') {
! 960: data4=data3[2].split(':');
! 961: if (col[data4[1]]>col[data4[0]]) {
! 962: left=col[data4[0]];
! 963: right=col[data4[1]];
! 964: thisarrow='lr';
! 965: } else {
! 966: right=col[data4[0]];
! 967: left=col[data4[1]];
! 968: thisarrow='rl';
! 969: }
! 970: if (data3[4].split(':')[0]==1) {
! 971: colmap[left]='tr';
! 972: } else {
! 973: colmap[left]='rd'; colmap2[left]='utd'; colmap3[left]='utd';
! 974: }
! 975: for (k=left+1;k<right;k++) {
! 976: if (colmap[k]=='') {
! 977: colmap[k]=thisarrow;
! 978: objd1[k]=data2[jk];
! 979: } else {
! 980: colmap[k]='tdrl';
! 981: objd1[k]='';
! 982: }
! 983: }
! 984: if (data3[4].split(':')[1]==1) {
! 985: colmap[right]='tl';
! 986: } else {
! 987: colmap[right]='ld'; colmap2[right]='utd'; colmap3[right]='utd';
! 988: }
! 989: objd1[left]=data2[jk];
! 990: objd1[right]=data2[jk];
! 991: }
! 992: if (data3[0]=='v') {
! 993: left=col[data3[1]];
! 994: if (colmap[left]=='') {
! 995: if (data3[3]==1) { colmap[left]='dt'; } else { colmap[left]='td'; }
! 996: objd1[left]=data2[jk];
! 997: objd2[left]=objd1[left];
! 998: } else {
! 999: colmap[left]='tdrl';
! 1000: objd1[left]='';
! 1001: }
! 1002: colmap2[left]='utd'; colmap3[left]='utd';
! 1003: }
! 1004: }
! 1005: rtype=rowtype[jid];
! 1006: for (k=0;k<=maxcol;k++) {
! 1007: drawcell(rtype,coltype[rcol[k]],colmap[k],colmap5[k],objd1[k],mode2,jid,k,
! 1008: notempty[k]);
! 1009: }
! 1010: if (rowtype[jid]==2) {
! 1011: parent.mapout.document.writeln('</tr><tr>');
! 1012: for (k=0;k<=maxcol;k++) {
! 1013: drawcell(1,coltype[rcol[k]],colmap2[k],colmap5[k],objd2[k],mode2,jid,k,
! 1014: 1);
! 1015: }
! 1016: parent.mapout.document.writeln('</tr><tr>');
! 1017: for (k=0;k<=maxcol;k++) {
! 1018: drawcell(1,coltype[rcol[k]],colmap3[k],colmap6[k],objd2[k],mode2,jid,k,
! 1019: 1);
! 1020: }
! 1021: }
! 1022: }
! 1023: parent.mapout.document.writeln('</tr>');
! 1024: }
! 1025: }
! 1026:
! 1027: // ------------------------------------------------------------- Draw the table
! 1028:
! 1029: function draw (mode,mode2) {
! 1030: var k; var kr;
! 1031:
! 1032:
! 1033: cleanup();
! 1034:
! 1035:
! 1036: if (mode=='debug') {
! 1037: var options="scrollbars=1,resizable=1,menubar=0,width=500,height=300";
! 1038: deb=open("","debout",options);
! 1039: deb.document.clear();
! 1040: deb.document.writeln('<html><body bgcolor="#FFFFFF">');
! 1041:
! 1042: for (k=0;k<obj.length;k++) { deb.document.writeln(k+' - '+obj[k]+'<br>'); }
! 1043: deb.document.writeln('<hr>Cols: '+col+'<hr>Rows: '+row+'<hr>');
! 1044: deb.document.writeln(objcont+'<hr>'+objlinks+'<hr>');
! 1045: for (kr=0;kr<=maxrow;kr++) {
! 1046: kid=findrow(kr);
! 1047: maprow(kid,-1,0);
! 1048: deb.document.writeln(kid+' : '+colmap+' '+rowcont[kid]+"<br>");
! 1049: }
! 1050: deb.document.writeln('<hr>Rowtype: '+rowtype+'<hr>Coltype: '+coltype);
! 1051: deb.document.writeln('<hr>maxcol: '+maxcol+'<hr>maxrow: '+maxrow);
! 1052: deb.document.writeln('</body></html>');
! 1053: deb.document.close();
! 1054: }
! 1055: for (k=0;k<=maxrow;k++) { rrow[row[k]]=k; }
! 1056: for (k=0;k<=maxcol;k++) { rcol[col[k]]=k; }
! 1057: rh[0]=0;
! 1058: rh[1]=30;
! 1059: rh[2]=60;
! 1060: cw[0]=0;
! 1061: cw[1]=30;
! 1062: cw[2]=60;
! 1063: parent.mapout.document.open('text/html','replace');
! 1064: parent.mapout.document.writeln('<html><body bgcolor="#FFFFFF">');
! 1065: parent.mapout.document.writeln(
! 1066: '<table cellpadding=0 cellspacing=0 border=0>');
! 1067:
! 1068: for (kr=0;kr<=maxrow;kr++) { drawrow(rrow[kr],mode2); }
! 1069:
! 1070: parent.mapout.document.writeln('</table>');
! 1071: parent.mapout.document.writeln('</body></html>');
! 1072: parent.mapout.document.close();
! 1073: parent.focus();
! 1074: parent.mapout.focus();
! 1075: }
! 1076:
! 1077: // --------------------------------------------------------- Clears info window
! 1078:
! 1079: function infoclear() {
! 1080: if (notclear!=1) {
! 1081: var options="scrollbars=1,resizable=1,menubar=0,width=400,height=300";
! 1082: var inf=open("","infout",options);
! 1083: inf.document.clear();
! 1084: inf.document.writeln
! 1085: ('<html><body bgcolor="#FFFFFF"><table><tr><td>'+
! 1086: '<img src="/adm/lonIcons/lonlogos.gif"></td>');
! 1087: if (linkmode!=0) {
! 1088: inf.document.writeln(
! 1089: '<td><b>Link Mode</b><hr>Click on a resource to link it with<br><b>'+
! 1090: (objcont[linkmode].split(':'))[0]+
! 1091: '</b><br>click anywhere else to cancel.</td>');
! 1092: }
! 1093: inf.document.writeln('</tr></table></body></html>');
! 1094: inf.document.close();
! 1095: parent.focus();
! 1096: parent.mapout.focus();
! 1097: notclear=1;
! 1098: lastinfo='';
! 1099: }
! 1100: }
! 1101:
! 1102: // --------------------------------------------------- Prints out resource info
! 1103:
! 1104: function info(infostr) {
! 1105: if ((editmode!=1) && (infostr!=lastinfo)) {
! 1106: notclear=1;
! 1107: var options="scrollbars=1,resizable=1,menubar=0,width=400,height=300";
! 1108: var inf=open("","infout",options);
! 1109: inf.document.clear();
! 1110: inf.document.writeln(
! 1111: '<html><body bgcolor="#FFFFFF">'+
! 1112: '<table><tr><td width=32><img src="info.gif"></td><td bgcolor="#AAFFAA">');
! 1113: data1=infostr.split('&');
! 1114: if (data1[0]=='c') {
! 1115: inf.document.write('<b>Condition (');
! 1116: data3=objlinks[data1[3]].split(':');
! 1117: if (data1[4]=='-') {
! 1118: inf.document.write('not set');
! 1119: } else {
! 1120: data2=objcont[data1[4]].split(':');
! 1121: if (data2[1]=='force') {
! 1122: inf.document.write('Blocking Other Links');
! 1123: } else {
! 1124: if (data2[1]=='stop') {
! 1125: inf.document.write('Blocking This Link');
! 1126: } else {
! 1127: inf.document.write('Recommendation');
! 1128: }
! 1129: }
! 1130: }
! 1131: inf.document.writeln(')</b><hr>From <b>'+objcont[data3[0]].split(':')[0]+
! 1132: '</b><br>to <b>'+objcont[data3[1]].split(':')[0]+'</b>');
! 1133: } else {
! 1134: if (data1[0]=='r') {
! 1135: inf.document.writeln('<b>Resource</b><hr>');
! 1136: data2=objcont[data1[1]].split(':');
! 1137: inf.document.writeln('<b>'+data2[0]+'</b><br>');
! 1138: inf.document.writeln((data2[1].split('/')).join(' / '));
! 1139: } else {
! 1140: inf.document.writeln('<b>Link</b><hr>');
! 1141: data2=obj[data1[0]].split('&');
! 1142: data3=objlinks[data2[data2.length-2]].split(':');
! 1143: inf.document.writeln('From <b>'+objcont[data3[0]].split(':')[0]+
! 1144: '</b><br>to <b>'+objcont[data3[1]].split(':')[0]+'</b>');
! 1145: }
! 1146: }
! 1147: if (linkmode==0) {
! 1148: inf.document.writeln('<p>(click to edit)');
! 1149: } else {
! 1150: if (data1[0]=='r') {
! 1151: inf.document.writeln('<p>(click to link)');
! 1152: } else {
! 1153: inf.document.writeln('<p>(click to cancel linking and edit)');
! 1154: }
! 1155: }
! 1156: inf.document.writeln('</td></tr></table></body></html>');
! 1157: inf.document.close();
! 1158: parent.focus();
! 1159: parent.mapout.focus();
! 1160: notclear=0;
! 1161: lastinfo=infostr;
! 1162: }
! 1163: }
! 1164:
! 1165: // ------------------------------------------------ "Escapes" out special chars
! 1166:
! 1167: function escape(instring) {
! 1168: var outstring='';
! 1169: var thischar;
! 1170: var k;
! 1171: for (k=0;k<instring.length;k++) {
! 1172: thischar=instring.charAt(k);
! 1173: if (thischar==':') { thischar=':'; }
! 1174: if (thischar=='"') { thischar='"'; }
! 1175: if (thischar=="'") { thischar='''; }
! 1176: if (thischar==',') { thischar=','; }
! 1177: outstring+=thischar;
! 1178: }
! 1179: return outstring;
! 1180: }
! 1181:
! 1182: // ---------------------------------------------------- Handles "click to edit"
! 1183:
! 1184: function handler(infostr) {
! 1185: var k;
! 1186: editmode=1;
! 1187: notclear=1;
! 1188: var options="scrollbars=1,resizable=1,menubar=0,width=400,height=300";
! 1189: var inf=open("","infout",options);
! 1190: inf.document.clear();
! 1191: inf.document.writeln(
! 1192: '<html><body bgcolor="#FFFFFF">'+
! 1193: '<table><tr><td width=32><img src="edit.gif"></td><td bgcolor="#AAFFAA">');
! 1194: data1=infostr.split('&');
! 1195: if (data1[0]=='c') {
! 1196: inf.document.writeln('<b>Condition</b><hr>');
! 1197: linkmode=0;
! 1198: if (data1[4]=='-') {
! 1199: data2[0]=''; data2[1]='normal';
! 1200: } else {
! 1201: data2=objcont[data1[4]].split(':');
! 1202: }
! 1203: inf.document.writeln(
! 1204: '<form name=condinfo><textarea name=c cols=40 rows=4>'
! 1205: +data2[0]+'</textarea><br><input type=radio name=s value=normal '+
! 1206: 'onClick="self.document.forms.condinfo.elements.h.value='+"'normal'"+'"');
! 1207: if (data2[1]=='normal') { inf.document.write(' checked'); }
! 1208: inf.document.write(
! 1209: '> Recommendation if true<br><input type=radio name=s value=stop '+
! 1210: 'onClick="self.document.forms.condinfo.elements.h.value='+"'stop'"+'"');
! 1211: if (data2[1]=='stop') { inf.document.write(' checked'); }
! 1212: inf.document.write(
! 1213: '> Blocking this link if false<br><input type=radio name=s value=force '+
! 1214: 'onClick="self.document.forms.condinfo.elements.h.value='+"'force'"+'"');
! 1215: if (data2[1]=='force') { inf.document.write(' checked'); }
! 1216: inf.document.write(
! 1217: '> Blocking other links if true<br><a href="javascript:opener.editmode=0;'
! 1218: +'opener.notclear=0;');
! 1219: if (data1[4]=='-') {
! 1220: inf.document.write('opener.crecond('+data1[2]+','+data1[1]+','
! 1221: +'opener.escape(self.document.forms.condinfo.elements.c.value),'
! 1222: +'self.document.forms.condinfo.elements.h.value);');
! 1223: } else {
! 1224: inf.document.write('opener.objcont['+data1[4]+']='
! 1225: +'opener.escape(self.document.forms.condinfo.elements.c.value)+'+"':'"
! 1226: +'+self.document.forms.condinfo.elements.h.value+'+"':cond';");
! 1227: }
! 1228: inf.document.writeln(
! 1229: 'opener.infoclear();opener.editmode=0;opener.draw('
! 1230: +"'debug','edit'"+');">Change to above values</a> '
! 1231: +' <a href="javascript:self.document.forms.condinfo.reset()">Reset</a>'
! 1232: +'<input type=hidden name=h value='+data2[1]
! 1233: +'></form>');
! 1234:
! 1235: inf.document.writeln(
! 1236: '<a href="javascript:opener.notclear=0;opener.infoclear();'
! 1237: +'opener.delcond('+data1[2]+','+data1[1]+');opener.editmode=0;opener.draw('
! 1238: +"'debug','edit'"+');">Delete Condition</a>');
! 1239: } else {
! 1240: if (data1[0]=='r') {
! 1241: if (linkmode!=0) {
! 1242: joinres(linkmode,data1[1],0);
! 1243: editmode=0;
! 1244: notclear=0;
! 1245: linkmode=0;
! 1246: inf.document.writeln('<b>Linked Resources</b>');
! 1247: draw('debug','edit');
! 1248: } else {
! 1249: inf.document.writeln('<b>Resource</b>');
! 1250: data2=objcont[data1[1]].split(':');
! 1251: inf.document.write(
! 1252: '<form name=resinfo><table><tr><td>Title:</td><td>'
! 1253: +'<input type=text name=t size=40 value="'
! 1254: +data2[0]+'"></td></tr><tr><td>URL:</td><td>'
! 1255: +'<input type=text name=u size=40 value="'+data2[1]+'"></td></tr>'
! 1256: +'<tr><td>External:</td><td><input type=checkbox name=e');
! 1257: if (data2[2]=='true') { inf.document.write(' checked'); }
! 1258: inf.document.writeln('></td></tr>'
! 1259: +'<tr><td colspan=2><a href="javascript:opener.editmode=0;'
! 1260: +'opener.notclear=0;opener.objcont['+data1[1]
! 1261: +']=opener.escape(self.document.forms.resinfo.elements.t.value)+'+"':'"
! 1262: +'+opener.escape(self.document.forms.resinfo.elements.u.value)+'+"':'"
! 1263: +'+self.document.forms.resinfo.elements.e.checked+'+"':res'"
! 1264: +';opener.infoclear();">'
! 1265: +'Change to above values</a> '
! 1266: +' <a href="javascript:self.document.forms.resinfo.reset()">Reset</a>'
! 1267: +'</td></tr></table></form>');
! 1268: inf.document.writeln(
! 1269: '<a href="javascript:opener.notclear=0;opener.infoclear();'
! 1270: +'opener.delres('+data1[1]+',0);opener.editmode=0;opener.draw('
! 1271: +"'debug','edit'"+');">Delete Resource (cutting links)</a>');
! 1272: inf.document.writeln(
! 1273: '<br><a href="javascript:opener.notclear=0;opener.infoclear();'
! 1274: +'opener.delres('+data1[1]+',1);opener.editmode=0;opener.draw('
! 1275: +"'debug','edit'"+');">Delete Resource (preserving links)</a>');
! 1276: inf.document.writeln(
! 1277: '<br><a href="javascript:opener.editmode=0;opener.notclear=0;'
! 1278: +'opener.linkmode='+data1[1]+';'
! 1279: +'opener.infoclear();">Link Resource</a>');
! 1280: }
! 1281: } else {
! 1282: linkmode=0;
! 1283: inf.document.writeln('<b>Link</b><hr>');
! 1284: data2=obj[data1[0]].split('&');
! 1285: k=data2[data2.length-2];
! 1286: data3=objlinks[k].split(':');
! 1287: inf.document.writeln('From <b>'+objcont[data3[0]].split(':')[0]+
! 1288: '</b><br>to <b>'+objcont[data3[1]].split(':')[0]+'</b>');
! 1289: inf.document.writeln('<br><a href="javascript:opener.dellink('+
! 1290: k+');opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
! 1291: +"'debug','edit'"+');">Delete Link</a>');
! 1292: }
! 1293: }
! 1294: inf.document.writeln(
! 1295: '<br><a href="javascript:opener.editmode=0;opener.notclear=0;'
! 1296: +'opener.infoclear();">Done</a>');
! 1297: inf.document.writeln('</td></tr></table></body></html>');
! 1298: inf.document.close();
! 1299: inf.focus();
! 1300: }
! 1301:
! 1302: // ----------------------------------------------------- Clicks on empty fields
! 1303:
! 1304: function empty(rid,k) {
! 1305: var cid=findcol(k);
! 1306: var lcol=k-1;
! 1307: trow=row[rid];
! 1308: lrow=trow-1;
! 1309: editmode=1;
! 1310: notclear=1;
! 1311: linkmode=0;
! 1312: var options="scrollbars=1,resizable=1,menubar=0,width=400,height=300";
! 1313: var inf=open("","infout",options);
! 1314: inf.document.clear();
! 1315: inf.document.writeln(
! 1316: '<html><body bgcolor="#FFFFFF">'+
! 1317: '<table><tr><td width=32><img src="edit.gif"></td><td bgcolor="#AAFFAA">'+
! 1318: '<b>Empty Field</b><hr>');
! 1319:
! 1320: inf.document.writeln('<br><a href="javascript:opener.newresource('+
! 1321: rid+','+cid+",'','');"+
! 1322: 'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
! 1323: +"'debug','edit'"+');">Insert Resource</a>');
! 1324: inf.document.writeln('<hr>Insert column:');
! 1325: inf.document.writeln('<a href="javascript:opener.insertcol('+
! 1326: lcol+');opener.addobj('+rid+",'e&'+opener.maxcol);"
! 1327: +'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
! 1328: +"'debug','edit'"+');">left</a>');
! 1329: inf.document.writeln('<a href="javascript:opener.insertcol('+
! 1330: k+');opener.addobj('+rid+",'e&'+opener.maxcol);"
! 1331: +'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
! 1332: +"'debug','edit'"+');">right</a> ');
! 1333: inf.document.writeln('<br>Insert row:');
! 1334: inf.document.writeln('<a href="javascript:opener.insertrow('+
! 1335: trow+');opener.addobj(opener.maxrow'+",'e&"+cid+"');"
! 1336: +'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
! 1337: +"'debug','edit'"+');">below</a>');
! 1338: inf.document.writeln('<a href="javascript:opener.insertrow('+
! 1339: lrow+');opener.addobj(opener.maxrow'+",'e&"+cid+"');"
! 1340: +'opener.editmode=0;opener.notclear=0;opener.infoclear();opener.draw('
! 1341: +"'debug','edit'"+');">above</a> ');
! 1342:
! 1343:
! 1344: inf.document.writeln(
! 1345: '<br><a href="javascript:opener.editmode=0;opener.notclear=0;'
! 1346: +'opener.infoclear();">Done</a>');
! 1347: inf.document.writeln('</td></tr></table></body></html>');
! 1348: inf.document.close();
! 1349: inf.focus();
! 1350: }
! 1351:
! 1352: // ---------------------------------------------------- Save into hidden fields
! 1353:
! 1354: function save() {
! 1355: var k;
! 1356: self.document.forms.storage.output.value='graphdef<:>yes';
! 1357: for (k=0;k<obj.length;k++) {
! 1358: self.document.forms.storage.output.value+=
! 1359: '<&>obj<:>'+k+'<:>'+obj[k];
! 1360: }
! 1361: for (k=0;k<row.length;k++) {
! 1362: self.document.forms.storage.output.value+=
! 1363: '<&>row<:>'+k+'<:>'+row[k];
! 1364: }
! 1365: for (k=0;k<col.length;k++) {
! 1366: self.document.forms.storage.output.value+=
! 1367: '<&>col<:>'+k+'<:>'+col[k];
! 1368: }
! 1369: for (k=0;k<rowcont.length;k++) {
! 1370: if (rowcont[k]) {
! 1371: self.document.forms.storage.output.value+=
! 1372: '<&>rowcont<:>'+k+'<:>'+rowcont[k];
! 1373: }
! 1374: }
! 1375: self.document.forms.storage.output.value+=
! 1376: '<&>maxcol<:>'+maxcol;
! 1377: self.document.forms.storage.output.value+=
! 1378: '<&>maxrow<:>'+maxrow;
! 1379:
! 1380: for (k=0;k<objcont.length;k++) {
! 1381: if (objcont[k]) {
! 1382: self.document.forms.storage.output.value+=
! 1383: '<&>objcont<:>'+k+'<:>'+objcont[k];
! 1384: }
! 1385: }
! 1386: for (k=0;k<objlinks.length;k++) {
! 1387: if (objlinks[k]) {
! 1388: self.document.forms.storage.output.value+=
! 1389: '<&>objlinks<:>'+k+'<:>'+objlinks[k];
! 1390: }
! 1391: }
! 1392: }
! 1393:
! 1394: // ----------------------------------------------- Reset all layout information
! 1395:
! 1396: function graphreset() {
! 1397:
! 1398: obj.length=0;
! 1399: obj[0]='';
! 1400: obj[1]='e&1';
! 1401:
! 1402: rowcont.length=0;
! 1403: rowcont[0]='';
! 1404: rowcont[1]='1';
! 1405: row.length=0;
! 1406: row[0]=0;
! 1407: row[1]=1;
! 1408: maxrow=1;
! 1409:
! 1410: col.length=0;
! 1411: colmap.length=0;
! 1412: maxcol=-1;
! 1413: insertcol(-1);
! 1414: insertcol(0);
! 1415:
! 1416: graphdef='no';
! 1417:
! 1418: }
! 1419:
! 1420: // --------------------- Compare two resources with each other for "straighten"
! 1421:
! 1422: function rescompare(a,b) {
! 1423: data1=a.split(':');
! 1424: data2=b.split(':');
! 1425: var rvalue=0;
! 1426: var k;
! 1427: for (k=1;k<data1.length;k++) {
! 1428: if (data1[k]==data2[0]) { rvalue--; }
! 1429: }
! 1430: for (k=1;k<data3.length;k++) {
! 1431: if (data2[k]==data1[0]) { rvalue++; }
! 1432: }
! 1433: if (rvalue==0) { rvalue=data2.length-data1.length; }
! 1434:
! 1435: return rvalue;
! 1436: }
! 1437:
! 1438: // ------------------------------------------- Sort objects to straighten graph
! 1439:
! 1440: function graphopt() {
! 1441: var k;
! 1442: var ij;
! 1443: var kj;
! 1444: var objsort=new Array();
! 1445: var objsorted=new Array();
! 1446: condense();
! 1447: graphreset();
! 1448: for (k=1;k<objcont.length;k++) {
! 1449: if (objcont[k]) {
! 1450: data1=objcont[k].split(':');
! 1451: if (data1[data1.length-1]=='res') {
! 1452: objsort[objsort.length]=''+k;
! 1453: }
! 1454: }
! 1455: }
! 1456: for (k=1;k<objlinks.length;k++) {
! 1457: data1=objlinks[k].split(':');
! 1458: kj=-1;
! 1459: for (j=0;j<objsort.length;j++) {
! 1460: if ((objsort[j].split(':'))[0]==data1[0]) {
! 1461: kj=j;
! 1462: }
! 1463: }
! 1464: objsort[kj]+=':'+data1[1];
! 1465: }
! 1466: objsorted=objsort.sort(rescompare);
! 1467: var thisnewobj=''+(objsorted[0].split(':'))[0];
! 1468: rowcont[1]=thisnewobj;
! 1469: var thiscolmax=1;
! 1470: obj[thisnewobj]='b&1&'+thiscolmax+':0:0:0';
! 1471: var allcolmax=0;
! 1472: for (k=1;k<objsorted.length;k++) {
! 1473: thisnewobj=(objsorted[k].split(':'))[0];
! 1474: if (rescompare(objsorted[k-1],objsorted[k])==0) {
! 1475: rowcont[rowcont.length-1]+=':'+thisnewobj;
! 1476: thiscolmax++;
! 1477: } else {
! 1478: rowcont[rowcont.length]=thisnewobj;
! 1479: if (thiscolmax>allcolmax) { allcolmax=thiscolmax; }
! 1480: thiscolmax=1;
! 1481: }
! 1482: kj=rowcont.length-1;
! 1483: obj[thisnewobj]='b&'+kj+'&'+thiscolmax+':0:0:0';
! 1484: }
! 1485: for (k=0;k<obj.length;k++) {
! 1486: if (!obj[k]) { obj[k]=''; }
! 1487: }
! 1488: for (k=0;k<=allcolmax;k++) { insertcol(0); }
! 1489: for (k=0;k<rowcont.length;k++) {
! 1490: row[k]=k;
! 1491: }
! 1492: maxrow=rowcont.length-1;
! 1493:
! 1494: var oldlinks=new Array();
! 1495: for (k=0;k<objlinks.length;k++) { oldlinks[k]=objlinks[k]; }
! 1496: objlinks.length=0;
! 1497: objlinks[0]='';
! 1498: for (k=0;k<objsorted.length;k++) {
! 1499: kj=(objsorted[k].split(':'))[0];
! 1500: for (ij=1;ij<oldlinks.length;ij++) {
! 1501: if (oldlinks[ij]) {
! 1502: data1=oldlinks[ij].split(':');
! 1503: if (data1[0]==kj) {
! 1504: joinres(data1[0],data1[1],data1[2]);
! 1505: }
! 1506: }
! 1507: }
! 1508: }
! 1509: }
! 1510:
! 1511: // ----------------------------------------------------------- Remove e-objects
! 1512:
! 1513: function condense() {
! 1514: var j;
! 1515: for (j=0;j<=maxrow;j++) {
! 1516: if (rowcont[j]!='') {
! 1517: data1=rowcont[j].split(':');
! 1518: rowcont[j]='';
! 1519: for (k=0;k<data1.length;k++) {
! 1520: if (obj[data1[k]].substring(0,2)!='e&') {
! 1521: if (rowcont[j]!='') { rowcont[j]+=':'; }
! 1522: rowcont[j]+=data1[k];
! 1523: }
! 1524: }
! 1525: }
! 1526: }
! 1527: }
! 1528:
! 1529: // ---------------------------------------------------- Load from hidden fields
! 1530:
! 1531: function load() {
! 1532: objcont.length=0;
! 1533: objlinks.length=0;
! 1534: objlinks[0]='';
! 1535: objcont[0]='';
! 1536: editmode=0;
! 1537: notclear=0;
! 1538: lastinfo='';
! 1539: graphreset();
! 1540: var inputstr=self.document.forms.storage.output.value;
! 1541: data1=inputstr.split('<&>');
! 1542: var k;
! 1543: for (k=0;k<data1.length;k++) {
! 1544: data2=data1[k].split('<:>');
! 1545: if (data2[0]=='graphdef') { graphdef=data2[1]; }
! 1546: if (data2[0]=='maxcol') { maxcol=1*data2[1]; }
! 1547: if (data2[0]=='maxrow') { maxrow=1*data2[1]; }
! 1548: if (data2[0]=='obj') { obj[data2[1]]=data2[2]; }
! 1549: if (data2[0]=='objcont') { objcont[data2[1]]=data2[2]; }
! 1550: if (data2[0]=='objlinks') { objlinks[data2[1]]=data2[2]; }
! 1551: if (data2[0]=='rowcont') { rowcont[data2[1]]=data2[2]; }
! 1552: if (data2[0]=='row') { row[data2[1]]=1*data2[2]; }
! 1553: if (data2[0]=='col') { col[data2[1]]=1*data2[2]; }
! 1554: }
! 1555: }
! 1556:
! 1557: // -------------------------------------------------------- Main program onLoad
! 1558:
! 1559: function main() {
! 1560:
! 1561: if (mainrun==0) {
! 1562: load();
! 1563: draw('debug','edit');
! 1564: mainrun=1;
! 1565: }
! 1566:
! 1567: }
! 1568:
! 1569: </script>
! 1570: </head>
! 1571:
! 1572: <body bgcolor="#FFFFFF" onLoad="main();">
! 1573: <a href="javascript:condense();draw('debug','edit');">Condense</a>
! 1574: <a href="javascript:graphopt();draw('debug','edit');">Straighten</a>
! 1575: <form name=storage method=post>
! 1576: <input type=hidden name=output>
! 1577: </form>
! 1578: </body>
! 1579: </html>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>