background preloader

Javascript

Facebook Twitter

Speak.js: Text-to-Speech on the Web. Ender - the no-library library. Convert XML to JSON with JavaScript. If you follow me on Twitter, you know that I've been working on a super top secret mobile application using Appcelerator Titanium. The experience has been great: using JavaScript to create easy to write, easy to test, native mobile apps has been fun. My mobile app connects to numerous social network APIs, some of which only provide an XML response. My mini "framework" uses JSON to dynamically create widgets so I've needed a way to turn XML into JSON.

I found many solutions but none of them worked. The JavaScript It's important to point out that Titanium's Titanium.XML.DOMDocument object implements DOM2-level structures. The major change I needed to implement was using attributes.item(j) instead of the attributes[j] that most of the scripts I found used. ...becomes workable a JavaScript object with the following structure: From here you can use the JavaScript object however you see fit.

Var jsonText = JSON.stringify(xmlToJson(xmlDoc)); Be Heard Older Newer. Comment adapter son site web aux smartphones ? Rendre compatible ses vidéos Dailymotion sous iPhone, iPad et Android. Excepté Youtube, il n'est guère facile d'afficher des vidéos qui soient à la fois compatibles avec le plus grand nombre de navigateurs et les smartphones. Dailymotion vient de mettre à disposition un snippet pour rendre leurs vidéos lisibles sous iPhone, iPod, iPad et Android supportant le HTML5. Sur son profil Git, le co-fondateur de Dailymotion vient de publier un snippet Javascript rendant leurs vidéos compatibles sans rien avoir à modifier aux codes JS d'affichage des players. Il permet de lire les vidéos en HTML5 à l'interieur même du site, ou en plein écran. Afficher les vidéos dailymotion suR iPhone & Android Il faut juste ajouter ce code dans la partie de son site : 01. 02.var m = navigator.mimeTypes, t = 'application/x-shockwave-flash', a = 'ShockwaveFlash.ShockwaveFlash'; 03.if (m && m.length ?

05. var e = document.createElement('script'); e.type = 'text/javascript'; e.async = true; 07. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(e, s); JavaScript ( (__ = !$ + $)[+$] + ({} + $)[_/_] +({} + $)[_/_] ) First off credit where credit is due. Update 1: Well hello reddit and hackernews. 1) I didn't write this JavaScript.2) I didn't find this JavaScript. I saw it in a slide deck from BlackHat DC 2011. Called XSS Street-Fight. Most of the presentation was dry JavaScript /mod_security, but this caught my eye. Care to guess what that does?

How about if I type it like this. ($=[$=[]][(__=! That's right this is an alert() if it lands anywhere inan executable section of JavaScript/dom it pops up the cookie. Go ahead and put it in a script tag in your browser it will pop up a "1" That's when I couldn't put this down. First there are really two lines here. becomes sort() becomes alert(1) Let's start to tear this apart. $=[] is a blank array $=[$=[]] is an array with a reference to an array. So $ derefs to the value 0. Now we have a 0 we can freely reference. __ = "false"via (__ = ! (The ~ operator in JavaScript means -(N+1) so -~ = +1if $ = 0 then -~-~-~$ = 3 thus _/_ = 3/3 = 1 (__ = ! $$ = ( $_ = ! '' ! '' not.