Archive for the ‘Uncategorized’ Category

Diagonal Accordion with jQuery

Friday, January 15th, 2010

diagonalAccordion is a jQuery plugin that allows for accordion functionality, but in a diagonal angle of your choice!

I forked Charles Marshall’s diagonal-accordion- plugin (on github) which allowed for a 45 degree angle accordion and hacked it to allow for any angle.

Use it like:

$("#someElement").diagonalaccordion({
acc_width:500,
acc_height:300,
bar_size:45,
speed:'slow',
accordion:'.accordion',
coverage:4,
diagAdjust: 3
});

Or even just:

$("#someElement").diagonalaccordion({
diagAdjust: 5
});

The only difference between using my plugin and his is the diagAdjust parameter. This parameter allows for incremental adjustments away from 45 degree angles. The bigger number you provide, the shallower the angle gets, until at number 11 it is effectively no angle. then after 11 it starts angling the other way.

Here’s the official demo for the original plugin. Like I said, mine works exactly the same way, it just has an extra param to use.

Making users confirm they want to leave the page

Wednesday, November 18th, 2009

Here is how to make a user confirm that they want to browse away from your page:

<script>

window.onbeforeunload = askconfirm;

function askconfirm(){
return "Using the back/forward/refresh buttons can have unexpected results";
}

</script>

Using jQuery, you can make it so the user only has to confirm if they are leaving the page for some reason other than clicking an “a” link or submitting a form:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
<head>

<meta http-equiv="content-type" content="text/html; charset=utf-8" />

<script src="http://www.google.com/jsapi">
<script>
google.load("jquery", "1");
</script>
<script>

window.onbeforeunload = askconfirm;
window.doAskConfirm = true;

function askconfirm(){
if(doAskConfirm){
return "Using the back/forward/refresh buttons can have unexpected results";
}
}

</script>
</head>
<body>

<a href="">test</a>

<form>
<input type="submit" value="submit" />
</form>

</body>
<script>
$(document).ready(function(){
$("a").click(function(){
window.doAskConfirm = false;
});
$("form").submit(function(){
window.doAskConfirm = false;
});
});
</script>
</html>

New H1N1 Tag Announced by w3

Tuesday, November 17th, 2009

Today the w3c announced the addition of the H1N1 tag to the HTML 5 standard. Apparently this is part of the new “semantic web”. You should use this tag when discussing the flu, or common worse-than-just-a-cold illnesses. I think this will especially help blind and vision impaired users because they can’t quickly scan a page like we can and thus aren’t able to avoid potentially harmful content. They will be able to set their browsers to stay clear of the H1N1 content so they aren’t exposed to it.

People die or at least become ill every day from over-exposure to H1N1 content. Symptoms include constant temperature taking, obsessive washing of the hands, hyperventilating when someone sneezes nearby and the weird compulsion to sneeze into one’s elbow instead of one’s hand (making it absolutely impossible to wash off the germs that you sneeze out).

The w3 feels it will help protect people if all H1N1 content is quarantined. It will help contain the spread of this content throughout the web, and give users a way to better deal with this content. The w3 can be hard to follow sometimes, so I will sum up their recommendation below:


4.4.12 The H1N1 Element

Status: Working Draft

The h1n1 element is a heading.

The first element of heading content in an element of sectioning content represents the heading for that section. Sections pertaining to and related to over-exposed and over-hyped disease and illness related topics should be quarantined by the h1n1 tag so as to allow users to deal with the content in a way of their choosing.

The level attribute, if present, must be a valid integer giving the fear inducing level of the content. The higher the level, the greater danger to users the content represents. User generated content should be treated as level 10 by default. News media content should be treated as level 6 or higher. Medical websites are at least a level 3. Scientific journals, since no one reads them and no one can understand them, are eligible for level 1 ranking.

For example, the following is correct:

<h1n1 level=”10″>
    <h1>OMG THE SWINE FLU IS GOING TO KILL US ALL</h1>
    <p>My brother’s sisters mom has a daughter who is in daycare and they had to shut down the whole day care because everyone was DIEING from swine flu. The swine flu will kill you because it turns you into a PIG!!!! YOU GET IT FROM PIGS AND YOU SHOULDN’T EAT PORK EVAR!</p>
</h1n1>


Here is a link to the full w3c recommendation.