Skip to content

Instantly share code, notes, and snippets.

View fillano's full-sized avatar

Hsu Ping Feng fillano

View GitHub Profile
@fillano
fillano / offline test
Created November 5, 2010 06:21
簡單的離線應用測試,參考http://www.fillano.idv.tw/test642.html
<!DOCTYPE html>
<html lang="zh-TW" manifest="test642.manifest">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<script src="test642.js"></script>
</head>
<body>
<input type="button" value="game" id="game"><input type="button" value="update" id="update">
<div id="data"></div>
<div id="panel"></div>
@fillano
fillano / simple geolocation test
Created November 5, 2010 16:26
測試getCurrentPosition(), watchPosition(), 結合google map api
<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<style>
div.info {
border: solid 2px #336699;
margin: 10px;
padding: 5px;
border-radius: 5px;
@fillano
fillano / simple worker global scope detection
Created November 7, 2010 12:48
測試瀏覽器的global worker scope中所支援的物件,這是網頁端,需要與worker端的程式來協作
<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<style>
div {
border: solid 2px #336699;
margin: 10px;
padding: 5px;
border-radius: 5px;
@fillano
fillano / test644.js
Created November 7, 2010 12:51
detect DedicatedWorker global scope and report to js in html
onmessage = function(global) {
return function(e) {
if(e.data.indexOf('start') > -1) {
var str = '<table width="100%" border="1" cellspacing="0" cellpadding="2">\n';
for (var i in global) {
if(i!=='onmessage') {
str += '<tr><td style="background: #AABBCC">' + i + '</td><td style="background: #DDEEFF">' + global[i] + '</td></tr>\n';
} else {
str += '<tr><td style="background: #AABBCC">' + i + '</td><td style="background: #DDEEFF">onmessage eventHandler</td></tr>\n';
}
@fillano
fillano / test644a.js
Created November 7, 2010 12:53
detect SharedWorker global scope and report to js in html
(function(global){
function handleConnect(e) {
try {
if(e.ports && e.ports[0]) {
e.ports[0].onmessage = handleMessage(e.ports[0]);
}
} catch(e) {
}
}
@fillano
fillano / graphic2.js
Created May 16, 2011 16:47
simple drawing functions
function Point (_x, _y) {
this.x = _x;
this.y = _y;
}
function getLine (_points) {
if (_points.length != 2) {
return false;
}
var points = new Array();
<!DOCTYPE html>
<html><head><meta charset="utf-8"></head>
<style>
div {
background: #AACCEE;
border: solid 1px #336699;
margin: 10px;
padding: 5px;
border-radius: 5px;
display: inline-block;
@fillano
fillano / example.js
Created August 29, 2011 06:07
CORS test
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {
'Content-Type': 'text/plain',
'Access-Control-Allow-Origin': 'http://localhost'
});
res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/ with CORS.');
@fillano
fillano / another wait.js
Created September 22, 2011 16:53
try another way to Do.parallel, inspired by Tim Caswell's howtonode blog articles
function Wait(fns, done) {
var count = 0;
var results = [];
this.getCallback = function(index) {
count++;
return (function(waitback) {
return function() {
var i=0,args=[];
for(;i<arguments.length;i++) {
args.push(arguments[i]);
@fillano
fillano / test755.html
Created November 24, 2011 15:33
trace animate behavior
<!DOCTYPE HTML">
<html>
<head>
<meta charset="utf-8" />
<!-- jQuery -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<!-- CSS -->
<style type="text/css">