Twitter Stream
Interesting News Items
Powered by Squarespace

Entries in JavaScript (2)

Friday
Feb192010

Linq for JavaScript

2010-02-19_jLinq[1] The past couple days I have been living on StackOverflow (I’m waiting on a client to give the go-ahead signal) and I came across an ad about jLinq.  Now, my first inclination was that of shock and bewilderment, but I’m starting to get over that.  jLinq is a Linq framework for working with Arrays in JavaScript.  If you don’t know about Linq then you probably don’t understand how awesomely scary that is.  Anyways, the syntax seems similar to the how C# works (with some added “memory” for previous actions). 

  1. <script type="text/javascript">
  2.     var results = jLinq
  3.         .from([
  4.             {name:"John", age:25, admin:true},
  5.             {name:"Mike", age:35, admin:false},
  6.             {name:"Randal", age:41, admin:false},
  7.             {name:"Stephanie", age:32, admin:true}]) // array of data
  8.         .ignoreCase()
  9.         .startsWith("name", "m") // "name" property starts with "a"
  10.         .or("j")                 // "name" property starts with "j"
  11.         .is("admin")             // "admin" property is true
  12.         .orderBy("age")
  13.         .select();
  14. </script>

While Linq is just a “less code” way of doing the same things you’ve been doing for years, I’m looking forward to using it and removing chunks of JavaScript loops.

Friday
May222009

Make Movable

Have you ever wanted to make your html elements move around? Well this function will make that happen for you.  All you need to do is call "makeMovable([your html element goes here]);".  This type of function can be used for UI constructs like popup windows and error dialogs, or just for impressing people with your mad skillz (jk!).

makeMovable.js
makeMovable.js

You can also specify a "Handle" for your object (in my experience this is the most common usage). When you specify a handle, your target object will only move when the handle is being dragged. Just use the following code: "makeMovable([your target element goes here],[your handle element goes here]);" It is recommended that the "Handle" element is a child of the "Target" element.