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 trigger(element, eventName) { | |
var event = document.createEvent('HTMLEvents'); | |
event.initEvent(eventName, true, true); | |
element.dispatchEvent(event); | |
} |
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
<html> | |
<head> | |
... | |
<link rel='stylesheet' href='retina.css' media='only screen and (min-device-pixel-ratio: 2)' /> | |
... | |
</head> | |
<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
//Open the file directly in the browser and run this script from the console | |
//Assumptions: The browser uses a <pre/> tag for showing the CSS code | |
var file = document.querySelector("pre"); | |
var fileContent = file.innerHTML; | |
var newContent = fileContent.replace(/([\d.]+)(px)/g, function(m){ | |
var measure = parseFloat(m.split("px")[0]); | |
var newMeasure = measure / 10; | |
newMeasure = newMeasure.toFixed(2); | |
newMeasure = newMeasure.replace(/(\.[0-9]*?)0+$/, "$1"); // remove trailing zeros |
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
<button id="btn1">Open Facebook app</button> |
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
// attach to window resize event | |
window.addEventListener("resize", function(e) { | |
// determine current orientation | |
var isLandscape = Math.abs(window.orientation) == 90; | |
if (isLandscape) { | |
// do something | |
} | |
}); |
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 hideAddressBar() { | |
window.setTimeout(function(){ | |
window.scrollTo(0,0); | |
}, 0); | |
} |
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
selector { | |
user-select: none; | |
-webkit-user-select: none; | |
-moz-user-select: none; | |
-ms-user-select: none; | |
} |
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="scroll"> | |
This is the scrollable content | |
</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
img { | |
-webkit-touch-callout: none; | |
} |
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
sudo android-sdk-path/platform-tools/adb logcat |