Print Story Further Adventures in Geographic linkage
Diary
By whazat (Tue Aug 02, 2005 at 11:33:42 AM EST) (all tags)
My previous effort turned out to be a bit meh and be a dead end at least until all web pages are well formed XML so that you can translate it all with no complaints.

So did I give up? No, I switched technologies. See inside for the continuing adventures of whazat as he encounters the XBL beast. Now with ecode magic!



XBL, eh? Whats that I here you ask. Well it is a extensible binding language that is only implemented by Mozilla at the moment, but is in the process of becoming a standard.

I have decided to abandon the previous, geo* name stuff. Instead we will have different classes of anchor.


<html>
<head>
     <title>Geological examples</title>
     <link rel="stylesheet" type="text/css" href="geo.css">
</head>
     <body>
          <a class="latlongloc" lat="25" long="28">Jim</a>
      <a class="nameloc" location="Washington D.C.">Location</a>
      <a class="route" startLocation="Woking" endLocation="Birmingham">Route</a>
     </body>
</html>

So these different classes of anchor will create the desired link using XBL voodoo. What happens to the link is specified by the geo.css and associated xml file.

So this is the geo.css

.latlongloc {

  -moz-binding: url(geoNew.xml#latlongloc);
  text-decoration: underline;
  color: blue;
}

.nameloc {
  -moz-binding: url(geoNew.xml#nameloc);
  text-decoration: underline;
  color: blue;

}

.route {
  -moz-binding: url(geoNew.xml#route);
  text-decoration: underline;
  color: blue;

}

The only magic is in the -moz-binding attribute. The rest is to make it look like a link. Which is not entirely successful. So any ways of making it keep the default attributes of an anchor, would be appreciated.

So the -moz-binding selects the the xml and the specific binding in that file.

And geoNew.xml

<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="latlongloc">

<implementation>
<constructor>
var myurl =  "http://maps.google.com/maps?q=N+" + this.getAttribute("lat") + "+W" + this.getAttribute("long");
this.setAttribute("href", myurl );
this.removeAttribute("lat");
this.removeAttribute("long");
this.removeAttribute("class");
<!-- Remember remove child for more complex structures-->
</constructor>
</implementation>

</binding>

<binding id="nameloc">
<implementation>
<constructor>
var myurl =  "http://maps.google.com/maps?q="+this.getAttribute("location");
this.setAttribute("href", myurl );
this.removeAttribute("location");
this.removeAttribute("class");
</constructor>
</implementation>

</binding>

<binding id="route">
<implementation>
<constructor>
var myurl =  "http://maps.google.com/maps?saddr=" + this.getAttribute("startLocation") + "&amp;daddr=" + this.getAttribute("endLocation");
this.setAttribute("href", myurl );
this.removeAttribute("startLocation");
this.removeAttribute("endLocation");
this.removeAttribute("class");

</constructor>
</implementation>

</binding>

</bindings>

Each binding in this application consists of a singular constructor. There is much else you can do with default elements and the like. It adds the href attributes and removes the non-standard attributes (I don't think I need to do it, but it is seems more neat).

So what does this have to do with husi? It would be nice to be able to write these in husi text and then have an option to have perl translate it to plain HTML if you don't have mozilla, otherwise leave it in so that people can have different CSS to use google or microsoft maps or any other mapping system people like.

< Dog tales | BBC White season: 'Rivers of Blood' >
Further Adventures in Geographic linkage | 2 comments (2 topical, 0 hidden)
Link-lookalike by TurboThy (2.00 / 0) #1 Wed Aug 03, 2005 at 01:21:01 AM EST
What's missing to make it look like a link? The proper "hand" cursor when hovering?
__
Sommerhus til salg, første række til Kattegat.
Oh, and by TurboThy (2.00 / 0) #2 Wed Aug 03, 2005 at 01:21:39 AM EST
do keep up the good work. I'd use it.
__
Sommerhus til salg, første række til Kattegat.
Further Adventures in Geographic linkage | 2 comments (2 topical, 0 hidden)