I’ve just been asked the following question by a friend:
in javascript - how do i get the text of an html-element, which doesn't include text of all the children? firefox only
Every html DOM element has a collection of direct children, called childNodes. Each node has a type, and text nodes (those are text portions that are part of an element’s inner content) have ‘3’ for their type.
So, the following code is the solution:
function extractFirstLevelTextFrom(elm) {
var text = '';
for (var i =0; i < elm.childNodes.length; ++i) {
if (elm.childNodes[i].nodeType==3)
text += elm.childNodes[i].nodeValue;
}
return text;
}You are building a Monorail web site, and want to setup a route from the application's path to a given action (usually home/index)
The pattern "/" does not work, so
RoutingModuleEx.Engine.Add(
new PatternRoute("Home", "/")
.DefaultForArea().IsEmpty
.DefaultForController().Is("Home")
.DefaultForAction().Is("Index")
);
will fail to serve http://yoursite/
Same will happen if you're using the Code Generator for setting up rules.
[PatternRoute("Homepage", "/")]
public void Index() { ... }
will fail just the same
Use the pattern "/[controller]", like that:
RoutingModuleEx.Engine.Add(
new PatternRoute("Home", "/[controller]")
.DefaultForArea().IsEmpty
.DefaultForController().Is("Home")
.DefaultForAction().Is("Index")
);
or if you're using the Code Generator:
[PatternRoute("Homepage", "/[controller]")]
public void Index() { ... }
I'm considering adding a useful HomepageRoute that will derive from PatternRoute and will have all the needed conventions for easily setting up the homepage rule. Hopefully will be in trunk by this weekend. This will allow a simpler default syntax:
RoutingModuleEx.Engine.Add(
new HomepageRoute()
);
or (using the code generator):
[HomepageRoute]
public void Index() { ... }
Convention over Configuration.
I hope that the new server will prove more stable.
Some interruptions etc. might occur, so please be patient. I hope it’ll be allright soon enough.
Please do not leave any comments meanwhile as they might not make it through to the new server.
Here is the promised presentation from the talk I gave yesterday, for the Web Developers Community at Microsoft offices in Ra'anana.
The sources for the demo I showed are hosted on github. If you're not using git (and you should give it a try if that is the case), you can grab a zip of the latest snapshot from that site (there's a 'download' button). Git is worth using if only for the great service given by github.
http://github.com/kenegozi/monorail-aspview-demo/tree/master
As for the slides - I tried using scribd and SlideShare, both attempts ended up not too well. I'll try to get a better format later on.
I'd like to thank Noam King, the organiser of the WDC group, for having me as a speaker. I'd also like to thank Damien Guard who have created the Envy Code R font which I used during the presentation.