- Precise Selector ( Loose when necessary )
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 obj = { | |
bindEvent: function() { | |
// Dom event | |
var dom = document.getElementById('dom'); | |
dom.addEventListener('change', this); | |
// window event | |
window.addEventListener('localized', this); | |
}, | |
handleEvent: function(evt) { |
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
window.addEventListener('iac-ftucomms', function() { | |
var message = evt.detail; | |
if (message === 'done') { | |
self.setBypassHome(true); | |
} | |
}); |
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
window.navigator.mozSetMessageHandler('connection', | |
function onConnected(request) { | |
var keyword = request.keyword; | |
var port = request.port; | |
port.onmessage = function onReceivedMessage(evt) { | |
// this is the message you sent | |
var message = evt.data; | |
// do whatever you want to do later | |
}; |
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
{ | |
"connections": { | |
"ftucomms": { | |
"description": "Communicate between communications/ftu and System", | |
"rules": {} | |
} | |
} | |
} |
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
if (this.currentStep > this.numTutorialSteps) { | |
Tutorial.tutorialScreen.classList.remove('show'); | |
Tutorial.tutorialFinish.classList.add('show'); | |
// for large devices, we have to use IAC to tell system ftu is done | |
if (this.layout !== 'tiny') { | |
navigator.mozApps.getSelf().onsuccess = function(evt) { | |
var app = evt.target.result; | |
app.connect('ftucomms').then(function onConnAccepted(ports) { | |
ports.forEach(function(port) { |
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
ack -l 'pattern' | xargs perl -pi -E 's/pattern/replacement/g' |
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
<script id="entry-template" type="text/x-handlebars-template"> | |
<div id="tmpl"> | |
<h1 class="header">{{header}}</h1> | |
<p class="content">{{content}}</p> | |
</div> | |
</script> | |
<body> | |
<div class="target"></div> | |
</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
$(document).ready(function(){ | |
// you can cache this $tmpl for later use | |
var $tmpl = $("#tmpl").remove().clone(); | |
$tmpl.find(".header").text("This is header"); | |
$tmpl.find(".content").text("This is Content"); | |
$tmpl.removeClass("hide"); | |
$(".target").append($tmpl); | |
}); |
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 div = document.getElementsByTagName("div"); | |
for ( var i = 0; i < div.length; i++ ) { | |
for ( var e = 0; e < elems.length; e++ ) { | |
div[i].appendChild( elems[e].cloneNode(true) ); | |
} | |
} |