This file contains 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
//Do not use docwrite | |
document.write('<script src="' + src + '" type="text/javascript"><\/script>'): | |
//Use Async | |
var newScript = document.createElement("script"); | |
newScript.async = true; | |
newScript.src = "http://xxxxxxxxxxxxxxxxxxxx.js"; | |
var s0 = document.getElementsByTagName('script')[0]; | |
s0.parentNode.insertBefore(newScript, s0); |
This file contains 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
//Know arguments number by length | |
function newFunction(a,b,c,d,e,f,g) { | |
return false; | |
} | |
newFunction.length = 7; | |
//return function callee for calling | |
function showSomething(a){ | |
alert(a); | |
return arguments.callee; |
This file contains 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 stack_holder = new Error | |
function stackPrepare(e,stacks) { | |
var stack = stacks | |
for(var p in stack[0]) { | |
stack[p] = stack[0][p] | |
} | |
stack.find = function(fn) { | |
console.log(stack) | |
for(var i=0;i<stack.length;i++) { | |
if(stack[i].getFunction() === fn) { |
This file contains 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
//JavaScript Scope Chain | |
var mytxt = 'test1'; | |
function echo() { | |
console.log("A-->" + mytxt); | |
var mytxt = 'test2'; | |
console.log("B-->" + mytxt); | |
} | |
echo(); | |
/* |
This file contains 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
* Polluting the global namespace by defining a large number of variables in the global context | |
* Passing strings rather than functions to either setTimeout or setInterval as this triggers the use of eval() internally. | |
* Modifying the Object class prototype (this is a particularly bad anti-pattern) | |
* Using JavaScript in an inline form as this is inflexible | |
* The use of document.write where native DOM alternatives such as document.createElement are more appropriate. document.write has been grossly misused over the years and has quite a few disadvantages including that if it's executed after the page has been loaded it can actually overwrite the page we're on, whilst document.createElement does not. We can see here for a live example of this in action. It also doesn't work with XHTML which is another reason opting for more DOM-friendly methods such as document.createElement is favorable. |
This file contains 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
basic concept | |
http://not-now-nigel.blogspot.tw/2010/07/cocos2d-as-application-framework-part-3.html | |
subclass uialertview | |
http://itsmybeats.blogspot.tw/2011/04/custom-uialertview.html | |
cocos2d alert | |
http://rombosblog.wordpress.com/2012/02/28/modal-alerts-for-cocos2d/ | |
http://itouchs.blogspot.tw/2011/07/stanford-cs193p-note-04.html | |
http://ios.biomsoft.com/2011/08/25/custom-dialog-boxes-using-cocos2d-on-iphone/ |
This file contains 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
Reward* reward = [merchantRewardList objectAtIndex:indexPath.row]; | |
CreditData* currentCreditData = [CreditData dataWithDictionary:[checkInData objectForKey:@"credit"]]; | |
// | |
[cell setSelectable:YES]; //Every item can be exchange default | |
// | |
if ([currentCreditData.points compare: reward.rewardPoints] == NSOrderedAscending) { //Insufficient points | |
[cell setSelectable:NO]; |
This file contains 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
require('http'); | |
function wget(host, path, https, callback) { | |
var port = (https) ? 443 : 80, | |
client = http.createClient(port, host, https), | |
request = client.request('get', path, { | |
'host': host | |
}), | |
response_body = ''; |
This file contains 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 () { | |
var images = ['image1.jpg','image2.jpg' /* ... */ ]; | |
var imageObjects = []; | |
var imagesToLoad = 0; | |
for (i = 0, z = images.length; i < z; i++) { | |
imageObjects[i] = new Image(); | |
imagesToLoad++; | |
$(imageObjects[i]) | |
.load(function () { |
This file contains 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 images = [ /* you get it by now */ ]; | |
for (i=0,z=images.length;i<z;i++) { | |
$('<img />') | |
.attr('src', images[i]) | |
.load(function(){ | |
$('.profile').append( $(this) ); | |
// Your other custom code | |
}); | |
} |
OlderNewer