Skip to content

Instantly share code, notes, and snippets.

View jigewxy's full-sized avatar

Cliff Wang jigewxy

  • Singapore
View GitHub Profile
@jigewxy
jigewxy / jsbin.kalovug.js
Last active June 28, 2017 06:08
JS Bin[Array-like object]// source http://jsbin.com/kalovug
var x = {'5':'cliff', '6':'19', length:3};
var y = Array.prototype.slice.call(x);
console.log(y);
// result: [undefined, "cliff", "19"]
var a = {'0':'cliff', '1':'19', length:4};
@jigewxy
jigewxy / flatterCtrl.js
Last active June 28, 2017 06:02
JS Bin[controlled _.flatten function]// source https://jsbin.com/hinawagohe
var arr =[1, [2,[3, [4, [5, [6]]]]]];
function flattenCtrl(list, level){
do {
list=_.flatten(list, true);
level--;
} while(level>0);
<!doctype html>
<html >
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
<script type="text/javascript">
var Dm = angular.module('testDirective',[]);
Dm.controller('DmCtrl', function($scope) {
$scope.name = "cliff";
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@jigewxy
jigewxy / gist:3e6aa8ad3953eaf1c72d12c8afa23e7b
Created February 6, 2018 03:37
angular form validation
--js----
/** Basic input validator for input text field, it detect empty input and special characters */
app.directive('inputValidator', function() {
return {
require: 'ngModel', //ngModelController is required here
link: function(scope, element, attr, mCtrl) {
function myValidation(value) {
if (value.trim()!=="" && new RegExp(/[~`!@#\$%\^&*\/\\\|\?\.,:;"']/g).test(value)==false) {
mCtrl.$setValidity('charE', true);
@jigewxy
jigewxy / gist:7684e50e24c4b26b2fa2879993606522
Created February 6, 2018 07:44
kendo chart, format percentage strings
$(chartId).kendoChart({
theme: 'bootstrap',
title: {
position: "bottom",
text: chartTitle,
color: "#ffffff",
fontSize: "22px"
},
legend: {
visible: false
@jigewxy
jigewxy / gist:2d962f057395e919badabf6392915bfa
Created February 7, 2018 11:13
resizeable window using jquery.draggable
$(document).ready(function () {
setCurrentTabHeaderText();
// $("#ownedTaskSection").resizable();
var prevY = 0,
nextY =0,
offset = 0;