Skip to content

Instantly share code, notes, and snippets.

@kawabataryo
kawabataryo / countCSSRules.js
Last active August 29, 2015 14:06 — forked from psebborn/countCSSRules.js
Bookmarklet
javascript:(function(){var c="",d="";if(!document.styleSheets){return;}for(var b=0;b<document.styleSheets.length;b++){a(document.styleSheets[b]);}function a(g){var h=0;if(g&&g.cssRules){for(var f=0,e=g.cssRules.length;f<e;f++){if(!g.cssRules[f].selectorText){continue;}h+=g.cssRules[f].selectorText.split(",").length;}d+="\nFile: "+(g.href?g.href:"inline <style> tag");d+="\nRules: "+g.cssRules.length;d+="\nSelectors: "+h;d+="\n--------------------------";if(h>=4096){c+="\n********************************\nWARNING:\n There are "+h+" CSS rules in the stylesheet "+g.href+" - IE will ignore the last "+(h-4096)+" rules!\n";}}}console.log(d);console.log(c);})();
@kawabataryo
kawabataryo / flame_animation.js
Last active August 29, 2015 14:06
JS Flame Animation
(function(window,namespace,$){
window[namespace] = {
play: function(){
var len = this.frame.length;
for(var i=0; i<len; i++){
setTimeout(this.frame[i].scene, this.frame[i].timeline);
}
},
@kawabataryo
kawabataryo / GetElementsOffsetTop.js
Last active August 29, 2015 14:07
指定したIDの縦の位置を配列で返す関数
/**
* @param {Array} idAry 位置を取得したい要素のID名を配列で ※必須
* @param {Number} adjustPosition 位置を調整 [初期値=0]
*
* 取得したデータの呼び出し [インスタンス名].hashTalbe;
*/
function GetElementsOffsetTop(idAry,adjustPosition){
this.idAry = idAry;
this.len = this.idAry.length;
this.adjustPosition = adjustPosition || 0;
@kawabataryo
kawabataryo / decideUserAgent.js
Last active August 29, 2015 14:08
ユーザーエージェントを判定
function DecideUA(){
this.name = window.navigator.userAgent.toLowerCase();
}
DecideUA.prototype = {
/**
* @param {Strihg} str 判定するデバイスのユニークな文字列
* @return {Boolean}
*/
@kawabataryo
kawabataryo / jquery.pageScroll.js
Last active August 29, 2015 14:08
スムーズスクロール
/**
* @param {String} el 対象のセレクター ※必須
* @param {Number} sub スクロール位置を調整 [初期値=0]
* @param {Number} time スクロールするスピード [初期値=200]
* @param {String} easing イージング [初期値='swing']
*/
function PageScroll(el, sub, time, easing){
this.$el = $(el);
this.sub = sub || 0;
this.time = time || 200;
@kawabataryo
kawabataryo / jquery.navControl.js
Last active August 29, 2015 14:08
一定量スクロールすると表示されるナビゲーション
/**
* @param {String} el 対象のセレクター ※必須
* @param {Number} position 特定の位置 ※必須
* @param {Number} height スライドの量 ※必須
* @param {Number} time スクロールするスピード [初期値=200]
* @param {String} easing イージング [初期値='swing']
*/
function NavControl(el,position,height,time,easing){
this.$el = $(el);
this.position = position;
function hasClass(selector,str){
var el = document.querySelector(selector);
var className = el.className();
var classArray = className.split(' ')
if(classArray.indexOf(str) !== -1){
return true;
}
return false;
}
function setEvent(selector,event,func){
var ary = document.querySelectorAll(selector);
var len = ary.length;
for (var i = 0; i < len; i++){
ary[i].addEventListener(event, func);
};
}
@kawabataryo
kawabataryo / inherits.js
Created November 8, 2014 08:34
クラス継承に関するメモ
//inherits
function inherits(ctor, superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
@kawabataryo
kawabataryo / jquery.showElementOnScroll.js
Last active August 29, 2015 14:09
特定の位置で対象を表示する
/**
* 特定の位置で対象を表示する
* @param {String} el 対象のセレクター ※必須
* @param {Number} position 特定の位置 ※必須
*/
function ShowElementOnScroll(el,position){
this.$el = $(el);
this.position = position;
this.$window = $(window);
this.event();