- Currently Listening to:
- Weezer — The World Has Turned And Left Me Here
Some ordered lists are better presented in descending order. For example, my publications list works better in reverse-chronological order so that the most recent work appears at the top of the list, and is numbered highest-to-lowest.
Ordered lists in HTML are created using the ol element, but there’s no way to present a list in descending order. (It’s in the HTML5 spec, but might be a while before it’s generally usable.)
The JavaScript solutions I found to achieve this were all a bit rubbish—adding spurious numbers to the margin and generally messing up the semantics of the list. So I wrote a quick function that finds each ol element on the page that has the class “reversed”, and changes the “value” attribute of each li to the number it would have in a native reversed-order presentation. It’s not semantically perfect, but it degrades gracefully and will do until browsers support the HTML5 incarnation of ol. The JavaScript looks like this:
function reverse_lists() {
var olists = document.getElementsByTagName('ol');
for (var i = 0; i < olists.length; i++) {
if (!olists[i].className.match(/\breversed\b/))
continue;
var items = olists[i].getElementsByTagName('li');
for(var j = 0; j < items.length; j++) {
items[j].setAttribute("value", items.length - j);
}
}
}
You can download a .js file with this function and upload it to your server. Apply the code by calling the function after all of your list elements (the first script element can be put in the document’s head if you have control over that):
<ol class="reversed">
<li>Most recent item.</li>
<li>Less recent item.</li>
⋮
</ol>
<script type="text/javascript" src="reorder.js"></script>
<script type="text/javascript">
reverse_lists();
</script>
And in your place an empty space
Has filled the void behind my face.
- Scripting with JavaScript in Cocoa
- Celerity | Easy and fast functional test automation for web applications
Celerity is a JRuby wrapper around HtmlUnit – a headless Java browser with JavaScript support. It provides a simple API for programmatic navigation through web applications. Celerity aims at being API compatible with Watir.
- Dean Edwards: A Base Class for JavaScript Inheritance
I’ve created a JavaScript class (Base.js) that I hope eases the pain of JavaScript OO. It’s a simple class and extends the Object object by adding two instance methods and one class method.
The Base class defines two instance methods:
extend
Call this method to extend an object with another interface:
var object = new Base;
object.extend({
value: "some data",
method: function() {
alert("Hello World!");
}
});
object.method();
// ==> Hello World!
- Enterprise JavaScript - Provides proven high performance, enterprise-level and scalable JavaScript tips and best practices.
- HtmlUnit - Welcome to HtmlUnit
- v8 - Project Hosting on Google Code
V8 is Google's open source JavaScript engine.
V8 is written in C++ and is used in Google Chrome, the open source browser from Google.
V8 implements ECMAScript as specified in ECMA-262, 3rd edition, and runs on Windows XP and Vista, Mac OS X 10.5 (Leopard), and Linux systems that use IA-32 or ARM processors.
V8 can run standalone, or can be embedded into any C++ application.
- How to use the double not (!!) operator in javascript - Stack Overflow
The Logical AND operator (&&), will return the value of the second operand if the first is truly:
true && "foo"; // "foo"
And it will return the value of the first operand if it is by itself falsy:
NaN && "anything"; // NaN
0 && "anything"; // 0
- Slow JavaScript on Apple iPad? « Tim Anderson’s ITWriting
- IE9, FF4 Beta In Real-World Benchmark
Chrome is the obvious winner in this benchmark. While Opera, Safari, and the IE9 beta approach Chrome in raw Javascript speed, those browsers drop far behind by taking too long to actually draw the image set up by the Javascript and get back into rendering the next frame.
Surprisingly, Firefox 4.0 Beta 6 came in behind all other browsers except for IE8–even coming in behind its predecessor, Firefox 3.6. While we expect its performance to improve before release, it was surprising to see this result. It should be noted that no Firefox 4.0 Beta 6 test run came in faster than any test run by another modern browser.
IE9 Beta 1 performed surprisingly well (with a few caveats; see the notes below). In fact, it performs well enough that LucidChart will finally be able to remove the obnoxious warning to IE users that they’re getting an inferior experience in LucidChart.
- Land Ho, Fast JavaScript! » Mystery Bail Theater