javascript
Why does TypeScript have to be the answer to anything?
DISCLAIMER: I don't work on TypeScript. I am not involved with that team and this is all my own opinion and conjecture.
TypeScript was announced and folks are saying "TypeScript is clearly Microsoft's answer to Google's Dart" or "So TypeScript is Microsoft's answer to CoffeeScript."
I was chatting with Jez Humble today about the intense interest and some little gnashing of teeth around TypeScript and he offered this little gem of a quote:
It's disappointing when smart people display a profound ignorance of computing history. - Jez Humble
Making a switchable Desktop and Mobile site with ASP.NET MVC 4 and jQuery Mobile
I really enjoy working on and thinking about mobile websites. There's something about making an experience great on a pocket supercomputer phone that is so much more satisfying than a desktop. I actually got this blog looking nice on mobile devices back in 2006 when nobody was mobile except doctors and, well, all of us techies here on the blogs.
ASP.NET Web Forms DynamicData FieldTemplates for DbGeography Spatial Types (plus Model Binders and Friendly URLs)
Did you enjoy my recent post on ASP.NET MVC DisplayTemplate and EditorTemplates for Entity Framework DbGeography Spatial Types and it's associated GIANT URL?
Modeling Binding and EditorTemplates...for ASP.NET Web Forms?
DisplayTemplates and EditorTemplates are a great way in ASP.NET MVC to keep things DRY (Don't Repeat Yourself.) That means I can just write EditorFor() calls like this:
@Html.EditorFor(model => model.Location)
See how I didn't say "TextBoxFor" or "MapFor"? You say EditorFor and it makes the right choice. If the type is called DbGeography then it will look for a Editor Template at ~/Shared/EditorTemplates/DbGeography.cshtml. It's a nice feature of ASP.NET MVC that folks don't use enough.
JavaScript Popup Blocker for Google Chrome
Popups, I do not like them, at all. While they are sometimes used by sites to make part of the website’s functionality available, they are more often than not used for advertisement. And while there is nothing wrong with advertising in general, popup ads tend to be one of the most annoying forms of advertisement that you encounter on the Internet. The core reason being that new windows are spawned, that you need to close manually at one point or the other. That’s fine if one window spawns, but there are sites out there that bombard you with popups.
With Firefox, I have NoScript which takes care of the popups. I can’t really say when I have seen the last unrequested popup show up in the web browser. For Chrome, things have been different. While you get your assortment of ad blocking scripts for the browser, I found the JavaScript Popup Blocker extension to be more reliable when it comes to blocking popup windows in the browser.
Kill Evil Gets Rid of Annoying JavaScript Tweaks All Over the Web
Chrome: Kill Evil is a simple extension that disables annoying scripts all across the web, like sites that won't let you right-click, sites that won't let you copy images, or sites that paste in citation links whenever you copy their text. More »
The Future of JavaScript – take a peek today!
The ECMA committee is working hard on designing the next version of JavaScript, also known as "Harmony". It is due by the end of next year and it is going to be the most comprehensive upgrade in the history of this language.
Chrome and V8 are committed to pushing JavaScript forward and have already started implementing the new features. You can try some of them today in the latest dev channel release. Here’s a summary:
- Lexical scoping. Now "let" is the new "var" – traditional "var" declarations are complemented with "let" and "const". Both are properly block-scoped bindings, eliminating a common source of errors and weird behaviour. Function declarations are now officially allowed in local scope as well, and also obey lexical scoping. (Note: Lexical scoping is only available in ES strict mode.)
- Collections. Efficient maps and sets will make your life easier. Any value can be used as a key or element, including objects. No surprises, no more need to abuse objects as dictionaries. (Caveat: Iteration over collections is not yet specified.)
- Weak maps. A special kind of map for which the garbage collector determines when a key is no longer reachable, so that the key-value pair can be removed from the map automatically. This goes a long way towards avoiding memory leaks in long-lived tables and relieves the developer from worrying about stale entries.
- Proxies. A proxy simulates a JavaScript object or function, and can customize just about any aspect of their behaviour that you can imagine. This is a real power feature, that takes reflection to a new level and can be used to implement various advanced abstractions and interfaces.
...and there is a lot more to come, as the V8 team will continue working on bringing new Harmony features to you.
To enable Harmony features in the latest dev channel release of Chrome, go to chrome://flags and toggle on "Experimental JavaScript features". We encourage you to try them out and give us feedback!
Translating JavaScript to Dart
Cross posted to: dartlang.org and the Google Code Blog
It took approximately 2000 years for the original Rosetta Stone to be discovered, which helped translate the Egyptian Hieroglyphs. We couldn’t wait that long to bridge the Dart and JavaScript worlds, so today we are releasing the JavaScript to Dart Synonym app.
Like most web developers, we are familiar, comfortable, and productive with JavaScript. We were curious about Dart, and thanks to a recent Dart hackathon, we had the chance to play with the language and libraries. The problem was, as JavaScript developers, we didn’t know how to map common JavaScript idioms to Dart. Hence the idea for this synonym app was born.
We started with the basics that every JavaScript and jQuery developer knows: variables, arrays, functions, classes, DOM manipulation, and many more. Then, with the help of the Dart team, we recorded the corresponding Dart versions of each idiom. To practice what we learned, we wrote this app with Dart.
We hope our app that maps between JavaScript and Dart eases your introduction to Dart and gives you a sense of where the project is going. We know the team is eager to hear your feedback. Don’t hesitate to join the conversation or file a new issue for either Dart or the Synonym app. And remember, Dart isn’t set in stone, so your feedback counts.
Chrome updated with faster JavaScript engine, tabbed settings and password sync
Last month's beta version of Chrome has become the new stable build, bringing a large JavaScript performance improvement to hundreds of millions of Chrome users. While it's a bit meaningless at this stage, this means the stable channel is now version 10, which first appeared at the end of 2010.
The main addition to this version is Crankshaft, a new version of the V8 JavaScript engine that results in 66% faster JavaScript performance -- as measured by Google's own V8 benchmark, anyway. Amongst other changes is the new-look tabbed settings page, sandboxed Adobe Flash for better security, and passwords are now synced with Chrome Sync. For complete release notes, check the Google Chrome Releases blog.
To update to the latest stable version of Chrome, simply close your browser and re-open it -- the update should be applied automatically. Alternatively, click the wrench icon and then About Google Chrome, which will check for the the latest update.
Onclick Javascript Does Not Work in Google Chrome and Firefox?
If you have found that onclick event does not work on Google Chrome, Firefox and Safari web browsers, then here is quick way to fix it:
Replace onclick form id with its name
For example, let’s say you have the following:
id=”form1″ name=”checkform1″
Find JS event:
onclick=”document.form1.cSSld.value=””
Replace with:
onclick=”document.checkform1.cSSld.value=””
All set. It now works with all web browsers.
Google Chrome beta update brings faster JavaScript, GPU acceleration, Web app backgrounding
Google's Chrome beta update brings with it a slew of goodies for the adventurous users who prefer slightly more cutting-edge features over tried-and-true stability. Version 10.0.648.82 hit the beta channel earlier today, and it affected just about every piece of the browser, from the settings interface to the rendering engine.
First and foremost, the already-impressive V8 "Crankshaft" JavaScript engine has been updated. Along with the addition of GPU-accelerated video, that means browsing with Chrome is going to be noticeably snappier than with the previous version. This is no placebo effect, either; according to the Official Chrome Blog, the V8 version used in this beta shows a 66% performance increase over the current stable release.
Browser settings are now opened in their own tab, as opposed to a separate window. The added space and cleaner layout that this provides is actually quite nice, and when you think about it, a browser that can use multiple tabs really has no reason to make new windows at all, so it just makes sense. One cool side-effect of moving settings into a tab is that they're actually browsable, meaning that if you get good enough at it, you can go directly to the page for certain settings just by using its address -- like "chrome://settings/advanced" or "chrome://settings/browser."
Google Chrome Canary hits v10, Crankshaft turbocharges V8 JavaScript engine

With all the Chrome OS and Chrome Web Store hoopla today, a post over at the Chromium blog went mostly unnoticed -- and it's definitely noteworthy. Freshly baked in the Chromium snapshot builds and Google Chrome Canary is Crankshaft, an enhancement to Chrome's V8 JavaScript engine that has yielded some impressive gains.
Crankshaft is made up of four components:
- a runtime profiler for identifying code that uses a significant number of CPU cycles
- a base compiler for generating code more quickly
- an optimizing compiler which re-compiles code pinpointed by the profiler
- deoptimization mechanism that allows Crankshaft to recover from overly-optimistic code optimizations
Crankshaft offers improvements in both startup time and maximum performance, with Google noting gains of up to 12% on JavaScript-heavy pages. On Google's own V8 benchmark, Crankshaft helps Chrome post scores which are almost 50% higher than previous versions with V8 alone.
...And for those of you wondering when Chrome was going to hit version ten, you've got your answer. It's already happened to the Canary build -- so hit your wrench menu > About Google Chrome and restart to update yourself to Chrome X! There's not much new that you'll notice right off the bat, with the exception of a selectable Instant option and experimental geolocation features in about:flags.
Safy, Run Links With JavaScript, Plugins Disabled In Google Chrome
I do not have a problem opening websites without JavaScript or plugins enabled in Firefox with the excellent NoScript add-on running. In fact, NoScript blocks those scripts on all pages by default. There is not an equivalent of NoScript for Google Chrome, even NotScript, which comes closest to the functionality does not offer the features that NoScript offers.
Chrome users who want to open some websites with scripts and plugins disabled have now another option. The Safy extension for Chrome offers to open links in the browser in in iframe sandbox with both JavaScript and all plugins disabled.

Options provided are to open the selected link in a new tab in the same browser window or in the current tab. This works fine in most instances, but not all the time. It is for instance not working in Google Search. An error message is displayed if Safy is used to display a search result in a sandboxed tab.
That’s the biggest quirk right now. The other problem that some users may experience is that they cannot launch websites using Safy if no link is present. Say you are on a website and want to open it without JavaScript or plugins, or you want to enter a web address directly, or open a bookmark in the browser. Safy cannot be used in all of those cases.
Then again, it works very well for normal links on most sites. Ideal for opening a link on Twitter, Facebook or blogs in a safer environment.
Safy is available only for the Chrome browser. It can be installed directly from the Chrome extension gallery.
V8 Benchmark Suite Updated
NotScripts for Chrome disables JavaScript, iframes, and plug-ins
When we browse the Web these days, there's a lot of JavaScript going on all the time. That's what Google uses to track us via Analytics and what sites use to show animations, etc. But sometimes you might want to disable all, or some, of that JavaScript - either on a single site, or in general. Not just because you don't like Analytics (which you can opt out of anyway), but because JavaScript is sometimes used maliciously.
Firefox users can do this easily using NoScript, but Chrome users don't have it so easy. Since Chrome architecture is significantly different, creating an add-on that would block JavaScript from executing is pretty tricky.
NotScripts is one effort to create such an add-on, and it seems to be fairly well advanced.
The whole thing feels like a giant workaround. It works "by cleverly using HTML5 storage caching to overcome the timing issues," and it requires you to set a manual password by editing an external file so that sites cannot view the extension's white list of "allowed sites."
It also doesn't provide advanced protection against clickjacking and other malicious JavaScript practices, which NoScript (for Firefox) does provide. But the general feeling I get is that the developer is doing all he can to provide a similar level of protection -- it's just far from trivial, given Chrome's architecture.
The Next Web uses cheap JavaScript hack to fool you into installing an extension, heralds new age of phishing attacks

Update: The Next Web has now removed the JavaScript alert bar. Hooray!
You may recall a couple of months ago when I falsely reported on what I thought was a new feature of Chrome. It was admittedly kind of neat: I thought websites could link themselves to a Chrome Extension, and pop up an alert at the top of your browser if you hadn't installed it.
As it turned out, it's just a cheap JavaScript hack that looks just like an official Chrome alert. I had hoped that I wouldn't see it again, but of course that was too much to ask of the Internet. As of today, The Next Web is now using it on every single one of its pages. Click through, check it out -- I'm sure they'll appreciate the extra ad impressions.
For a technology blog, TNW displays disgustingly little foresight. This bar is, in effect, an updated phishing or rogue malware attack. You all know the type: that pop-up that claims to scan your hard disk for viruses but actually installs a bunch of Trojans.
Does TNW not realise that you could make this bar link to a nefarious domain that looks exactly like the Chrome Extensions website? TNW's intentions might be benevolent, but with such high profile use of this JavaScript copycat, I guarantee that phishers and malware writers will soon be using this bar for the forces of evil.
Wouldn't it be easy to change the appearance of the bar so that it's obviously not part of the browser? How about making it pink, or changing the logo on the left to something distinctly un-Chromeish?
TNW has just opened a smelly kettle of fish -- and from now on, I suggest you all read your Chrome alerts carefully before clicking.
Keep Your Gmail Tasks, Chat, and Compositions Open in New Chrome Windows

Chrome only: Up until now, closing the main Gmail or Google Apps mail tab in your browser would close down any connected windows you had open, too—compose windows, Gmail tasks, popped-out chats, and the like. Now Gmail's fixed that with a JavaScript tweak for Chrome, so you can keep working on the email, or keep a conversation running, after you've closed down your main inbox. [Official Gmail Blog] More »
Learn to Make Your Own Chrome Extensions [Programming]

Lifehacker readers are often interested in learning how to code, and if you're a Chrome user, development blog Tutorialzine has a great tutorial to start you off making simple Chrome extensions. More »
Turn Google Chrome's search bar into a powerful Quix command line
I'm a big fan of Quix, the handy scriptable bookmarklet that works like a command line from your browser.
Wouldn't it be cool if you could use the search bar as a command line, though, instead of triggering a Quix window? If you use Google Chrome, you can. This neat little hack requires setting up Quix as the default search engine, which will require copy-pasting a little bit of code.
To get Chrome to recognize Quix as a search engine, grab the code from this intrepid coder's blog and follow the detailed instructions there. It actually doesn't take long to set up, and anybody who's savvy enough to use Quix can probably manage it. If you're worried that using Quix as your default search will make Googling tougher, don't sweat it too much: simply putting a g in front of your search is the default Quix command for Google.
[via Lifehacker]





