Skip to content

Instantly share code, notes, and snippets.

@pocotan001
pocotan001 / gist:1180581
Created August 30, 2011 10:02 — forked from ahomu/gist:877105
わくわくjQuery編
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8" />
<title>わくわくjQuery編</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script >
<script type="text/javascript">
$(function()
{
// ★ 画像の読み込みをテキトーに待つよ
@pocotan001
pocotan001 / gist:1183608
Created August 31, 2011 14:02
Utilities
/**
* getElementById wrapper.
* @param {String} 要素の一意のIDを表す文字列
* @returns {Element} 一致する要素
*/
function $(id){
return $[id] || ($[id] = document.getElementById(id));
}
/**
@pocotan001
pocotan001 / gist:1183656
Created August 31, 2011 14:19
ブックマークレット: グローバル変数を一覧(alert,consoleに出力)
javascript:(function(){var d=document,f=d.createElement('iframe'),b=d.body,o={0:1,getInterface:1,GetWeakReference:1,console:1,loadFirebugConsole:1,_createFirebugConsole:1,_firebug:1,_FirebugCommandLine:1},c=typeof this.console!='undefined',r='';f.src=d.URL+'?';b.appendChild(f);var w=f.contentWindow;for(var i in this){if(!(i in w)&&!o[i]&&!/^script\d{13}$/.test(i)){r+=i+'\n';if(c)console.log(i+':',this[i]);}}b.removeChild(f);alert(r);})();
// Uncompressed
javascript:
(function(){
var d = document,
f = d.createElement('iframe'),
b = d.body,
o = {
@pocotan001
pocotan001 / gist:1183673
Created August 31, 2011 14:29
ブックマークレット: ファーストビュー確認用(550px)
javascript:(function(){var d=document,o=d.createElement('div');with(o.style){position='fixed';top='550px';left='0';width='100%';height='100%';borderTop='1px #f00 solid';backgroundColor='rgba(255,255,255,.9)';color='#fff';fontSize='10px';zIndex='10000';}o.innerHTML='<p style='position:absolute;top:0;left:0;margin:0;padding:0pt 8px;background-color:#f00;'>550px</p>';d.body.appendChild(o);})();
// Uncompressed
javascript:
(function(){
var d = document,
o = d.createElement('div');
with(o.style){
@pocotan001
pocotan001 / global.js
Last active September 27, 2015 03:48
in strict mode.
var global = Function('return this')();
@pocotan001
pocotan001 / prefix.js
Created December 11, 2012 11:47
ベンダープレフィックス調べる
var prefix = !getComputedStyle ? null : (function() {
var prefix = null, i = 0,
style = getComputedStyle(document.documentElement, null);
while (style[i++]) {
if (style[i].charAt(0) === '-') {
prefix = style[i].split('-')[1];
break;
}
}
@pocotan001
pocotan001 / setScrollTo.js
Created December 12, 2012 11:48
値の更新を待つscrollToのラッパー(for Android)
/**
* 値の更新を待つscrollToのラッパー(for Android)
*
* @param {Number} x
* @param {Number} y
* @param {[Function]} callback
*/
function setScrollTo(x, y, callback) {
var body = document.body;
article, aside, details, figcaption, figure, footer, header, hgroup, nav, section { display: block; }
audio, canvas, video { display: inline-block; *display: inline; *zoom: 1; }
audio:not([controls]) { display: none; }
[hidden] { display: none; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; }
body { margin: 0; font-size: 13px; line-height: 1.231; }
body, button, input, select, textarea { font-family: sans-serif; color: #222; }
a { color: #00e; }
a:visited { color: #551a8b; }
a:hover { color: #06e; }
_人人人人人人_
> 突然の死 <
 ̄Y^Y^Y^Y^Y ̄
@pocotan001
pocotan001 / sleep.js
Created April 20, 2013 11:41
sleep.js
/**
* @param {Number} ms
*/
function sleep(ms) {
var end = Date.now() + ms;
while (Date.now() < end);
}