Encoding assets into pure HTML
A Pen by Sven Neumann on CodePen.
| /* | |
| Title: CodePen Module Loader v 1.0.1 | |
| Author: Sven Neumann <[email protected]> | |
| GitHub: https://github.com/killroy42/CodePen-module-loader | |
| CodePen: http://codepen.io/killroy/pen/xVqNeL | |
| */ | |
| (function(scope, module, require) { | |
| 'use strict'; | |
| /*jslint evil: true */ |
| { | |
| "name": "Better-CodePen", | |
| "permissions" : ["http://*.codepen.io/*", "https://*.codepen.io/*"], | |
| "version": "1.0", | |
| "content_scripts": [{ | |
| "matches": ["http://*.codepen.io/*", "https://*.codepen.io/*"], | |
| "js": ["script.js"], | |
| "all_frames": true, | |
| "run_at": "document_start" | |
| }], |
| function extrudeProfileOnPath(profileVs, outlineVs, sharedUVs) { | |
| /* | |
| TODO: | |
| - if sharedUVs == false, create multiple UV layers | |
| - Smooth according to edge angles | |
| - Accept Shapes/CurvePaths directly | |
| - Don't scale UVs along profile. Reuse reference profile | |
| */ | |
| var upVector = new THREE.Vector3(0, 1, 0); | |
| var backVector = new THREE.Vector3(0, 0, -1); |
Encoding assets into pure HTML
A Pen by Sven Neumann on CodePen.
| <html> | |
| <style> | |
| /* | |
| @import url(http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,700italic,300,400,700); | |
| body { | |
| font-family: 'Open Sans', sans-serif; | |
| } | |
| */ | |
| body { | |
| margin: 0; |
A Pen by Sven Neumann on CodePen.
| function fetchRemoteImage(id) { | |
| console.log('fetchRemoteImage(%s);', id); | |
| var card = cards[id]; | |
| if(card === undefined) throw new Error('Card "'+id+'" not found.'); | |
| var url = 'http://hearthstone.gamepedia.com/'+encodeURIComponent(card.name.replace(/ /g, '_')); | |
| return fetch(url) | |
| .then(function(body) { | |
| var m = body.toString('utf8').match(/<img alt="" src="([^"]+)" width="[^"]+" height="[^"]+" class="thumbimage"/); | |
| var url = m[1].replace(/(\?.*)/, ''); | |
| m = url.match(/\.(png|jpg)$/); |
| <html><head><script> | |
| var map = Array.prototype.map; | |
| var toArray = [].slice.apply.bind([].slice); | |
| var p = Promise.resolve(); | |
| var htmlStyle = 'height: 100%; background: #000;'; | |
| var bodyStyle = | |
| 'height: 100%; margin: 0;'+ | |
| 'text-align: center;'+ | |
| 'color: grey;'+ | |
| 'background-repeat: no-repeat;'+ |
| <html><head><script> | |
| var loituma_ogg, audio, frame1, frame2, frame3, frame4, playButtonHtml, bodyCss, playing = false; | |
| var imgUrls = new Array(4); | |
| var frames = new Array(4); | |
| document.addEventListener('DOMContentLoaded', function() { | |
| document.body.parentNode.style.height = '100%'; | |
| document.body.style.cssText = bodyCss; | |
| var i = frames.length; while (i--) { | |
| frames[i] = new Image(); |
A Pen by Sven Neumann on CodePen.