Inspecting Angular Forms

Thursday, Oct 24, 2013 11:38 am
William Barnes

I have a long, multi-part Angular form on my <a href=”http://www.divorces.ca/” title=”Toronto Uncontested Divorces – Lawyer Prepared”>new website</a>. At a certain point, I began to find it difficult to review the source to ensure that the model being produced lined up with the output I wanted, so I wrote a bookmarklet that displays the ngModel attribute above each form control.

The current version unfortunately requires jQuery to be used on the page.

  1. javascript:$('.debugAngular').remove();$("[ng-model]").each(function(i, el){ var pos = $(el).offset(); varNewEl = $("body").append('<div style="position:absolute;z-index:9999;top:'+(pos.top-15)+'px;left:'+pos.left+'px;background:#000;color:#fff" class="debugAngular">'+$(el).attr("ng-model")+'</div>') });

Dojox/Socket, Node.js, and Socket.io

Monday, Sep 16, 2013 10:57 pm
William Barnes

I’ve been playing around with node.js and I decided to try setting up a web socket connection. I’m using socket.io on the server side and Dojo Toolkit on the client side. Things on the server-side were straightforward. However, I decided to give dojox/socket a shot and got the following error:

-debug- destroying non-socket.io upgrade

As it turns out, dojox/socket is a fairly plain wrapper over the browser’s built-in Websocket object (with long-polling support added). Socket.io does rather a bit more and (rightly or wrongly) seems to prefer talking to itself. Luckily, if you’re not too picky, you can easily include the official (AMD-compatible) socket.io client:

  1. require([
  2. '../socket.io/socket.io.js'
  3. ], function(io) {
  4. var socket = io.connect('ws://localhost:8000');
  5. socket.send("Hiya server!");
  6. });

Note that the proper relative path to the socket.io.js file has to be specified (the proper version of this file is automatically served by socket.io through node.js).

Gave 4 stars to The Pillars of the Earth by Ken Follett on Goodreads.
bookshelves: to-read Good, but it always seemed like it was about to end.
August 28
RT @google: The power of the Apollo missions in a single Google search http://t.co/X2vsznoy
August 25
Why won’t the people at the front of the crowd at Busker Fest sit down?
August 24
Why, #ttc, is the air conditioning never on in a crowded bus or a on a hot day?
July 26
The official teaser trailer for ‘Les Miserables (2012) starring Hugh Jackman, Russell Crowe and Anne Hathaway. An adaptation of the successful stage musical based on Victor Hugo’s classic novel…
July 18
British court censors documentary on London riots: http://t.co/PTEn05Cf
June 22
@SGgrc See grc.securitynow re: position on Stuxnet. Can a computer virus be targeted enough?
Harry Potter theme played on wine glasses: http://t.co/RLIiYhwv
June 19
@shwood Not Xbox 720. “The New Xbox”.
June 15
I wish it didn’t clash. http://t.co/EQhSOVpc
June 14
@leolaporte I find it odd that everyone loves unlimited subscriptions to music, but wants a la carte cable.
June 10
RT @ginatrapani: “there’s a whole industry of sites devoted to Apple fan fiction”
May 21
The absolute best things in the world. Tell me he doesn’t get it right. http://t.co/UPtoIw0N
May 20
Mmmm. Bacon wrapped steak.