This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(jQuery('.discussion .toolbar:contains("Open for comments")').length){ | |
commentCount = jQuery('.content-comment-count'); | |
commentCount.text(commentCount.text().replace('Comments','Jump to comments')); | |
} | |
Variants: | |
1 Jump to comments | |
2 See all comments | |
3 Read the comments | |
4 Readers' comments |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
</head> | |
<body> | |
<style> | |
body.article #content .related-content p, | |
#content .related-content ul li { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Developer(skill) { | |
this.skill = skill; | |
this.says = function(){ | |
alert(this.skill + ' rocks!'); | |
} | |
} | |
var john = new Developer('Backbone'); | |
var func = john.says; | |
func.apply(john); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// backbone.js continues to impress, I needed to get data from a jsonp api | |
// I really wanted to do this the "right" backbone.js way and create a model and call fetch. | |
// But the default backbone synch is not jsonp | |
// Turns out you can override a synch on a per model basis (thanks stackoverflow) | |
// whats nice is backbone.js continue to work as expected with the override | |
// here's a snippet (some changes to protect our privacy). An improvement could be to create a jsonp model class which MyModel inherits | |
// the synch function is most important below, that's what tells backbone it's jsonp | |
MyModel = Backbone.Model.extend({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var twice_37 = 0; | |
$(document).on('keydown', function( e ){ | |
var key = e.which; | |
if(key==37){ | |
twice_37 += 1; // almost :) | |
if(twice_37==2){ | |
alert('Do something! you pressed twice left!'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makeId() | |
{ | |
var txt = "", | |
rand = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | |
for (var i = 5; i >= 0; i--) { | |
txt += rand.charAt(Math.floor(Math.random() * rand.length)); | |
} | |
return txt; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.getJSON('/my/url', function(data) { | |
}); | |
vs | |
request = new XMLHttpRequest(); | |
request.open('GET', '/my/url', true); | |
request.onload = function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prices = jQuery('#item-page-wrapper .price-section .a-color-price').text() | |
prices = prices.replace(/\s/g,'').split('£'); | |
total = 0; | |
var v; | |
for(var i = 0; i < prices.length; i++) { | |
v = parseFloat(prices[i]); | |
if (!isNaN(v)) total += v; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var re = /(\w+)\s(\w+)/; | |
var str = "John Smith"; | |
var newstr = str.replace(re, "$2, $1"); | |
console.log(newstr); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[].forEach.call($$("*"),function(a){ | |
a.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16) | |
}) |
OlderNewer