Skip to content

Instantly share code, notes, and snippets.

💜

Eunkwang Shin gracefullight

💜
Block or report user

Report or block gracefullight

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View daum_address_api.js
/**
* [searchAddr 다음주소검색 API]
* @return {[JsonArray]} [주소데이터]
* <script src="http://dmaps.daum.net/map_js_init/postcode.v2.js">가 선행되어야함
*/
var searchAddr = function(){
new daum.Postcode({
oncomplete: function(data){
var fullAddr = ''; // 최종 주소 변수
var extraAddr = ''; // 조합형 주소 변수
View cilpboard_example.html
<script src="/bower_components/clipboard/dist/clipboard.min.js"></script>
<!-- 1. URL copy -->
<a href="#" id="btnCopyUrl" data-clipboard-action="copy" >url 복사</a>
<script>
$(function({
// 복사 버튼을 만들시 data-clipboard-text 안에 복사할 문구를 넣어준다
$('#btnCopyUrl').attr('data-clipboard-text', document.location.href);
// callback 설정
var clipboard = new Clipboard('#btnCopyUrl');
View datetimepicker_with_moment_example.html
<link rel="stylesheet" type="text/css" href="/bower_components/datetimepicker/build/jquery.datetimepicker.min.css">
<!-- php.date.formatter.js 와 jquery.mousewheeel.js 를 포함하는 full.js-->
<!-- moment는 이미 선언되어있다고 가정합니다 -->
<script src="/bower_components/datetimepicker/build/jquery.datetimepicker.full.min.js"></script>
<script>
// dateTimePicker localization
$.datetimepicker.setLocale('ko');
// dateTimePicker moment.js와 연동
$.datetimepicker.setDateFormatter({
View async_imageupload_example.html
<script type="text/javascript">
var imageModule = (function () {
'use strict';
var possible = window.File && window.FileReader && window.FormData; // html5 업로드를 지원하는지의 여부
var apiPath = '/api/test.php'; // 업로드 서버 처리 경로
var folder = '/upload/review/'; // 기본 이미지 업로드 폴더
var $input;
var maxWidth = 600;
var maxHeight = 480;
View jq_validation_error_handling_example.html
<script>
$.validator.setDefaults({
onfocusout: false,
invalidHandler: function(form, validator) { // 커스텀 포커스 핸들링
if (validator.numberOfInvalids()) {
validator.errorList[0].element.focus();
//alert(validator.errorList[0].message); // 경고창
}
},
errorClass:'text-danger', // 에러 스타일을 입힐 클래스 지정
View jq_validation_with_materialize_example.js
// p 태그를 이용하는 방법
$.validator.setDefaults({
errorClass: "invalid form-error red-text",
errorElement : 'p',
errorPlacement: function(error, element) {
var e = element.get(0);
if(e.type==='radio' || e.type==='checkbox'){
var $a = error.appendTo(element.parent());
$a.css({'margin-top':'10px'});
}else{
View jq_validation_custom_method.js
(function($) {
$.validator.addMethod('biznum', function(bizID, element) {
var checkID = [1, 3, 7, 1, 3, 7, 1, 3, 5, 1];
var tmpBizID, i, chkSum=0, c2, remander;
bizID = bizID.replace(/-/gi, '');
for (i=0; i<=7; i++) {
chkSum += checkID[i] * bizID.charAt(i);
}
c2 = "0" + (checkID[8] * bizID.charAt(8));
View number_to_korean.js
/**
* [num2han 숫자를 한글로 변환]
* @param {[integer]} num [숫자]
* @return {[string]} [한글 숫자]
* @author http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=14981
*/
function num2han(num){
var i, j=0, k=0;
var han1 = ["","일","이","삼","사","오","육","칠","팔","구"];
var han2 = ["","만","억","조","경","해","시","양","구","간"];
View number_with_commas_using_regex.js
// function
function comma(num){
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
// prototype
Number.prototype.format = function(){
return this.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
};
View js_unix_timestamp.js
// === PHP time();
var timestamp = Math.round(new Date().getTime() / 1000);
You can’t perform that action at this time.