Bearded Octo - OO JS in 15mins or Less A JavaScript survival guide Are you a programmer who is considering learning JavaScript, but unsure whether it is worth the pain? Then this blog post is for you: I argue that it is worth it and give tips for surviving the language. Why learn JavaScript? The present The main reason for choosing JavaScript is the breadth of its ecosystem: the web platform, Node.js, JSON, NoSQL databases, Cordova/PhoneGap, automating PhotoShop and many other apps, etc. Compared to Java, I like the interactivity of JavaScript and the web platform. I also like the flexibility of the language. The future ECMAScript 6 [1], the upcoming version of JavaScript fixes many of JavaScript’s problems: not enough data structures, limited built-in support for inheritance, no built-in support for modules, shadowing this, functions playing too many roles, … Additionally, there is much innovation and experimentation around: Take your time to get to know JavaScript An important insight for learning JavaScript (paraphrasing Golo Roden): JavaScript’s power
sourceMappingURL and sourceURL syntax changed If you use either sourcemaps or sourceURL (both covered in the HTML5 Rocks Primer on Sourcemaps), then you may see a warning in Chrome console like "/*@ sourceMappingURL=" source mapping URL declaration is deprecated, "/*# sourceMappingURL=" declaration should be used instead. Here's what that's about: Impetus //@ sourceMappingURL was found to have a conflict with IE whenever it was found in the page after //@cc_on was interpreted to turn on conditional compilation in the IE JScript engine. Spec Change The //@ sourceMappingURL syntax is defined in the Sourcemap V3 spec It was changed there to use //# syntax instead. sourceURL //@ sourceURL is also defined in the spec and was made to match the //# syntax for consistency. Implementation in Browser DevTools = done! Safari Inspector now supports //# for sourceMappingURL and sourceURL Firebug's change has landed for sourceURL. ⟪ Introduction to Custom Filters (aka CSS Shaders)Alpha transparency in Chrome video ⟫
Changing Drop Down selector Arrow Each browser displays select elements differently and it’s usually the one thing that will stop your forms from looking amazing. Where is with a regular button it’s fairly easy to change it, changing the selector arrow is another story. Just look at some of the possible variations (and those are outdated)! There are many tutorials out there to change the selector drop down. Unfortunately many of them involve placing an image over the entire element or creating your own image and sticking it in the corner. The below solution will work for all browsers and only take seconds to implement and only needs some CSS! How does it work? Simple, we hide the standard arrow, then we create “<>” text and just rotate it 90 degrees. basic select html code <div class="selectdiv"><label><select><option selected> Select Box </option><option>Option 1</option><option>Option 2</option><option>Last long option</option></select></label></div> The CSS : So the final magical CSS that will make this work is:
La revolución de Javascript De un lenguaje de script, Javascript se ha convertido en los últimos años en la plataforma de desarrollo más usada en el mundo. Hoy, Javascript se está reinventando gracias a proyectos como Coffeescript, DART, Node.js y jQuery.Javascript es un lenguaje de script muy simple. Orientado a objetos (como Actionscript 2, sin clases) y basado en la sintaxis ECMAScript, derivado de C. DART es el esfuerzo de Google por crear un Javascript más Java. Código : class HelloDartTest { static testMain() { print("Hello, Darter!") Las desventajas: Ese hola mundo de unas 5 lineas de código se convierten en ! Node.js Node.js es la capacidad de usar Javascript del lado del servidor, igual que usarías PHP. Y esto en el JS del HTML: ¿Desventajas? CoffeeScript Coffeescript es una revolución muy interesante. mensaje = parte1: "hola " parte2: "mundo" holaMundo = -> alert mensaje.parte1 + mensaje.parte2 + "!" Y este el resultado compilado en Javascript: Es bastante eficiente y robusto y todo se convierte a JS nativo.
Visual Event 2 Events in Javascript are often seen as a bit of an enigma. This is odd given that Javascript is very much an event driven language, but it is typically down to their complex nature and difficulty to debug. To this end I've created Visual Event to help track events which are subscribed to DOM nodes. Introduction Visual Event is an open source Javascript bookmarklet which provides debugging information about events that have been attached to DOM elements. Visual Event shows: Which elements have events attached to them The type of events attached to an element The code that will be run with the event is triggered The source file and line number for where the attached function was defined (Webkit browsers and Opera only) In addition to being useful for debugging your own code, Visual Event can be used as an educational tool, showing how many web-sites have been authored. Visual Event is open source software (GPLv2) and a Git repo is hosted on GitHub for you to fork and modify as you wish!
Download and Install New to PhantomJS? Read and study the Quick Start guide. Windows Download phantomjs-2.1.1-windows.zip (17.4 MB) and extract (unzip) the content. The executable phantomjs.exe is ready to use. Note: For this static build, the binary is self-contained with no external dependency. Mac OS X Download phantomjs-2.1.1-macosx.zip (16.4 MB) and extract (unzip) the content. Note: For this static build, the binary is self-contained with no external dependency. Linux 64-bit Download phantomjs-2.1.1-linux-x86_64.tar.bz2 (22.3 MB) and extract the content. Note: For this static build, the binary is self-contained. Linux 32-bit Download phantomjs-2.1.1-linux-i686.tar.bz2 (23.0 MB) and extract the content. Note: For this static build, the binary is self-contained. FreeBSD Binary packages are available via pkg: $ sudo pkg install phantomjs Source Code To get the source code, check the official git repository: github.com/ariya/phantomjs. Checksums MD5 Checksums SHA-256 Checksums Acknowledgement
Change the Default Select Drop-Down List In this article I’m going to help you style a Select drop-down input with just CSS without the need for javascript. Ok let’s get to it! So here’s the story – The awesome designer in your team sends you a new PSD (Photoshop Document) with the final design of a new website or app. Well the reality is that you shouldn’t complain to the designer because little things like this makes you push yourself a little bit harder and not rely on default stylings just because. This article is based on two workarounds (One for Chrome and Safari and one for Firefox) already posted on the web. Credit for Chrome workaround goes to Chris Coyier from CSS-tricks.com Credit for Firefox workaround goes to João Cunha who posted this on stackoverflow Ok let’s get started! Let’s say that the design for the drop-down is this one: When we add the html for a Select Dropdown we get this: Firefox Default styling Chrome Default Styling Not very pretty. It will start to look something like this on Firefox: On Chrome: On Safari:
Frameworks Javascript prometedores para tus proyectos Los populares Frameworks para Javascript: jQuery, Prototype, MooTools y demás, no son lo únicos que existen. Actualmente disponemos de alternativas orientadas a diferentes públicos y tipos de aplicaciones, que no son populares, pero sí prometedoras. Es bueno recordar que los Frameworks son simplemente herramientas utilizadas bajo ciertas necesidades. RightJS: El Framework JavaScript correcto RightJS está dirigido al público de los lenguajes dinámicos, intenta posicionarse dentro del grupo de los Frameworks Javascript más populares. Su instalación es prácticamente igual que todos los demás Frameworks, simplemente incluyes el archivo del núcleo en la página, de la siguiente manera: La librería viene con dos archivos, uno es el código actualizado y el otro contiene código soportado por navegadores viejos. Fue probado y funciona en los siguientes navegadores: Firefox >= 1.5Safari >= 3Todas las versiones de Google ChromeInternet Explorer >=6Opera >= 9.25Konqueror >= 3.10 Qooxdoo: creación RIA
JS NICE: Statistical renaming, Type inference and Deobfuscation Introduction to Unit Testing | QUnit You probably know that testing is good, but the first hurdle to overcome when trying to write unit tests for client-side code is the lack of any actual units; JavaScript code is written for each page of a website or each module of an application and is closely intermixed with back-end logic and related HTML. In the worst case, the code is completely mixed with HTML, as inline events handlers. This is likely the case when no JavaScript library for some DOM abstraction is being used; writing inline event handlers is much easier than using the DOM APIs to bind those events. More and more developers are picking up a library such as jQuery to handle the DOM abstraction, allowing them to move those inline events to distinct scripts, either on the same page or even in a separate JavaScript file. However, putting the code into separate files doesn’t mean that it is ready to be tested as a unit. What is a unit anyway? Building Unit Tests That should be enough theory for now. Make Things Testable
Create animations on page scroll using CSS Hi there, you probably seen this done many times on web sites before. You get to the site and as you scroll elements will animate in (ex bounce, fade in etc). Today we are going to learn how to do this quickly. For this tutorial we are going to use animate.css this file will have all of our animations already created and you can just pick the ones you want to use. Final Result See the Pen mejvpj What we will use: animate.css – can be downloaded herewow.js – can be downloaded here Setup The reason we are using animate.css is because it comes pre built with almost all animations you can think of. First things first import our files: We are using CloudFlare CDN services (cdnjs.com which you should too to save on your bandwidth!) /** * Register and enqueue a wow script, it doesn't depend on anything */ function wow_add_scripts() { wp_register_script( 'wow-script', get_stylesheet_directory_uri() . Now we just need to add initialization of our script on to the html page itself: Creating basic html