Archive for Internet

Textarea Backup Localstorage v1.21

I figured I’d drop a note that I updated my Textarea Backup UserJS last month. What follows is the description from ExtendOpera.

Textarea Backup Localstorage

Retains what you type into textareas and contentEditable elements.

This script is only compatible with Opera 10.50 and up. If you need to use it with an older version use Textarea Backup but be advised that it comes with some disadvantages.

  1. Can automatically place previously typed text in textareas.
  2. Can add an unobtrusive menu in the top right corner of textareas

Actions menu screenshot (note the transparent object in the top right corner of the textarea):

Development can be followed on GitHub. Don’t be shy, open an issue or send me a pull request if you think you have something to contribute! 😉


1.21 July 25, 2013. Sorry, I was a bit hasty about that last one. I passed my testcase, but only noticed that many contentEditables work differently in practice on this very site.

  • Fixed a bug that occurred when BODY was contentEditable, as is typical in iframes.
  • Properly compare initial value of contentEditable element to backed up value so you’ll only get prompted to overwrite when relevant.
  • Full changelog.

1.20 July 25, 2013. I wasn’t going to make yet another release in three days, but these new features could be implemented much faster than I initially predicted.

  • Trustworthy old persistent preferences support added. I also uploaded a sample settings file.
  • Fixed the keep_after_submission bug, so setting it to false is safe again.
  • Removed the form requirement.
  • Support contentEditable. This is a pretty big one, seeing how it was the most obvious missing feature.

1.11 July 24, 2013. Added configuration switches for the new feature.

  • For Opera 11.6x and Opera 12.x it now defaults to off because of potential performance concerns.

1.10 July 23, 2013. Added support for dynamically added textareas.

  • This new feature will only work in Opera 11.6x and up.


Cutting Corners With Linear Gradients

Presumably unnoticed by all, back in December 2012 I replaced the image-based cut corners in post headings with pure CSS. Border-radius removed the need for images to round corners, but you don’t need images anymore to cut them either.

Edited down to only the cutting of corners, this is what it looks like now:

