by Terri Ann on August 14, 2009
I’ve been working on a site lately that uses a lot of jQuery. I’m much more familiar with prototype so sometimes I find myself stumped at some of the problems I run into.
I had the site looking beautiful with superfish drop down menu and a nice side slider. Then I opened a page and suddenly superfish was throwing an error:
Error: jQuery("ul.sf-menu").superfish is not a function
My code looked like:
Javascript
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/superfish.js"></script>
<script type="text/javascript">
jQuery('ul.sf-menu').superfish();
</script>
What baffled me most was that it went from working to not working in zero-to-ten!
After fumbling and useless google searching I finally figured it out. For some reason it was calling the superfish() function before the js/superfish.js file was loaded. There’s an easy fix for that:
Javascript
<script type="text/javascript">
$(document).ready(function(){
jQuery('ul.sf-menu').superfish();
});
</script>
Tada! Easy to fix: using the ready function on the document.
by Terri Ann on August 10, 2009
I recently set up WAMP on one of my computers to host a local MediaWikirepository for personal notes about how to complete frequent / infrequent tasks and to organize the huge desktop directory of ‘notes’.
It’s been very useful and seeing as MediaWiki doesn’t requite you to use HTML in the posts I know I can export everything to human readable text files if need be.
I did occur to me, though, that I may need to put my WAMP server online every now and then to allow access from other machines. I don’t want this wiki of notes to be publicly accessible so I decided on using the .htaccess and .htpasswd file combination on WAMP to protect that directory. For the sake of simplicity we’ll assume you installed WAMP to the default directory (c:\wamp\)
This requires you have the Apache auth_basic_module module enabled.
Create your Password repository: .htpasswd
I chose to add my password file outside the web directory in a new directory called pwds (c:\wamp\pwds\.htpasswd) this way I can ensure it’s not accessibly via HTTP.
To add a user name and password to the .htpasswd file you’ll set it up as
user:password
Some setups require that you store an encrypted version of the password and there are tools online but I’d rather encrypt the value myself. By default WAMP doesn’t encrypt the password since it defaults to the auth_basic_module module which doesn’t require encryption.
You can enable the auth_digest_module module and restart services to use encrypted passwords but that’s a whole other article.
Add your .htaccess File
If you want to password protect everything you’d add the .htaccess file with the following lines to the root of your WAMP directory (c:\wamp\www\.htaccess), otherwise add these lines to an .htaccess file inside of the directory you want to protect.
AuthUserFile c:\wamp\pwds\.htpasswd
AuthName "Members Only"
AuthType Basic
require valid-user
The .htaccess file acts recursively. It will directly effect sub directories within the directory it is places. That’s why adding it to the root directory will password protect all directories
Login
Now when you try to access anything in the directory you just places your .htaccess file you’ll be prompted for a user name and password. There is no additional code required to create this login.
Learn More