Geeks With Blogs

News profile for Aligned at Stack Overflow, Q&A for professional and enthusiast programmers

Donate Bitcoins

Check out Elapser from T3rse!
"free in Christ Jesus from the law of sin and death." Romans 8:2 (ESV) Check out the Falling Plates video on YouTube.
more about the Gospel
And then listen to Francis Chan speaking at LifeLight in SD.

Programming and Learning from SD JavaScript
Ajax promises without jQuery
I’m trying to move away from jQuery, since I’m using Knockout and AngularJS more all the time. I’ve always done my AJAX calls with the useful jQuery $.ajax( method. Searching for “ajax without jquery” brings up a lot of results, but they all include how to do it with jQuery. First a friend found a tutorial on ES6 promises on HTML5 rocks that included an example of “Promisifying XMLHttpRequest”. Since promises aren’t in all browsers yet (IE and Android Browser) you can polyfill with es6-promise. Or ......

Posted On Tuesday, October 7, 2014 4:20 PM

Find an element in a JavaScript array
I needed a C# Dictionary like data structure in JavaScript and then a way to find that object by a key. I had forgotten how to do this, so did some searching and talked to a colleague and came up with this JsFiddle. See the code in my jsFiddle or below: var processingProgressTimeoutIds = []; var file = { name: 'test', timeId: 1 }; var file2 = { name: 'test2', timeId: 2 }; var file3 = { name: 'test3', timeId: 3 }; processingProgressTimeoutId... name: file.name, timerId: file.id }); processingProgressTimeoutId... ......

Posted On Friday, August 22, 2014 6:27 PM

Mock the window.setTimeout in a Jasmine test to avoid waiting
Jasmine has a clock mocking feature, but I was unable to make it work in a function that I’m calling and want to test. The example only shows using clock for a setTimeout in the spec tests and I couldn’t find a good example. Here is my current and slightly limited approach. If we have a method we want to test: var test = function(){ var self = this; self.timeoutWasCalled = false; self.testWithTimeout = function(){ window.setTimeout(function(){ self.timeoutWasCalled = true; }, 6000); }; }; Here’s ......

Posted On Thursday, August 21, 2014 4:42 PM

Angular Panel Discussion with Dan Wahlin, Jeremy Likness, John Papa, and Ward Bell
10 Reasons Web Developers Should Learn AngularThere is a very informative video discussing AngularJs, TypeScript, etc that is well worth your time. It got me interested and even excited about Angular and the possibilities. I’m a big fan of KnockoutJs, but this video gave me the bug to look into Angular more. Here’s a good article comparing KnockoutJs and AngularJS. Here are some notes from their discussion: They mentioned the cool demos at babylonjs.com. TypeScript pros and cons around 20 minutes ......

Posted On Monday, February 3, 2014 2:48 PM

Mock RequireJS define dependencies with config.map
I had a module dependency, that I’m pulling down with RequireJS that I needed to use and write tests against. In this case, I don’t care about the actual implementation of the module (it’s simple enough that I’m just avoiding some AJAX calls). EDIT: make sure you look at the bottom example after the edit before using the config.map approach. I found that there is an easier way. I did not want to change the constructor of the consumer as I had a chain of changes that would have to be made and that ......

Posted On Monday, August 18, 2014 4:53 PM

Notes from a short presentation on NodeJs
I volunteered myself to give a short 30 minute presentation at a work lunch and learn on NodeJs. With my limited experience I see using Node as a great tool for build process improvement, scaffolding with yeoman, and running tests with Karma. I haven’t looked into using as a full server or development stack. I guess I’m too stuck on IIS and Visual Studio :-). Here are my notes, that aren’t very well formatted, but I wanted to share it anyways. What is it? "Node.js is a platform built on Chrome's ......

Posted On Friday, May 30, 2014 8:43 AM

Pointer Event W3C Specification
Our team was using hammer.js for touch events, mainly the tap event, but found some limitations in how we are using it. A colleague investigated more and decided we should use the Pointer Event Specification and Touch Event Specification contributed by Microsoft. It’s only in Candidate recommendation and only supported in IE10 and 11 (on 1/9/2014), but there is a polyfill for that called Hand.js. “Pointer events offer a way to unify handling mouse, touch, and pen input. This means that we can add ......

Posted On Thursday, January 9, 2014 3:38 PM

Referencing files TypeScript 0.9
I was trying to reference an existing JavaScript file from my new TypeScript file using /// <reference path="app.js"/> It wasn’t being found, until I found that you need to have the file saved as UTF-8. To do this in Visual Studio 2012 on Windows 7, click on file –> save as –> then click on the down arrow of the save button and choose save with encoding. TypeScript then found my JavaScript and started parsing. Now I have a lot of errors when I build the solution (other references aren’t ......

Posted On Friday, July 12, 2013 11:51 AM

Include your JavaScript references in the correct order
I was stuck for 2 hours on this. I was using Wijmo library and was including the complete library before the open js file. I kept getting’Uncaught TypeError: Cannot call method 'formatString' of undefined’. Finally, I switched the order and put the open js file before the complete js file and the error went away. The lesson is that undefined means you haven’t defined it yet . Make sure it isn’t defined below it and that you didn’t forget to include it ......

Posted On Monday, January 7, 2013 3:51 PM

Uncaught SyntaxError: Unexpected token u. file JavaScript Error in MVC
I was getting a JavaScript error that pointed to line number 1 of my MVC page. I have a form on the page and expected the Unobtrusive Validation to work with the Data Annotations. It took me a while to realize the validation messages weren't showing. After I while I found that I was missing the @Html.ValidationMessageFor(m => m.Name). Adding that for each field fixed it. My password reset with token example. I was missing line 12 and 17. 1: @using (Html.BeginForm("PasswordRe... "Home")) 2: { ......

Posted On Monday, May 20, 2013 1:45 PM

Copyright © Aligned | Powered by: GeeksWithBlogs.net | Join free