Skip to content

Instantly share code, notes, and snippets.

View simevidas's full-sized avatar
🦊
sticking with Firefox till the end

Šime Vidas simevidas

🦊
sticking with Firefox till the end
View GitHub Profile
@simevidas
simevidas / finished-polyfill.js
Last active August 3, 2020 10:58 — forked from AdaRoseCannon/Finished polyfill.js
Animation.prototype.finished polyfill
// only polyfill .finished in browsers that already support animate()
if (document.body.animate) {
// Chrome does not seem to expose the Animation constructor globally
if (typeof Animation === 'undefined') {
window.Animation = document.body.animate({}).constructor;
}
if (Animation.prototype.finished === undefined) {
Object.defineProperty(Animation.prototype, 'finished', {
@simevidas
simevidas / applyTemplate.js
Created July 5, 2017 02:52 — forked from PaulKinlan/applyTemplate.js
Simple Templating
const applyTemplate = (templateElement, data) => {
const element = templateElement.content.cloneNode(true);
const treeWalker = document.createTreeWalker(element, NodeFilter.SHOW_ELEMENT, () => NodeFilter.FILTER_ACCEPT);
while (treeWalker.nextNode()) {
const node = treeWalker.currentNode;
for (let bindAttr in node.dataset) {
if (bindAttr.startsWith('bind_')) {
let dataKey = node.dataset[bindAttr];
let bindKey = bindAttr.substr(5);
<!doctype html>
<html>
<head>
<title>Tabs Demo!</title>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
.container {
margin-top: 20px;
}
@simevidas
simevidas / gist:6708899
Last active December 23, 2015 23:19 — forked from miketaylr/gist:6701828
<script>
if (screen.width <= 640) document.write('<meta name="viewport" content="width=device-width, initial-scale=1">');
</script>
<head>
<script>document.write('<meta charset="utf-8">')</script>
</head>
<body>
<script>
document.body.innerHTML += "✓";
</script>
</body>