Skip to content

Instantly share code, notes, and snippets.

View kunukn's full-sized avatar

Kunuk Nykjær kunukn

View GitHub Profile
/*
Author: Kunuk Nykjaer
version 0.13
About: prototype util to make a webpage responsive
Usage: copy and run this code in a browser console
and see the result by changing the width size of the browser
Optionally edit the config data at the bottom of this script
!function() {
// attach a css file to a webpage dynamically
var cssUrl = '//rawgit.com/kunukn/misc/master/src/temp/styles/whiteOnBlack.css'
var styleElement = document.createElement('link');
styleElement.rel = 'stylesheet';
styleElement.type = 'text/css';
styleElement.href = cssUrl;
document.getElementsByTagName('head')[0].appendChild(styleElement);
}();
(function(d){
if (typeof jQuery === 'undefined') {
var script = d.createElement('script');
script.src = '//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js';
d.getElementsByTagName('head')[0].appendChild(script);
}
})(document)
(function(d){
var script = d.createElement('script');
script.src = '//rawgithub.com/kunukn/misc/master/src/temp/script/whiteOnBlack.js';
d.getElementsByTagName('head')[0].appendChild(script);
})(document)
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>Handlebars Helloworld</title>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<!-- handlebars from CDN -->
<script
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>Google News</title>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<link rel="stylesheet" type="text/css" href="google-news-responsive.css">
<script src="//code.jquery.com/jquery.min.js"></script>
<script src='//cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0/handlebars.min.js'>
/* Responsive design, smallest device first */
#rendered .title::after {
content: ' - Phone';
}
@media (min-width: 480px) {
#rendered .title::after {
content: ' - Phone large';
}
#rendered {
!function(d, $) {
var stub = {
entries: [{
title: 'title 1',
link: 'link 1',
author: 'author 1',
publishedDate: 'publishedDate 1',
categories: ['category 11', 'category 12']
}, {
title: 'title 2',
var feed = {
entries: [
{
title: 'title 1',
link: 'link 1',
author: 'author 1',
publishedDate: 'publishedDate 1',
categories: ['category 11', 'category 12']
},
{
(() => {
const rAF = window.requestAnimationFrame
? window.requestAnimationFrame.bind(window)
: callback => window.setTimeout(callback, 16);
const getNow = () => new Date().getTime();
const tween = ({ duration = 1000 } = {}) => {
const start = ({ update, complete } = {}) => {
const play = () => {
if (duration <= 0) return;