Skip to content

Instantly share code, notes, and snippets.

@annaliahsiao
annaliahsiao / package.json
Created August 22, 2019 07:23
my package.json
{
"name": "product_name",
"version": "1.0.0",
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack --progress --colors --watch --mode production",
"dev": "webpack && webpack-dev-server --progress --colors --config webpack.config.js"
},
"author": "annalia.hsiao",
@annaliahsiao
annaliahsiao / webpack.bundle.js
Last active November 22, 2019 07:01
my webpack.config.js setting
const webpackMerge = require('webpack-merge');
const commonConfig = require('./webpack.common.js');
module.exports = webpackMerge(commonConfig, {
mode: 'production',
optimization: {
minimize: false,
runtimeChunk: {
name: 'runtime'
@annaliahsiao
annaliahsiao / exif_photo_demo
Created May 13, 2019 10:37
照片預覽與取得照片資訊、照片旋轉功能
function img_load(_this){
if(_this.files && _this.files[0]){
var reader = new FileReader();
//獲取照片方向角屬性,使用者旋轉控制
EXIF.getData(_this.files[0], function(e) {
//orientation表示取得照片的角度,EXIF.getTag()表示取得照片的指定參數數據
var orientation = EXIF.getTag(this, 'Orientation');
//exifdata.DateTime表示取得照片的拍攝時間
var photo_time = this.exifdata.DateTime;
@annaliahsiao
annaliahsiao / firebase_mailpassword_authentication.js
Created March 27, 2019 03:19
Sign in a user with an email address and password - firebase
//初始化 firebase
var config = {
apiKey: "<API_KEY>",
authDomain: "<PROJECT_ID>.firebaseapp.com",
databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
projectId: "<PROJECT_ID>",
storageBucket: "<BUCKET>.appspot.com",
messagingSenderId: "<SENDER_ID>",
};
firebase.initializeApp(config);
@annaliahsiao
annaliahsiao / firebase_fb_authentication.js
Last active March 21, 2024 14:45
Firebase FaceBook Authentication
//初始化 firebase
var config = {
apiKey: "<API_KEY>",
authDomain: "<PROJECT_ID>.firebaseapp.com",
databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
projectId: "<PROJECT_ID>",
storageBucket: "<BUCKET>.appspot.com",
messagingSenderId: "<SENDER_ID>",
};
firebase.initializeApp(config);
@annaliahsiao
annaliahsiao / google_excel_api.js
Last active March 18, 2020 18:25
將Google試算表當成線上資料庫
/*-----------------google試算表程式碼區-----------------*/
function doGet(e) {
var callback = e.parameter.callback;
var returnObject = getDate();
return ContentService.createTextOutput(callback+'('+ JSON.stringify(returnObject)+')').setMimeType(ContentService.MimeType.JAVASCRIPT);
}
function getDate(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var rtjs = [];
@annaliahsiao
annaliahsiao / htmltopdf.js
Created December 20, 2018 02:50
html to pdf
function add_iframe(){
var html_content = $('#html_content').html();
$("#download").contents().find("#wrapper").html(html_content);
setTimeout(function(){
$("#download").get(0).contentWindow.print_html();
},500)
}
function print_html(){
var random = new Date().getTime();
@annaliahsiao
annaliahsiao / canvaseaseljs_base.js
Created December 14, 2018 16:02
use EASELJS to building a canvas
/*------canvas building------*/
var canvas_width,
canvas_height,
stage,
imgs = ['https://cdn.tutsplus.com/net/uploads/2014/01/character2.png','http://images.669pic.com/element_min_new_pic/61/53/95/63/485904e3a0a661184c55b4817f293c18.png!/fw/320/quality/90/unsharp/true/canvas/320x302/compress/true/cvscolor/ffffffff'];
function init(){
stage = new createjs.Stage("canvas");
responsiveCanvas();
canvas_width = stage.canvas.width;
@annaliahsiao
annaliahsiao / formvalidation.js
Created December 13, 2018 14:48
簡單的表單驗證
var re_nm = /^\W$/,
re_idt = /^[A-Z]{1}\d{9}$/,
re_tel = /^0\d{1}\d{6,8}$/,
re_ctel = /^09\d{8}$/,
re_eml = /^\S+@\w+((\.|-)\w+)*\.\w+$/,
errstr = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_.#@()*[]{}|!~';:<>,?/\&^%$\"+-";
function form_chk(){
var name = $('input[name="name"]').val(),
identity = $('input[name="identity"]').val(),
@annaliahsiao
annaliahsiao / fbshare_v3.1.js
Last active December 12, 2018 08:39
facebook api v3.1
var fb_share_url = 'https://www.yourwebsite.com', //帶入網址
fb_name, //使用者的FB名稱
fb_id, //使用者的FB ID
perms, //FB帶入參數
fb_app_id = '123456789'; //FB APP_ID
var is_uiwebview = /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent); // 判斷瀏覽裝置
var userAgent = window.navigator.userAgent.toLowerCase(),
line = /line/.test(userAgent), //LINE內建瀏覽器
fbav = /fbav/.test(userAgent); //FB內建瀏覽器