Skip to content

Instantly share code, notes, and snippets.

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

許益銘 rc1021

🏠
Working from home
View GitHub Profile
function queryStringToJson(s="")
{
return JSON.parse(s.replace(/[?|&]([A-Za-z0-9]*)=([^&]*)/ig, ",\"$1\":\"$2\"").slice(1).replace(/(.*)/, "{ $1 }"));
}
/*----------------------------------------------------*/
/* MOBILE DETECT FUNCTION
/*----------------------------------------------------*/
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
@rc1021
rc1021 / ParsedUrl.js
Last active April 3, 2018 08:59 — forked from acdcjunior/ParsedUrl.js
Cross-browser URL parsing in JavaScript
function ParsedUrl(url) {
this.parse(url);
}
ParsedUrl.prototype.parse = function (url) {
var parser = document.createElement("a");
parser.href = url;
// IE 8 and 9 dont load the attributes "protocol" and "host" in case the source URL
// is just a pathname, that is, "/example" and not "http://domain.com/example".
@rc1021
rc1021 / webpack.config.js
Created February 2, 2018 07:39 — forked from JesterXL/webpack.config.js
Example webpack for ES6 unit testing
'use strict';
// Modules
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var _ = require('lodash');
@rc1021
rc1021 / main.html
Last active December 24, 2017 12:36
demo serializeArray of form to json object
<!DOCTYPE html>
<html>
<head>
<title>demo serializeArray of form to json object</title>
<script type="text/javascript" src="main.js"></script>
</head>
<body>
<form>
<input type="text" name="desc" value="demo serializeArray of form to json object.">
<input type="text" name="users[0].name" value="user A">
let _ = require('lodash');
//Input
var input = [
{ key: '1', val: 'a' },
{ key: '2', val: 'b' },
{ key: '3', val: 'c' }
];
//Desired output
@rc1021
rc1021 / jquery-scroll-bottom.js
Last active August 8, 2018 06:56
指定 selector 如果有捲軸時,當滑動至底部時觸發事件
/**
* @description jQuery-scroll-bottom。
*
* 指定 selector 如果有捲軸時,當滑動至底部時觸發事件
* @module ScrollBottom
* @author 許益銘 <mufasa.hsu@gmail.com>
* @example
* require('./jquery-scroll-bottom');
*
* // method 1
@rc1021
rc1021 / PasswordEntryCell.cs
Last active April 14, 2017 06:02
加入PasswordEntryCell,讓 Xamarin 具有密碼輸入的 EntryCell
/**
* 這檔案是參考 https://forums.xamarin.com/discussion/21298/entrycell-password 並加以修正。
* 主要是 xamarin 目前暫無密碼輸入的 EntryCell,
*
* 我增加的部份:
* 1. 建立 BindableProperty 讓 XAML 也可以使用 Value 屬性 | 2017.04
*/
using System;
using Xamarin.Forms;
@rc1021
rc1021 / AutoArrangement.xaml
Created March 29, 2017 05:56
Custom layouts with Xamarin.Forms: auto arrangement cells (not finish)
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:App1"
x:Class="App1.AutoArrangement"
Title="Auto-Arrangement">
<ContentPage.Content>
<local:GridListView
@rc1021
rc1021 / CustomerPage.xaml
Created March 3, 2017 07:55
How to: NavigationPage in XAML
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:App1.Pages"
x:Class="App1.CustomerPage">
<Label Text="Say something here..."/>
</ContentPage>