.posttitle a {background:#0b0; background:linear-gradient(225deg, transparent 8px, #0b0 8px)}
.posttitle a:hover, .posttitle a:active {background:#6c0; background:linear-gradient(225deg, transparent 8px, #6c0 8px)}

And this is how it used to be:

.posttitle a {background:#0b0 url(images/posttitle.gif) no-repeat top right;overflow:hidden;}/*overflow:hidden for Webkit which insists on adding some kind of margin*/
.posttitle a:hover, .posttitle a:active {background:#6c0 url(images/posttitle.gif) no-repeat 100% -91px;}

Size-wise the difference is small: the GIF was only 107 bytes. You’d pretty much make up the difference by adding prefixed versions of linear-gradient if desired, albeit you do still save an HTTP request and you avoid one of Webkit/Blink’s bugs.

For scaling it matters only very little. But not having to open up an image editor for simple things like this? Fantastic.


How To Fix SVG Height in Webkit/Blink

It’s pretty simple: also specify a height if you specify a width. To quote from the workaround in my stylesheet, which I added on account of my previous post:

figure svg {
	/*what follows is because Webkit/Blink is broken*/

I really shouldn’t have added that as I don’t cater to broken browsers anymore, but I have a bit of a soft spot for Opera—even if it’s never required any workarounds before. Presto is clearly superior, and so is Gecko. Chromium still doesn’t support SVG favicons. Gecko does. And just look at this table. Unfortunately Gecko doesn’t support SVG fonts, so it’s all looking pretty miserable without Presto.

Comments (1)


The results of parseInt() are somewhat inconsistent, so I wrote this to clean it up (also see there). What to do with it? Who knows; it might come in handy someday.

function parseIntHelper(numberString, radix) {
	numberString = (typeof numberString === 'number') ? numberString.toString() : numberString; // I guess we should support number input just like parseInt.
	radix = (typeof radix === 'undefined') ? 10 : radix; // Set radix to 10 if undefined.
	numberString = numberString.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); // Trim. Taken from
	// Check if octal; non-standard but in line with other languages
	if ( numberString.indexOf('0o') === 0 || numberString.indexOf('0O') === 0 ) {
		numberString = numberString.slice(2); // Remove '0o'.
		radix = 8;
	// Check if hex
	if ( numberString.indexOf('0x') === 0 || numberString.indexOf('0X') === 0 ) {
		numberString = numberString.slice(2); // Remove '0x'.
		radix = 16;
	for (var i=0; i<numberString.length; i++) {
		var nStr = numberString[i];
		if (nStr === '.') {
			continue; // Ignore decimal mark, or rather the radix point. Maybe a check against more than 1 of these?
		var parsed = parseInt(nStr, radix);
		if (isNaN(parsed)) {
			return parsed; // Return NaN if found
	return parseInt(numberString, radix); // Return regular parseInt if there was no shenanigans. Note that we do not support octal numbers prefixed with 0 because it's not in the ECMAScript 5 spec, although we do support the equally non-standard prefixed with 0o. That's because the behavior prefixed with 0 is just too unreliable, while we control what happens with 0o.


Using WordPress Excerpts in Meta Description

For a long time I’ve been aware of the fact that few, if any, WordPress themes seemed to do anything with the META element’s description feature. I never bothered to look into a solution, especially since I never used to add excerpts to my posts half a decade ago. However, I’ve bothered to do so ever since I started notifying people about updates on Twitter. It already makes the search results much more readable if you’re looking for something in the archives of this site, and I figured I should do the same for search engines.

Some uneventful searching later I found what I was looking for, but it definitely wasn’t right for me: I’ve got a huge volume of posts without any excerpts, so printing empty descriptions no matter what would be silly at best, and besides there are more descriptions out there than merely those of posts. After all, categories and even my site itself have a description as well. The comment by Matthew Slyman was much more to my liking, which I then customized as follows:

if ( is_single() ) {
	$desc = get_the_excerpt();
elseif ( is_page() ) {
	$desc = get_the_excerpt();
elseif ( is_category() ) {
	$desc = category_description();
elseif ( is_home() ) {
	$desc = get_bloginfo('description');
$desc = htmlspecialchars(trim(strip_tags($desc)));
if (!empty($desc)) {
	echo '<meta name="description" content="';
	echo $desc;
	echo '"/>';

Add the whole thing anywhere in your HEAD element in header.php. If excerpts seem to be missing from pages, there’s a simple solution. If you want to reuse the code above for some reason, wrap some sort of function around it and stick it in functions.php. Enjoy.


Word Count

Since I wanted to know the actual number of words in a paper in near-MLA format and couldn’t find my previous (simple) PHP script, I reimplemented an equally simplistic word counter in Javascript. It strips out citations between parentheses. Suggestions welcome and use at your own risk.


Why Opera’s XHTML Error Handling Is Superior

I found this old, unfinished post in my drafts. I’m not quite sure when I originally wrote it, but it was over a year ago. Rather than updating the content I decided to publish it as is, as I’m not sure why I didn’t, with a small addendum at the end.

I made a little compilation of the various error messages displayed by browsers upon encountering an XML syntax error. Firefox (Gecko) has the unfriendly looking error on top, Chromium (Webkit) renders the page up to the error, but shows a large error message (albeit not at all useful like in Opera & Fx), and for Opera I included 10.10 and the latest 10.50 pre-alpha build. Note that it’s just the styles behind the error message that changed a bit: the content and helpfulness of the error message is still the same. I’ll run it down a bit more:

  • Firefox displays an error message that’s only useful if you already know sufficiently much about X(HT)ML, whereas Opera’s error message not only highlights more clearly where parsing failed — although ultimately this difference might just be one of preference. More important, its error message might just helpfully link you precisely where you need to go to learn how to avoid it. When I first started messing about with XHTML back in ’03 or so, I probably would’ve appreciated it if Opera had done that. At the time Opera behaved the same as Fx does now.
  • Chromium displays an error message that doesn’t even manage to clearly indicate what’s the problem. This compares negatively to Fx and Opera highlighting the &.
  • Chromium renders the page up to the problem, which may result in a get out of jail free card. The error message doesn’t seem very annoying, but if the error is in the middle of the page it’ll still be in the way. In my sample page it’s at the end, however. (My example page is basically a standard installation of phpGraphy on which I decided to switch to application/xml+xhtml because it claims to be more or less XHTML compliant now — I had to fix all the unclosed meta and link tags first.)
  • Despite rendering the page, you won’t be able to see the page fully in Chromium. You will with Opera’s reparse as HTML function.

I hope that clarifies why I think Opera’s handling is best, both as a user and as an author.

This blog post is now outdated. You can return to the behavior I hailed by disabling the opera:config#UserPrefs|AutomaticallyreparseXHTMLwithparsingerrorsasHTML option.


Please, Use HTTP Language Headers

I’ve got my HTTP header set up as “Accept-Language: en-US,en;q=0.9,nl;q=0.8”, but the number of sites that actually seem to use this (that I have encountered) can be counted on one hand. Especially on Belgian sites it’s ludicrous: I’m clearly saying that I don’t want French, so unless there is a choice between English, Dutch, and French (on a minority of sites, sometimes also German) there’s no rationale whatsoever to bug me with the option for French when the only options are French and Dutch.

Don’t get me wrong: I want the option to override this automatic detection system with a language selector in the top-right or some such, but it seems like I’m sending out these headers to waste bandwidth. I guess I should just be grateful that they don’t make their language-selection pages Flash-based, though they do typically come attached with gigantic pictures that aren’t reused on the actual site.

I don’t know what the best method would be to utilize this, but in the case of the aforementioned majority of Belgian sites they tend to be like and, so I’d say just quietly redirect me to (all through HTTP) whereas if I go directly to /nl or /fr nothing should happen.

PS The few sites that initially seemed to utilize this method (like actually perform some IP-based shenanigans. It happens to work out for me in this particular case, but generally speaking I consider that far worse than the redundant language selection screens, although a lot of that depends on overridability as well. Which reminds me of software that insists on displaying itself in Dutch based on my location settings while it should really just align itself with my OS language.


Opera 11 Addressbar Revisited

I already wrote down some thoughts about the addressbar changes in Opera 11 a few days ago, and it got me thinking that the addressbar could definitely be improved, just not by detracting from it.

To cut to the chase, here’s the addressbar I’m envisioning:

What you see on this screenshot, however, does not tell the whole story. Let’s start with what’s visible:

  • The protocol is grayed out. This is the method that most so-called URL highlighting uses to emphasize the domain. I think this is the wrong approach, but in the case of the protocol it seems the right thing to do. It is somewhat hidden, but still fully visible: no need to select the addressbar to find out what protocol is being used. People know that something is a web address when they see it in print thanks to the protocol, even if they have no idea what it means (and in fact many might mistakenly interpret HTTPS as safe), and combined with the large, clear button indicating security information you’d really have to try to misinterpret HTTPS as safe.
  • The domain is highlighted, specifically by bolding in this example, but it could also be done through underlining, a background color, or a combination of various things. The important part is that the domain is highlighted, rather than the rest of the URI lowlighted.
  • Query strings have parameter highlighting, and characters that separate parameters like ? and & are hidden and replaced by a small outline indicating what goes with what. The space between the various parameters corresponds to the size of the hidden ? or & characters and thus no shifting will occur when selecting them. I did not look into things like color blindness and the colors I used are solely for illustration purposes; they are no suggestion for specific colors.

Then, what’s not visible:

  • Complex query strings, meaning with 3 or 4 parameters or more, could be hidden from that point on, but this should be visibly indicated. An ellipsis is the standard method of conveying such information, so there’s no need to come up with something fancy. A complex query string like Google’s would thus look something like [client=opera] [rls=en] [q=test]…

    Perhaps the number of parameters before hiding occurs should be configurable as well.

    This hiding should not affect links to IDs like #someID, which are hidden along with the query string at the moment.

  • Linkify URI segments on hover when a modifier key, such as Ctrl or Shift, is pressed. This has been implemented quite nicely by the Firefox extension Locationbar².

That’s about it for my proposal regarding how to truly upgrade the addressbar as opposed to trying to make it little more than a domain display.

Comments (3)

What’s Wrong With the Opera 11 Address Bar, And How to Fix It.

Opera 11 made some drastic changes to the addressbar. I think the thought is good, but the execution leaves quite a bit to be desired.

Opera 10.63

Here you can see the classic method as it is in 10.63: full URL. You could say that the security information is somewhat detached on the right.

Opera 11

This is Opera 11, with the changed addressbar. The favicon is removed, the protocol and query string are hidden, and the security information is made more prevalent.

Generally speaking I don’t care too much about http vs. https; secure vs. insecure certainly is a better way of presenting that, lest https give you a false sense of security. Then again, I think that keeping the protocol and simply moving the security indication to the spot of the favicon (while still getting rid of that) would’ve accomplished the same effect better without losing out on such information. After all, if I notice some site uses https, but is insecure, I should probably notify the site, right? The lack of something like ftp is slightly more annoying, but the lack query strings is the absolute worst. I realize that some query strings can be overly complex, but I fail to see why the lowest common denominator should get rid of the good query strings as well. Seeing or not seeing it is only part of the issue: it also kills the ability to easily select the relevant part of the query string that you want to change (like a search term).

Opera 11 as it should be

And here is my combination of both. Remove the favicon, which might give a false sense of being on the real site (and is already visible on the tab), and move the security information to where the favicon used to be. The rest of the URL can remain fully accessible, displaying information for those who can use it. Domain highlighting can take care of those who have trouble spotting the domain they’re on (and on Windows it already does, making the removal of the query string even more peculiar). No extra step is necessary to select parts of the URL.

I feel that this is a fair compromise: it makes the security information more accessible without compromising existing functionality.

Comments (1)

« Newer EntriesOlder Entries »