Java-ScriptGate.com - Java Script Is Difficult

JS and App

January 7, 2010

ECMAScript 5′s Date Extensions

SEO Service Company India - We provide ethical search engine optimisation services to companies world wide. Contact us to get high quality seo services at affordable prices. One of the changes that ECMAScript 5 introduces is extensions to the Date class. Some of these are very useful — Date.now and Date.UTC as well as ISO-8601 format support. Michael J. Ryan has written support for these API changes in DateExtensions.js so you can get started using them now. SEO Consulting - With the most effective affordable SEO packages services in New York, ELM Consulting is the leader in helping small business grow on the web. Click here to learn more about our affordable SEO packages services and much more. redesign website Basariyorum is a leading web solution company catering to all your website design and development needs there by helping your business grow. Usage looks like this:
var epoch1 = new Date("1970-01-01T00:00:00.000Z");
var epoch2 = new Date(0);

if (epoch1.getTime() == epoch2.getTime())
    alert("Epochs match!");

alert(epoch1.toString()); //localized date instance of the JS epoch
alert(epoch2.toISOString()); // "1970-01-01T00:00:00.000Z"
alert(epoch1 instanceof Date); // true
alert(Date.UTC(1970,0,1,0,0,0,0)); // 0

More on ECMAScript

Other ECMAScript 5 extensions to the base library include: You can read a PDF of the spec here: ECMA-262.pdf Free Autoresponders - Welcome to Free autoresponders services officelive webpage. We offer to download a free email autoresponders software you can use for gmail, outlook and other email services. Web Design - Web Design offers custom web design, website development, flash website, portal development, search engine optimization and website designing services. situs-bebas.info - free download Business VPN - HughesNet Business Solutions provides business VPN, virtual private network, business internet with vpn, setting up vpn, satellite vpn for small and medium businesses, affordable and flexible, available anywhere. Transport Software Transport software has details of consignment, lorry hire, unloading or delivery. Transportation & Logistics Software also related with retail software, manufacturing software, ERP software, retail management, POS retail software, retail business software, production planning control PPC, human resource and payroll, sales force automation, point of sale software company, point of sale software for small business, retail point of sale solutions. Custom Web Design- Custom Website Design Services India Including Website Redesign and Ecommerce Solutions.A leading Web Design and Web Application Development Company in India, that specializes in Low Cost,Professional and Custom Website Design. Website Designs - Affordable & Professional Custom web site designing, Website development with Search Engine Optimization Services and content writing services from a 9001:2000 certified complete web solutions provider. Best address management services - Are you looking to hire best address management services. Your search ends here. Hire Improvemydata.com and get Consumer Data Cleansing & Address Management Service. Call us at 0845 60 60 609 or visit Improvemydata.com now! Offshore Product development - Q3 Technologies is Offshore Product Development Company leading in Outsourced product development, Offshore Product Development India, Outsourced product development India, software development, Application Development and Enterprise Applications Development Services. cam chat - Flashcoms is a reliable developer of flash-based interactive software designed to provide live communication support for websites and web-based communities. SEO Tools Read SEO Tools Reviews & Compare SEO Softwares for IBP, Web CEO & SEO Elite. SEO Software Reviews are rated by professional SEO Expert on the basis of customer reviews. Step and repeat buy computers TopFiveComputers.com is a user friendly computer product review and comparison site for computers and related items. The site was created by Lorenzo Loero, a CompTIA A+ certified IT technician based out of Orlando, FL. The main focus is to give novice computer shoppers the information they need to make purchasing decisions. posicionamiento paginas web Aparece en los Primeros Resultados de los Buscadores a través del servicio de Posicionamiento SEO de Internet Advantage y aumenta la visibilidad de tu Web Web Design India E2 Solutions, India's leading web design company offering top quality website designing services at affordable prices. Hosting - Web Hosting Buzz provides Reseller Web Hosting, cheap shared website hosting, virtual private server (VPS), managed dedicated servers and hosting on reliable high performance reseller hosting server, virtual hosting solutions, semi-dedicated and business hosting accounts home.php Ancestry Search - Radaris people search engine allows you to find and track anyone online. Our records contain current addresses, phone numbers and more. People Search - Online Address Book & People Search allow you to store  all your contacts, find people by name, address, etc. Comfibook helps to connect people! Justhost reviews - Best reviews of justhost hosting plan. Link building company india - cheapest SEO Company in India offers free SEO consultation and Search Engine Optimization. Laser Printers -  Thenerds.net offers great pricing on all ink cartridge, ink toner, laser printers, gps navigation, portable gps, office furniture, notebooks, hard drives, laptops, networking, systems and  digital cameras. Dog Insurance Atlanta IT Consulting- DynaSis, take care of all your Business Technology and IT Management Solutions needs. Custom Software Applications- Custom software development, consulting and data integration services. Should you buy or build a custom application? Contact us for FREE professional IT expert advise. Pink Laptops Professional Link Building Company - Link Building Company: Professional Link Building Company in India provides Professional Link Building Service. A Link Building Company with fully Professional Link Builders offering One Way, Reciprocal and Triangular Linking Services at affordable price link building services - Award winning SEO Link Building Services. Vertical Measures is top rated Internet marketing company helping businesses. get more website traffic via higher search engine rankings, link building, social media, local search, and search engine optimization. Improve web site search engine rankings with high quality relevant links- Buy high quality, relevant text links from us and improve your website search engine rankings. SEO service Quickbooks Hosting - Access Quickbooks Anytime, Anywhere- NovelAspect is a trusted leader in Quickbooks Web Hosting Services. They are the most reliable, and fully-licensed desktop QuickBooks hosting provider. Their QuickBooks Hosting provides unlimited remote user capability and every feature available on the local PC.

