highlight: JavaScript text higlighting jQuery plugin
Posted 2007-09-15 in JavaScript by Johann.
Text higlighting is part of DynaCloud – where tags/keywords are automatically highlighted once they’re clicked – so I took that code and made it a stand-alone JavaScript text highlighting jQuery plugin.
Demo
Each of the links will highlight the corresponding word.
Remove highlights again.
Usage
Add highlight
Download jquery.highlight-5.js (2 KB) and add it to your page after jQuery. A Closure Compiler compressed version (1 KB) is also available.
Style the highlight class
Create an entry in your style sheet for the highlight
class.
.highlight { background-color: yellow }
Highlight terms
Call the highlight
function with the text to highlight. To highlight all occurrances of “bla” (case insensitive) in all li
elements, use the following code:
$('li').highlight('bla');
Remove highlighting
The highlight can be removed from any element with the removeHighlight
function. In this example, all highlights under the element with the ID highlight-plugin
are removed.
$('#highlight-plugin').removeHighlight();
Forks and Extensions
- Jon Raasch changed the
normalize
function to make highlight work in Internet Explorer 6. - Marshal made a variation that supports regular expressions.
- Chintan Tank made highlight support arrays.
- Paul Lang has added support for arbitrary class names beyond “highlight.”.
- Julian’s fork supports multiple class names.
Changelog
- 2014-01-11: Bugfix for character expansion during uppercasing. Thanks Guido Jansen.
- 2009-02-22: Bugfix for one or two strange problems with IE. Also made API easier to use.
- 2008-06-04: Bugfix for incorrect DOM normalization. Thanks Georgy.
- 2007-09-15: Initial release.
26 comments
Legendary guitar effects: Univox Super-Fuzz
Posted 2007-09-11 in Effects by Johann.
The Univox Super Fuzz is the ultimate fuzz box of all time.
The Superfuzz is so evil, it’s unbelievable. If you step on a Super-Fuzz, people will die.
Made by Univox of Japan (later Korg), the Super-Fuzz was launched before 1970 although I would consider it a fuzzbox typical for the 70’s. Super harsh, super over-the-top and super aggressive, it launched a new generation of fuzzboxes that probably influenced other 70’s classics like the Ibanez Standard Fuzz or the Roland Bee-Baa.
“Tone”
Like other 70’s fuzzes, the Super Fuzz has two “tone” settings. Don’t bother with the other one. There’s a little bit included in the sound sample, but not much.
When I got mine there was is no obvious octave-up. But thanks to a tip I now get better octave-up.
Audio clips
Sound samples were recorded with an Ibanez 2027XVV into a DOD 201 phasor/phaser and the Univox Super-Fuzz into a Boss VF-1 set to a small amp model with a lot of delay.
4 comments
lighttpd and Java application servers: integrating JSP and Servlets
Posted 2007-09-09 in WWW by Johann.
In this blog entry, I’ll show you how to integrate lighttpd in a JEE environment. After performing all the changes, lighty will transparently proxy your Java application server.
1. When to use lighttpd
You can use lighttpd to
- secure access to your application server
- reduce load on your server by offloading static requests
- load balance your application servers
- use lighttpd’s spambot and bad bot blocking capabilities
- get more request rewriting and redirecting flexibility
- use the above flexibility to improve your search engine rankings
- profit.
2. When not to use lighttpd
You might not like lighttpd if you
- don’t like configuring software
- use URL rewriting and
;jsessionid
.
3. lighttpd modules you need
The following lighty modules are needed:
- mod_access
- mod_redirect
- mod_rewrite
- mod_proxy
Add them to your server.modules
section:
server.modules = ( "mod_accesslog", "mod_access", "mod_redirect", "mod_rewrite", "mod_proxy", "mod_status", "mod_evhost", "mod_expire" )
4. Denying access to JEE directories
The WEB-INF
and META-INF
directories shouldn’t be accessible through lighttpd. Files from your development environment also shouldn’t be visible.
url.access-deny = ( "WEB-INF", ".classpath", ".project", "META-INF" )
5. Binding your application server to localhost
To prevent duplicate content penalties, your application server shouldn’t be visible from the web. Even if you run it on a high port, someone might eventually find it.
Binding a web site to localhost looks like this in Orion’s <name>-web-site.xml
:
<web-site host="127.0.0.1" port="12345"> <frontend host="johannburkard.de" port="80"/>
Consult your documentation if you aren’t using Orion.
6. Redirecting www.
to non-www.
hosts
Even if you don’t really need to do this, I recommend doing so. Removing duplicate content will improve your rankings.
The following snippet redirects all visitors from www.<domain>
to <domain>
with a 301
permanent redirect.
$HTTP["host"] =~ "^www\.(.*)$" { url.redirect = ( "^/(.*)" => "http://%1/$1" ) }
You should also redirect all additional domains (johannburkard.com
, johann-burkard.org
) to your main domain.
7. Proxying dynamic requests
We will use mod_proxy
to proxy some requests to your Java application server.
Depending on your site’s structure, one of the following approaches will work better.
Simple JSP
If all you have is a bunch of Java Server Pages, the following mod_proxy
rule is sufficient:
proxy.server = ( ".jsp" => ( ( "host" => "127.0.0.1", "port" => "12345" ) ) )
Note that the JSP must be actual files. You cannot use Servlets mapped to these URIs.
Applications
If you use Servlets or more complex applications, you can proxy URIs by prefix:
proxy.server = ( "/blog/" => ( ( "host" => "127.0.0.1", "port" => "12345" ) ) )
Proxying with exceptions
If most of your site is dynamic and you have a directory for static content (/assets
, /static
or so), you can proxy all requests except requests for static files:
$HTTP["url"] !~ "^/static" { proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => "12345" ) ) ) }
8. Rewriting requests
lighttpd can dynamically rewrite requests. I mostly use this to use default.jsp
as dynamic index file instead of index.html
. Here’s an example:
url.rewrite-once = ( "^(.*)/$" => "$1/default.jsp", "^(.*)/([;?]+.*)$" => "$1/default.jsp$2" )
This is visible at gra0.com and internally rewrites all requests from /
to /default.jsp
(including jsessionid
and query string).
mod_rewrite
can also be used to make URLs shorter. For example, to remove the ?page=comments
query string, I use the following:
url.rewrite-once = ( "^/blog/(.*)\.html$" => "/blog/$1.html?page=comments" )
9. Redirecting requests
You can use mod_redirect
to redirect the user to a different URL. Contrary to mod_rewrite
where the request is rewritten, a 301
permanent redirect will be sent to the browser.
In this example, I’m redirecting requests to an old domain to a new domain:
$HTTP["host"] == "olddomain.com" { url.redirect = ( "^/(.*)$" => "http://newdomain.com/$1" ) }
10. More things to be aware of
- The only IP address in your application server log files should be
127.0.0.1
. If you need the original address, log theX-FORWARDED-FOR
header. - Don’t analyze both lighttpd and application server logs – lighty’s log files already contain all requests.
- You might want to set up virtual hosts sooner or later.
- Use
mod_expire
to make resources cacheable. Doing so can make your site a lot faster and save you money.
2 comments
DynaCloud v2 (more dynamic tag clouds) plus automatic related content
Posted 2007-08-24 in JavaScript by Johann.
I have just released version 2 of DynaCloud.
DynaCloud is a JavaScript plugin for jQuery that generates tag or keyword clouds from text on web pages and highlights matching parts once a keyword is clicked.
What’s new in DynaCloud v2
- DynaCloud properties have been moved to the
jQuery.dynaCloud
object. - Only one tag/keyword can be active at a time (switchable).
- Automatic wordStats integration (switchable).
Demo
wordStats
Jean-François Hovinne’s wordStats plugin is quite amazing.
[wordStats] tries to determine what a page is about by computing the density of its keywords.
While DynaCloud is good at finding key words, wordStats is good at determining the topic of a page. Jean-François uses this to great effect to transparently retrieve related blog posts. Of course, this is all client-side and on-the-fly.
I like wordStats, so DynaCloud now offers transparent integration of wordStats. If the wordStats JavaScript is available, wordStats will be used. If not, the default DynaCloud algorithm is used.
Pages
Page 14 · Page 15 · Page 16 · Page 17 · Page 18 · Page 19 · Page 20 · Next Page »
Subscribe
RSS 2.0, Atom or subscribe by Email.
Top Posts
- DynaCloud - a dynamic JavaScript tag/keyword cloud with jQuery
- 6 fast jQuery Tips: More basic Snippets
- xslt.js version 3.2 released
- xslt.js version 3.0 released XML XSLT now with jQuery plugin
- Forum Scanners - prevent forum abuse
- Automate JavaScript compression with YUI Compressor and /packer/