Javascript

Logistics & Inventory Management with Alutiiq

Logistics & Inventory Management with Alutiiq

Alutiiq recently award Cyber Sprocket a 1-year teaming agreement, making this our 4th year of working with Alutiiq on developing, supporting, & maintaining their military logistics & inventory management application.  We are very excited to be working with Alutiiq for another year.  The upcoming year will bring some exciting new possibilities for follow on projects that augment the system already in place.  We're looking forward to being part of the design & development team and supporting our clients and our country both at home and abroad. Technical Overview Services Provided Web Application Programming Database Design Database Maintenance System Architecture Network Support Platform Details ASP.Net / VB.net IIS MS-SQL HTML Javascript CSS

Comments Off   |   Posted in ASP.Net,Charleston SC,Javascript,MS-SQL,VB.Net,portfolio April 15, 2010
Consumer Web Apps with Abundatrade

Consumer Web Apps with Abundatrade

When Abundatrade decided to take their project to the next level they chose Cyber Sprocket Labs to help them get there.   They brought their existing website to us and asked us to help.  They were looking for a more fluid, more enjoyable web experience for their users.   They needed an updated easy-to-use web calculator & they needed it fast. Cyber Sprocket did the job quickly & did it right.   More than a year after that first quick "help us fix our site" project we are still helping them push their technology further.   We are now not only helping them slowly morph their consumer services into something bigger & better, we are also helping them run their operations more efficiently by integrating the web technologies with their daily operations & services that run the business. The main part of the consumer interface is a product valuation calculator.  Using ...

0 Comment   |   Posted in Javascript,MySQL,PHP,portfolio April 05, 2010

Anonymous Functions With Names?

I discovered an odd thing about JavaScript last night. As you know, one way to add methods to an object is to assign anonymous functions to property names. For example: var foo = { woo: function (鯣) { print(鯣); } }; Strictly speaking, our function has no name. We just happen to assign it to a property which we can use to call the function. Contrast that to the ‘normal’ way of defining functions: function woo(色魚) { print(色魚); } But here’s the weird thing, we can combine these two styles. var foo = { woo: function specialHiddenName(鯣) { print(鯣); } }; We get no error for this. Interestingly, I could not find a way to call the function using specialHiddenName. So ...

0 Comment   |   Posted in Javascript,blog April 02, 2010

Pitfalls With Optional Arguments

Let’s talk about a couple of problems we can run into when writing functions that have optional arguments. First there is the matter of how we should declare such functions to begin with. If our function can take any number of arguments then it is easiest to use the ‘arguments’ array inside of the code. This array[1] is always available inside of our functions, so if we have an unknown number of parameters we can loop through it to get all of them. function Σ() { var total = 0; Array.forEach( arguments, function (n) { total += n; }, this ); ...

0 Comment   |   Posted in Javascript,Programming Languages,blog March 11, 2010

Holy Hell, Properties!

I was studying the code for Mozilla’s Venkman program and discovered that the Mozilla platform supports properties for Javascript objects. Now when I say properties I mean in the sense of Python, C#, Visual Basic, and so forth; members of a class whose getters and setters are called transparently. That is, when we write code like print( user.access ); user.access = “Admin”; it gets translated into print( user.getAccess() ); user.setAccess(“Admin”); We can actually do this in Javascript on Mozilla's platform! The way it works is by calling __defineGetter__() and __defineSetter__() on the prototypes of our classes. The each take two arguments: the name of the property as a string, and a function implementing the getter or setter behavior. Here is an example. var userLevelmap = [ "None", "Standard", "Premium", "Admin" ]; function User() { this._access = ...

0 Comment   |   Posted in Javascript,blog March 08, 2010

Scoping in Javascript With ‘Let’

In my post yesterday about multiple-values I used the keyword ‘let’ in some of the examples. This is another feature of the Mozilla Javascript platform. I assume it is named after ‘let’ from Lisp, because it performs the same task: letting you bind values in block scope. As you know, the scope of variables in Javascript is the entire function in which they appear. So take a trivial function like this. function foo() { var f = 10; print(f); { var f = 20; print(f); } print(f); } When we call the function the output will be 10 20 20 Our rebinding of ‘f’ inside the inner block changes ‘f’ on the outside. ...

0 Comment   |   Posted in Javascript,blog March 04, 2010

Returning Multiple Values

Mozilla’s Javascript platform supports returning multiple values, as of version 1.7. I don’t know when that got incorporated into the XUL platform, but the features from 1.7 are usable there. In fact, we already use this in ColorFish: this.getHSL = function () { var h, s, l; // ... return [h, s, l] } The last line returns an array with three values. This is how we pass back multiple values. If we are only interested in one return value then we can use this approach: this.getHue = function(){ return this.getHSL()[0]; } this.getSaturation = function(){ return this.getHSL()[1]; } this.getLightness = function() { return this.getHSL()[2]; } We can also get all of the values using destructuring binding. That is a fancy way of saying that when we assign a value, the left side of the assignment ...

0 Comment   |   Posted in Javascript,blog March 03, 2010

What’s With ‘with’

Yesterday Richard asked me about 'with' in Javascript.  I said I knew of it, and what it did, and that in general the community seemed to be against using it, but for reasons unknown.  I decided to look into the subject a little, realizing I didn't know why the community avoids it. If you don't know, here's the gist of how 'with' works: it takes an expression and a series of statements.  It evaluates that expression to get an object, and then sets that object to be the lexical environment of the statements, which are then executed.  And then the original lexical environment is restored. This makes 'with' useful to cut down on typing.  For example, this series of statements: myReallyLongObject.foo(); myReallyLongObject.bar(); myReallyLongObject.baz(); Can be more succinctly written as: with ( myReallyLongObject ) { foo(); bar(); baz(); } Pretty straight-forward stuff. Why would people be against this?  The main ...

0 Comment   |   Posted in Javascript,Programming Languages,blog January 20, 2010

Javascript: Notes on Scoping

In the last Javascript discussion I touched on potential scoping problems with 'this'. The reality is a little more confusing. The way scoping works in Javascript may be counter-intuitive to what you expect. Here are some things to keep in mind, especially with large-scale projects like CSSchemer where these things can lead to unexpected behavior. Function Scope In Javascript a function has a single scope. That is to say, it does _not_ have block scope. Consider this snippet of Perl code: sub foo($) { my $bar = shift; my $number = 10; if ($bar) { my $number = 20; say $number; } say $number; } If we call foo() with a true argument then we will see the output 20 10 That's because Perl has ...

0 Comment   |   Posted in Javascript,blog January 20, 2010

Javascript Array.forEach

A quick tip, while it's fresh on my mind: If you are writing Javascript for Firefox or XULRunner---or anything supporting Javascript 1.6 technically---then you don't need to write loops like for (var i = 0; i < some.object.length; i++) { var item = some.object[i]; ... } Instead use the generic Array.forEach() function and save yourself from creating a temporary variable. The above is more cleanly written as Array.forEach( some.object, function(item) { ... }); This works for any object which has the length property.

0 Comment   |   Posted in Javascript,Programming Languages,blog October 31, 2009