JS and App

January 6, 2010

Drawter

Drawter by Damian Wielgosik is a simple tool for drawing HTML interfaces and exporting the results. It uses jQuery and Damian’s own GUI code. You can draw HTML tags using The Tagname to draw option and the mouse. To switch between drawing and editing content and CSS, use the Draw Mode and Edit buttons. There are also menu items at the top of the page — click Code then Generate code to export your design. Drawter is a great example of what can be done with JavaScript, but it’s also potentially a useful tool. The author of Konigi was already blown away by it, and he’s something of a web prototyping tool enthusiast. online computer support Best Remote Computer Repair Services with Ask PC Experts on 1-888-518-9191. Online Computer Support Specialists & Remote PC Repair, We fix computer problems remotely and provide Online PC troubleshooting Help & Online Computer Tech Support Help to USA, UK, Canada, Australia and other English Speaking Countries. computer support Computer Support Specialists & Remote PC Repair in Australia. We fix computer problems remotely and provide Online PC troubleshooting Help & Online Computer Tech Support. ProStores Ecommerce Design, Customization & SEO/a> from IntuitSolutions, the Ecommerce experts.
Remote Pc Access flash game development Web Design Company Chennai - Visuals India - Web design and Development Company Chennai and SEO company. If you need our services then visit visualindia.com . When it comes to finding a reliable marketing partner the printing company http://www.originalimpressions.comperforms outstandingly as can be expected from a top tier supplier. Sharepoint Migration - Idera SharePoint migration suite is the most comprehensive solution available for SharePoint content migration. IP Telephone Systems - We provide reliable IP telephone systems and we are the leading provider of pure IP telephony solutions worldwide. If you’re preparing for retirement in Ontario, OHIP may not be enough, since it does not cover some medications as well as extensive treatment. Consider individual health insurance Ontario options which will help you medical expenses you may encounter.

JS and App

January 5, 2010

JSpec

