How to Get the Current Script’s Parent in Javascript

The following is a method of getting the current script’s parent, which may be useful if, for example, you need to append HTML in the same location as the script: var scripts = document.getElementsByTagName(‘script’); parent = scripts[scripts.length – 1].parentNode; The above code maintains the assumption that the currently executing script …

Javascript Object Class Literal vs. Constructor

Something I dug up while learning Javascript a long, long while ago. Here’s is an interesting article on the differences between a literal class declaration and a constructor. Essentially, the main difference is that with a literal class declaration, the object itself as well as its properties and methods are …

WordPress Disqus Popular Threads Widget Using Pure Javascript (Updated)

WpDisqusPt, or WordPress Disqus Popular Threads Widget, is a small script that you can drop into a Text Widget in WordPress. This widget shows which threads on your site are the most commented on, similar to Engadget’s old Most Commented widget. UPDATE 04-12-2013: WpDisqusPt is now on GitHub! https://github.com/ronaldcs/wp-disqus-pt UPDATE …

Create an Extensible Object in Javascript

There’s a whole mess of ways to accomplish this (see this article). Obviously, YMMV, but I chose this route for one simple reason: it makes sense to me. Anyhow, here’s a method of creating an extensible object in Javascript. var theObject = function (config) {   this.exProperty = “”;   this.exFunction = …

WordPress Disqus Recent Comments Widget Using Pure Javascript (Updated)

WpDisqusRc, or WordPress Disqus Recent Comments Widget, is a small script that you can drop into a Text Widget in WordPress. With just a few options, you can display the most recent comments for your Disqus-enabled site! UPDATE 12-17-2012: Version 0.3 – Added fade in/out animation to popup (Webkit browsers …

SlidingPane: Slide Page to Reveal Content Underneath Using HTML5 (Updated)

SlidingPane is a super simple script that allows you to slide an entire page or a section of a page to reveal content underneath. It was built as a self-contained component using HTML5 with no dependency on any Javascript library. Project Background First off, check out the demo here! UPDATE …