Skip to content

Instantly share code, notes, and snippets.

View mach3's full-sized avatar
🏠
Working from home

まっは mach3

🏠
Working from home
View GitHub Profile
@mach3
mach3 / remove-utm.js
Created October 1, 2011 02:17
utmのパラメータをURLから取り除くブックマークレット
/**
* Remove utm parameters from url
* ( Use this as bookmarklet )
*/
(function(){
var loc, search, params, i;
loc = location;
search = loc.search.replace( /^\?/, '' ).split( '&' );
params = [];
i = search.length;
@mach3
mach3 / mixin.js
Created August 6, 2019 10:24
vnodeRender
export const vnodeRender = {
methods: {
vnodeRender(vnode) {
if (process.browser) {
if (!vnode.tag) {
return document.createTextNode(vnode.text)
}
const el = document.createElement(vnode.tag)
if (vnode.data) {
if (vnode.data.staticClass) {
@mach3
mach3 / delegate.js
Created January 23, 2017 06:10
$.fn.on(eventType, selector, selector, handler) みたいな物を。挙動はちょっと異なります。
var _delegate = function(elms, type, selector, callback){
elms = (_type(elms) === "string") ? document.querySelectorAll(elms)
: (! elms.length) ? [elms]
: elms;
Array.from(elms).forEach(function(elm){
elm.addEventListener(type, function(e){
var valid = !! Array.from(this.querySelectorAll(selector))
.filter(function(el){
return el === e.target;
}).length;
/*
* jquery.xgradient.js
* http://blog.mach3.jp/
*
* Publish Date : 2010/5/13
* Requirement : jQuery 1.4 or later
* http://jquery.com/
*
* Copyright 2010, Mach3
*/
@mach3
mach3 / grunt-pngquant.js
Last active December 25, 2015 05:59
更新時刻を保持するpngquantタスク
/**
* Grunt task for pngquant
* -----------------------
*/
// @example:
//
// pngquant: {
// options: {
// preserve_mtime: true
@mach3
mach3 / jquery-attrs.js
Created September 17, 2013 18:37
html要素に設定した属性を全て取得するやつ
(function($, undefined){
/**
* Get all custom attributes
* @param HTMLElement el
* @return Object
*/
$.getAttributes = function(el){
var $el, data, add, i;
$el = $(el);
@mach3
mach3 / jquery-transition.js
Last active December 22, 2015 21:58
CSSのTransitionを$.fn.animateっぽく使うやつ。Transition非対応環境で$.fn.animateでそれっぽくフォールバックする。
(function($){
/**
* Detect support of css transition, event name
*/
$.support.transitionInfo = (function(){
var el, names, name, info = null;
el = document.createElement("div");
names = {
"WebkitTransition": "webkitTransitionEnd",
@mach3
mach3 / jquery.swipeevents.js
Created September 4, 2013 12:38
スワイプイベントを発火するやつを試作
(function($){
/**
* Detect supports
*/
$.support.touchEvents = "ontouchstart" in document;
$.support.msPointerEvents = window.navigator.msPointerEnabled;
/**
* Swipe event object
@mach3
mach3 / assets.js
Last active December 21, 2015 19:29
harvestは根本的な不具合があったので、ローダーだけクラスにしてみた
(function(win, doc){
var Assets = function(){
this.items = [];
this.nodes = [];
this.attrs = {
callback: null,
append: true
};
};
@mach3
mach3 / harvest.js
Created August 24, 2013 20:30
シンプルなスクリプトローダーの試作版
(function(win, doc){
/**
* Namespace
* ---------
*/
var ns = win._harvest = {};
/**
* Loader