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
/* | |
applications are made up of separate objects, which need a way to communicate among themselves. | |
when objects know too much about each other, and communicate directly.. means, too tight coupling. | |
in this pattern | |
independent objects(colleagues) dont communicate directly. but through a mediator object | |
*/ | |
function Player(name){ |
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
/* | |
Progress: | |
Essentially, the right way to do it is… | |
Iterate over all text nodes. | |
Find the substring in text nodes. | |
Split it at the offset. | |
Insert a span element in between the split. | |
*/ | |
matchText(document.getElementsByTagName('artcle')[0], new RegExp("\\b" + saerchTerm + "\\b",'g'), 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
Selectors | |
Zepto implements only a subset of jQuery’s proprietary selectors. It’s definitely something to be mindful of. | |
clone() | |
Zepto’s clone() doesn’t support passing in an argument to clone event handlers. | |
data() | |
Unlike jQuery, Zepto doesn’t attempt to do any type inferring from the value stored in the data-* attribute. | |
offset() |
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
Example | |
目前本機有一個 josephj.git、在 /home/josephj/www 下,而我需要將 javascript platform 放到 /home/josephj/www/static/ | |
cd /home/josephi/www | |
git submodule add <git addr> static/platform | |
论坛 | |
在父亲项目下, 删除目录(template/weekxx, static/) |
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
// Back in the old days, classes were manipulated on elements simply with the className property. | |
// This led to an awful lot of string manipulation for manipulating the class attribute. | |
Thankfully, the classList property has popped up recently. | |
var supportsClassList = ({}).toString.call(document.body.classList) == '[object DOMTokenList]'; | |
the fallback implementation | |
var getClasses = function(element){ | |
return element.className.split(/\s+/); | |
} |
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
<div id="loadplace<?php echo $msg_id; ?>"></div> | |
<div id="flash<?php echo $msg_id; ?>"></div> | |
<div class='panel' id="slidepanel<?php echo $msg_id; ?>"> | |
<form action="" method="post" name="<?php echo $msg_id; ?>"> | |
<textarea id="textboxcontent<?php echo $msg_id; ?>" ></textarea><br /> | |
<input type="submit" value=" Comment_Submit " class="comment_submit" id="<?php echo $msg_id; ?>" /> | |
</form> | |
</div> |
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($) { | |
/** | |
* @author Sam Sehnert | |
* @desc A small plugin that checks whether elements are within | |
* the user visible viewport of a web browser. | |
* only accounts for vertical position, not horizontal. | |
*/ |
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
$('#content a').each(function () { | |
$('<div class="fader" />').css('opacity', 0).prependTo(this); | |
}).hover(function () { | |
$('img', this).stop().animate({ | |
marginLeft : 5 | |
}, 250); | |
$('.fader', this).stop().animate({ | |
opacity : 0.15 | |
}); |
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
<?php | |
/* | |
* Simple but powerful flatfile database | |
* See http://lukeplant.me.uk/resources/flatfile/ for documentation and examples | |
*/ | |
?> |
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 gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); | |
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js'type='text/javascript'%3E%3C/script%3E")); | |
var pageTracker = _gat._getTracker("YOUR ACCOUNT NUMBER HERE"); pageTracker._trackPageview(); | |
$(document).ready(function(){ | |
$('a[data*="track"]').click(function(){ | |
pageTracker._trackPageview('click_link/'+$(this).attr('href')); | |
}); | |
}); |