We recently posted a unit test roundup, so I noticed that JSpec has been updated to version 3. This version introduces several interesting updates (see the full change list):
  • Rhino’s jar is included so console tests can work without installing extra stuff
  • Added a jspec stats command
  • Subcommand hooks — checks for spec/commands/*_command.rb
  • Ruby server is now a Sinatra app
JSpec is now version 3.0 and currently has over 200 followers on GitHub, so it’s worth checking out.

Syntax Examples

JSpec tests can be written using a custom DSL or a grammar-less JavaScript syntax. When using the DSL in browser-based tests, be sure to use JSpec.exec() to run tests rather than including the code in script tags (more details are in the README). Tests written with the DSL look like this:
describe 'ShoppingCart'
  before_each
    cart = new ShoppingCart
  end

  describe 'addProducts'
    it 'should add several products'
      cart.addProduct('cookie')
      cart.addProduct('icecream')
      cart.should.have 2, 'products'
    end
  end

  describe 'checkout'
    it 'should throw an error when checking out with no products'
      -{ cart.clear().checkout() }.should.throw_error EmptyCart
    end
  end
end
JavaScript equivalent:
JSpec.describe('ShoppingCart', function(){
  before_each(function{
    cart = new ShoppingCart
  })

  describe('addProducts', function(){
    it ('should add several products', function(){
      cart.addProducts('cookie')
      cart.addProducts('icecream')
      expect(cart).to(have, 2, 'products')
    })
  })

  describe('checkout', function(){
    it ('should throw an error when checking out with no products', function(){
      expect(function(){ cart.clear().checkout() }).to(throw_error, EmptyCart)
    })
  })
})

Custom Matchers

Custom matchers can be defined using JSpec.addMatchers. It’s possible to control the error messages. It’s also possible to create sets of macros with similar names:
JSpec.addMatchers({
  'be disabled selected checked' : function(attr) {
    return 'jQuery(actual).attr("' + attr + '")'
  },

  'have type id title alt href src sel rev name target' : function(attr) {
    return function(actual, value) {
      return value ? jQuery(actual).attr(attr) ## value:
                     jQuery(actual).attr(attr)
    }
  }
})

Other Features

JSpec includes a command-line tool that can initialise project templates, as well as auto-testing when files are changed. It can also work with Growl in Mac OS X. It includes lots of familiar matchers and works well in a browser and console.

Installation

To try JSpec out, you can install it with RubyGemsgem install jspec and read the docs on github.com/visionmedia/jspec. The future telecommunication technology is video conference facilities or video conferencing solutions. This communication facility allows several locations to interact with people via audio and video simultaneously. Video conference software brings a cost effective video conferencing system which is held over ISDN. This is very good video picture quality and also much more reliable than the normal internet.
Online Betting
SPORTSBETTING.COM is the simplest and most popular destination for sports betting on the Internet. Our many years of experience guarantee you a superior betting service. Join today to take advantage of all our great offers.

JS and App

January 4, 2010

Benchmarks in JavaScript

Speeding up page load times is a good way to decrease bounce rates and increase customer satisfaction. And if you’re using JavaScript in your server-side architecture, speed will become increasingly important. So you might be tempted to write your own benchmarking code when puzzling over a tricky performance issue. Fortunately there are quite a few JavaScript benchmarking libraries out there.

Unit Tests

If you’re writing unit tests you should get some benchmark information. Most libraries automatically benchmark tests — unittest.js includes a benchmark method. You could use this outside of tests for some foresnic analysis.

JavaScript Benchmark

JavaScript Benchmark is a nice little library that features:
  • ASCII-friendly output that’s great for server-side JavaScript
  • A simple API
  • Test suite support
Each benchmark will be run once by default, or you can specify a value:
suite('Iteration', 50000, function() {
  array = [1,2,3,4,5,6,7,8,9];

  benchmark('for', function() {
    for (var i = 0; i < array.length; ++i);
  });

  benchmark('for cached', function() {
    for (var i = 0, len = array.length; i < len; ++i);
  });

  benchmark('for in', function() {
    for (var i in array);
  });
});
This library won’t work in a browser due to the use of the print() function, but all you need to do is supply your own. Something like this will do:
function print(message) {
  document.getElementById('log').innerHTML += message + "\n";
}
I’ve put a full example up here: benchmarks.html

BenchmarkBuddy

BenchmarkBuddy is inspired by the RunSingleBenchmark from the V8 source. Here’s one of the author’s examples:
alert(BenchmarkBuddy.run(Math.random));

Benchmark.js

Benchmark.js is based on Ruby’s benchmark library. It’s still a work in progress and isn’t currently console-friendly, but when it works it will look like this:
Benchmark.benchmark(function() {
  for (i = 0; i < 10000000; i++) { }
});

link building services 
web content management

Development

December 31, 2009

2010 New Year’s Resolution

I have a backlog of draft posts, and I’m going to start working my way through them. I had a very interesting semester, and the next should be even more interesting. I’m keen to resume sharing. Look for more posts to come.

JS and App

December 30, 2009

JavaScript Unit Testing

Our JavaScript Developer Survey results showed that a large percentage of readers don’t currently unit test their JavaScript. I’ve been unit testing my own JavaScript projects for a few years, which resulted in the creation of riotjs — for more on riotjs see my blog post: Riotjs: A JavaScript Unit Testing Framework

There are lots of JavaScript test frameworks. I’ve presented a summary below — there are both traditional unit testing libraries and behaviour-driven frameworks.

unittest.js

unittest.js by Thomas Fuchs has been used by many JavaScript developers since Scriptaculous became popular in 2006. It provides a test framework that is recognisable to Ruby developers, and the relationship between Rails and Scriptaculous further increased adoption in this group.

This library depends on Prototype and is usually run inside HTML templates rather than a JavaScript interpreter.

Tests look like this:

  new Test.Unit.Runner({
    testExample: function() { with(this) {
      var exampleVar = '1234';
      assertEqual('1234', exampleVar);
      assert(true);
    }}
    
  }, "testlog");

Fuchs uses with(this) to cut down unnecessary syntax — you don’t have to write tests this way though.

Setup and teardown methods are supported. Shoulda-style assertion names have also been added. This adds methods to the prototypes for common JavaScript objects, so it’s possible to write 'test'.shouldEqual('test').

unittest.js also includes a handy benchmark method, and the following assertions:

assertNotEqual(expected, actual) Inverse of assertEqual
assertNotVisible(element) Checks if an element has display: none
assertVisible(element) Inverse of above
assertInspect(expected, actual) Checks if expected is the same as actual.inspect()
assertEnumEqual(expected, actual) Ensured two enumerables are equal
assertIdentical(expected, actual) Comparison using ===
assertNotIdentical(expected, actual) Inverse of above
assertNull(obj) Is obj null?
assertNotNull(obj) Inverse of above
assertMatch(expected, actual) Performs a regex, where expected is the regex
assertType(expected, actual) Checks if actual.constructor == expected
assertNotOfType(expected, actual) Inverse of above
assertInstanceOf(expected, actual) Checks if actual is instanceof expected
assertNotInstanceOf(expected, actual) Inverse of above
assertRespondsTo(method, obj) Checks if obj has a method named method
assertReturnsTrue(method, obj) Ensured that the method named method called on obj returns true
assertReturnsFalse Inverse of above
assertRaise(exceptionName, method) Ensures calling method raises an exception named exceptionName
assertElementsMatch([elements], expression1, expression2, ...) Ensures the array of elements match the list of expressions
assertElementMatches(element, expression) A helper for the above assertion when supplying a single element

JsUnitTest

JsUnitTest is a port of unittest.js without the Prototype dependency.

JsUnit

Development for JsUnit started in 2001, and is based on JUnit. Like unittest.js, tests are designed to be run in a web browser. By using the build.xml Ant file, tests can be run against multiple browsers on a local machine, or on multiple remote machines.

JsUnit tests are grouped within a Test Page. Test pages contain your tests. If a Test Page has setUp or tearDown functions, they will be run before and after each test function. A function called setUpPage will be run once per Test Page.

Each test function is written prefixed with test:

function testExample() {
    assert(true);
}

The following assertions are available:

  • assert([comment], booleanValue)
  • assertTrue([comment], booleanValue)
  • assertFalse([comment], booleanValue)
  • assertEquals([comment], value1, value2)
  • assertNotEquals([comment], value1, value2)
  • assertNull([comment], value)
  • assertNotNull([comment], value)
  • assertUndefined([comment], value)
  • assertNotUndefined([comment], value)
  • assertNaN([comment], value)
  • assertNotNaN([comment], value)
  • fail(comment)

QUnit

QUnit is used by jQuery for its unit tests. To use QUnit, include qunit.js and qunit.css within a HTML file that can display the test results.

Tests look like this:

test("a basic test example", function() {
  ok(true, "this test is fine");
  var value = "hello";
  equals("hello", value, "We expect value to be hello");
});

The jQuery QUnit documentation has full examples.

jspec

jspec (by Yehuda Katz) is an RSpec inspired framework. Rather than traditional unit tests, jspec attempts to provide a behaviour-driven development approach.

This is best illustrated with an example:

jspec.describe("The browser environment", function() {
  it("should have Array.prototype.push", function() {
    Array.prototype.push.should("exist");
  });
 
  it("should have Function.prototype.apply", function() {
    Function.prototype.apply.should("exist");
  });
})

Tests are written with it() blocks and chained should() calls.

The GitHub repository is currently pretty spartan, with no documentation or README, but jspec is a good port for those of you who are familiar with RSpec or want a change from JUnit-style libraries.

JSpec

JSpec by visionmedia (who have cropped up frequently on DailyJS) is a much more fleshed out BDD library. The author has tried to keep it minimal, but it has a unique and friendly DSL. It’s possible to write “grammar-less” tests using plain JavaScript.

Jasmine

Jasmine builds on the ideas of the previous libraries to provide a BDD library that supports asynchronous tests — Ajax-friendly testing.

JS and App

December 29, 2009

Doodle.js

I’ve written a few posts about canvas-based animation and graphics libraries lately. Before moving on to another topic I thought I’d mention Doodle.js, which is a sprite-based canvas library. Doodle.js simplifies working with the canvas, and includes excanvas for IE support.

Code using Doodle.js looks like this:

(function(oo) {
 oo.canvas('#my_canvas');
 var box = oo.rect({x:25, y:25,
                    width:50, height:50, fill:"#ff0000"});
 box.draw(); //draw a red box with initial parameters
 
 box.modify({fill:'rgb(0,255,0)'}).translate(50,0).draw();
 box.modify({fill:'purple'}).rotate(-45).draw();
 box.modify({fill:'yellow'}).translate(50,0).scale(1.5).draw();
 box.modify({fill:'blue'}).transform(1.5,0,0,1.5,50,0).draw();
 
})($doodle);

As you can see, the API is fairly clean. There isn’t currently much documentation, but the author has written a length blog post with examples.

While Processing.js is a full drawing and animation system, and Raphael is a vector graphics library, Doodle.js provides a simple way of working with sprites.

Frameworks

December 27, 2009

WTFramework – Detect Which Framework A Site Is Using, The Easy Way

Tags: , ,

WTFramework Summary

WTFramework is a dead simple, and well designed way to detect which framework a site is using as well as version. Being primarily a JavaScript developer I was always looking through the source to find which framework a certain site was using. Or to see if the developer had done something particularly cool with my favorite framework MooTools. It was developed by Oskar Krawczyk and is implemented as a bookmark for any A grade browser. You simply drag it into your bookmarks bar and its installed. You can now use it on any site you visit. The notifications are “Growl” like and are very well designed. Kudos to Oskar on this one, a dead simple, but time saving tool.

Installation

  1. Visit The Site
  2. Drag the big red icon into your bookmarks.
  3. It is now installed.

Fortunately For Us

Oskar has a public Git Hub repository for this. So if needs be you can change it to suit your needs.

Gallery

London based Website Design Company is providing professional website design and website development services. They create a range of website applications and solutions - from secure ecommerce platforms to tailored content management system. Hampshire based Web design agency is specializing in ecommerce website development. Browse through our work portfolio on website designing. Our programming team focuses to deliver an ecommerce web design that produces great ROI.

JS and App

December 23, 2009

Conway’s Game of Life

Our recent post about Processing.js made me think about Conway’s Game of Life. If you haven’t come across it before, it’s a simulation that works like this:

1. Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.
2. Any live cell with more than three live neighbours dies, as if by overcrowding.
3. Any live cell with two or three live neighbours lives on to the next generation.
4. Any dead cell with exactly three live neighbours becomes a live cell.

I like to use this algorithm to experiment with new graphics libraries, so I had my own Processing version from back in 2005. I’ve ported it to Processing.js here conway-js.

I’ve also found lots of interesting pure JavaScript implementations. ConwayJS by Joseph Robert is my favourite. It’s pretty fast and allows you to draw cells with the mouse.

Another interesting one is game_of_life by sukhchander.

I’ve uploaded my Processing.js examples to DailyJS so you can see them without checking out the git repositories:

JS and App

December 22, 2009

JavaScript Particle System

After yesterday’s Processing.js article I discovered this post about creating a particle system with JavaScript and a canvas: Parcycle: A Particle System with HTML5 canvas.

You can view the effect in action in this demo: Parcycle

I found the use of globalCompositeOperation very interesting in this code. It allowed the author to make particles appear lighter when they overlap by using a drawing mode rather than detecting the colour on the canvas.