From Dr. Nic's Blog:
Autotesting Javascript in Rails
Tech Tidbits - Ruby, Ruby On Rails, Merb, .Net, Javascript, jQuery, Ajax, CSS...and other random bits and pieces.
Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts
Wednesday, March 12, 2008
Monday, March 10, 2008
Javascript - insertAfter(), formatCurrency, DOM Scripting
insertAfter()
formatCurrency()
DOM scripting - create text node with value of
function insertAfter(newElement,targetElement) {
var parent = targetElement.parentNode;
if (parent.lastChild == targetElement) {
parent.appendChild(newElement);
} else {
parent.insertBefore(newElement,targetElement.nextSibling);
}
}
formatCurrency()
function formatCurrency(amount) {
var i = parseFloat(amount);
if(isNaN(i)) { i = 0.00; }
var minus = '';
if(i < 0) { minus = '-'; }
i = Math.abs(i);
i = parseInt((i + .005) * 100);
i = i / 100;
s = new String(i);
if(s.indexOf('.') < 0) { s += '.00'; }
if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
s = minus + s;
return s;
}
DOM scripting - create text node with value of
var textEl = document.createTextNode('\u00a0');
Accordion Effects with Scriptaculous
I had a couple recent projects that required an accordion effect. I normally use jQuery, but found a couple nice Prototype/Scriptaculous accordions (one is for a Rails project, so we're already using Scriptaculous).
stickman labs
grf-design
Note - The stickman labs accordion doesn't appear to work with the latest Prototype (1.6.1). I'm using the combined js file from the stickman site.
stickman labs
grf-design
Note - The stickman labs accordion doesn't appear to work with the latest Prototype (1.6.1). I'm using the combined js file from the stickman site.
Labels:
accordion,
javascript,
prototype,
scriptaculous
Tuesday, February 19, 2008
jQuery
I've been using the jQuery Javascript library a lot lately and it's definitely become my favorite library. (I've written four plugins in the last couple months to boot)
Here are a few links to useful jQuery resources.
jQuery: The Write Less, Do More, JavaScript Library
jQuery UI: Widgets, Components, and Interaction
Plugins - jQuery JavaScript Library
jQuery Blog
Learning jQuery
Visual jQuery
IBM developerWorks: Simplify Ajax development with jQuery
Here are a few links to useful jQuery resources.
jQuery: The Write Less, Do More, JavaScript Library
jQuery UI: Widgets, Components, and Interaction
Plugins - jQuery JavaScript Library
jQuery Blog
Learning jQuery
Visual jQuery
IBM developerWorks: Simplify Ajax development with jQuery
Wednesday, January 23, 2008
jQuery: Cookie Plugin
I've become a big fan of jQuery and have contributed two small plugins myself, so when it came time to switch to a library for cookie manipulation with Javascript (time to replace all that nasty inline JS code) my first choice was jQuery.
Not to be disappointed, I found that Klaus Hartl has written a very slim and useful Cookie Plugin for jQuery.
Here's a small page test using the jQuery Cookie plugin:
My jQuery cookie demo using jquery.cookie.js
Not to be disappointed, I found that Klaus Hartl has written a very slim and useful Cookie Plugin for jQuery.
Here's a small page test using the jQuery Cookie plugin:
<html>
<head>
<title>jquery cookie</title>
<script type="text/javascript" src="jquery-1.2.1.min.js"></script>
<script type="text/javascript" src="jquery.cookie.js"></script>
<script type="text/javascript">
$(function($) {
function displayMessage(msg) {
$('#message').html(msg).css({color: 'green'});
}
displayMessage('jQuery cookie plugin test');
$('#setSessionCookie').click(function() {
$.cookie('test', 'Hmmm, cookie');
displayMessage("Cookie 'test' has been set.");
});
$('#setCookie').click(function() {
$.cookie('test', 'Hmmm, cookie', { expires: 7 });
displayMessage("Cookie 'test' has been set and will expire in 7 days.");
});
$('#getCookie').click(function() {
displayMessage("The value of the cookie named 'test' is: " + $.cookie('test'));
});
$('#deleteCookie').click(function() {
$.cookie('test', null);
displayMessage("Cookie 'test' has been deleted.");
});
$('#testCookiesEnabled').click(function() {
$.cookie('testcookiesenabled', null);
$.cookie('testcookiesenabled', 'enabled');
if ($.cookie('testcookiesenabled')) {
displayMessage("Cookie: "+ $.cookie('testcookiesenabled'));
} else {
displayMessage("Cookies disabled");
$.cookie('testcookiesenabled', null);
}
});
});
</script>
</head>
<body>
<p><span id="message" style="forecolor: red;"></span>
<p><input type="button" id="testCookiesEnabled" value="Cookies enabled?"/></p>
<p><input type="button" id="setSessionCookie" value="Set session cookie"/></p>
<p><input type="button" id="setCookie" value="Set cookie expires in 7 days"/></p>
<p><input type="button" id="getCookie" value="Show cookie value"/></p>
<p><input type="button" id="deleteCookie" value="Delete the cookie"/></p>
</body>
</html>
My jQuery cookie demo using jquery.cookie.js
Saturday, January 5, 2008
Wednesday, September 26, 2007
JavaScript Style
As I've been doing a lot of Javascript and Ajax these days, I've found these resources valuable:
JavaScript style and the art of anal retention
Dojo style guide
Ajaxian commentary on Dojo style guide
Crockford style guide, part 1
Crockford style guide, part 2
Ajaxian commentary on Crockford style guide
Mozilla style guide
JavaScript style and the art of anal retention
Dojo style guide
Ajaxian commentary on Dojo style guide
Crockford style guide, part 1
Crockford style guide, part 2
Ajaxian commentary on Crockford style guide
Mozilla style guide
Saturday, September 8, 2007
Javascript Resources
Yahoo! UI Library: YUI Theater
Douglas Crockford — "The JavaScript Programming Language"
Douglas Crockford — "An Inconvenient API: The Theory of the DOM"
Douglas Crockford — "Advanced JavaScript"
Douglas Crockford
Douglas Crockford's Javascript
Code Conventions for the JavaScript Programming Language
John Resig
John Resig
John Resig - JavaScript Talk at Northeastern (video)
Misc
QuirksMode - JavaScript
netscape devedge: JavaScript Central
webdeveloper.com: JavaScript
Web Reference JavaScript
W3Schools JavaScript
Tutorial
DHTML Goodies
JavaScript Toolbox
JavaScript Toolbox
JavaScript Toolbox - Best Practices
comp.lang.javascript FAQ
Tools
JSLint, The JavaScript Verifier
JSMIN, The JavaScript Minifier
dean.edwards.name/packer/
JsUnit
W3C
W3C Document Object Model
Books
JavaScript: The Definitive Guide by David Flanagan
Pro Javascript Techniques by John Resig
JavaScript: The Good Part by Douglas Crockford
Learning jQuery by Karl Swedberg and Jonathan Chaffer
Douglas Crockford — "The JavaScript Programming Language"
Douglas Crockford — "An Inconvenient API: The Theory of the DOM"
Douglas Crockford — "Advanced JavaScript"
Douglas Crockford
Douglas Crockford's Javascript
Code Conventions for the JavaScript Programming Language
John Resig
John Resig
John Resig - JavaScript Talk at Northeastern (video)
Misc
QuirksMode - JavaScript
netscape devedge: JavaScript Central
webdeveloper.com: JavaScript
Web Reference JavaScript
W3Schools JavaScript
Tutorial
DHTML Goodies
JavaScript Toolbox
JavaScript Toolbox
JavaScript Toolbox - Best Practices
comp.lang.javascript FAQ
Tools
JSLint, The JavaScript Verifier
JSMIN, The JavaScript Minifier
dean.edwards.name/packer/
JsUnit
W3C
W3C Document Object Model
Books
JavaScript: The Definitive Guide by David Flanagan
Pro Javascript Techniques by John Resig
JavaScript: The Good Part by Douglas Crockford
Learning jQuery by Karl Swedberg and Jonathan Chaffer
Thursday, June 7, 2007
Javascript/Ajax Libraries
I've been working on a few Ajax and DOM scripting projects at work using prototype.js and scriptaculous. Now we're looking at a "Web 2.0" upgrade for some of our sites, so I'm looking at several libraries:
Prototype JavaScript Framework
script.aculo.us
The Dojo Toolkit
Rico
Yahoo! UI Library (YUI)
mootools framework
MochiKit
JQuery
There are many, many more...
OSA Foundation - Survey of Ajax/JavaScript Libraries
Here's an accoridion demo I created with Rico:
My Rico Accordion Demo
Prototype JavaScript Framework
script.aculo.us
The Dojo Toolkit
Rico
Yahoo! UI Library (YUI)
mootools framework
MochiKit
JQuery
There are many, many more...
OSA Foundation - Survey of Ajax/JavaScript Libraries
Here's an accoridion demo I created with Rico:
My Rico Accordion Demo
Subscribe to:
Posts (Atom)
About Me
- Doug Sparling
- Developer (Ruby on Rails, iOS), musician/composer, Buddhist, HSP, Vegan, Aspie.
Labels
- .NET (8)
- accordion (1)
- ActiveRecord (1)
- ajax (2)
- APT (1)
- apt-get (1)
- ASP (1)
- ASP.NET .NET (5)
- Audio (1)
- aws (1)
- Bash (1)
- bdd (1)
- C# (1)
- cache_fu (1)
- caching (1)
- DocBook (1)
- DOM (1)
- Eclipse (1)
- Excel (1)
- Firefox (1)
- gem (5)
- Gems (5)
- git (1)
- GridView (2)
- Hibernate (1)
- iBATIS (1)
- Java (9)
- javascript (9)
- javascript css (1)
- jQuery (4)
- jsspec (1)
- mdb2 (2)
- Merb (2)
- mongrel (2)
- mp3 (2)
- Music (2)
- MySQL (2)
- nginx (1)
- openssl (1)
- osx (3)
- pdocast (1)
- pear (2)
- Perl (7)
- php (5)
- plugin (2)
- podcast (1)
- prototype (1)
- REST (1)
- RMagick MacOSX (1)
- rspec (1)
- ruby (14)
- ruby on rails (21)
- RubyGems Merb (1)
- s3 (1)
- screencasts (1)
- scriptaculous (1)
- scriptrunner ruby rails erlang (1)
- Sortable (1)
- subversion (1)
- testing (1)
- testing erlang tsung (1)
- tomcat (1)
- ubuntu (2)
- WebSphere (1)
- will_paginate (1)