var svgNS="http://www.w3.org/2000/svg"; var xlinkNS="http://www.w3.org/1999/xlink"; var anNS="http://rdf.desire.org/vocab/recommend.rdf#"; var rdfNS="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; var imgNS="http://jibbering.com/2002/3/svg/#"; var DCNS="http://purl.org/dc/elements/1.1/"; var foafNS="http://xmlns.com/foaf/0.1/"; var foafCorp="http://xmlns.com/foaf/corp#" var wordnetNS="http://xmlns.com/wordnet/1.6/"; var svgrNS="http://www.w3.org/2001/svgRdf/axsvg-schema.rdf#"; var jimNS="http://jibbering.com/foaf/jim.rdf#"; GetCOUNT=0; _ONLINE=true; Relationships=[]; Relationships.push({NS:foafCorp,name:"member"}); Relationships.push({NS:foafCorp,name:"memberOf"}); // The urls, for online, and offline viewing: // startURL+Sha1+endURL gives the url to retrieve // for info on that sha1 if (_ONLINE) { startURL="theyRuleData.1?obj="; startURLsha1="theyRuleData.1?obj="; endURL=""; } else { startURL="cache/"; startURLsha1="cache/"; endURL=""; } // Lots of global variables, Namespaces etc. Many are not // used, but this I keep the same everywhere. var BLUB_SIZE_SMALL=0.6; var BLUB_EXP_DISTANCE_DEL=62; var BLUB_EXP_DISTANCE=3.2; var BLUB_EXPLOSION_DELTA=6; var OPACITY_DIM=0.8; var BLUB_MOVE_GROUP=true; var Templates=[]; var gdoc=document; var gdocDE=gdoc.documentElement; var globalBlubBatikId; var svgelement=gdoc.rootElement; var currentBlub=null; var gCirc=null; var gPanelCount=3; var photoCount=0; var searchCount=1; // The colours used for paths get shown. var highlightColours=['red','blue','black','#ffff00','green','#00ffff','#ff00ff']; var pathCount=0; // Creates references to the svg elements used to add the // blub/sproings to later var blubsgroup, sproingsgroup, form; // create some SVG elements for later cloning... // element creation is dead slow, avoid, either clone // or use parseXML. createElement should be avoided! var globalgEL=gdoc.createElementNS(svgNS, "g"); var FADE=true; var nextId=0; var blubs=new Array(); var blubhash=new Array(); var sproings=new Array(); var currentBlubId=-1; var dataReady=0; var detailPanel; var dirList=new Array(); function parse(str) { // A simple query string parser, initialise the object // with default values like email/sha1 here or there // will be errors. var o={} o['email']=''; o['sha1']=''; o['fade']='true'; o['template']='default.template'; var arr=str.split('&'); for (i=0;i3) { nick=nick.substr(0,nick.indexOf('.')); } str=nick.toUpperCase(); if (nick+''=='undefined') { nick='?'; } this.nick=nick; template=Templates[this.blubType+';Initial']; if (template.script) { myHash=new Function(template.script)(this); } else { myHash={}; } myHash.NICK=str; myHash.ID=this.id; myTxt=myReplace(template.svg,myHash); // create the svg for the blub, IDs are important this.group=parseXML(''+myTxt+'',gdoc).firstChild; this.text=this.group.getElementsByTagName('tspan').item(0); moveBlubTo(this, startx, starty); blubsgroup.appendChild(this.group); setTimeout("moveBlub('" + this.id + "')", 10); } return this; } function addLine(from, to,type,img,existing) { // adds a line from node from, to node to, with type type, and image // img (if codepicted) This is only for lines to new blubs, existing is // true if the blub is expanded. // type is a string looking something like "knows-codepicts-isknownby" // pretty odd way of doing it, but it grew to organically, do it better // next time. var gel=globalgEL.cloneNode(true); for (i=0;i'+myTxt+'',gdoc).firstChild.firstChild); } var lines=gel.getElementsByTagName('line'); for (var i=0;iwindow.innerHeight) { photoCount=0; } y=50+(photoCount++)*15; codX=(x-trans.x)/scale; codY=(y-trans.y)/scale; template=Templates[foafNS+"codepiction;PANEL"] ; myHash={}; myHash.CODX=codX; myHash.CODY=codY; myHash.IMG=img; myHash.PANELCOUNT=gPanelCount; myHash.SCALE=(1/scale); myHash.NICKFROM=blubs[a].nick.toUpperCase(); myHash.NICKTO=blubs[b].nick.toUpperCase(); myTxt=myReplace(template.svg,myHash); gPanelCount++; panel.appendChild(parseXML(''+myTxt+'',gdoc).firstChild); } catch (e) {} } function moveBlubGroup(blub, x, y) { nhbs=blub.outNeighbours; var x=blub.x; var y=blub.y; var numBlubsToCreate=nhbs.length; for (var i=0;i'+myTxt+'',gdoc).firstChild); } function expandBlub(id) { // Expand the blub, changes the + to o and requests the new // data from the server, does nothing if it has already been // expanded. // Also changes the function on the o to updatePanel, be // careful with the structure of the blub, at the moment it // is the 3rd g element if you change this, you must also // change the way you get the onclick reference here. theBlub=blubs[id]; if (!theBlub.expanded) { RefreshBlub(theBlub); dataReady=0; theBlub.getStuff(theBlub.link,theBlub); } } Blub.prototype.getStuff= function (url,a) { // A getStuff function added to the Blub class // so we can use Blub.getStuff to get new data // and keep the data with the blub. // does not work in Batik, so we use global blud ID // there, which obviously means you can only expand // one at a time. // This now works in Batik beta 5, so hack removed. getURL(url.replace(/:/gim,'%3A'),this); }; function opComplete(urlRS) { // The callback function called when the data url is returned // from the server. // try { var doc=parseXML(urlRS.content,null); thisProxy=this; // get all the foaf:knows elements, and loop over them // not using RDF parser, but you could put mine in here // but it would be slower! // for each element create an object (a,b,c,d) // (sha1,knows|isknownby|codepicts,nick,img) // img is only for codepicts obviously. var dirList=[]; var tmp=[]; var count=0; for (var j=0;j'+str+'',gdoc).firstChild); try { gdoc.getElementById('imgNick').firstChild.nodeValue=theBlub.nick; } catch (e) {} try { gdoc.getElementById('knows').firstChild.nodeValue="KNOWS "+theBlub.kCount+" PEOPLE"; gdoc.getElementById('knownby').firstChild.nodeValue="KNOWN BY "+theBlub.knownCount+" PEOPLE"; gdoc.getElementById('codepicted').firstChild.nodeValue="PICTURED WITH "+theBlub.cCount+" PEOPLE"; } catch (e) {} try { gdoc.getElementById('imageLoc').removeChild(gdoc.getElementById('imageLoc').firstChild); } catch (E) {} dep=theBlub.depiction; if (dep && dep.img) { str=''; } else { str=''; } try { gdoc.getElementById('imageLoc').appendChild(parseXML(str,gdoc).firstChild); } catch (e) {} // The code that makes blubs further away dim into the background // needs work, odd blubs not dimmed if (FADE) { for (var i=0;i -3 && dx < 3 && dy > -3 && dy < 3) { var nowToX=toX; var nowToY=toY; } else { var nowToX=nowX + dx/BLUB_EXPLOSION_DELTA; var nowToY=nowY + dy/BLUB_EXPLOSION_DELTA; setTimeout("moveBlub('" + id + "')", 10); } moveBlubTo(theBlub, nowToX, nowToY); } // Key handling code on the form... function keyPress(evt) { var cc=evt.charCode; if (cc < 32) { if (cc == 13 || cc == 10) { go(); } return; } var inp=String.fromCharCode(cc); try { form.getFirstChild().appendData(inp); } catch (e) {} } function keyDown(evt) { try { var code=evt.keyCode; if (code == 8) { var s=form.getFirstChild(); if (s.length > 1) { s.deleteData(s.length-1, 1); } } } catch (e) {} } function getFormValue() { return form.getFirstChild().nodeValue; } function go() { // called on "submitting" the form, does a check that there is an @ // in the field, this is where you could handle nick/name etc. with // another callback to a suitable service such as identify.1? var fullName=String(getFormValue()); if (fullName.indexOf('@')>1) { doStuff(fullName); } } function doStuff(fullName) { // creates a blub from an email address "fullname" add mailto: // if necessary. Positioning changes in a pretty crap way. a={id:''}; try { fullName=fullName.Trim(); } catch (e) { fullName='undefined'; } if (fullName.length > 0) { var idName=startURLsha1+fullName+endURL; if (typeof findBlub(fullName)=='undefined') { a=new Blub(280+((searchCount%3)*100), 180+((searchCount%3)*100), 280+((searchCount%3)*100), 180+((searchCount%3)*100), 1, fullName, idName,"Director",foafNS+"Person"); searchCount++; } else { // update a panel if the blub was found, should probably want // to do some zoom/pan stuff here to bring it into the middle // of the viewport updatePanel(a=findBlub(fullName)); } try { form.getFirstChild().setData(' '); } catch (e) {} } return a.id; } function doStuffSha1(sha1) { // same as doStuff but for a sha1 - does not do updatePanel if it // exists - should probably combine these two functions. var nick='PERSON'; var fullName=sha1; var idName=startURLsha1+sha1+endURL; var a=new Blub(280+((searchCount%3)*100), 200+((searchCount%3)*100), 280+((searchCount%3)*100), 200+((searchCount%3)*100), 1, fullName, idName,nick,foafNS+"Person"); /* expandBlub(a.id);*/ searchCount++; form.getFirstChild().setData(' '); } function zoom() { // handle the fixing the viewport - called on zoom. try { var trans=gdocDE.currentTranslate; var scale=gdocDE.currentScale; } catch (e) { trans={x:0,y:0}; scale=1; } X=((0-trans.x)/scale); Y=((0-trans.y)/scale); var p1=gdoc.getElementById('aboutbox'); var p2=gdoc.getElementById('branding'); p1.setAttribute("transform","translate("+X+","+Y+") scale("+(1/scale)+")"); p2.setAttribute("transform","translate("+X+","+Y+") scale("+(1/scale)+")"); } function ShowPath(b1,b2) { if (b1!=-1 && b2 !=-1) { // Show a path between 2 blubs var col=highlightColours[pathCount++%highlightColours.length]; var high1=blubs[b1]; var high2=blubs[b2]; makeGraph(); high1.tree=findShortestPathsFromNode(high1.name); nde=high1.tree[high2.name]; while (nde) { if (nde.par) { highlightPath(nde,nde.par,col); } nde=nde.par; } } } function highlightPath(fromNde,toNde,col) { // Highlights the path between two nodes. from=blubhash[fromNde.node.id]; to=blubhash[toNde.node.id]; var gel=globalgEL.cloneNode(true); var line=globalLine.cloneNode(true); line.setAttribute("fill", "none"); line.setAttribute("x1", from.groupx); line.setAttribute("y1", from.groupy); line.setAttribute("x2", to.groupx); line.setAttribute("y2", to.groupy); line.setAttribute("stroke", col); gel.appendChild(line); gdoc.getElementById("highlightGroup").appendChild(gel); } // Path Finding Algorithm. TNodes=[]; TEdges=[]; function makeGraph() { // Create a graph see // http://rdfweb.org/people/damian/2002/02/foafnation/ // for more info, stolen from Damian. var bl; TNodes=[]; TEdges=[]; // create the Nodes for (var i=0;i