From e19147dc737979d02e63586fa97a61819007de5b Mon Sep 17 00:00:00 2001 From: Bkk1234 Date: Sat, 24 Oct 2026 17:32:25 +0700 Subject: [PATCH] add one ui theme --- app/README.md | 85 +- app/app.js | 524 -------- app/css/app.css | 853 +++++++++++++ app/index.html | 217 +--- app/js/archive.js | 112 ++ app/js/camera.js | 187 +++ app/js/config.js | 14 + app/js/db.js | 98 ++ app/js/device.js | 74 ++ app/js/exif.js | 147 +++ app/js/main.js | 763 ++++++++++++ app/js/naming.js | 67 + app/js/ui.js | 319 +++++ app/manifest.json | 42 +- app/sw.js | 86 +- app/vendor/jszip.min.js | 13 + app/vendor/piexif.js | 2482 ++++++++++++++++++++++++++++++++++++++ app/vendor/qrcode.min.js | 1 + 18 files changed, 5299 insertions(+), 785 deletions(-) delete mode 100644 app/app.js create mode 100644 app/css/app.css create mode 100644 app/js/archive.js create mode 100644 app/js/camera.js create mode 100644 app/js/config.js create mode 100644 app/js/db.js create mode 100644 app/js/device.js create mode 100644 app/js/exif.js create mode 100644 app/js/main.js create mode 100644 app/js/naming.js create mode 100644 app/js/ui.js create mode 100644 app/vendor/jszip.min.js create mode 100644 app/vendor/piexif.js create mode 100644 app/vendor/qrcode.min.js diff --git a/app/README.md b/app/README.md index e06c95c..283b95a 100644 --- a/app/README.md +++ b/app/README.md @@ -1,57 +1,62 @@ -# CamCat — Web Camera Category PWA +# CamCat — Web Camera Category PWA (One UI) -Progressive Web App สำหรับถ่ายรูป จัดหมวดใน folder และแชร์เป็น zip +PWA ถ่ายรูปหน้างาน แยกโฟลเดอร์ตามไซต์ พร้อม Metadata, ZIP ทั้งโฟลเดอร์ และแชร์ผ่านระบบของมือถือ +หน้าตาออกแบบตามภาษา **Samsung One UI** (การ์ดมุมโค้ง 26px, พิลล์, ธีมสว่าง/มืด, ไอคอน SVG ล้วน) ## Features -- 📷 ถ่ายรูปจากกล้อง (front/back switch) -- 📁 สร้าง/แก้ชื่อ/ลบ folder -- 🖼️ Gallery view พร้อมเลือกหลายรูป -- 📦 Zip รูปที่เลือกเป็น .zip -- 📤 Share ผ่าน Web Share API (หรือ download fallback) -- 📊 EXIF data (camera model, date, GPS, ISO, aperture) -- 💾 Offline storage (IndexedDB + Service Worker) -- 📱 Installable PWA (Add to Home Screen) +- กล้องหลัง/หน้า, ไฟแฟลช (torch), ซูมแบบ pills 1×/2×/3×, เส้นแบ่ง 3 ส่วน +- ถ่ายด้วย `ImageCapture.takePhoto()` (ความละเอียดเต็ม) fallback เป็น canvas +- เขียน EXIF ลงไฟล์จริง (Make/Model/DateTimeOriginal/GPS) ก่อนบันทึก → ติดไปตอนแชร์ +- โฟลเดอร์ชื่อเริ่มต้น `Site A <ปี พ.ศ.>-<เดือน>-<วัน>` อัตโนมัติ (Asia/Bangkok) +- ZIP **ทุกรูปในโฟลเดอร์** + `metadata.json` แล้วดาวน์โหลดลงเครื่อง +- ปุ่มแชร์ = สร้าง ZIP แล้วส่งเข้า share sheet ของ Samsung ไปแอปอื่น (fallback = ดาวน์โหลด) +- ธีมสว่าง/มืด/ตามระบบ (จำค่าไว้), safe-area, 100dvh, ปุ่ม ≥44px ตาม One UI +- QR ลิงก์ทดสอบบนมือถือ (ต้อง HTTPS) + หน้าข้อมูลอุปกรณ์/กล้อง (diagnostics) +- Offline: Service Worker + IndexedDB, ติดตั้งเป็น PWA ได้ -## Install on Mobile +## Design (One UI) + +| องค์ประกอบ | ค่า | +|---|---| +| สีหลัก light | bg `#F2F3F5` · card `#FFFFFF` · text `#101114` · accent `#0A72DE` | +| สีหลัก dark | bg `#000000` · card `#1B1B1D` · text `#F2F3F5` · accent `#4E9DFF` | +| มุมโค้ง | การ์ด 26px · ช่องกรอก 16px · ปุ่ม/ชิปเป็น pills | +| ตัวอักษร | One UI Sans → SF / Segoe / Roboto / Noto Sans Thai | +| ระยะ | 4/8px rhythm, ขอบข้าง 20px | +| Accessibility | ข้อความ ≥4.5:1, ปุ่ม ≥44px, reduced-motion, focus ring | +| หน้าเมนูกล้อง | โครมดำทั้งหน้าแบบ One UI Camera | + +## รันทดสอบ -### Option 1: Serve locally ```bash cd app -python3 -m http.server 8080 -# บนมือถือเปิด: http://:8080 +python -m http.server 8099 --bind 0.0.0.0 + +# กล้องใช้ได้เฉพาะ HTTPS — เปิด tunnel แล้วสแกน QR ในแอป +cloudflared tunnel --url http://127.0.0.1:8099 ``` -### Option 2: Deploy to hosting -Upload ไฟล์ใน `app/` ไปยัง static host (Netlify, Vercel, GitHub Pages) - -### Install PWA -1. เปิด URL ใน browser (Chrome/Safari) -2. Menu → "Add to Home Screen" / "Install" -3. เปิดจาก icon บน home screen เหมือน native app - ## Files ``` app/ -├── index.html # UI shell -├── app.js # App logic (camera, folders, zip, share, EXIF) -├── sw.js # Service Worker (offline cache) -├── manifest.json # PWA manifest -├── icon-192.png # App icon 192x192 -└── icon-512.png # App icon 512x512 +├── index.html # shell + header/nav แบบ One UI +├── css/app.css # design tokens + components (light/dark) +├── js/config.js # ค่าคงที่ (Site A, timezone, quality) +├── js/naming.js # ชื่อโฟลเดอร์/ไฟล์ ปี พ.ศ. +├── js/db.js # IndexedDB (folders, images, thumbs) +├── js/exif.js # อ่าน/เขียน EXIF (piexifjs) +├── js/device.js # ตรวจรุ่นเครื่อง (SM-S911B → Galaxy S23) +├── js/camera.js # getUserMedia, ImageCapture, torch, zoom +├── js/archive.js # ZIP + ดาวน์โหลด + Web Share (มี cache) +├── js/ui.js # markup + bottom sheet + toast +├── js/main.js # state, events, ธีม, diagnostics +├── vendor/ # jszip, piexif, qrcode (ใช้ offline) +├── sw.js · manifest.json · icon-*.png +└── README.md ``` -## Browser Support +## Browser -- Chrome/Edge 90+ (full) -- Safari 15+ (camera + install) -- Firefox 88+ (no PWA install) - -## Tech - -- IndexedDB — local storage for folders + images -- MediaDevices API — camera access -- Web Share API — native share sheet -- JSZip — zip generation -- Service Worker — offline support +Chrome/Edge Android (Samsung S23 คือเครื่องทดสอบหลัก) · Safari 16+ (ไม่มี torch/zoom) diff --git a/app/app.js b/app/app.js deleted file mode 100644 index 9a0020c..0000000 --- a/app/app.js +++ /dev/null @@ -1,524 +0,0 @@ -// ───────────────────────────────────────────────────────────── -// CamCat — Web Camera Category PWA -// Take photos → organize into folders → zip & share -// ───────────────────────────────────────────────────────────── - -// ── State ── -const DB_NAME = "camcat-db"; -const STORE_FOLDERS = "folders"; -const STORE_IMAGES = "images"; -let db = null; -let currentView = "camera"; -let activeFolderId = null; -let currentStream = null; -let facingMode = "environment"; -let selectedImages = new Set(); -let viewingImage = null; - -// ── IndexedDB setup ── -function openDB() { - return new Promise((resolve, reject) => { - const req = indexedDB.open(DB_NAME, 1); - req.onupgradeneeded = (e) => { - const d = e.target.result; - if (!d.objectStoreNames.contains(STORE_FOLDERS)) { - d.createObjectStore(STORE_FOLDERS, { keyPath: "id" }); - } - if (!d.objectStoreNames.contains(STORE_IMAGES)) { - const s = d.createObjectStore(STORE_IMAGES, { keyPath: "id" }); - s.createIndex("folderId", "folderId", { unique: false }); - } - }; - req.onsuccess = () => resolve(req.result); - req.onerror = () => reject(req.error); - }); -} - -function dbGet(store, key) { - return new Promise((resolve, reject) => { - const tx = db.transaction(store, "readonly"); - tx.objectStore(store).get(key).onsuccess = (e) => resolve(e.target.result); - tx.onerror = () => reject(tx.error); - }); -} - -function dbGetAll(store) { - return new Promise((resolve, reject) => { - const tx = db.transaction(store, "readonly"); - tx.objectStore(store).getAll().onsuccess = (e) => resolve(e.target.result); - tx.onerror = () => reject(tx.error); - }); -} - -function dbGetByIndex(store, indexName, value) { - return new Promise((resolve, reject) => { - const tx = db.transaction(store, "readonly"); - tx.objectStore(store).index(indexName).getAll(value).onsuccess = (e) => resolve(e.target.result); - tx.onerror = () => reject(tx.error); - }); -} - -function dbPut(store, obj) { - return new Promise((resolve, reject) => { - const tx = db.transaction(store, "readwrite"); - tx.objectStore(store).put(obj).onsuccess = () => resolve(obj); - tx.onerror = () => reject(tx.error); - }); -} - -function dbDelete(store, key) { - return new Promise((resolve, reject) => { - const tx = db.transaction(store, "readwrite"); - tx.objectStore(store).delete(key).onsuccess = () => resolve(); - tx.onerror = () => reject(tx.error); - }); -} - -// ── Folder operations ── -async function createFolder(name) { - const folder = { id: "f_" + Date.now(), name, createdAt: Date.now() }; - await dbPut(STORE_FOLDERS, folder); - return folder; -} - -async function renameFolder(id, name) { - const f = await dbGet(STORE_FOLDERS, id); - if (f) { f.name = name; await dbPut(STORE_FOLDERS, f); } -} - -async function deleteFolder(id) { - const imgs = await dbGetByIndex(STORE_IMAGES, "folderId", id); - for (const img of imgs) await dbDelete(STORE_IMAGES, img.id); - await dbDelete(STORE_FOLDERS, id); - if (activeFolderId === id) activeFolderId = null; -} - -async function getFolders() { - return dbGetAll(STORE_FOLDERS); -} - -async function getActiveFolder() { - if (!activeFolderId) return null; - return dbGet(STORE_FOLDERS, activeFolderId); -} - -async function setActiveFolder(id) { - activeFolderId = id; - const f = await dbGet(STORE_FOLDERS, id); - document.getElementById("active-folder-pill").textContent = "📁 " + (f ? f.name : "None"); -} - -// ── Image operations ── -async function saveImage(blob, exifData) { - if (!activeFolderId) { - const folders = await getFolders(); - if (folders.length === 0) { - const f = await createFolder("Default"); - await setActiveFolder(f.id); - } else { - await setActiveFolder(folders[0].id); - } - } - const img = { - id: "img_" + Date.now(), - folderId: activeFolderId, - blob: blob, - exif: exifData, - createdAt: Date.now(), - }; - await dbPut(STORE_IMAGES, img); - return img; -} - -async function getImages(folderId) { - return dbGetByIndex(STORE_IMAGES, "folderId", folderId); -} - -async function getImage(id) { - return dbGet(STORE_IMAGES, id); -} - -// ── EXIF parsing (basic) ── -function parseEXIF(blob) { - return new Promise((resolve) => { - const reader = new FileReader(); - reader.onload = () => { - const buf = new DataView(reader.result); - let exif = {}; - try { - // Check JPEG SOI marker - if (buf.getUint16(0) !== 0xFFD8) return resolve({}); - let offset = 2; - while (offset < buf.byteLength) { - if (buf.getUint16(offset) !== 0xFFE1) { offset += 2; continue; } - // Found APP1 (EXIF) - const exifLen = buf.getUint16(offset + 2); - const exifStart = offset + 4; - const tiffStart = exifStart + 6; - const bigEndian = buf.getUint16(tiffStart) === 0x4D4D; - const getU16 = (o) => bigEndian ? buf.getUint16(o) : buf.getUint16(o, true); - const getU32 = (o) => bigEndian ? buf.getUint32(o) : buf.getUint32(o, true); - const ifdOffset = tiffStart + getU32(tiffStart + 4); - const numEntries = getU16(ifdOffset); - const tags = { - 0x010F: "Make", 0x0110: "Model", 0x0132: "DateTime", - 0x0100: "ImageWidth", 0x0101: "ImageHeight", - 0x011A: "FocalLength", 0x876D: "ISO", - 0x829A: "ExposureTime", 0x829D: "FNumber", - }; - for (let i = 0; i < numEntries; i++) { - const entry = ifdOffset + 2 + i * 12; - const tag = getU16(entry); - const type = getU16(entry + 2); - const count = getU32(entry + 4); - const valOffset = count > 4 ? tiffStart + getU32(entry + 8) : entry + 8; - const name = tags[tag]; - if (!name) continue; - if (type === 2) { // ASCII - let s = ""; - for (let j = 0; j < count - 1; j++) s += String.fromCharCode(buf.getUint8(valOffset + j)); - exif[name] = s; - } else if (type === 3) { // SHORT - exif[name] = getU16(valOffset); - } else if (type === 4) { // LONG - exif[name] = getU32(valOffset); - } else if (type === 5) { // RATIONAL - exif[name] = (getU32(valOffset) / getU32(valOffset + 4)).toFixed(2); - } - } - break; - } - } catch (e) { /* ignore parse errors */ } - resolve(exif); - }; - reader.readAsArrayBuffer(blob); - }); -} - -// ── Camera ── -async function startCamera() { - if (currentStream) currentStream.getTracks().forEach(t => t.stop()); - try { - currentStream = await navigator.mediaDevices.getUserMedia({ - video: { facingMode, width: { ideal: 4032 }, height: { ideal: 3024 } }, - audio: false, - }); - const video = document.getElementById("video"); - if (video) { video.srcObject = currentStream; await video.play(); } - } catch (e) { - toast("Camera access denied: " + e.message); - } -} - -function stopCamera() { - if (currentStream) { - currentStream.getTracks().forEach(t => t.stop()); - currentStream = null; - } -} - -async function takePhoto() { - const video = document.getElementById("video"); - if (!video || !video.videoWidth) { toast("Camera not ready"); return; } - const canvas = document.createElement("canvas"); - canvas.width = video.videoWidth; - canvas.height = video.videoHeight; - canvas.getContext("2d").drawImage(video, 0, 0); - const blob = await new Promise(r => canvas.toBlob(r, "image/jpeg", 0.9)); - const exif = await parseEXIF(blob); - // Add GPS if available - if (navigator.geolocation) { - try { - const pos = await new Promise((res, rej) => navigator.geolocation.getCurrentPosition(res, rej, { timeout: 3000 })); - exif.GPS = `${pos.coords.latitude.toFixed(4)}, ${pos.coords.longitude.toFixed(4)}`; - } catch (e) { /* GPS not available */ } - } - await saveImage(blob, exif); - const f = await getActiveFolder(); - toast(`📸 Saved to ${f ? f.name : "folder"}`); - // Flash effect - const flash = document.createElement("div"); - flash.style.cssText = "position:fixed;inset:0;background:white;opacity:0.6;z-index:999;pointer-events:none"; - document.body.appendChild(flash); - setTimeout(() => flash.remove(), 200); -} - -// ── Zip & Share ── -async function zipSelected() { - if (selectedImages.size === 0) { toast("Select images first"); return; } - toast("Creating ZIP..."); - const zip = new JSZip(); - const folder = await getActiveFolder(); - const zipName = (folder ? folder.name : "photos") + "_" + selectedImages.size + "items"; - for (const imgId of selectedImages) { - const img = await getImage(imgId); - if (img) { - const ext = "jpg"; - zip.file(img.id + "." + ext, img.blob); - } - } - const zipBlob = await zip.generateAsync({ type: "blob" }); - const file = new File([zipBlob], zipName + ".zip", { type: "application/zip" }); - if (navigator.canShare && navigator.canShare({ files: [file] })) { - await navigator.share({ files: [file], title: zipName }); - } else { - // Fallback: download - const url = URL.createObjectURL(zipBlob); - const a = document.createElement("a"); - a.href = url; a.download = zipName + ".zip"; a.click(); - URL.revokeObjectURL(url); - } - selectedImages.clear(); - toast("✅ ZIP shared"); -} - -async function shareImage(imgId) { - const img = await getImage(imgId); - if (!img) return; - const file = new File([img.blob], img.id + ".jpg", { type: "image/jpeg" }); - if (navigator.canShare && navigator.canShare({ files: [file] })) { - await navigator.share({ files: [file] }); - } else { - const url = URL.createObjectURL(img.blob); - const a = document.createElement("a"); - a.href = url; a.download = img.id + ".jpg"; a.click(); - URL.revokeObjectURL(url); - } -} - -// ── Navigation & Rendering ── -function navigate(view) { - currentView = view; - document.querySelectorAll("nav button").forEach(b => b.classList.remove("active")); - document.getElementById("nav-" + view).classList.add("active"); - if (view !== "camera") stopCamera(); - render(); -} - -async function render() { - const main = document.getElementById("main"); - if (currentView === "camera") renderCamera(main); - else if (currentView === "folders") await renderFolders(main); - else if (currentView === "gallery") await renderGallery(main); -} - -function renderCamera(main) { - main.innerHTML = ` -
- -
- - -
-
-
`; - startCamera(); -} - -function switchCamera() { - facingMode = facingMode === "environment" ? "user" : "environment"; - startCamera(); -} - -async function renderFolders(main) { - const folders = await getFolders(); - let html = `

📁 Folders

`; - if (folders.length === 0) { - html += `

No folders yet

`; - } else { - for (const f of folders) { - const count = (await getImages(f.id)).length; - const isActive = f.id === activeFolderId; - html += `
-
${esc(f.name)}
${count} items${isActive ? " · Active" : ""}
-
- - -
-
`; - } - } - html += `
`; - main.innerHTML = html; -} - -async function selectFolder(id) { - await setActiveFolder(id); - await render(); - const f = await getActiveFolder(); - toast("📁 Active: " + (f ? f.name : "")); -} - -async function renderGallery(main) { - if (!activeFolderId) { - main.innerHTML = `

Select a folder first

`; - return; - } - const folder = await getActiveFolder(); - const images = await getImages(activeFolderId); - let html = `

🖼️ ${esc(folder ? folder.name : "")}

-
`; - if (images.length === 0) { - html += `

No photos yet

`; - } else { - html += ``; - html += ``; - } - main.innerHTML = html; -} - -function toggleSelect(id) { - if (selectedImages.has(id)) selectedImages.delete(id); - else selectedImages.add(id); - render(); -} - -function clearSelection() { selectedImages.clear(); render(); } - -async function shareSelected() { - if (selectedImages.size === 0) { toast("Select images first"); return; } - if (selectedImages.size === 1) { await shareImage([...selectedImages][0]); return; } - await zipSelected(); -} - -// ── Image viewer with EXIF ── -async function showImageViewer(imgId) { - const img = await getImage(imgId); - if (!img) return; - const url = URL.createObjectURL(img.blob); - let exifHtml = ""; - if (img.exif) { - const rows = Object.entries(img.exif).map(([k, v]) => `
${k}${esc(String(v))}
`); - exifHtml = `
EXIF Data${rows.join("")}
`; - } - document.getElementById("modal-content").innerHTML = ` -

Image

- - ${exifHtml} - `; - document.getElementById("modal-overlay").classList.add("show"); -} - -// ── Modals ── -function showNewFolderModal() { - document.getElementById("modal-content").innerHTML = ` -

New Folder

- - `; - document.getElementById("modal-overlay").classList.add("show"); -} - -async function doCreateFolder() { - const name = document.getElementById("folder-name-input").value.trim(); - if (!name) { toast("Enter a name"); return; } - const f = await createFolder(name); - await setActiveFolder(f.id); - closeModal(); - await render(); - toast("✅ Folder created"); -} - -function showRenameModal(id, name) { - document.getElementById("modal-content").innerHTML = ` -

Rename Folder

- - `; - document.getElementById("modal-overlay").classList.add("show"); -} - -async function doRenameFolder(id) { - const name = document.getElementById("folder-name-input").value.trim(); - if (!name) { toast("Enter a name"); return; } - await renameFolder(id, name); - closeModal(); - await render(); - toast("✅ Renamed"); -} - -function confirmDeleteFolder(id, name) { - document.getElementById("modal-content").innerHTML = ` -

Delete "${esc(name)}"?

-

All photos in this folder will be deleted.

- `; - document.getElementById("modal-overlay").classList.add("show"); -} - -async function doDeleteFolder(id) { - await deleteFolder(id); - closeModal(); - await render(); - toast("✅ Deleted"); -} - -function closeModal() { - document.getElementById("modal-overlay").classList.remove("show"); -} - -// ── Toast ── -let toastTimer = null; -function toast(msg) { - const el = document.getElementById("toast"); - el.textContent = msg; - el.classList.add("show"); - clearTimeout(toastTimer); - toastTimer = setTimeout(() => el.classList.remove("show"), 2500); -} - -// ── Utils ── -function esc(s) { return s.replace(/&/g, "&").replace(//g, ">").replace(/"/g, """).replace(/'/g, "'"); } - -// ── Init ── -async function init() { - db = await openDB(); - // Ensure default folder - const folders = await getFolders(); - if (folders.length === 0) { - const f = await createFolder("Default"); - await setActiveFolder(f.id); - } else { - await setActiveFolder(folders[0].id); - } - // Register service worker - if ("serviceWorker" in navigator) { - try { await navigator.serviceWorker.register("sw.js"); } catch (e) { console.warn("SW registration failed", e); } - } - // Request persistent storage - if (navigator.storage && navigator.storage.persist) { - await navigator.storage.persist(); - } - await render(); -} - -// Close modal on overlay click -document.getElementById("modal-overlay").addEventListener("click", (e) => { - if (e.target.id === "modal-overlay") closeModal(); -}); - -// Init on load -window.addEventListener("DOMContentLoaded", init); diff --git a/app/css/app.css b/app/css/app.css new file mode 100644 index 0000000..558a825 --- /dev/null +++ b/app/css/app.css @@ -0,0 +1,853 @@ +/* ============================================================ + CamCat — One UI (Samsung) look & feel + ภาษาเดียวกับ One UI 6/7: การ์ดมุมโค้ง 26px, พิลล์แคปซูล, + พื้นผิวเรียบ ไม่มีเส้นขอบหนา, ไอคอน SVG 24px, ระยะ 4/8px + ปรับให้ Galaxy S23 (360–412 CSS px, safe area, 100dvh) + ============================================================ */ + +:root { + /* Light — ค่าเริ่มต้นแบบ One UI */ + --bg: #F2F3F5; + --bg-2: #E8EAED; + --card: #FFFFFF; + --card-2: #F7F8F9; + --text: #101114; + --text-2: #5C6169; + --text-3: #62676F; + --line: rgba(16, 17, 20, 0.08); + --accent: #0A72DE; + --accent-text: #0E5FB8; + --accent-soft: #E4EFFC; + --on-accent: #FFFFFF; + --danger: #D93025; + --danger-soft: #FCE8E6; + --field: #EBEDF0; + + --shadow-card: 0 1px 2px rgba(16, 17, 20, 0.05), 0 6px 18px rgba(16, 17, 20, 0.05); + --shadow-float: 0 6px 20px rgba(16, 17, 20, 0.14); + + --radius-card: 26px; + --radius-row: 20px; + --radius-field: 16px; + --radius-pill: 999px; + + --pad: 20px; + --gap: 12px; + --nav-h: 64px; + + --safe-top: env(safe-area-inset-top, 0px); + --safe-bottom: env(safe-area-inset-bottom, 0px); + --safe-left: env(safe-area-inset-left, 0px); + --safe-right: env(safe-area-inset-right, 0px); + + --ease: cubic-bezier(0.2, 0, 0, 1); + --dur: 180ms; +} + +@media (prefers-color-scheme: dark) { + :root:not([data-theme="light"]) { + --bg: #000000; + --bg-2: #101114; + --card: #1B1B1D; + --card-2: #232326; + --text: #F2F3F5; + --text-2: #A9AEB6; + --text-3: #7C8188; + --line: rgba(255, 255, 255, 0.10); + --accent: #4E9DFF; + --accent-text: #6FB3FF; + --accent-soft: #16304D; + --on-accent: #06121F; + --danger: #FF6B60; + --danger-soft: #3A1A18; + --field: #26272A; + --shadow-card: none; + --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.55); + } +} + +:root[data-theme="dark"] { + --bg: #000000; + --bg-2: #101114; + --card: #1B1B1D; + --card-2: #232326; + --text: #F2F3F5; + --text-2: #A9AEB6; + --text-3: #7C8188; + --line: rgba(255, 255, 255, 0.10); + --accent: #4E9DFF; + --accent-text: #6FB3FF; + --accent-soft: #16304D; + --on-accent: #06121F; + --danger: #FF6B60; + --danger-soft: #3A1A18; + --field: #26272A; + --shadow-card: none; + --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.55); +} + +* { + margin: 0; + padding: 0; + box-sizing: border-box; + -webkit-tap-highlight-color: transparent; +} + +button, input, label { touch-action: manipulation; } + +html { height: 100%; background: var(--bg); } + +body { + font-family: "SamsungOneUI", "SF Pro Text", -apple-system, BlinkMacSystemFont, + "Segoe UI", Roboto, "Noto Sans Thai", "IBM Plex Sans Thai", sans-serif; + background: var(--bg); + color: var(--text); + height: 100vh; + height: 100dvh; + overflow: hidden; + overscroll-behavior: none; + user-select: none; + -webkit-user-select: none; + font-size: 15px; + line-height: 1.45; + letter-spacing: -0.1px; + -webkit-font-smoothing: antialiased; +} + +#app { + display: flex; + flex-direction: column; + height: 100dvh; + padding-left: var(--safe-left); + padding-right: var(--safe-right); + background: var(--bg); +} + +/* ── Header (One UI large title) ─────────────────────────── */ +header { + flex-shrink: 0; + display: flex; + align-items: center; + gap: 12px; + padding: calc(8px + var(--safe-top)) var(--pad) 10px; + background: var(--bg); +} + +.head-text { flex: 1; min-width: 0; } + +header h1 { + font-size: 23px; + font-weight: 700; + letter-spacing: -0.4px; + line-height: 1.2; + display: flex; + align-items: center; + gap: 8px; +} + +.head-sub { + display: inline-flex; + align-items: center; + gap: 3px; + margin-top: 2px; + max-width: 100%; + background: none; + border: 0; + padding: 0; + color: var(--text-2); + font-family: inherit; + font-size: 13px; + font-weight: 500; + text-align: left; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + cursor: pointer; + min-height: 32px; +} +.head-sub svg { width: 14px; height: 14px; flex-shrink: 0; opacity: 0.8; } + +.head-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; } + +.icon-round { + width: 44px; + height: 44px; + border-radius: 50%; + border: 0; + background: var(--card); + color: var(--text-2); + display: inline-flex; + align-items: center; + justify-content: center; + cursor: pointer; + box-shadow: var(--shadow-card); + transition: background var(--dur) var(--ease), transform var(--dur) var(--ease); +} +.icon-round svg { width: 22px; height: 22px; } +.icon-round:active { transform: scale(0.94); background: var(--bg-2); } + +/* ── Main ────────────────────────────────────────────────── */ +main { + flex: 1; + min-height: 0; + overflow-y: auto; + overflow-x: hidden; + -webkit-overflow-scrolling: touch; + position: relative; +} + +/* ── Bottom tabs (One UI) ────────────────────────────────── */ +nav { + flex-shrink: 0; + display: flex; + background: var(--card); + border-top: 1px solid var(--line); + padding: 6px 6px calc(6px + var(--safe-bottom)); +} + +nav button { + flex: 1; + min-height: 52px; + background: none; + border: 0; + color: var(--text-3); + font-family: inherit; + font-size: 11.5px; + font-weight: 500; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 2px; + padding: 4px 2px; + border-radius: var(--radius-row); + cursor: pointer; + transition: color var(--dur) var(--ease); +} + +nav button .tab-ico { + width: 56px; + height: 30px; + border-radius: var(--radius-pill); + display: flex; + align-items: center; + justify-content: center; + transition: background var(--dur) var(--ease); +} +nav button svg { width: 23px; height: 23px; } +nav button.active { color: var(--accent-text); font-weight: 600; } +nav button.active .tab-ico { background: var(--accent-soft); } +nav button:active .tab-ico { background: var(--bg-2); } + +/* ── หน้าเมนูกล้อง: โครมทั้งหน้าเป็นดำแบบ One UI Camera ──── */ +#app[data-view="camera"] { background: #000; } +#app[data-view="camera"] header { background: #000; color: #F5F6F7; } +#app[data-view="camera"] header h1 { color: #F5F6F7; } +#app[data-view="camera"] .head-sub { color: #A9AEB6; } +#app[data-view="camera"] .icon-round { background: #1B1B1D; color: #E7E8EA; box-shadow: none; } +#app[data-view="camera"] nav { background: #000; border-top-color: rgba(255, 255, 255, 0.10); } +#app[data-view="camera"] nav button { color: #8A9099; } +#app[data-view="camera"] nav button.active { color: #6FB3FF; } +#app[data-view="camera"] nav button.active .tab-ico { background: #16304D; } +#app[data-view="camera"] nav button:active .tab-ico { background: #232326; } + +/* ── Camera (One UI Camera = black) ──────────────────────── */ +#camera-view { + display: flex; + flex-direction: column; + height: 100%; + min-height: 0; + background: #000; + color: #F5F6F7; +} + +.stage { + position: relative; + flex: 1; + min-height: 0; + overflow: hidden; + background: #000; +} + +#video { + width: 100%; + height: 100%; + object-fit: cover; + display: block; + background: #000; +} + +.grid-lines { + position: absolute; + inset: 0; + pointer-events: none; + opacity: 0.3; + background-image: + linear-gradient(to right, #fff 1px, transparent 1px), + linear-gradient(to bottom, #fff 1px, transparent 1px); + background-size: 33.333% 33.333%; + background-position: -1px -1px; + display: none; +} +.grid-lines.on { display: block; } + +.cam-top { + position: absolute; + top: 0; + left: 0; + right: 0; + display: flex; + justify-content: flex-end; + gap: 10px; + padding: 12px 14px; +} + +.cam-chip { + width: 44px; + height: 44px; + border-radius: 50%; + background: rgba(28, 29, 32, 0.62); + backdrop-filter: blur(10px); + -webkit-backdrop-filter: blur(10px); + border: 0; + color: #fff; + display: inline-flex; + align-items: center; + justify-content: center; + cursor: pointer; + transition: background var(--dur) var(--ease), transform var(--dur) var(--ease); +} +.cam-chip svg { width: 21px; height: 21px; } +.cam-chip:active { transform: scale(0.93); } +.cam-chip[aria-pressed="true"] { background: #FFD54A; color: #201A00; } + +.cam-bottom { + flex-shrink: 0; + background: #000; + padding: 10px 18px 14px; +} + +/* zoom pills แบบ One UI Camera (1× / 2× / 3×) */ +.zoom-pills { + display: flex; + justify-content: center; + gap: 8px; + min-height: 40px; + align-items: center; + margin-bottom: 6px; +} +.zoom-pills[hidden] { display: none; } + +.zoom-pill { + min-width: 44px; + height: 36px; + padding: 0 11px; + border-radius: var(--radius-pill); + border: 0; + background: rgba(255, 255, 255, 0.14); + color: #EDEEF0; + font-family: inherit; + font-size: 12.5px; + font-weight: 600; + cursor: pointer; + transition: background var(--dur) var(--ease), color var(--dur) var(--ease); +} +.zoom-pill.on { background: #FFD54A; color: #201A00; } + +.shutter-row { + display: flex; + align-items: center; + justify-content: space-between; +} + +.shutter-side { + width: 56px; + height: 56px; + display: flex; + align-items: center; + justify-content: center; +} + +.thumb-btn { + width: 50px; + height: 50px; + border-radius: 16px; + border: 1px solid rgba(255, 255, 255, 0.18); + background: #1B1B1D; + overflow: hidden; + padding: 0; + cursor: pointer; + color: #8A9099; +} +.thumb-btn img { width: 100%; height: 100%; object-fit: cover; display: block; } +.thumb-btn:empty::after { + content: ""; + display: block; + width: 16px; + height: 16px; + margin: auto; + border-radius: 4px; + border: 2px solid currentColor; +} + +#shutter { + width: 76px; + height: 76px; + border-radius: 50%; + background: #FFFFFF; + border: 4px solid #000; + box-shadow: 0 0 0 3px #FFFFFF; + cursor: pointer; + transition: transform 90ms var(--ease), background 90ms var(--ease); +} +#shutter:active { transform: scale(0.9); background: #D7D9DD; } +#shutter:disabled { opacity: 0.45; } + +#shot-count { font-size: 12px; color: #A9AEB6; font-weight: 500; } + +/* ── Section heads / buttons ─────────────────────────────── */ +.section-head { + display: flex; + align-items: flex-end; + justify-content: space-between; + gap: 12px; + padding: 14px var(--pad) 10px; +} +.section-head h2 { + font-size: 20px; + font-weight: 700; + letter-spacing: -0.3px; + line-height: 1.25; +} +.section-head .sub { + font-size: 12.5px; + color: var(--text-2); + font-weight: 400; + margin-top: 3px; +} + +.btn { + font-family: inherit; + font-size: 14px; + font-weight: 600; + border-radius: var(--radius-pill); + border: 0; + padding: 0 18px; + min-height: 44px; + cursor: pointer; + display: inline-flex; + align-items: center; + justify-content: center; + gap: 7px; + transition: transform var(--dur) var(--ease), background var(--dur) var(--ease); +} +.btn:active { transform: scale(0.97); } +.btn:disabled { opacity: 0.45; } +.btn svg { width: 18px; height: 18px; } +.btn-primary { background: var(--accent); color: var(--on-accent); } +.btn-ghost { background: var(--card); color: var(--text); box-shadow: var(--shadow-card); } +.btn-tonal { background: var(--accent-soft); color: var(--accent-text); } +.btn-danger { background: var(--danger); color: #fff; } +.btn-block { width: 100%; min-height: 52px; font-size: 15px; } + +/* ── Folder list (One UI cards) ──────────────────────────── */ +.folder-list { + padding: 0 var(--pad) 8px; + display: flex; + flex-direction: column; + gap: 10px; +} + +.folder-item { + display: flex; + align-items: center; + gap: 12px; + background: var(--card); + border-radius: var(--radius-card); + padding: 12px 12px 12px 14px; + cursor: pointer; + box-shadow: var(--shadow-card); + transition: background var(--dur) var(--ease), transform var(--dur) var(--ease); +} +.folder-item:active { transform: scale(0.985); background: var(--card-2); } +.folder-item.active { box-shadow: var(--shadow-card), inset 0 0 0 2px var(--accent); } + +.f-ico { + width: 44px; + height: 44px; + border-radius: 15px; + background: var(--accent-soft); + color: var(--accent-text); + display: inline-flex; + align-items: center; + justify-content: center; + flex-shrink: 0; +} +.f-ico svg { width: 23px; height: 23px; } + +.folder-item .f-main { flex: 1; min-width: 0; } +.folder-item .f-name { + font-size: 15.5px; + font-weight: 600; + letter-spacing: -0.1px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.folder-item .f-meta { + font-size: 12.5px; + color: var(--text-2); + margin-top: 1px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.folder-item .f-actions { display: flex; gap: 2px; flex-shrink: 0; } + +.icon-btn { + width: 44px; + height: 44px; + border-radius: 50%; + background: transparent; + border: 0; + color: var(--text-2); + display: inline-flex; + align-items: center; + justify-content: center; + cursor: pointer; + transition: background var(--dur) var(--ease); +} +.icon-btn svg { width: 20px; height: 20px; } +.icon-btn:active { background: var(--bg-2); } +.icon-btn.danger { color: var(--danger); } + +.storage-line { + padding: 4px var(--pad) calc(20px + 4px); + font-size: 12.5px; + color: var(--text-2); + line-height: 1.7; + text-align: center; +} + +/* ── Gallery ─────────────────────────────────────────────── */ +.gallery-view { + display: flex; + flex-direction: column; + min-height: 100%; +} +.gallery-view .gallery-grid { flex: 1; align-content: start; } + +.gallery-grid { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 4px; + padding: 0 12px 12px; +} +.gallery-item { + position: relative; + aspect-ratio: 1; + border-radius: 10px; + overflow: hidden; + background: var(--card); + border: 0; + padding: 0; + cursor: pointer; + transition: transform var(--dur) var(--ease), filter var(--dur) var(--ease); +} +.gallery-item:active { transform: scale(0.96); filter: brightness(0.9); } +.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; } + +.action-bar { + position: sticky; + bottom: 0; + display: flex; + gap: 10px; + padding: 10px 16px calc(12px + 2px); + background: linear-gradient(to top, var(--bg) 62%, rgba(0, 0, 0, 0)); +} +.action-bar .btn { flex: 1; min-height: 52px; font-size: 14.5px; } + +/* ── Empty / notice ──────────────────────────────────────── */ +.empty { + text-align: center; + padding: 48px 28px; + color: var(--text-2); + font-size: 13.5px; +} +.empty .ico { + display: flex; + width: 64px; + height: 64px; + border-radius: 22px; + background: var(--card); + color: var(--text-2); + align-items: center; + justify-content: center; + margin: 0 auto 12px; + box-shadow: var(--shadow-card); +} +.empty .ico svg { width: 28px; height: 28px; } + +.notice { + margin: 12px var(--pad); + padding: 14px 16px; + border-radius: var(--radius-row); + background: var(--danger-soft); + color: var(--text); + font-size: 13px; + line-height: 1.6; +} +.notice b { display: block; margin-bottom: 4px; font-size: 13.5px; } +.notice ol { margin: 6px 0 0 18px; } +.notice code { + background: rgba(0, 0, 0, 0.06); + padding: 1px 5px; + border-radius: 5px; + font-size: 12px; +} + +/* ── Camera hero / permission ────────────────────────────── */ +.hero { + padding: 28px 26px; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 14px; + text-align: center; + height: 100%; + background: #000; + color: #F5F6F7; +} +.hero .ico { + width: 72px; + height: 72px; + border-radius: 24px; + background: #1B1B1D; + color: #A9AEB6; + display: inline-flex; + align-items: center; + justify-content: center; +} +.hero .ico svg { width: 34px; height: 34px; } +.hero.cover { position: absolute; inset: 0; z-index: 6; } +.hero h2 { font-size: 19px; font-weight: 700; letter-spacing: -0.2px; } +.hero p { font-size: 13.5px; color: #A9AEB6; line-height: 1.65; max-width: 300px; } +.hero .btn { min-height: 52px; padding: 0 26px; } +.hero.cover .notice { + max-width: 340px; + margin: 0; + text-align: left; + background: rgba(217, 48, 37, 0.16); + color: #FFD9D5; +} +.hero .notice code { background: rgba(255, 255, 255, 0.12); color: #F5F6F7; word-break: break-all; } +.hero .spinner { border-color: rgba(255, 255, 255, 0.18); border-top-color: #fff; } + +/* ── Bottom sheet (One UI) ───────────────────────────────── */ +.sheet-overlay { + position: fixed; + inset: 0; + z-index: 100; + background: rgba(0, 0, 0, 0.48); + display: flex; + align-items: flex-end; + justify-content: center; + animation: fade-in 160ms var(--ease); +} +.sheet-overlay[hidden] { display: none; } + +@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } } +@keyframes sheet-up { + from { transform: translateY(24px); opacity: 0.4; } + to { transform: none; opacity: 1; } +} + +.sheet { + position: relative; + background: var(--bg); + width: 100%; + max-width: 520px; + max-height: 88vh; + overflow-y: auto; + border-radius: 28px 28px 0 0; + padding: 26px var(--pad) calc(16px + var(--safe-bottom)); + box-shadow: var(--shadow-float); + animation: sheet-up 220ms var(--ease); +} +.sheet::before { + content: ""; + position: absolute; + top: 9px; + left: 50%; + transform: translateX(-50%); + width: 38px; + height: 4px; + border-radius: var(--radius-pill); + background: var(--text-3); + opacity: 0.5; +} +.sheet h3 { + font-size: 20px; + font-weight: 700; + letter-spacing: -0.3px; + margin-bottom: 4px; +} +.sheet .hint { + font-size: 12.5px; + color: var(--text-2); + margin-bottom: 14px; + line-height: 1.55; +} +.sheet img.preview { + width: 100%; + max-height: 44vh; + object-fit: contain; + border-radius: 18px; + background: #000; + margin-bottom: 12px; +} + +input[type="text"], input[type="search"] { + width: 100%; + min-height: 52px; + padding: 0 16px; + background: var(--card); + border: 2px solid transparent; + border-radius: var(--radius-field); + color: var(--text); + font-size: 16px; /* ≥16px กัน Chrome Android ซูม */ + font-family: inherit; + margin-bottom: 12px; + transition: border-color var(--dur) var(--ease); +} +input[type="text"]:focus, input[type="search"]:focus { + outline: none; + border-color: var(--accent); +} + +.sheet-actions { display: flex; gap: 10px; } +.sheet-actions .btn { flex: 1; min-height: 52px; } + +/* ── Metadata table (One UI list) ────────────────────────── */ +.meta-table { + font-size: 13.5px; + margin-top: 4px; + background: var(--card); + border-radius: var(--radius-row); + padding: 2px 16px; + box-shadow: var(--shadow-card); +} +.meta-table .row { + display: flex; + justify-content: space-between; + gap: 14px; + padding: 11px 0; + border-bottom: 1px solid var(--line); +} +.meta-table .row:last-child { border-bottom: 0; } +.meta-table .k { color: var(--text-2); flex-shrink: 0; } +.meta-table .v { text-align: right; word-break: break-word; font-weight: 500; } + +/* ── QR ──────────────────────────────────────────────────── */ +.qr-box { + background: #fff; + border-radius: 24px; + padding: 16px; + display: flex; + justify-content: center; + margin-bottom: 12px; +} +.qr-box canvas, .qr-box img { + width: 232px !important; + height: 232px !important; + display: block; +} +.qr-url { + font-size: 11.5px; + color: var(--text-2); + word-break: break-all; + text-align: center; + margin-bottom: 12px; + font-family: ui-monospace, Menlo, Consolas, monospace; +} + +/* ── Toast (One UI pill) ─────────────────────────────────── */ +#toast { + position: fixed; + left: 50%; + bottom: calc(88px + var(--safe-bottom)); + transform: translate(-50%, 10px); + max-width: 86vw; + background: #2A2A2D; + color: #F2F3F5; + padding: 11px 20px; + border-radius: var(--radius-pill); + font-size: 13.5px; + text-align: center; + z-index: 200; + opacity: 0; + pointer-events: none; + box-shadow: var(--shadow-float); + transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); +} +#toast.show { opacity: 1; transform: translate(-50%, 0); } + +/* ── Progress ────────────────────────────────────────────── */ +.progress-card { + display: flex; + flex-direction: column; + align-items: center; + gap: 14px; + padding: 18px 0 10px; +} +.spinner { + width: 36px; + height: 36px; + border: 3px solid var(--line); + border-top-color: var(--accent); + border-radius: 50%; + animation: spin 0.8s linear infinite; +} +@keyframes spin { to { transform: rotate(360deg); } } +.progress-card .label { font-size: 13.5px; color: var(--text-2); } + +/* ── Focus / reduced motion ──────────────────────────────── */ +:focus-visible { + outline: 2px solid var(--accent); + outline-offset: 2px; + border-radius: 8px; +} + +@media (prefers-reduced-motion: reduce) { + *, *::before, *::after { + animation-duration: 1ms !important; + animation-iteration-count: 1 !important; + transition-duration: 1ms !important; + } +} + +/* ── Landscape (S23 หมุนจอ 832×384) ──────────────────────── */ +@media (max-height: 560px) and (orientation: landscape) { + header { padding-top: calc(4px + var(--safe-top)); padding-bottom: 4px; } + header h1 { font-size: 19px; } + .head-sub { font-size: 12px; } + .cam-bottom { padding: 4px 16px 8px; } + .zoom-pills { min-height: 32px; margin-bottom: 2px; } + .zoom-pill { height: 30px; } + #shutter { width: 60px; height: 60px; box-shadow: 0 0 0 2px #FFFFFF; } + .thumb-btn { width: 42px; height: 42px; } + nav { padding: 4px 6px calc(4px + var(--safe-bottom)); } + nav button { min-height: 44px; font-size: 10.5px; padding: 2px; } + nav button .tab-ico { height: 24px; } + .section-head { padding: 8px var(--pad) 6px; } + .section-head h2 { font-size: 18px; } +} + +/* ── Tablet / จอกว้าง ───────────────────────────────────── */ +@media (min-width: 600px) { + :root { --pad: 28px; } + .sheet { border-radius: 28px; margin-bottom: 12px; } + .sheet-overlay { align-items: center; } + .gallery-grid { grid-template-columns: repeat(4, 1fr); } +} diff --git a/app/index.html b/app/index.html index 7aeeee8..ac20de5 100644 --- a/app/index.html +++ b/app/index.html @@ -1,203 +1,66 @@ - + - - + + + + + - + -CamCat — Camera Folder Organizer - + +CamCat — ถ่ายรูปแยกโฟลเดอร์
-

📷 CamCat

-
📁 Default
+
+

CamCat

+ +
+
+ + +
-
+
-
- -`; + } + + html += ``; + + html += `
+ + +
`; + return html; +} + +// ── Photo sheet ── +export function photoSheet({ record, url, folderName }) { + const m = record.meta || {}; + const rows = [ + ["ไฟล์", record.name || "-"], + ["ขนาด", fmtBytes(record.size || record.blob?.size || 0)], + ["ความละเอียด", m.width && m.height ? `${m.width} × ${m.height} (${(m.width * m.height / 1e6).toFixed(1)} MP)` : "—"], + ["ถ่ายเมื่อ", humanDateTime(record.createdAt)], + ["โฟลเดอร์", folderName || "-"], + ["อุปกรณ์", m.device || "—"], + ["กล้อง", m.facingLabel || "—"], + ["ที่มาไฟล์", m.sourceLabel || "—"], + ]; + if (m.gps) rows.push(["พิกัด GPS", `${m.gps.lat.toFixed(6)}, ${m.gps.lng.toFixed(6)}${m.gps.accuracy ? ` (±${Math.round(m.gps.accuracy)} ม.)` : ""}`]); + if (m.exif && (m.exif.fNumber || m.exif.iso || m.exif.exposureTime)) rows.push(["ค่าแสง EXIF", formatExposure(m.exif)]); + if (m.exif?.model) { + const make = (m.exif.make || "").trim(); + const model = m.exif.model.trim(); + const label = make && !model.toLowerCase().startsWith(make.toLowerCase()) ? `${make} ${model}` : model; + rows.push(["รุ่นใน EXIF", label]); + } + if (m.exif?.orientation) rows.push(["Orientation", String(m.exif.orientation)]); + if (m.exif?.dateTimeOriginal) rows.push(["EXIF DateTimeOriginal", m.exif.dateTimeOriginal]); + + const rowsHtml = rows + .map(([k, v]) => `
${esc(k)}${esc(v)}
`) + .join(""); + + return ` +

${esc(record.name || "รูปภาพ")}

+
${esc(humanDateTime(record.createdAt))}
+ +
${rowsHtml}
+
+ + +
+
+ +
`; +} + +// ── Folder sheet ── +export function folderSheet(mode, { id = "", name = "", suggested = "", count = 0 }) { + if (mode === "delete") { + return `

ลบโฟลเดอร์นี้?

+
"${esc(name)}" · ${count} รูป จะถูกลบทั้งหมดและกู้คืนไม่ได้
+
+ + +
`; + } + const isNew = mode === "new"; + return `

${isNew ? "โฟลเดอร์ใหม่" : "เปลี่ยนชื่อโฟลเดอร์"}

+
ชื่อเริ่มต้นอิงวันที่ไทย (พ.ศ.) ของวันนี้ — แก้ไขได้
+ + ${isNew ? `
ถ้าชื่อซ้ำ ระบบจะเติม (2) ให้อัตโนมัติ
` : ""} +
+ + +
`; +} + +// ── QR ลิงก์ทดสอบบนมือถือ ──────────────────────────── +export function qrSheet(url) { + return `

ทดสอบบนมือถือ

+
สแกนด้วยกล้อง Samsung S23 แล้วเปิดใน Chrome
+
+
${esc(url)}
+
กล้องใช้ได้เฉพาะหน้า HTTPS — ถ้าลิงก์ขึ้นต้น http:// กล้องจะถูกบล็อก
+
+ + +
`; + } + +// ── Diagnostics ── +export function diagnosticsSheet(rows) { + const body = rows + .map(([k, v]) => `
${esc(k)}${esc(v)}
`) + .join(""); + return `

ข้อมูลอุปกรณ์และกล้อง

+
ใช้ตรวจว่ารันบน S23 จริงและกล้องได้ความละเอียดเท่าไร
+
${body}
+
+ +
`; +} + +// ── Progress ── +export function progressSheet(label) { + openSheet(`
+
+
${esc(label)}
+
`); +} + +export function progressUpdate(pct, label) { + const card = document.getElementById("progress-card"); + if (!card) return; + const p = Math.max(0, Math.min(100, Math.round(pct))); + card.innerHTML = `
${esc(label || "")} ${p}%
`; +} diff --git a/app/manifest.json b/app/manifest.json index 7c70a46..e14be3f 100644 --- a/app/manifest.json +++ b/app/manifest.json @@ -1,27 +1,35 @@ { - "name": "Web Camera Category", + "id": "./", + "name": "CamCat — ถ่ายรูปแยกโฟลเดอร์", "short_name": "CamCat", - "description": "Take photos, organize into folders, zip & share — Progressive Web App", - "start_url": "/", + "description": "ถ่ายรูปด้วยกล้องมือถือ แยกโฟลเดอร์ตามไซต์ พร้อม EXIF/GPS, ZIP ทั้งโฟลเดอร์ และแชร์ผ่านระบบของเครื่อง", + "start_url": "./", + "scope": "./", "display": "standalone", + "display_override": ["standalone", "fullscreen"], "orientation": "portrait", - "background_color": "#0F172A", - "theme_color": "#7C83FF", + "background_color": "#F2F3F5", + "theme_color": "#F2F3F5", + "lang": "th", + "dir": "ltr", + "categories": ["photography", "productivity", "utilities"], "icons": [ + { "src": "icon-192.png", "sizes": "192x192", "type": "image/png", "purpose": "any" }, + { "src": "icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any" }, + { "src": "icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" } + ], + "shortcuts": [ { - "src": "icon-192.png", - "sizes": "192x192", - "type": "image/png", - "purpose": "any maskable" + "name": "ถ่ายรูป", + "short_name": "กล้อง", + "url": "./?view=camera", + "icons": [{ "src": "icon-192.png", "sizes": "192x192" }] }, { - "src": "icon-512.png", - "sizes": "512x512", - "type": "image/png", - "purpose": "any maskable" + "name": "รูปในโฟลเดอร์", + "short_name": "รูปภาพ", + "url": "./?view=gallery", + "icons": [{ "src": "icon-192.png", "sizes": "192x192" }] } - ], - "categories": ["photography", "utilities"], - "lang": "en", - "dir": "ltr" + ] } diff --git a/app/sw.js b/app/sw.js index cfed702..e435eb6 100644 --- a/app/sw.js +++ b/app/sw.js @@ -1,45 +1,77 @@ -// Service Worker — Web Camera Category PWA -// Caches app shell for offline use +// Service Worker — CamCat 2.0 +// กลยุทธ์: navigation = network-first (ได้เวอร์ชันใหม่ก่อน) · asset = stale-while-revalidate +const CACHE = "camcat-v2.1.1"; -const CACHE_NAME = "camcat-v1"; -const APP_SHELL = [ - "/", - "/index.html", - "/manifest.json", - "/icon-192.png", - "/icon-512.png", - "https://cdn.jsdelivr.net/npm/jszip@3.10.1/dist/jszip.min.js", +const ASSETS = [ + "./", + "./index.html", + "./manifest.json", + "./css/app.css", + "./js/config.js", + "./js/naming.js", + "./js/db.js", + "./js/exif.js", + "./js/device.js", + "./js/camera.js", + "./js/archive.js", + "./js/ui.js", + "./js/main.js", + "./vendor/jszip.min.js", + "./vendor/piexif.js", + "./vendor/qrcode.min.js", + "./icon-192.png", + "./icon-512.png", ]; -// ── Install: cache app shell ── self.addEventListener("install", (e) => { e.waitUntil( - caches.open(CACHE_NAME).then((cache) => cache.addAll(APP_SHELL)).then(() => self.skipWaiting()) + caches.open(CACHE) + .then((c) => Promise.allSettled(ASSETS.map((u) => c.add(new Request(u, { cache: "reload" }))))) + .then(() => self.skipWaiting()) ); }); -// ── Activate: clean old caches ── self.addEventListener("activate", (e) => { e.waitUntil( - caches.keys().then((keys) => - Promise.all(keys.filter((k) => k !== CACHE_NAME).map((k) => caches.delete(k))) - ).then(() => self.clients.claim()) + caches.keys() + .then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))) + .then(() => self.clients.claim()) ); }); -// ── Fetch: cache-first for app shell, network-first for photos ── self.addEventListener("fetch", (e) => { - const url = new URL(e.request.url); - // Don't intercept non-GET - if (e.request.method !== "GET") return; - // Cache-first for same-origin - if (url.origin === self.location.origin) { + const req = e.request; + if (req.method !== "GET") return; + const url = new URL(req.url); + if (url.origin !== self.location.origin) return; + + // หน้าเว็บ: เอาจากเครือข่ายก่อน ถ้าออฟไลน์ค่อยใช้แคช + if (req.mode === "navigate") { e.respondWith( - caches.match(e.request).then((cached) => cached || fetch(e.request).then((resp) => { - const clone = resp.clone(); - caches.open(CACHE_NAME).then((c) => c.put(e.request, clone)); - return resp; - }).catch(() => caches.match("/index.html"))) + fetch(req) + .then((resp) => { + const clone = resp.clone(); + caches.open(CACHE).then((c) => c.put(req, clone)); + return resp; + }) + .catch(() => caches.match(req).then((r) => r || caches.match("./index.html"))) ); + return; } + + // ไฟล์อื่น: คืนแคชทันที + อัปเดตเบื้องหลัง + e.respondWith( + caches.match(req).then((cached) => { + const network = fetch(req) + .then((resp) => { + if (resp && resp.ok) { + const clone = resp.clone(); + caches.open(CACHE).then((c) => c.put(req, clone)); + } + return resp; + }) + .catch(() => cached); + return cached || network; + }) + ); }); diff --git a/app/vendor/jszip.min.js b/app/vendor/jszip.min.js new file mode 100644 index 0000000..ff4cfd5 --- /dev/null +++ b/app/vendor/jszip.min.js @@ -0,0 +1,13 @@ +/*! + +JSZip v3.10.1 - A JavaScript class for generating and reading zip files + + +(c) 2009-2016 Stuart Knightley +Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. + +JSZip uses the library pako released under the MIT license : +https://github.com/nodeca/pako/blob/main/LICENSE +*/ + +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).JSZip=e()}}(function(){return function s(a,o,h){function u(r,e){if(!o[r]){if(!a[r]){var t="function"==typeof require&&require;if(!e&&t)return t(r,!0);if(l)return l(r,!0);var n=new Error("Cannot find module '"+r+"'");throw n.code="MODULE_NOT_FOUND",n}var i=o[r]={exports:{}};a[r][0].call(i.exports,function(e){var t=a[r][1][e];return u(t||e)},i,i.exports,s,a,o,h)}return o[r].exports}for(var l="function"==typeof require&&require,e=0;e>2,s=(3&t)<<4|r>>4,a=1>6:64,o=2>4,r=(15&i)<<4|(s=p.indexOf(e.charAt(o++)))>>2,n=(3&s)<<6|(a=p.indexOf(e.charAt(o++))),l[h++]=t,64!==s&&(l[h++]=r),64!==a&&(l[h++]=n);return l}},{"./support":30,"./utils":32}],2:[function(e,t,r){"use strict";var n=e("./external"),i=e("./stream/DataWorker"),s=e("./stream/Crc32Probe"),a=e("./stream/DataLengthProbe");function o(e,t,r,n,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=r,this.compression=n,this.compressedContent=i}o.prototype={getContentWorker:function(){var e=new i(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a("data_length")),t=this;return e.on("end",function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),e},getCompressedWorker:function(){return new i(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},o.createWorkerFrom=function(e,t,r){return e.pipe(new s).pipe(new a("uncompressedSize")).pipe(t.compressWorker(r)).pipe(new a("compressedSize")).withStreamInfo("compression",t)},t.exports=o},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,r){"use strict";var n=e("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},r.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,r){"use strict";var n=e("./utils");var o=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==n.getTypeOf(e)?function(e,t,r,n){var i=o,s=n+r;e^=-1;for(var a=n;a>>8^i[255&(e^t[a])];return-1^e}(0|t,e,e.length,0):function(e,t,r,n){var i=o,s=n+r;e^=-1;for(var a=n;a>>8^i[255&(e^t.charCodeAt(a))];return-1^e}(0|t,e,e.length,0):0}},{"./utils":32}],5:[function(e,t,r){"use strict";r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(e,t,r){"use strict";var n=null;n="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:n}},{lie:37}],7:[function(e,t,r){"use strict";var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,i=e("pako"),s=e("./utils"),a=e("./stream/GenericWorker"),o=n?"uint8array":"array";function h(e,t){a.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}r.magic="\b\0",s.inherits(h,a),h.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(s.transformTo(o,e.data),!1)},h.prototype.flush=function(){a.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},h.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this._pako=null},h.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var t=this;this._pako.onData=function(e){t.push({data:e,meta:t.meta})}},r.compressWorker=function(e){return new h("Deflate",e)},r.uncompressWorker=function(){return new h("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,r){"use strict";function A(e,t){var r,n="";for(r=0;r>>=8;return n}function n(e,t,r,n,i,s){var a,o,h=e.file,u=e.compression,l=s!==O.utf8encode,f=I.transformTo("string",s(h.name)),c=I.transformTo("string",O.utf8encode(h.name)),d=h.comment,p=I.transformTo("string",s(d)),m=I.transformTo("string",O.utf8encode(d)),_=c.length!==h.name.length,g=m.length!==d.length,b="",v="",y="",w=h.dir,k=h.date,x={crc32:0,compressedSize:0,uncompressedSize:0};t&&!r||(x.crc32=e.crc32,x.compressedSize=e.compressedSize,x.uncompressedSize=e.uncompressedSize);var S=0;t&&(S|=8),l||!_&&!g||(S|=2048);var z=0,C=0;w&&(z|=16),"UNIX"===i?(C=798,z|=function(e,t){var r=e;return e||(r=t?16893:33204),(65535&r)<<16}(h.unixPermissions,w)):(C=20,z|=function(e){return 63&(e||0)}(h.dosPermissions)),a=k.getUTCHours(),a<<=6,a|=k.getUTCMinutes(),a<<=5,a|=k.getUTCSeconds()/2,o=k.getUTCFullYear()-1980,o<<=4,o|=k.getUTCMonth()+1,o<<=5,o|=k.getUTCDate(),_&&(v=A(1,1)+A(B(f),4)+c,b+="up"+A(v.length,2)+v),g&&(y=A(1,1)+A(B(p),4)+m,b+="uc"+A(y.length,2)+y);var E="";return E+="\n\0",E+=A(S,2),E+=u.magic,E+=A(a,2),E+=A(o,2),E+=A(x.crc32,4),E+=A(x.compressedSize,4),E+=A(x.uncompressedSize,4),E+=A(f.length,2),E+=A(b.length,2),{fileRecord:R.LOCAL_FILE_HEADER+E+f+b,dirRecord:R.CENTRAL_FILE_HEADER+A(C,2)+E+A(p.length,2)+"\0\0\0\0"+A(z,4)+A(n,4)+f+b+p}}var I=e("../utils"),i=e("../stream/GenericWorker"),O=e("../utf8"),B=e("../crc32"),R=e("../signature");function s(e,t,r,n){i.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=r,this.encodeFileName=n,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}I.inherits(s,i),s.prototype.push=function(e){var t=e.meta.percent||0,r=this.entriesCount,n=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,i.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:r?(t+100*(r-n-1))/r:100}}))},s.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var r=n(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0},s.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,r=n(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),t)this.push({data:function(e){return R.DATA_DESCRIPTOR+A(e.crc32,4)+A(e.compressedSize,4)+A(e.uncompressedSize,4)}(e),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},s.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t=this.index;t--)r=(r<<8)+this.byteAt(t);return this.index+=e,r},readString:function(e){return n.transformTo("string",this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i},{"../utils":32}],19:[function(e,t,r){"use strict";var n=e("./Uint8ArrayReader");function i(e){n.call(this,e)}e("../utils").inherits(i,n),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,r){"use strict";var n=e("./DataReader");function i(e){n.call(this,e)}e("../utils").inherits(i,n),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],21:[function(e,t,r){"use strict";var n=e("./ArrayReader");function i(e){n.call(this,e)}e("../utils").inherits(i,n),i.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,r){"use strict";var n=e("../utils"),i=e("../support"),s=e("./ArrayReader"),a=e("./StringReader"),o=e("./NodeBufferReader"),h=e("./Uint8ArrayReader");t.exports=function(e){var t=n.getTypeOf(e);return n.checkSupport(t),"string"!==t||i.uint8array?"nodebuffer"===t?new o(e):i.uint8array?new h(n.transformTo("uint8array",e)):new s(n.transformTo("array",e)):new a(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,r){"use strict";r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,r){"use strict";var n=e("./GenericWorker"),i=e("../utils");function s(e){n.call(this,"ConvertWorker to "+e),this.destType=e}i.inherits(s,n),s.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta})},t.exports=s},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,r){"use strict";var n=e("./GenericWorker"),i=e("../crc32");function s(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(s,n),s.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=s},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,r){"use strict";var n=e("../utils"),i=e("./GenericWorker");function s(e){i.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}n.inherits(s,i),s.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}i.prototype.processChunk.call(this,e)},t.exports=s},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,r){"use strict";var n=e("../utils"),i=e("./GenericWorker");function s(e){i.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then(function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=n.getTypeOf(e),t.isPaused||t._tickAndRepeat()},function(e){t.error(e)})}n.inherits(s,i),s.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},s.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0)},s.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},s.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=s},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,r){"use strict";function n(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}n.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var r=0;r "+e:e}},t.exports=n},{}],29:[function(e,t,r){"use strict";var h=e("../utils"),i=e("./ConvertWorker"),s=e("./GenericWorker"),u=e("../base64"),n=e("../support"),a=e("../external"),o=null;if(n.nodestream)try{o=e("../nodejs/NodejsStreamOutputAdapter")}catch(e){}function l(e,o){return new a.Promise(function(t,r){var n=[],i=e._internalType,s=e._outputType,a=e._mimeType;e.on("data",function(e,t){n.push(e),o&&o(t)}).on("error",function(e){n=[],r(e)}).on("end",function(){try{var e=function(e,t,r){switch(e){case"blob":return h.newBlob(h.transformTo("arraybuffer",t),r);case"base64":return u.encode(t);default:return h.transformTo(e,t)}}(s,function(e,t){var r,n=0,i=null,s=0;for(r=0;r>>6:(r<65536?t[s++]=224|r>>>12:(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63),t[s++]=128|r>>>6&63),t[s++]=128|63&r);return t}(e)},s.utf8decode=function(e){return h.nodebuffer?o.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,r,n,i,s=e.length,a=new Array(2*s);for(t=r=0;t>10&1023,a[r++]=56320|1023&n)}return a.length!==r&&(a.subarray?a=a.subarray(0,r):a.length=r),o.applyFromCharCode(a)}(e=o.transformTo(h.uint8array?"uint8array":"array",e))},o.inherits(a,n),a.prototype.processChunk=function(e){var t=o.transformTo(h.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(h.uint8array){var r=t;(t=new Uint8Array(r.length+this.leftOver.length)).set(this.leftOver,0),t.set(r,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var n=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+u[e[r]]>t?r:t}(t),i=t;n!==t.length&&(h.uint8array?(i=t.subarray(0,n),this.leftOver=t.subarray(n,t.length)):(i=t.slice(0,n),this.leftOver=t.slice(n,t.length))),this.push({data:s.utf8decode(i),meta:e.meta})},a.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},s.Utf8DecodeWorker=a,o.inherits(l,n),l.prototype.processChunk=function(e){this.push({data:s.utf8encode(e.data),meta:e.meta})},s.Utf8EncodeWorker=l},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,a){"use strict";var o=e("./support"),h=e("./base64"),r=e("./nodejsUtils"),u=e("./external");function n(e){return e}function l(e,t){for(var r=0;r>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=n(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t,r,n,i=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4>>6:(r<65536?t[s++]=224|r>>>12:(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63),t[s++]=128|r>>>6&63),t[s++]=128|63&r);return t},r.buf2binstring=function(e){return l(e,e.length)},r.binstring2buf=function(e){for(var t=new h.Buf8(e.length),r=0,n=t.length;r>10&1023,o[n++]=56320|1023&i)}return l(o,n)},r.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0?t:0===r?t:r+u[e[r]]>t?r:t}},{"./common":41}],43:[function(e,t,r){"use strict";t.exports=function(e,t,r,n){for(var i=65535&e|0,s=e>>>16&65535|0,a=0;0!==r;){for(r-=a=2e3>>1:e>>>1;t[r]=e}return t}();t.exports=function(e,t,r,n){var i=o,s=n+r;e^=-1;for(var a=n;a>>8^i[255&(e^t[a])];return-1^e}},{}],46:[function(e,t,r){"use strict";var h,c=e("../utils/common"),u=e("./trees"),d=e("./adler32"),p=e("./crc32"),n=e("./messages"),l=0,f=4,m=0,_=-2,g=-1,b=4,i=2,v=8,y=9,s=286,a=30,o=19,w=2*s+1,k=15,x=3,S=258,z=S+x+1,C=42,E=113,A=1,I=2,O=3,B=4;function R(e,t){return e.msg=n[t],t}function T(e){return(e<<1)-(4e.avail_out&&(r=e.avail_out),0!==r&&(c.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function N(e,t){u._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,F(e.strm)}function U(e,t){e.pending_buf[e.pending++]=t}function P(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function L(e,t){var r,n,i=e.max_chain_length,s=e.strstart,a=e.prev_length,o=e.nice_match,h=e.strstart>e.w_size-z?e.strstart-(e.w_size-z):0,u=e.window,l=e.w_mask,f=e.prev,c=e.strstart+S,d=u[s+a-1],p=u[s+a];e.prev_length>=e.good_match&&(i>>=2),o>e.lookahead&&(o=e.lookahead);do{if(u[(r=t)+a]===p&&u[r+a-1]===d&&u[r]===u[s]&&u[++r]===u[s+1]){s+=2,r++;do{}while(u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&sh&&0!=--i);return a<=e.lookahead?a:e.lookahead}function j(e){var t,r,n,i,s,a,o,h,u,l,f=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=f+(f-z)){for(c.arraySet(e.window,e.window,f,f,0),e.match_start-=f,e.strstart-=f,e.block_start-=f,t=r=e.hash_size;n=e.head[--t],e.head[t]=f<=n?n-f:0,--r;);for(t=r=f;n=e.prev[--t],e.prev[t]=f<=n?n-f:0,--r;);i+=f}if(0===e.strm.avail_in)break;if(a=e.strm,o=e.window,h=e.strstart+e.lookahead,u=i,l=void 0,l=a.avail_in,u=x)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=(e.ins_h<=x&&(e.ins_h=(e.ins_h<=x)if(n=u._tr_tally(e,e.strstart-e.match_start,e.match_length-x),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=x){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<=x&&(e.ins_h=(e.ins_h<=x&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-x,n=u._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-x),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(j(e),0===e.lookahead&&t===l)return A;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,N(e,!1),0===e.strm.avail_out))return A;if(e.strstart-e.block_start>=e.w_size-z&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=0,t===f?(N(e,!0),0===e.strm.avail_out?O:B):(e.strstart>e.block_start&&(N(e,!1),e.strm.avail_out),A)}),new M(4,4,8,4,Z),new M(4,5,16,8,Z),new M(4,6,32,32,Z),new M(4,4,16,16,W),new M(8,16,32,32,W),new M(8,16,128,128,W),new M(8,32,128,256,W),new M(32,128,258,1024,W),new M(32,258,258,4096,W)],r.deflateInit=function(e,t){return Y(e,t,v,15,8,0)},r.deflateInit2=Y,r.deflateReset=K,r.deflateResetKeep=G,r.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?_:(e.state.gzhead=t,m):_},r.deflate=function(e,t){var r,n,i,s;if(!e||!e.state||5>8&255),U(n,n.gzhead.time>>16&255),U(n,n.gzhead.time>>24&255),U(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),U(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(U(n,255&n.gzhead.extra.length),U(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=p(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(U(n,0),U(n,0),U(n,0),U(n,0),U(n,0),U(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),U(n,3),n.status=E);else{var a=v+(n.w_bits-8<<4)<<8;a|=(2<=n.strategy||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(a|=32),a+=31-a%31,n.status=E,P(n,a),0!==n.strstart&&(P(n,e.adler>>>16),P(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),F(e),i=n.pending,n.pending!==n.pending_buf_size));)U(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),F(e),i=n.pending,n.pending===n.pending_buf_size)){s=1;break}s=n.gzindexi&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),0===s&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),F(e),i=n.pending,n.pending===n.pending_buf_size)){s=1;break}s=n.gzindexi&&(e.adler=p(e.adler,n.pending_buf,n.pending-i,i)),0===s&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&F(e),n.pending+2<=n.pending_buf_size&&(U(n,255&e.adler),U(n,e.adler>>8&255),e.adler=0,n.status=E)):n.status=E),0!==n.pending){if(F(e),0===e.avail_out)return n.last_flush=-1,m}else if(0===e.avail_in&&T(t)<=T(r)&&t!==f)return R(e,-5);if(666===n.status&&0!==e.avail_in)return R(e,-5);if(0!==e.avail_in||0!==n.lookahead||t!==l&&666!==n.status){var o=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(j(e),0===e.lookahead)){if(t===l)return A;break}if(e.match_length=0,r=u._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=0,t===f?(N(e,!0),0===e.strm.avail_out?O:B):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?A:I}(n,t):3===n.strategy?function(e,t){for(var r,n,i,s,a=e.window;;){if(e.lookahead<=S){if(j(e),e.lookahead<=S&&t===l)return A;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=x&&0e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=x?(r=u._tr_tally(e,1,e.match_length-x),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=u._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(N(e,!1),0===e.strm.avail_out))return A}return e.insert=0,t===f?(N(e,!0),0===e.strm.avail_out?O:B):e.last_lit&&(N(e,!1),0===e.strm.avail_out)?A:I}(n,t):h[n.level].func(n,t);if(o!==O&&o!==B||(n.status=666),o===A||o===O)return 0===e.avail_out&&(n.last_flush=-1),m;if(o===I&&(1===t?u._tr_align(n):5!==t&&(u._tr_stored_block(n,0,0,!1),3===t&&(D(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),F(e),0===e.avail_out))return n.last_flush=-1,m}return t!==f?m:n.wrap<=0?1:(2===n.wrap?(U(n,255&e.adler),U(n,e.adler>>8&255),U(n,e.adler>>16&255),U(n,e.adler>>24&255),U(n,255&e.total_in),U(n,e.total_in>>8&255),U(n,e.total_in>>16&255),U(n,e.total_in>>24&255)):(P(n,e.adler>>>16),P(n,65535&e.adler)),F(e),0=r.w_size&&(0===s&&(D(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new c.Buf8(r.w_size),c.arraySet(u,t,l-r.w_size,r.w_size,0),t=u,l=r.w_size),a=e.avail_in,o=e.next_in,h=e.input,e.avail_in=l,e.next_in=0,e.input=t,j(r);r.lookahead>=x;){for(n=r.strstart,i=r.lookahead-(x-1);r.ins_h=(r.ins_h<>>=y=v>>>24,p-=y,0===(y=v>>>16&255))C[s++]=65535&v;else{if(!(16&y)){if(0==(64&y)){v=m[(65535&v)+(d&(1<>>=y,p-=y),p<15&&(d+=z[n++]<>>=y=v>>>24,p-=y,!(16&(y=v>>>16&255))){if(0==(64&y)){v=_[(65535&v)+(d&(1<>>=y,p-=y,(y=s-a)>3,d&=(1<<(p-=w<<3))-1,e.next_in=n,e.next_out=s,e.avail_in=n>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function s(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new I.Buf16(320),this.work=new I.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function a(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=P,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new I.Buf32(n),t.distcode=t.distdyn=new I.Buf32(i),t.sane=1,t.back=-1,N):U}function o(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,a(e)):U}function h(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15=s.wsize?(I.arraySet(s.window,t,r-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(n<(i=s.wsize-s.wnext)&&(i=n),I.arraySet(s.window,t,r-n,i,s.wnext),(n-=i)?(I.arraySet(s.window,t,r-n,n,0),s.wnext=n,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave>>8&255,r.check=B(r.check,E,2,0),l=u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=30;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=30;break}if(l-=4,k=8+(15&(u>>>=4)),0===r.wbits)r.wbits=k;else if(k>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<>8&1),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0)),l=u=0,r.mode=3;case 3:for(;l<32;){if(0===o)break e;o--,u+=n[s++]<>>8&255,E[2]=u>>>16&255,E[3]=u>>>24&255,r.check=B(r.check,E,4,0)),l=u=0,r.mode=4;case 4:for(;l<16;){if(0===o)break e;o--,u+=n[s++]<>8),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0)),l=u=0,r.mode=5;case 5:if(1024&r.flags){for(;l<16;){if(0===o)break e;o--,u+=n[s++]<>>8&255,r.check=B(r.check,E,2,0)),l=u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(o<(d=r.length)&&(d=o),d&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),I.arraySet(r.head.extra,n,s,d,k)),512&r.flags&&(r.check=B(r.check,n,d,s)),o-=d,s+=d,r.length-=d),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===o)break e;for(d=0;k=n[s+d++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k)),k&&d>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;l<32;){if(0===o)break e;o--,u+=n[s++]<>>=7&l,l-=7&l,r.mode=27;break}for(;l<3;){if(0===o)break e;o--,u+=n[s++]<>>=1)){case 0:r.mode=14;break;case 1:if(j(r),r.mode=20,6!==t)break;u>>>=2,l-=2;break e;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}u>>>=2,l-=2;break;case 14:for(u>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,u+=n[s++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&u,l=u=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(d=r.length){if(o>>=5,l-=5,r.ndist=1+(31&u),u>>>=5,l-=5,r.ncode=4+(15&u),u>>>=4,l-=4,286>>=3,l-=3}for(;r.have<19;)r.lens[A[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},x=T(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,x){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>>=_,l-=_,r.lens[r.have++]=b;else{if(16===b){for(z=_+2;l>>=_,l-=_,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}k=r.lens[r.have-1],d=3+(3&u),u>>>=2,l-=2}else if(17===b){for(z=_+3;l>>=_)),u>>>=3,l-=3}else{for(z=_+7;l>>=_)),u>>>=7,l-=7}if(r.have+d>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;d--;)r.lens[r.have++]=k}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,S={bits:r.lenbits},x=T(D,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,x){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},x=T(F,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,x){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(6<=o&&258<=h){e.next_out=a,e.avail_out=h,e.next_in=s,e.avail_in=o,r.hold=u,r.bits=l,R(e,c),a=e.next_out,i=e.output,h=e.avail_out,s=e.next_in,n=e.input,o=e.avail_in,u=r.hold,l=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;g=(C=r.lencode[u&(1<>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>v)])>>>16&255,b=65535&C,!(v+(_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>>=v,l-=v,r.back+=v}if(u>>>=_,l-=_,r.back+=_,r.length=b,0===g){r.mode=26;break}if(32&g){r.back=-1,r.mode=12;break}if(64&g){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&g,r.mode=22;case 22:if(r.extra){for(z=r.extra;l>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;g=(C=r.distcode[u&(1<>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>v)])>>>16&255,b=65535&C,!(v+(_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>>=v,l-=v,r.back+=v}if(u>>>=_,l-=_,r.back+=_,64&g){e.msg="invalid distance code",r.mode=30;break}r.offset=b,r.extra=15&g,r.mode=24;case 24:if(r.extra){for(z=r.extra;l>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===h)break e;if(d=c-h,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}p=d>r.wnext?(d-=r.wnext,r.wsize-d):r.wnext-d,d>r.length&&(d=r.length),m=r.window}else m=i,p=a-r.offset,d=r.length;for(hd?(m=R[T+a[v]],A[I+a[v]]):(m=96,0),h=1<>S)+(u-=h)]=p<<24|m<<16|_|0,0!==u;);for(h=1<>=1;if(0!==h?(E&=h-1,E+=h):E=0,v++,0==--O[b]){if(b===w)break;b=t[r+a[v]]}if(k>>7)]}function U(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function P(e,t,r){e.bi_valid>d-r?(e.bi_buf|=t<>d-e.bi_valid,e.bi_valid+=r-d):(e.bi_buf|=t<>>=1,r<<=1,0<--t;);return r>>>1}function Z(e,t,r){var n,i,s=new Array(g+1),a=0;for(n=1;n<=g;n++)s[n]=a=a+r[n-1]<<1;for(i=0;i<=t;i++){var o=e[2*i+1];0!==o&&(e[2*i]=j(s[o]++,o))}}function W(e){var t;for(t=0;t>1;1<=r;r--)G(e,s,r);for(i=h;r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],G(e,s,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,s[2*i]=s[2*r]+s[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,s[2*r+1]=s[2*n+1]=i,e.heap[1]=i++,G(e,s,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,s,a,o,h=t.dyn_tree,u=t.max_code,l=t.stat_desc.static_tree,f=t.stat_desc.has_stree,c=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,p=t.stat_desc.max_length,m=0;for(s=0;s<=g;s++)e.bl_count[s]=0;for(h[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<_;r++)p<(s=h[2*h[2*(n=e.heap[r])+1]+1]+1)&&(s=p,m++),h[2*n+1]=s,u>=7;n>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return o;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return h;for(t=32;t>>3,(s=e.static_len+3+7>>>3)<=i&&(i=s)):i=s=r+5,r+4<=i&&-1!==t?J(e,t,r,n):4===e.strategy||s===i?(P(e,2+(n?1:0),3),K(e,z,C)):(P(e,4+(n?1:0),3),function(e,t,r,n){var i;for(P(e,t-257,5),P(e,r-1,5),P(e,n-4,4),i=0;i>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(A[r]+u+1)]++,e.dyn_dtree[2*N(t)]++),e.last_lit===e.lit_bufsize-1},r._tr_align=function(e){P(e,2,3),L(e,m,z),function(e){16===e.bi_valid?(U(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":41}],53:[function(e,t,r){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,r){(function(e){!function(r,n){"use strict";if(!r.setImmediate){var i,s,t,a,o=1,h={},u=!1,l=r.document,e=Object.getPrototypeOf&&Object.getPrototypeOf(r);e=e&&e.setTimeout?e:r,i="[object process]"==={}.toString.call(r.process)?function(e){process.nextTick(function(){c(e)})}:function(){if(r.postMessage&&!r.importScripts){var e=!0,t=r.onmessage;return r.onmessage=function(){e=!1},r.postMessage("","*"),r.onmessage=t,e}}()?(a="setImmediate$"+Math.random()+"$",r.addEventListener?r.addEventListener("message",d,!1):r.attachEvent("onmessage",d),function(e){r.postMessage(a+e,"*")}):r.MessageChannel?((t=new MessageChannel).port1.onmessage=function(e){c(e.data)},function(e){t.port2.postMessage(e)}):l&&"onreadystatechange"in l.createElement("script")?(s=l.documentElement,function(e){var t=l.createElement("script");t.onreadystatechange=function(){c(e),t.onreadystatechange=null,s.removeChild(t),t=null},s.appendChild(t)}):function(e){setTimeout(c,0,e)},e.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;rH", [exif.length + 2]) + exif; + var segments = splitIntoSegments(jpeg); + var new_data = mergeSegments(segments, exifStr); + if (b64) { + new_data = "data:image/jpeg;base64," + btoa(new_data); + } + + return new_data; + }; + + + that.load = function (data) { + var input_data; + if (typeof (data) == "string") { + if (data.slice(0, 2) == "\xff\xd8") { + input_data = data; + } else if (data.slice(0, 23) == "data:image/jpeg;base64," || data.slice(0, 22) == "data:image/jpg;base64,") { + input_data = atob(data.split(",")[1]); + } else if (data.slice(0, 4) == "Exif") { + input_data = data.slice(6); + } else { + throw new Error("'load' gots invalid file data."); + } + } else { + throw new Error("'load' gots invalid type argument."); + } + + var exifDict = {}; + var exif_dict = { + "0th": {}, + "Exif": {}, + "GPS": {}, + "Interop": {}, + "1st": {}, + "thumbnail": null + }; + var exifReader = new ExifReader(input_data); + if (exifReader.tiftag === null) { + return exif_dict; + } + + if (exifReader.tiftag.slice(0, 2) == "\x49\x49") { + exifReader.endian_mark = "<"; + } else { + exifReader.endian_mark = ">"; + } + + var pointer = unpack(exifReader.endian_mark + "L", + exifReader.tiftag.slice(4, 8))[0]; + exif_dict["0th"] = exifReader.get_ifd(pointer, "0th"); + + var first_ifd_pointer = exif_dict["0th"]["first_ifd_pointer"]; + delete exif_dict["0th"]["first_ifd_pointer"]; + + if (34665 in exif_dict["0th"]) { + pointer = exif_dict["0th"][34665]; + exif_dict["Exif"] = exifReader.get_ifd(pointer, "Exif"); + } + if (34853 in exif_dict["0th"]) { + pointer = exif_dict["0th"][34853]; + exif_dict["GPS"] = exifReader.get_ifd(pointer, "GPS"); + } + if (40965 in exif_dict["Exif"]) { + pointer = exif_dict["Exif"][40965]; + exif_dict["Interop"] = exifReader.get_ifd(pointer, "Interop"); + } + if (first_ifd_pointer != "\x00\x00\x00\x00") { + pointer = unpack(exifReader.endian_mark + "L", + first_ifd_pointer)[0]; + exif_dict["1st"] = exifReader.get_ifd(pointer, "1st"); + if ((513 in exif_dict["1st"]) && (514 in exif_dict["1st"])) { + var end = exif_dict["1st"][513] + exif_dict["1st"][514]; + var thumb = exifReader.tiftag.slice(exif_dict["1st"][513], end); + exif_dict["thumbnail"] = thumb; + } + } + + return exif_dict; + }; + + + that.dump = function (exif_dict_original) { + var TIFF_HEADER_LENGTH = 8; + + var exif_dict = copy(exif_dict_original); + var header = "Exif\x00\x00\x4d\x4d\x00\x2a\x00\x00\x00\x08"; + var exif_is = false; + var gps_is = false; + var interop_is = false; + var first_is = false; + + var zeroth_ifd, + exif_ifd, + interop_ifd, + gps_ifd, + first_ifd; + + if ("0th" in exif_dict) { + zeroth_ifd = exif_dict["0th"]; + } else { + zeroth_ifd = {}; + } + + if ((("Exif" in exif_dict) && (Object.keys(exif_dict["Exif"]).length)) || + (("Interop" in exif_dict) && (Object.keys(exif_dict["Interop"]).length))) { + zeroth_ifd[34665] = 1; + exif_is = true; + exif_ifd = exif_dict["Exif"]; + if (("Interop" in exif_dict) && Object.keys(exif_dict["Interop"]).length) { + exif_ifd[40965] = 1; + interop_is = true; + interop_ifd = exif_dict["Interop"]; + } else if (Object.keys(exif_ifd).indexOf(that.ExifIFD.InteroperabilityTag.toString()) > -1) { + delete exif_ifd[40965]; + } + } else if (Object.keys(zeroth_ifd).indexOf(that.ImageIFD.ExifTag.toString()) > -1) { + delete zeroth_ifd[34665]; + } + + if (("GPS" in exif_dict) && (Object.keys(exif_dict["GPS"]).length)) { + zeroth_ifd[that.ImageIFD.GPSTag] = 1; + gps_is = true; + gps_ifd = exif_dict["GPS"]; + } else if (Object.keys(zeroth_ifd).indexOf(that.ImageIFD.GPSTag.toString()) > -1) { + delete zeroth_ifd[that.ImageIFD.GPSTag]; + } + + if (("1st" in exif_dict) && + ("thumbnail" in exif_dict) && + (exif_dict["thumbnail"] != null)) { + first_is = true; + exif_dict["1st"][513] = 1; + exif_dict["1st"][514] = 1; + first_ifd = exif_dict["1st"]; + } + + var zeroth_set = _dict_to_bytes(zeroth_ifd, "0th", 0); + var zeroth_length = (zeroth_set[0].length + exif_is * 12 + gps_is * 12 + 4 + + zeroth_set[1].length); + + var exif_set, + exif_bytes = "", + exif_length = 0, + gps_set, + gps_bytes = "", + gps_length = 0, + interop_set, + interop_bytes = "", + interop_length = 0, + first_set, + first_bytes = "", + thumbnail; + if (exif_is) { + exif_set = _dict_to_bytes(exif_ifd, "Exif", zeroth_length); + exif_length = exif_set[0].length + interop_is * 12 + exif_set[1].length; + } + if (gps_is) { + gps_set = _dict_to_bytes(gps_ifd, "GPS", zeroth_length + exif_length); + gps_bytes = gps_set.join(""); + gps_length = gps_bytes.length; + } + if (interop_is) { + var offset = zeroth_length + exif_length + gps_length; + interop_set = _dict_to_bytes(interop_ifd, "Interop", offset); + interop_bytes = interop_set.join(""); + interop_length = interop_bytes.length; + } + if (first_is) { + var offset = zeroth_length + exif_length + gps_length + interop_length; + first_set = _dict_to_bytes(first_ifd, "1st", offset); + thumbnail = _get_thumbnail(exif_dict["thumbnail"]); + if (thumbnail.length > 64000) { + throw new Error("Given thumbnail is too large. max 64kB"); + } + } + + var exif_pointer = "", + gps_pointer = "", + interop_pointer = "", + first_ifd_pointer = "\x00\x00\x00\x00"; + if (exif_is) { + var pointer_value = TIFF_HEADER_LENGTH + zeroth_length; + var pointer_str = pack(">L", [pointer_value]); + var key = 34665; + var key_str = pack(">H", [key]); + var type_str = pack(">H", [TYPES["Long"]]); + var length_str = pack(">L", [1]); + exif_pointer = key_str + type_str + length_str + pointer_str; + } + if (gps_is) { + var pointer_value = TIFF_HEADER_LENGTH + zeroth_length + exif_length; + var pointer_str = pack(">L", [pointer_value]); + var key = 34853; + var key_str = pack(">H", [key]); + var type_str = pack(">H", [TYPES["Long"]]); + var length_str = pack(">L", [1]); + gps_pointer = key_str + type_str + length_str + pointer_str; + } + if (interop_is) { + var pointer_value = (TIFF_HEADER_LENGTH + + zeroth_length + exif_length + gps_length); + var pointer_str = pack(">L", [pointer_value]); + var key = 40965; + var key_str = pack(">H", [key]); + var type_str = pack(">H", [TYPES["Long"]]); + var length_str = pack(">L", [1]); + interop_pointer = key_str + type_str + length_str + pointer_str; + } + if (first_is) { + var pointer_value = (TIFF_HEADER_LENGTH + zeroth_length + + exif_length + gps_length + interop_length); + first_ifd_pointer = pack(">L", [pointer_value]); + var thumbnail_pointer = (pointer_value + first_set[0].length + 24 + + 4 + first_set[1].length); + var thumbnail_p_bytes = ("\x02\x01\x00\x04\x00\x00\x00\x01" + + pack(">L", [thumbnail_pointer])); + var thumbnail_length_bytes = ("\x02\x02\x00\x04\x00\x00\x00\x01" + + pack(">L", [thumbnail.length])); + first_bytes = (first_set[0] + thumbnail_p_bytes + + thumbnail_length_bytes + "\x00\x00\x00\x00" + + first_set[1] + thumbnail); + } + + var zeroth_bytes = (zeroth_set[0] + exif_pointer + gps_pointer + + first_ifd_pointer + zeroth_set[1]); + if (exif_is) { + exif_bytes = exif_set[0] + interop_pointer + exif_set[1]; + } + + return (header + zeroth_bytes + exif_bytes + gps_bytes + + interop_bytes + first_bytes); + }; + + + function copy(obj) { + return JSON.parse(JSON.stringify(obj)); + } + + + function _get_thumbnail(jpeg) { + var segments = splitIntoSegments(jpeg); + while (("\xff\xe0" <= segments[1].slice(0, 2)) && (segments[1].slice(0, 2) <= "\xff\xef")) { + segments = [segments[0]].concat(segments.slice(2)); + } + return segments.join(""); + } + + + function _pack_byte(array) { + return pack(">" + nStr("B", array.length), array); + } + + + function _pack_short(array) { + return pack(">" + nStr("H", array.length), array); + } + + + function _pack_long(array) { + return pack(">" + nStr("L", array.length), array); + } + + + function _value_to_bytes(raw_value, value_type, offset) { + var four_bytes_over = ""; + var value_str = ""; + var length, + new_value, + num, + den; + + if (value_type == "Byte") { + length = raw_value.length; + if (length <= 4) { + value_str = (_pack_byte(raw_value) + + nStr("\x00", 4 - length)); + } else { + value_str = pack(">L", [offset]); + four_bytes_over = _pack_byte(raw_value); + } + } else if (value_type == "Short") { + length = raw_value.length; + if (length <= 2) { + value_str = (_pack_short(raw_value) + + nStr("\x00\x00", 2 - length)); + } else { + value_str = pack(">L", [offset]); + four_bytes_over = _pack_short(raw_value); + } + } else if (value_type == "Long") { + length = raw_value.length; + if (length <= 1) { + value_str = _pack_long(raw_value); + } else { + value_str = pack(">L", [offset]); + four_bytes_over = _pack_long(raw_value); + } + } else if (value_type == "Ascii") { + new_value = raw_value + "\x00"; + length = new_value.length; + if (length > 4) { + value_str = pack(">L", [offset]); + four_bytes_over = new_value; + } else { + value_str = new_value + nStr("\x00", 4 - length); + } + } else if (value_type == "Rational") { + if (typeof (raw_value[0]) == "number") { + length = 1; + num = raw_value[0]; + den = raw_value[1]; + new_value = pack(">L", [num]) + pack(">L", [den]); + } else { + length = raw_value.length; + new_value = ""; + for (var n = 0; n < length; n++) { + num = raw_value[n][0]; + den = raw_value[n][1]; + new_value += (pack(">L", [num]) + + pack(">L", [den])); + } + } + value_str = pack(">L", [offset]); + four_bytes_over = new_value; + } else if (value_type == "SRational") { + if (typeof (raw_value[0]) == "number") { + length = 1; + num = raw_value[0]; + den = raw_value[1]; + new_value = pack(">l", [num]) + pack(">l", [den]); + } else { + length = raw_value.length; + new_value = ""; + for (var n = 0; n < length; n++) { + num = raw_value[n][0]; + den = raw_value[n][1]; + new_value += (pack(">l", [num]) + + pack(">l", [den])); + } + } + value_str = pack(">L", [offset]); + four_bytes_over = new_value; + } else if (value_type == "Undefined") { + length = raw_value.length; + if (length > 4) { + value_str = pack(">L", [offset]); + four_bytes_over = raw_value; + } else { + value_str = raw_value + nStr("\x00", 4 - length); + } + } + + var length_str = pack(">L", [length]); + + return [length_str, value_str, four_bytes_over]; + } + + function _dict_to_bytes(ifd_dict, ifd, ifd_offset) { + var TIFF_HEADER_LENGTH = 8; + var tag_count = Object.keys(ifd_dict).length; + var entry_header = pack(">H", [tag_count]); + var entries_length; + if (["0th", "1st"].indexOf(ifd) > -1) { + entries_length = 2 + tag_count * 12 + 4; + } else { + entries_length = 2 + tag_count * 12; + } + var entries = ""; + var values = ""; + var key; + + for (var key in ifd_dict) { + if (typeof (key) == "string") { + key = parseInt(key); + } + if ((ifd == "0th") && ([34665, 34853].indexOf(key) > -1)) { + continue; + } else if ((ifd == "Exif") && (key == 40965)) { + continue; + } else if ((ifd == "1st") && ([513, 514].indexOf(key) > -1)) { + continue; + } + + var raw_value = ifd_dict[key]; + var key_str = pack(">H", [key]); + var value_type = TAGS[ifd][key]["type"]; + var type_str = pack(">H", [TYPES[value_type]]); + + if (typeof (raw_value) == "number") { + raw_value = [raw_value]; + } + var offset = TIFF_HEADER_LENGTH + entries_length + ifd_offset + values.length; + var b = _value_to_bytes(raw_value, value_type, offset); + var length_str = b[0]; + var value_str = b[1]; + var four_bytes_over = b[2]; + + entries += key_str + type_str + length_str + value_str; + values += four_bytes_over; + } + + return [entry_header + entries, values]; + } + + + + function ExifReader(data) { + var segments, + app1; + if (data.slice(0, 2) == "\xff\xd8") { // JPEG + segments = splitIntoSegments(data); + app1 = getExifSeg(segments); + if (app1) { + this.tiftag = app1.slice(10); + } else { + this.tiftag = null; + } + } else if (["\x49\x49", "\x4d\x4d"].indexOf(data.slice(0, 2)) > -1) { // TIFF + this.tiftag = data; + } else if (data.slice(0, 4) == "Exif") { // Exif + this.tiftag = data.slice(6); + } else { + throw new Error("Given file is neither JPEG nor TIFF."); + } + } + + ExifReader.prototype = { + get_ifd: function (pointer, ifd_name) { + var ifd_dict = {}; + var tag_count = unpack(this.endian_mark + "H", + this.tiftag.slice(pointer, pointer + 2))[0]; + var offset = pointer + 2; + var t; + if (["0th", "1st"].indexOf(ifd_name) > -1) { + t = "Image"; + } else { + t = ifd_name; + } + + for (var x = 0; x < tag_count; x++) { + pointer = offset + 12 * x; + var tag = unpack(this.endian_mark + "H", + this.tiftag.slice(pointer, pointer + 2))[0]; + var value_type = unpack(this.endian_mark + "H", + this.tiftag.slice(pointer + 2, pointer + 4))[0]; + var value_num = unpack(this.endian_mark + "L", + this.tiftag.slice(pointer + 4, pointer + 8))[0]; + var value = this.tiftag.slice(pointer + 8, pointer + 12); + + var v_set = [value_type, value_num, value]; + if (tag in TAGS[t]) { + ifd_dict[tag] = this.convert_value(v_set); + } + } + + if (ifd_name == "0th") { + pointer = offset + 12 * tag_count; + ifd_dict["first_ifd_pointer"] = this.tiftag.slice(pointer, pointer + 4); + } + + return ifd_dict; + }, + + convert_value: function (val) { + var data = null; + var t = val[0]; + var length = val[1]; + var value = val[2]; + var pointer; + + if (t == 1) { // BYTE + if (length > 4) { + pointer = unpack(this.endian_mark + "L", value)[0]; + data = unpack(this.endian_mark + nStr("B", length), + this.tiftag.slice(pointer, pointer + length)); + } else { + data = unpack(this.endian_mark + nStr("B", length), value.slice(0, length)); + } + } else if (t == 2) { // ASCII + if (length > 4) { + pointer = unpack(this.endian_mark + "L", value)[0]; + data = this.tiftag.slice(pointer, pointer + length - 1); + } else { + data = value.slice(0, length - 1); + } + } else if (t == 3) { // SHORT + if (length > 2) { + pointer = unpack(this.endian_mark + "L", value)[0]; + data = unpack(this.endian_mark + nStr("H", length), + this.tiftag.slice(pointer, pointer + length * 2)); + } else { + data = unpack(this.endian_mark + nStr("H", length), + value.slice(0, length * 2)); + } + } else if (t == 4) { // LONG + if (length > 1) { + pointer = unpack(this.endian_mark + "L", value)[0]; + data = unpack(this.endian_mark + nStr("L", length), + this.tiftag.slice(pointer, pointer + length * 4)); + } else { + data = unpack(this.endian_mark + nStr("L", length), + value); + } + } else if (t == 5) { // RATIONAL + pointer = unpack(this.endian_mark + "L", value)[0]; + if (length > 1) { + data = []; + for (var x = 0; x < length; x++) { + data.push([unpack(this.endian_mark + "L", + this.tiftag.slice(pointer + x * 8, pointer + 4 + x * 8))[0], + unpack(this.endian_mark + "L", + this.tiftag.slice(pointer + 4 + x * 8, pointer + 8 + x * 8))[0] + ]); + } + } else { + data = [unpack(this.endian_mark + "L", + this.tiftag.slice(pointer, pointer + 4))[0], + unpack(this.endian_mark + "L", + this.tiftag.slice(pointer + 4, pointer + 8))[0] + ]; + } + } else if (t == 7) { // UNDEFINED BYTES + if (length > 4) { + pointer = unpack(this.endian_mark + "L", value)[0]; + data = this.tiftag.slice(pointer, pointer + length); + } else { + data = value.slice(0, length); + } + } else if (t == 9) { // SLONG + if (length > 1) { + pointer = unpack(this.endian_mark + "L", value)[0]; + data = unpack(this.endian_mark + nStr("l", length), + this.tiftag.slice(pointer, pointer + length * 4)); + } else { + data = unpack(this.endian_mark + nStr("l", length), + value); + } + } else if (t == 10) { // SRATIONAL + pointer = unpack(this.endian_mark + "L", value)[0]; + if (length > 1) { + data = []; + for (var x = 0; x < length; x++) { + data.push([unpack(this.endian_mark + "l", + this.tiftag.slice(pointer + x * 8, pointer + 4 + x * 8))[0], + unpack(this.endian_mark + "l", + this.tiftag.slice(pointer + 4 + x * 8, pointer + 8 + x * 8))[0] + ]); + } + } else { + data = [unpack(this.endian_mark + "l", + this.tiftag.slice(pointer, pointer + 4))[0], + unpack(this.endian_mark + "l", + this.tiftag.slice(pointer + 4, pointer + 8))[0] + ]; + } + } else { + throw new Error("Exif might be wrong. Got incorrect value " + + "type to decode. type:" + t); + } + + if ((data instanceof Array) && (data.length == 1)) { + return data[0]; + } else { + return data; + } + }, + }; + + + if (typeof window !== "undefined" && typeof window.btoa === "function") { + var btoa = window.btoa; + } + if (typeof btoa === "undefined") { + var btoa = function (input) { var output = ""; + var chr1, chr2, chr3, enc1, enc2, enc3, enc4; + var i = 0; + var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + + while (i < input.length) { + + chr1 = input.charCodeAt(i++); + chr2 = input.charCodeAt(i++); + chr3 = input.charCodeAt(i++); + + enc1 = chr1 >> 2; + enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); + enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); + enc4 = chr3 & 63; + + if (isNaN(chr2)) { + enc3 = enc4 = 64; + } else if (isNaN(chr3)) { + enc4 = 64; + } + + output = output + + keyStr.charAt(enc1) + keyStr.charAt(enc2) + + keyStr.charAt(enc3) + keyStr.charAt(enc4); + + } + + return output; + }; + } + + + if (typeof window !== "undefined" && typeof window.atob === "function") { + var atob = window.atob; + } + if (typeof atob === "undefined") { + var atob = function (input) { + var output = ""; + var chr1, chr2, chr3; + var enc1, enc2, enc3, enc4; + var i = 0; + var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + + input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); + + while (i < input.length) { + + enc1 = keyStr.indexOf(input.charAt(i++)); + enc2 = keyStr.indexOf(input.charAt(i++)); + enc3 = keyStr.indexOf(input.charAt(i++)); + enc4 = keyStr.indexOf(input.charAt(i++)); + + chr1 = (enc1 << 2) | (enc2 >> 4); + chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); + chr3 = ((enc3 & 3) << 6) | enc4; + + output = output + String.fromCharCode(chr1); + + if (enc3 != 64) { + output = output + String.fromCharCode(chr2); + } + if (enc4 != 64) { + output = output + String.fromCharCode(chr3); + } + + } + + return output; + }; + } + + + function getImageSize(imageArray) { + var segments = slice2Segments(imageArray); + var seg, + width, + height, + SOF = [192, 193, 194, 195, 197, 198, 199, 201, 202, 203, 205, 206, 207]; + + for (var x = 0; x < segments.length; x++) { + seg = segments[x]; + if (SOF.indexOf(seg[1]) >= 0) { + height = seg[5] * 256 + seg[6]; + width = seg[7] * 256 + seg[8]; + break; + } + } + return [width, height]; + } + + + function pack(mark, array) { + if (!(array instanceof Array)) { + throw new Error("'pack' error. Got invalid type argument."); + } + if ((mark.length - 1) != array.length) { + throw new Error("'pack' error. " + (mark.length - 1) + " marks, " + array.length + " elements."); + } + + var littleEndian; + if (mark[0] == "<") { + littleEndian = true; + } else if (mark[0] == ">") { + littleEndian = false; + } else { + throw new Error(""); + } + var packed = ""; + var p = 1; + var val = null; + var c = null; + var valStr = null; + + while (c = mark[p]) { + if (c.toLowerCase() == "b") { + val = array[p - 1]; + if ((c == "b") && (val < 0)) { + val += 0x100; + } + if ((val > 0xff) || (val < 0)) { + throw new Error("'pack' error."); + } else { + valStr = String.fromCharCode(val); + } + } else if (c == "H") { + val = array[p - 1]; + if ((val > 0xffff) || (val < 0)) { + throw new Error("'pack' error."); + } else { + valStr = String.fromCharCode(Math.floor((val % 0x10000) / 0x100)) + + String.fromCharCode(val % 0x100); + if (littleEndian) { + valStr = valStr.split("").reverse().join(""); + } + } + } else if (c.toLowerCase() == "l") { + val = array[p - 1]; + if ((c == "l") && (val < 0)) { + val += 0x100000000; + } + if ((val > 0xffffffff) || (val < 0)) { + throw new Error("'pack' error."); + } else { + valStr = String.fromCharCode(Math.floor(val / 0x1000000)) + + String.fromCharCode(Math.floor((val % 0x1000000) / 0x10000)) + + String.fromCharCode(Math.floor((val % 0x10000) / 0x100)) + + String.fromCharCode(val % 0x100); + if (littleEndian) { + valStr = valStr.split("").reverse().join(""); + } + } + } else { + throw new Error("'pack' error."); + } + + packed += valStr; + p += 1; + } + + return packed; + } + + function unpack(mark, str) { + if (typeof (str) != "string") { + throw new Error("'unpack' error. Got invalid type argument."); + } + var l = 0; + for (var markPointer = 1; markPointer < mark.length; markPointer++) { + if (mark[markPointer].toLowerCase() == "b") { + l += 1; + } else if (mark[markPointer].toLowerCase() == "h") { + l += 2; + } else if (mark[markPointer].toLowerCase() == "l") { + l += 4; + } else { + throw new Error("'unpack' error. Got invalid mark."); + } + } + + if (l != str.length) { + throw new Error("'unpack' error. Mismatch between symbol and string length. " + l + ":" + str.length); + } + + var littleEndian; + if (mark[0] == "<") { + littleEndian = true; + } else if (mark[0] == ">") { + littleEndian = false; + } else { + throw new Error("'unpack' error."); + } + var unpacked = []; + var strPointer = 0; + var p = 1; + var val = null; + var c = null; + var length = null; + var sliced = ""; + + while (c = mark[p]) { + if (c.toLowerCase() == "b") { + length = 1; + sliced = str.slice(strPointer, strPointer + length); + val = sliced.charCodeAt(0); + if ((c == "b") && (val >= 0x80)) { + val -= 0x100; + } + } else if (c == "H") { + length = 2; + sliced = str.slice(strPointer, strPointer + length); + if (littleEndian) { + sliced = sliced.split("").reverse().join(""); + } + val = sliced.charCodeAt(0) * 0x100 + + sliced.charCodeAt(1); + } else if (c.toLowerCase() == "l") { + length = 4; + sliced = str.slice(strPointer, strPointer + length); + if (littleEndian) { + sliced = sliced.split("").reverse().join(""); + } + val = sliced.charCodeAt(0) * 0x1000000 + + sliced.charCodeAt(1) * 0x10000 + + sliced.charCodeAt(2) * 0x100 + + sliced.charCodeAt(3); + if ((c == "l") && (val >= 0x80000000)) { + val -= 0x100000000; + } + } else { + throw new Error("'unpack' error. " + c); + } + + unpacked.push(val); + strPointer += length; + p += 1; + } + + return unpacked; + } + + function nStr(ch, num) { + var str = ""; + for (var i = 0; i < num; i++) { + str += ch; + } + return str; + } + + function splitIntoSegments(data) { + if (data.slice(0, 2) != "\xff\xd8") { + throw new Error("Given data isn't JPEG."); + } + + var head = 2; + var segments = ["\xff\xd8"]; + while (true) { + if (data.slice(head, head + 2) == "\xff\xda") { + segments.push(data.slice(head)); + break; + } else { + var length = unpack(">H", data.slice(head + 2, head + 4))[0]; + var endPoint = head + length + 2; + segments.push(data.slice(head, endPoint)); + head = endPoint; + } + + if (head >= data.length) { + throw new Error("Wrong JPEG data."); + } + } + return segments; + } + + + function getExifSeg(segments) { + var seg; + for (var i = 0; i < segments.length; i++) { + seg = segments[i]; + if (seg.slice(0, 2) == "\xff\xe1" && + seg.slice(4, 10) == "Exif\x00\x00") { + return seg; + } + } + return null; + } + + + function mergeSegments(segments, exif) { + var hasExifSegment = false; + var additionalAPP1ExifSegments = []; + + segments.forEach(function(segment, i) { + // Replace first occurence of APP1:Exif segment + if (segment.slice(0, 2) == "\xff\xe1" && + segment.slice(4, 10) == "Exif\x00\x00" + ) { + if (!hasExifSegment) { + segments[i] = exif; + hasExifSegment = true; + } else { + additionalAPP1ExifSegments.unshift(i); + } + } + }); + + // Remove additional occurences of APP1:Exif segment + additionalAPP1ExifSegments.forEach(function(segmentIndex) { + segments.splice(segmentIndex, 1); + }); + + if (!hasExifSegment && exif) { + segments = [segments[0], exif].concat(segments.slice(1)); + } + + return segments.join(""); + } + + + function toHex(str) { + var hexStr = ""; + for (var i = 0; i < str.length; i++) { + var h = str.charCodeAt(i); + var hex = ((h < 10) ? "0" : "") + h.toString(16); + hexStr += hex + " "; + } + return hexStr; + } + + + var TYPES = { + "Byte": 1, + "Ascii": 2, + "Short": 3, + "Long": 4, + "Rational": 5, + "Undefined": 7, + "SLong": 9, + "SRational": 10 + }; + + + var TAGS = { + 'Image': { + 11: { + 'name': 'ProcessingSoftware', + 'type': 'Ascii' + }, + 254: { + 'name': 'NewSubfileType', + 'type': 'Long' + }, + 255: { + 'name': 'SubfileType', + 'type': 'Short' + }, + 256: { + 'name': 'ImageWidth', + 'type': 'Long' + }, + 257: { + 'name': 'ImageLength', + 'type': 'Long' + }, + 258: { + 'name': 'BitsPerSample', + 'type': 'Short' + }, + 259: { + 'name': 'Compression', + 'type': 'Short' + }, + 262: { + 'name': 'PhotometricInterpretation', + 'type': 'Short' + }, + 263: { + 'name': 'Threshholding', + 'type': 'Short' + }, + 264: { + 'name': 'CellWidth', + 'type': 'Short' + }, + 265: { + 'name': 'CellLength', + 'type': 'Short' + }, + 266: { + 'name': 'FillOrder', + 'type': 'Short' + }, + 269: { + 'name': 'DocumentName', + 'type': 'Ascii' + }, + 270: { + 'name': 'ImageDescription', + 'type': 'Ascii' + }, + 271: { + 'name': 'Make', + 'type': 'Ascii' + }, + 272: { + 'name': 'Model', + 'type': 'Ascii' + }, + 273: { + 'name': 'StripOffsets', + 'type': 'Long' + }, + 274: { + 'name': 'Orientation', + 'type': 'Short' + }, + 277: { + 'name': 'SamplesPerPixel', + 'type': 'Short' + }, + 278: { + 'name': 'RowsPerStrip', + 'type': 'Long' + }, + 279: { + 'name': 'StripByteCounts', + 'type': 'Long' + }, + 282: { + 'name': 'XResolution', + 'type': 'Rational' + }, + 283: { + 'name': 'YResolution', + 'type': 'Rational' + }, + 284: { + 'name': 'PlanarConfiguration', + 'type': 'Short' + }, + 290: { + 'name': 'GrayResponseUnit', + 'type': 'Short' + }, + 291: { + 'name': 'GrayResponseCurve', + 'type': 'Short' + }, + 292: { + 'name': 'T4Options', + 'type': 'Long' + }, + 293: { + 'name': 'T6Options', + 'type': 'Long' + }, + 296: { + 'name': 'ResolutionUnit', + 'type': 'Short' + }, + 301: { + 'name': 'TransferFunction', + 'type': 'Short' + }, + 305: { + 'name': 'Software', + 'type': 'Ascii' + }, + 306: { + 'name': 'DateTime', + 'type': 'Ascii' + }, + 315: { + 'name': 'Artist', + 'type': 'Ascii' + }, + 316: { + 'name': 'HostComputer', + 'type': 'Ascii' + }, + 317: { + 'name': 'Predictor', + 'type': 'Short' + }, + 318: { + 'name': 'WhitePoint', + 'type': 'Rational' + }, + 319: { + 'name': 'PrimaryChromaticities', + 'type': 'Rational' + }, + 320: { + 'name': 'ColorMap', + 'type': 'Short' + }, + 321: { + 'name': 'HalftoneHints', + 'type': 'Short' + }, + 322: { + 'name': 'TileWidth', + 'type': 'Short' + }, + 323: { + 'name': 'TileLength', + 'type': 'Short' + }, + 324: { + 'name': 'TileOffsets', + 'type': 'Short' + }, + 325: { + 'name': 'TileByteCounts', + 'type': 'Short' + }, + 330: { + 'name': 'SubIFDs', + 'type': 'Long' + }, + 332: { + 'name': 'InkSet', + 'type': 'Short' + }, + 333: { + 'name': 'InkNames', + 'type': 'Ascii' + }, + 334: { + 'name': 'NumberOfInks', + 'type': 'Short' + }, + 336: { + 'name': 'DotRange', + 'type': 'Byte' + }, + 337: { + 'name': 'TargetPrinter', + 'type': 'Ascii' + }, + 338: { + 'name': 'ExtraSamples', + 'type': 'Short' + }, + 339: { + 'name': 'SampleFormat', + 'type': 'Short' + }, + 340: { + 'name': 'SMinSampleValue', + 'type': 'Short' + }, + 341: { + 'name': 'SMaxSampleValue', + 'type': 'Short' + }, + 342: { + 'name': 'TransferRange', + 'type': 'Short' + }, + 343: { + 'name': 'ClipPath', + 'type': 'Byte' + }, + 344: { + 'name': 'XClipPathUnits', + 'type': 'Long' + }, + 345: { + 'name': 'YClipPathUnits', + 'type': 'Long' + }, + 346: { + 'name': 'Indexed', + 'type': 'Short' + }, + 347: { + 'name': 'JPEGTables', + 'type': 'Undefined' + }, + 351: { + 'name': 'OPIProxy', + 'type': 'Short' + }, + 512: { + 'name': 'JPEGProc', + 'type': 'Long' + }, + 513: { + 'name': 'JPEGInterchangeFormat', + 'type': 'Long' + }, + 514: { + 'name': 'JPEGInterchangeFormatLength', + 'type': 'Long' + }, + 515: { + 'name': 'JPEGRestartInterval', + 'type': 'Short' + }, + 517: { + 'name': 'JPEGLosslessPredictors', + 'type': 'Short' + }, + 518: { + 'name': 'JPEGPointTransforms', + 'type': 'Short' + }, + 519: { + 'name': 'JPEGQTables', + 'type': 'Long' + }, + 520: { + 'name': 'JPEGDCTables', + 'type': 'Long' + }, + 521: { + 'name': 'JPEGACTables', + 'type': 'Long' + }, + 529: { + 'name': 'YCbCrCoefficients', + 'type': 'Rational' + }, + 530: { + 'name': 'YCbCrSubSampling', + 'type': 'Short' + }, + 531: { + 'name': 'YCbCrPositioning', + 'type': 'Short' + }, + 532: { + 'name': 'ReferenceBlackWhite', + 'type': 'Rational' + }, + 700: { + 'name': 'XMLPacket', + 'type': 'Byte' + }, + 18246: { + 'name': 'Rating', + 'type': 'Short' + }, + 18249: { + 'name': 'RatingPercent', + 'type': 'Short' + }, + 32781: { + 'name': 'ImageID', + 'type': 'Ascii' + }, + 33421: { + 'name': 'CFARepeatPatternDim', + 'type': 'Short' + }, + 33422: { + 'name': 'CFAPattern', + 'type': 'Byte' + }, + 33423: { + 'name': 'BatteryLevel', + 'type': 'Rational' + }, + 33432: { + 'name': 'Copyright', + 'type': 'Ascii' + }, + 33434: { + 'name': 'ExposureTime', + 'type': 'Rational' + }, + 34377: { + 'name': 'ImageResources', + 'type': 'Byte' + }, + 34665: { + 'name': 'ExifTag', + 'type': 'Long' + }, + 34675: { + 'name': 'InterColorProfile', + 'type': 'Undefined' + }, + 34853: { + 'name': 'GPSTag', + 'type': 'Long' + }, + 34857: { + 'name': 'Interlace', + 'type': 'Short' + }, + 34858: { + 'name': 'TimeZoneOffset', + 'type': 'Long' + }, + 34859: { + 'name': 'SelfTimerMode', + 'type': 'Short' + }, + 37387: { + 'name': 'FlashEnergy', + 'type': 'Rational' + }, + 37388: { + 'name': 'SpatialFrequencyResponse', + 'type': 'Undefined' + }, + 37389: { + 'name': 'Noise', + 'type': 'Undefined' + }, + 37390: { + 'name': 'FocalPlaneXResolution', + 'type': 'Rational' + }, + 37391: { + 'name': 'FocalPlaneYResolution', + 'type': 'Rational' + }, + 37392: { + 'name': 'FocalPlaneResolutionUnit', + 'type': 'Short' + }, + 37393: { + 'name': 'ImageNumber', + 'type': 'Long' + }, + 37394: { + 'name': 'SecurityClassification', + 'type': 'Ascii' + }, + 37395: { + 'name': 'ImageHistory', + 'type': 'Ascii' + }, + 37397: { + 'name': 'ExposureIndex', + 'type': 'Rational' + }, + 37398: { + 'name': 'TIFFEPStandardID', + 'type': 'Byte' + }, + 37399: { + 'name': 'SensingMethod', + 'type': 'Short' + }, + 40091: { + 'name': 'XPTitle', + 'type': 'Byte' + }, + 40092: { + 'name': 'XPComment', + 'type': 'Byte' + }, + 40093: { + 'name': 'XPAuthor', + 'type': 'Byte' + }, + 40094: { + 'name': 'XPKeywords', + 'type': 'Byte' + }, + 40095: { + 'name': 'XPSubject', + 'type': 'Byte' + }, + 50341: { + 'name': 'PrintImageMatching', + 'type': 'Undefined' + }, + 50706: { + 'name': 'DNGVersion', + 'type': 'Byte' + }, + 50707: { + 'name': 'DNGBackwardVersion', + 'type': 'Byte' + }, + 50708: { + 'name': 'UniqueCameraModel', + 'type': 'Ascii' + }, + 50709: { + 'name': 'LocalizedCameraModel', + 'type': 'Byte' + }, + 50710: { + 'name': 'CFAPlaneColor', + 'type': 'Byte' + }, + 50711: { + 'name': 'CFALayout', + 'type': 'Short' + }, + 50712: { + 'name': 'LinearizationTable', + 'type': 'Short' + }, + 50713: { + 'name': 'BlackLevelRepeatDim', + 'type': 'Short' + }, + 50714: { + 'name': 'BlackLevel', + 'type': 'Rational' + }, + 50715: { + 'name': 'BlackLevelDeltaH', + 'type': 'SRational' + }, + 50716: { + 'name': 'BlackLevelDeltaV', + 'type': 'SRational' + }, + 50717: { + 'name': 'WhiteLevel', + 'type': 'Short' + }, + 50718: { + 'name': 'DefaultScale', + 'type': 'Rational' + }, + 50719: { + 'name': 'DefaultCropOrigin', + 'type': 'Short' + }, + 50720: { + 'name': 'DefaultCropSize', + 'type': 'Short' + }, + 50721: { + 'name': 'ColorMatrix1', + 'type': 'SRational' + }, + 50722: { + 'name': 'ColorMatrix2', + 'type': 'SRational' + }, + 50723: { + 'name': 'CameraCalibration1', + 'type': 'SRational' + }, + 50724: { + 'name': 'CameraCalibration2', + 'type': 'SRational' + }, + 50725: { + 'name': 'ReductionMatrix1', + 'type': 'SRational' + }, + 50726: { + 'name': 'ReductionMatrix2', + 'type': 'SRational' + }, + 50727: { + 'name': 'AnalogBalance', + 'type': 'Rational' + }, + 50728: { + 'name': 'AsShotNeutral', + 'type': 'Short' + }, + 50729: { + 'name': 'AsShotWhiteXY', + 'type': 'Rational' + }, + 50730: { + 'name': 'BaselineExposure', + 'type': 'SRational' + }, + 50731: { + 'name': 'BaselineNoise', + 'type': 'Rational' + }, + 50732: { + 'name': 'BaselineSharpness', + 'type': 'Rational' + }, + 50733: { + 'name': 'BayerGreenSplit', + 'type': 'Long' + }, + 50734: { + 'name': 'LinearResponseLimit', + 'type': 'Rational' + }, + 50735: { + 'name': 'CameraSerialNumber', + 'type': 'Ascii' + }, + 50736: { + 'name': 'LensInfo', + 'type': 'Rational' + }, + 50737: { + 'name': 'ChromaBlurRadius', + 'type': 'Rational' + }, + 50738: { + 'name': 'AntiAliasStrength', + 'type': 'Rational' + }, + 50739: { + 'name': 'ShadowScale', + 'type': 'SRational' + }, + 50740: { + 'name': 'DNGPrivateData', + 'type': 'Byte' + }, + 50741: { + 'name': 'MakerNoteSafety', + 'type': 'Short' + }, + 50778: { + 'name': 'CalibrationIlluminant1', + 'type': 'Short' + }, + 50779: { + 'name': 'CalibrationIlluminant2', + 'type': 'Short' + }, + 50780: { + 'name': 'BestQualityScale', + 'type': 'Rational' + }, + 50781: { + 'name': 'RawDataUniqueID', + 'type': 'Byte' + }, + 50827: { + 'name': 'OriginalRawFileName', + 'type': 'Byte' + }, + 50828: { + 'name': 'OriginalRawFileData', + 'type': 'Undefined' + }, + 50829: { + 'name': 'ActiveArea', + 'type': 'Short' + }, + 50830: { + 'name': 'MaskedAreas', + 'type': 'Short' + }, + 50831: { + 'name': 'AsShotICCProfile', + 'type': 'Undefined' + }, + 50832: { + 'name': 'AsShotPreProfileMatrix', + 'type': 'SRational' + }, + 50833: { + 'name': 'CurrentICCProfile', + 'type': 'Undefined' + }, + 50834: { + 'name': 'CurrentPreProfileMatrix', + 'type': 'SRational' + }, + 50879: { + 'name': 'ColorimetricReference', + 'type': 'Short' + }, + 50931: { + 'name': 'CameraCalibrationSignature', + 'type': 'Byte' + }, + 50932: { + 'name': 'ProfileCalibrationSignature', + 'type': 'Byte' + }, + 50934: { + 'name': 'AsShotProfileName', + 'type': 'Byte' + }, + 50935: { + 'name': 'NoiseReductionApplied', + 'type': 'Rational' + }, + 50936: { + 'name': 'ProfileName', + 'type': 'Byte' + }, + 50937: { + 'name': 'ProfileHueSatMapDims', + 'type': 'Long' + }, + 50938: { + 'name': 'ProfileHueSatMapData1', + 'type': 'Float' + }, + 50939: { + 'name': 'ProfileHueSatMapData2', + 'type': 'Float' + }, + 50940: { + 'name': 'ProfileToneCurve', + 'type': 'Float' + }, + 50941: { + 'name': 'ProfileEmbedPolicy', + 'type': 'Long' + }, + 50942: { + 'name': 'ProfileCopyright', + 'type': 'Byte' + }, + 50964: { + 'name': 'ForwardMatrix1', + 'type': 'SRational' + }, + 50965: { + 'name': 'ForwardMatrix2', + 'type': 'SRational' + }, + 50966: { + 'name': 'PreviewApplicationName', + 'type': 'Byte' + }, + 50967: { + 'name': 'PreviewApplicationVersion', + 'type': 'Byte' + }, + 50968: { + 'name': 'PreviewSettingsName', + 'type': 'Byte' + }, + 50969: { + 'name': 'PreviewSettingsDigest', + 'type': 'Byte' + }, + 50970: { + 'name': 'PreviewColorSpace', + 'type': 'Long' + }, + 50971: { + 'name': 'PreviewDateTime', + 'type': 'Ascii' + }, + 50972: { + 'name': 'RawImageDigest', + 'type': 'Undefined' + }, + 50973: { + 'name': 'OriginalRawFileDigest', + 'type': 'Undefined' + }, + 50974: { + 'name': 'SubTileBlockSize', + 'type': 'Long' + }, + 50975: { + 'name': 'RowInterleaveFactor', + 'type': 'Long' + }, + 50981: { + 'name': 'ProfileLookTableDims', + 'type': 'Long' + }, + 50982: { + 'name': 'ProfileLookTableData', + 'type': 'Float' + }, + 51008: { + 'name': 'OpcodeList1', + 'type': 'Undefined' + }, + 51009: { + 'name': 'OpcodeList2', + 'type': 'Undefined' + }, + 51022: { + 'name': 'OpcodeList3', + 'type': 'Undefined' + } + }, + 'Exif': { + 33434: { + 'name': 'ExposureTime', + 'type': 'Rational' + }, + 33437: { + 'name': 'FNumber', + 'type': 'Rational' + }, + 34850: { + 'name': 'ExposureProgram', + 'type': 'Short' + }, + 34852: { + 'name': 'SpectralSensitivity', + 'type': 'Ascii' + }, + 34855: { + 'name': 'ISOSpeedRatings', + 'type': 'Short' + }, + 34856: { + 'name': 'OECF', + 'type': 'Undefined' + }, + 34864: { + 'name': 'SensitivityType', + 'type': 'Short' + }, + 34865: { + 'name': 'StandardOutputSensitivity', + 'type': 'Long' + }, + 34866: { + 'name': 'RecommendedExposureIndex', + 'type': 'Long' + }, + 34867: { + 'name': 'ISOSpeed', + 'type': 'Long' + }, + 34868: { + 'name': 'ISOSpeedLatitudeyyy', + 'type': 'Long' + }, + 34869: { + 'name': 'ISOSpeedLatitudezzz', + 'type': 'Long' + }, + 36864: { + 'name': 'ExifVersion', + 'type': 'Undefined' + }, + 36867: { + 'name': 'DateTimeOriginal', + 'type': 'Ascii' + }, + 36868: { + 'name': 'DateTimeDigitized', + 'type': 'Ascii' + }, + 37121: { + 'name': 'ComponentsConfiguration', + 'type': 'Undefined' + }, + 37122: { + 'name': 'CompressedBitsPerPixel', + 'type': 'Rational' + }, + 37377: { + 'name': 'ShutterSpeedValue', + 'type': 'SRational' + }, + 37378: { + 'name': 'ApertureValue', + 'type': 'Rational' + }, + 37379: { + 'name': 'BrightnessValue', + 'type': 'SRational' + }, + 37380: { + 'name': 'ExposureBiasValue', + 'type': 'SRational' + }, + 37381: { + 'name': 'MaxApertureValue', + 'type': 'Rational' + }, + 37382: { + 'name': 'SubjectDistance', + 'type': 'Rational' + }, + 37383: { + 'name': 'MeteringMode', + 'type': 'Short' + }, + 37384: { + 'name': 'LightSource', + 'type': 'Short' + }, + 37385: { + 'name': 'Flash', + 'type': 'Short' + }, + 37386: { + 'name': 'FocalLength', + 'type': 'Rational' + }, + 37396: { + 'name': 'SubjectArea', + 'type': 'Short' + }, + 37500: { + 'name': 'MakerNote', + 'type': 'Undefined' + }, + 37510: { + 'name': 'UserComment', + 'type': 'Ascii' + }, + 37520: { + 'name': 'SubSecTime', + 'type': 'Ascii' + }, + 37521: { + 'name': 'SubSecTimeOriginal', + 'type': 'Ascii' + }, + 37522: { + 'name': 'SubSecTimeDigitized', + 'type': 'Ascii' + }, + 40960: { + 'name': 'FlashpixVersion', + 'type': 'Undefined' + }, + 40961: { + 'name': 'ColorSpace', + 'type': 'Short' + }, + 40962: { + 'name': 'PixelXDimension', + 'type': 'Long' + }, + 40963: { + 'name': 'PixelYDimension', + 'type': 'Long' + }, + 40964: { + 'name': 'RelatedSoundFile', + 'type': 'Ascii' + }, + 40965: { + 'name': 'InteroperabilityTag', + 'type': 'Long' + }, + 41483: { + 'name': 'FlashEnergy', + 'type': 'Rational' + }, + 41484: { + 'name': 'SpatialFrequencyResponse', + 'type': 'Undefined' + }, + 41486: { + 'name': 'FocalPlaneXResolution', + 'type': 'Rational' + }, + 41487: { + 'name': 'FocalPlaneYResolution', + 'type': 'Rational' + }, + 41488: { + 'name': 'FocalPlaneResolutionUnit', + 'type': 'Short' + }, + 41492: { + 'name': 'SubjectLocation', + 'type': 'Short' + }, + 41493: { + 'name': 'ExposureIndex', + 'type': 'Rational' + }, + 41495: { + 'name': 'SensingMethod', + 'type': 'Short' + }, + 41728: { + 'name': 'FileSource', + 'type': 'Undefined' + }, + 41729: { + 'name': 'SceneType', + 'type': 'Undefined' + }, + 41730: { + 'name': 'CFAPattern', + 'type': 'Undefined' + }, + 41985: { + 'name': 'CustomRendered', + 'type': 'Short' + }, + 41986: { + 'name': 'ExposureMode', + 'type': 'Short' + }, + 41987: { + 'name': 'WhiteBalance', + 'type': 'Short' + }, + 41988: { + 'name': 'DigitalZoomRatio', + 'type': 'Rational' + }, + 41989: { + 'name': 'FocalLengthIn35mmFilm', + 'type': 'Short' + }, + 41990: { + 'name': 'SceneCaptureType', + 'type': 'Short' + }, + 41991: { + 'name': 'GainControl', + 'type': 'Short' + }, + 41992: { + 'name': 'Contrast', + 'type': 'Short' + }, + 41993: { + 'name': 'Saturation', + 'type': 'Short' + }, + 41994: { + 'name': 'Sharpness', + 'type': 'Short' + }, + 41995: { + 'name': 'DeviceSettingDescription', + 'type': 'Undefined' + }, + 41996: { + 'name': 'SubjectDistanceRange', + 'type': 'Short' + }, + 42016: { + 'name': 'ImageUniqueID', + 'type': 'Ascii' + }, + 42032: { + 'name': 'CameraOwnerName', + 'type': 'Ascii' + }, + 42033: { + 'name': 'BodySerialNumber', + 'type': 'Ascii' + }, + 42034: { + 'name': 'LensSpecification', + 'type': 'Rational' + }, + 42035: { + 'name': 'LensMake', + 'type': 'Ascii' + }, + 42036: { + 'name': 'LensModel', + 'type': 'Ascii' + }, + 42037: { + 'name': 'LensSerialNumber', + 'type': 'Ascii' + }, + 42240: { + 'name': 'Gamma', + 'type': 'Rational' + } + }, + 'GPS': { + 0: { + 'name': 'GPSVersionID', + 'type': 'Byte' + }, + 1: { + 'name': 'GPSLatitudeRef', + 'type': 'Ascii' + }, + 2: { + 'name': 'GPSLatitude', + 'type': 'Rational' + }, + 3: { + 'name': 'GPSLongitudeRef', + 'type': 'Ascii' + }, + 4: { + 'name': 'GPSLongitude', + 'type': 'Rational' + }, + 5: { + 'name': 'GPSAltitudeRef', + 'type': 'Byte' + }, + 6: { + 'name': 'GPSAltitude', + 'type': 'Rational' + }, + 7: { + 'name': 'GPSTimeStamp', + 'type': 'Rational' + }, + 8: { + 'name': 'GPSSatellites', + 'type': 'Ascii' + }, + 9: { + 'name': 'GPSStatus', + 'type': 'Ascii' + }, + 10: { + 'name': 'GPSMeasureMode', + 'type': 'Ascii' + }, + 11: { + 'name': 'GPSDOP', + 'type': 'Rational' + }, + 12: { + 'name': 'GPSSpeedRef', + 'type': 'Ascii' + }, + 13: { + 'name': 'GPSSpeed', + 'type': 'Rational' + }, + 14: { + 'name': 'GPSTrackRef', + 'type': 'Ascii' + }, + 15: { + 'name': 'GPSTrack', + 'type': 'Rational' + }, + 16: { + 'name': 'GPSImgDirectionRef', + 'type': 'Ascii' + }, + 17: { + 'name': 'GPSImgDirection', + 'type': 'Rational' + }, + 18: { + 'name': 'GPSMapDatum', + 'type': 'Ascii' + }, + 19: { + 'name': 'GPSDestLatitudeRef', + 'type': 'Ascii' + }, + 20: { + 'name': 'GPSDestLatitude', + 'type': 'Rational' + }, + 21: { + 'name': 'GPSDestLongitudeRef', + 'type': 'Ascii' + }, + 22: { + 'name': 'GPSDestLongitude', + 'type': 'Rational' + }, + 23: { + 'name': 'GPSDestBearingRef', + 'type': 'Ascii' + }, + 24: { + 'name': 'GPSDestBearing', + 'type': 'Rational' + }, + 25: { + 'name': 'GPSDestDistanceRef', + 'type': 'Ascii' + }, + 26: { + 'name': 'GPSDestDistance', + 'type': 'Rational' + }, + 27: { + 'name': 'GPSProcessingMethod', + 'type': 'Undefined' + }, + 28: { + 'name': 'GPSAreaInformation', + 'type': 'Undefined' + }, + 29: { + 'name': 'GPSDateStamp', + 'type': 'Ascii' + }, + 30: { + 'name': 'GPSDifferential', + 'type': 'Short' + }, + 31: { + 'name': 'GPSHPositioningError', + 'type': 'Rational' + } + }, + 'Interop': { + 1: { + 'name': 'InteroperabilityIndex', + 'type': 'Ascii' + } + }, + }; + TAGS["0th"] = TAGS["Image"]; + TAGS["1st"] = TAGS["Image"]; + that.TAGS = TAGS; + + + that.ImageIFD = { + ProcessingSoftware:11, + NewSubfileType:254, + SubfileType:255, + ImageWidth:256, + ImageLength:257, + BitsPerSample:258, + Compression:259, + PhotometricInterpretation:262, + Threshholding:263, + CellWidth:264, + CellLength:265, + FillOrder:266, + DocumentName:269, + ImageDescription:270, + Make:271, + Model:272, + StripOffsets:273, + Orientation:274, + SamplesPerPixel:277, + RowsPerStrip:278, + StripByteCounts:279, + XResolution:282, + YResolution:283, + PlanarConfiguration:284, + GrayResponseUnit:290, + GrayResponseCurve:291, + T4Options:292, + T6Options:293, + ResolutionUnit:296, + TransferFunction:301, + Software:305, + DateTime:306, + Artist:315, + HostComputer:316, + Predictor:317, + WhitePoint:318, + PrimaryChromaticities:319, + ColorMap:320, + HalftoneHints:321, + TileWidth:322, + TileLength:323, + TileOffsets:324, + TileByteCounts:325, + SubIFDs:330, + InkSet:332, + InkNames:333, + NumberOfInks:334, + DotRange:336, + TargetPrinter:337, + ExtraSamples:338, + SampleFormat:339, + SMinSampleValue:340, + SMaxSampleValue:341, + TransferRange:342, + ClipPath:343, + XClipPathUnits:344, + YClipPathUnits:345, + Indexed:346, + JPEGTables:347, + OPIProxy:351, + JPEGProc:512, + JPEGInterchangeFormat:513, + JPEGInterchangeFormatLength:514, + JPEGRestartInterval:515, + JPEGLosslessPredictors:517, + JPEGPointTransforms:518, + JPEGQTables:519, + JPEGDCTables:520, + JPEGACTables:521, + YCbCrCoefficients:529, + YCbCrSubSampling:530, + YCbCrPositioning:531, + ReferenceBlackWhite:532, + XMLPacket:700, + Rating:18246, + RatingPercent:18249, + ImageID:32781, + CFARepeatPatternDim:33421, + CFAPattern:33422, + BatteryLevel:33423, + Copyright:33432, + ExposureTime:33434, + ImageResources:34377, + ExifTag:34665, + InterColorProfile:34675, + GPSTag:34853, + Interlace:34857, + TimeZoneOffset:34858, + SelfTimerMode:34859, + FlashEnergy:37387, + SpatialFrequencyResponse:37388, + Noise:37389, + FocalPlaneXResolution:37390, + FocalPlaneYResolution:37391, + FocalPlaneResolutionUnit:37392, + ImageNumber:37393, + SecurityClassification:37394, + ImageHistory:37395, + ExposureIndex:37397, + TIFFEPStandardID:37398, + SensingMethod:37399, + XPTitle:40091, + XPComment:40092, + XPAuthor:40093, + XPKeywords:40094, + XPSubject:40095, + PrintImageMatching:50341, + DNGVersion:50706, + DNGBackwardVersion:50707, + UniqueCameraModel:50708, + LocalizedCameraModel:50709, + CFAPlaneColor:50710, + CFALayout:50711, + LinearizationTable:50712, + BlackLevelRepeatDim:50713, + BlackLevel:50714, + BlackLevelDeltaH:50715, + BlackLevelDeltaV:50716, + WhiteLevel:50717, + DefaultScale:50718, + DefaultCropOrigin:50719, + DefaultCropSize:50720, + ColorMatrix1:50721, + ColorMatrix2:50722, + CameraCalibration1:50723, + CameraCalibration2:50724, + ReductionMatrix1:50725, + ReductionMatrix2:50726, + AnalogBalance:50727, + AsShotNeutral:50728, + AsShotWhiteXY:50729, + BaselineExposure:50730, + BaselineNoise:50731, + BaselineSharpness:50732, + BayerGreenSplit:50733, + LinearResponseLimit:50734, + CameraSerialNumber:50735, + LensInfo:50736, + ChromaBlurRadius:50737, + AntiAliasStrength:50738, + ShadowScale:50739, + DNGPrivateData:50740, + MakerNoteSafety:50741, + CalibrationIlluminant1:50778, + CalibrationIlluminant2:50779, + BestQualityScale:50780, + RawDataUniqueID:50781, + OriginalRawFileName:50827, + OriginalRawFileData:50828, + ActiveArea:50829, + MaskedAreas:50830, + AsShotICCProfile:50831, + AsShotPreProfileMatrix:50832, + CurrentICCProfile:50833, + CurrentPreProfileMatrix:50834, + ColorimetricReference:50879, + CameraCalibrationSignature:50931, + ProfileCalibrationSignature:50932, + AsShotProfileName:50934, + NoiseReductionApplied:50935, + ProfileName:50936, + ProfileHueSatMapDims:50937, + ProfileHueSatMapData1:50938, + ProfileHueSatMapData2:50939, + ProfileToneCurve:50940, + ProfileEmbedPolicy:50941, + ProfileCopyright:50942, + ForwardMatrix1:50964, + ForwardMatrix2:50965, + PreviewApplicationName:50966, + PreviewApplicationVersion:50967, + PreviewSettingsName:50968, + PreviewSettingsDigest:50969, + PreviewColorSpace:50970, + PreviewDateTime:50971, + RawImageDigest:50972, + OriginalRawFileDigest:50973, + SubTileBlockSize:50974, + RowInterleaveFactor:50975, + ProfileLookTableDims:50981, + ProfileLookTableData:50982, + OpcodeList1:51008, + OpcodeList2:51009, + OpcodeList3:51022, + NoiseProfile:51041, + }; + + + that.ExifIFD = { + ExposureTime:33434, + FNumber:33437, + ExposureProgram:34850, + SpectralSensitivity:34852, + ISOSpeedRatings:34855, + OECF:34856, + SensitivityType:34864, + StandardOutputSensitivity:34865, + RecommendedExposureIndex:34866, + ISOSpeed:34867, + ISOSpeedLatitudeyyy:34868, + ISOSpeedLatitudezzz:34869, + ExifVersion:36864, + DateTimeOriginal:36867, + DateTimeDigitized:36868, + ComponentsConfiguration:37121, + CompressedBitsPerPixel:37122, + ShutterSpeedValue:37377, + ApertureValue:37378, + BrightnessValue:37379, + ExposureBiasValue:37380, + MaxApertureValue:37381, + SubjectDistance:37382, + MeteringMode:37383, + LightSource:37384, + Flash:37385, + FocalLength:37386, + SubjectArea:37396, + MakerNote:37500, + UserComment:37510, + SubSecTime:37520, + SubSecTimeOriginal:37521, + SubSecTimeDigitized:37522, + FlashpixVersion:40960, + ColorSpace:40961, + PixelXDimension:40962, + PixelYDimension:40963, + RelatedSoundFile:40964, + InteroperabilityTag:40965, + FlashEnergy:41483, + SpatialFrequencyResponse:41484, + FocalPlaneXResolution:41486, + FocalPlaneYResolution:41487, + FocalPlaneResolutionUnit:41488, + SubjectLocation:41492, + ExposureIndex:41493, + SensingMethod:41495, + FileSource:41728, + SceneType:41729, + CFAPattern:41730, + CustomRendered:41985, + ExposureMode:41986, + WhiteBalance:41987, + DigitalZoomRatio:41988, + FocalLengthIn35mmFilm:41989, + SceneCaptureType:41990, + GainControl:41991, + Contrast:41992, + Saturation:41993, + Sharpness:41994, + DeviceSettingDescription:41995, + SubjectDistanceRange:41996, + ImageUniqueID:42016, + CameraOwnerName:42032, + BodySerialNumber:42033, + LensSpecification:42034, + LensMake:42035, + LensModel:42036, + LensSerialNumber:42037, + Gamma:42240, + }; + + + that.GPSIFD = { + GPSVersionID:0, + GPSLatitudeRef:1, + GPSLatitude:2, + GPSLongitudeRef:3, + GPSLongitude:4, + GPSAltitudeRef:5, + GPSAltitude:6, + GPSTimeStamp:7, + GPSSatellites:8, + GPSStatus:9, + GPSMeasureMode:10, + GPSDOP:11, + GPSSpeedRef:12, + GPSSpeed:13, + GPSTrackRef:14, + GPSTrack:15, + GPSImgDirectionRef:16, + GPSImgDirection:17, + GPSMapDatum:18, + GPSDestLatitudeRef:19, + GPSDestLatitude:20, + GPSDestLongitudeRef:21, + GPSDestLongitude:22, + GPSDestBearingRef:23, + GPSDestBearing:24, + GPSDestDistanceRef:25, + GPSDestDistance:26, + GPSProcessingMethod:27, + GPSAreaInformation:28, + GPSDateStamp:29, + GPSDifferential:30, + GPSHPositioningError:31, + }; + + + that.InteropIFD = { + InteroperabilityIndex:1, + }; + + that.GPSHelper = { + degToDmsRational:function (degFloat) { + var degAbs = Math.abs(degFloat); + var minFloat = degAbs % 1 * 60; + var secFloat = minFloat % 1 * 60; + var deg = Math.floor(degAbs); + var min = Math.floor(minFloat); + var sec = Math.round(secFloat * 100); + + return [[deg, 1], [min, 1], [sec, 100]]; + }, + + dmsRationalToDeg:function (dmsArray, ref) { + var sign = (ref === 'S' || ref === 'W') ? -1.0 : 1.0; + var deg = dmsArray[0][0] / dmsArray[0][1] + + dmsArray[1][0] / dmsArray[1][1] / 60.0 + + dmsArray[2][0] / dmsArray[2][1] / 3600.0; + + return deg * sign; + } + }; + + + if (typeof exports !== 'undefined') { + if (typeof module !== 'undefined' && module.exports) { + exports = module.exports = that; + } + exports.piexif = that; + } else { + window.piexif = that; + } + +})(); diff --git a/app/vendor/qrcode.min.js b/app/vendor/qrcode.min.js new file mode 100644 index 0000000..993e88f --- /dev/null +++ b/app/vendor/qrcode.min.js @@ -0,0 +1 @@ +var QRCode;!function(){function a(a){this.mode=c.MODE_8BIT_BYTE,this.data=a,this.parsedData=[];for(var b=[],d=0,e=this.data.length;e>d;d++){var f=this.data.charCodeAt(d);f>65536?(b[0]=240|(1835008&f)>>>18,b[1]=128|(258048&f)>>>12,b[2]=128|(4032&f)>>>6,b[3]=128|63&f):f>2048?(b[0]=224|(61440&f)>>>12,b[1]=128|(4032&f)>>>6,b[2]=128|63&f):f>128?(b[0]=192|(1984&f)>>>6,b[1]=128|63&f):b[0]=f,this.parsedData=this.parsedData.concat(b)}this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),this.parsedData.unshift(187),this.parsedData.unshift(239))}function b(a,b){this.typeNumber=a,this.errorCorrectLevel=b,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}function i(a,b){if(void 0==a.length)throw new Error(a.length+"/"+b);for(var c=0;c=f;f++){var h=0;switch(b){case d.L:h=l[f][0];break;case d.M:h=l[f][1];break;case d.Q:h=l[f][2];break;case d.H:h=l[f][3]}if(h>=e)break;c++}if(c>l.length)throw new Error("Too long data");return c}function s(a){var b=encodeURI(a).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return b.length+(b.length!=a?3:0)}a.prototype={getLength:function(){return this.parsedData.length},write:function(a){for(var b=0,c=this.parsedData.length;c>b;b++)a.put(this.parsedData[b],8)}},b.prototype={addData:function(b){var c=new a(b);this.dataList.push(c),this.dataCache=null},isDark:function(a,b){if(0>a||this.moduleCount<=a||0>b||this.moduleCount<=b)throw new Error(a+","+b);return this.modules[a][b]},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(a,c){this.moduleCount=4*this.typeNumber+17,this.modules=new Array(this.moduleCount);for(var d=0;d=7&&this.setupTypeNumber(a),null==this.dataCache&&(this.dataCache=b.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,c)},setupPositionProbePattern:function(a,b){for(var c=-1;7>=c;c++)if(!(-1>=a+c||this.moduleCount<=a+c))for(var d=-1;7>=d;d++)-1>=b+d||this.moduleCount<=b+d||(this.modules[a+c][b+d]=c>=0&&6>=c&&(0==d||6==d)||d>=0&&6>=d&&(0==c||6==c)||c>=2&&4>=c&&d>=2&&4>=d?!0:!1)},getBestMaskPattern:function(){for(var a=0,b=0,c=0;8>c;c++){this.makeImpl(!0,c);var d=f.getLostPoint(this);(0==c||a>d)&&(a=d,b=c)}return b},createMovieClip:function(a,b,c){var d=a.createEmptyMovieClip(b,c),e=1;this.make();for(var f=0;f=g;g++)for(var h=-2;2>=h;h++)this.modules[d+g][e+h]=-2==g||2==g||-2==h||2==h||0==g&&0==h?!0:!1}},setupTypeNumber:function(a){for(var b=f.getBCHTypeNumber(this.typeNumber),c=0;18>c;c++){var d=!a&&1==(1&b>>c);this.modules[Math.floor(c/3)][c%3+this.moduleCount-8-3]=d}for(var c=0;18>c;c++){var d=!a&&1==(1&b>>c);this.modules[c%3+this.moduleCount-8-3][Math.floor(c/3)]=d}},setupTypeInfo:function(a,b){for(var c=this.errorCorrectLevel<<3|b,d=f.getBCHTypeInfo(c),e=0;15>e;e++){var g=!a&&1==(1&d>>e);6>e?this.modules[e][8]=g:8>e?this.modules[e+1][8]=g:this.modules[this.moduleCount-15+e][8]=g}for(var e=0;15>e;e++){var g=!a&&1==(1&d>>e);8>e?this.modules[8][this.moduleCount-e-1]=g:9>e?this.modules[8][15-e-1+1]=g:this.modules[8][15-e-1]=g}this.modules[this.moduleCount-8][8]=!a},mapData:function(a,b){for(var c=-1,d=this.moduleCount-1,e=7,g=0,h=this.moduleCount-1;h>0;h-=2)for(6==h&&h--;;){for(var i=0;2>i;i++)if(null==this.modules[d][h-i]){var j=!1;g>>e));var k=f.getMask(b,d,h-i);k&&(j=!j),this.modules[d][h-i]=j,e--,-1==e&&(g++,e=7)}if(d+=c,0>d||this.moduleCount<=d){d-=c,c=-c;break}}}},b.PAD0=236,b.PAD1=17,b.createData=function(a,c,d){for(var e=j.getRSBlocks(a,c),g=new k,h=0;h8*l)throw new Error("code length overflow. ("+g.getLengthInBits()+">"+8*l+")");for(g.getLengthInBits()+4<=8*l&&g.put(0,4);0!=g.getLengthInBits()%8;)g.putBit(!1);for(;;){if(g.getLengthInBits()>=8*l)break;if(g.put(b.PAD0,8),g.getLengthInBits()>=8*l)break;g.put(b.PAD1,8)}return b.createBytes(g,e)},b.createBytes=function(a,b){for(var c=0,d=0,e=0,g=new Array(b.length),h=new Array(b.length),j=0;j=0?p.get(q):0}}for(var r=0,m=0;mm;m++)for(var j=0;jm;m++)for(var j=0;j=0;)b^=f.G15<=0;)b^=f.G18<>>=1;return b},getPatternPosition:function(a){return f.PATTERN_POSITION_TABLE[a-1]},getMask:function(a,b,c){switch(a){case e.PATTERN000:return 0==(b+c)%2;case e.PATTERN001:return 0==b%2;case e.PATTERN010:return 0==c%3;case e.PATTERN011:return 0==(b+c)%3;case e.PATTERN100:return 0==(Math.floor(b/2)+Math.floor(c/3))%2;case e.PATTERN101:return 0==b*c%2+b*c%3;case e.PATTERN110:return 0==(b*c%2+b*c%3)%2;case e.PATTERN111:return 0==(b*c%3+(b+c)%2)%2;default:throw new Error("bad maskPattern:"+a)}},getErrorCorrectPolynomial:function(a){for(var b=new i([1],0),c=0;a>c;c++)b=b.multiply(new i([1,g.gexp(c)],0));return b},getLengthInBits:function(a,b){if(b>=1&&10>b)switch(a){case c.MODE_NUMBER:return 10;case c.MODE_ALPHA_NUM:return 9;case c.MODE_8BIT_BYTE:return 8;case c.MODE_KANJI:return 8;default:throw new Error("mode:"+a)}else if(27>b)switch(a){case c.MODE_NUMBER:return 12;case c.MODE_ALPHA_NUM:return 11;case c.MODE_8BIT_BYTE:return 16;case c.MODE_KANJI:return 10;default:throw new Error("mode:"+a)}else{if(!(41>b))throw new Error("type:"+b);switch(a){case c.MODE_NUMBER:return 14;case c.MODE_ALPHA_NUM:return 13;case c.MODE_8BIT_BYTE:return 16;case c.MODE_KANJI:return 12;default:throw new Error("mode:"+a)}}},getLostPoint:function(a){for(var b=a.getModuleCount(),c=0,d=0;b>d;d++)for(var e=0;b>e;e++){for(var f=0,g=a.isDark(d,e),h=-1;1>=h;h++)if(!(0>d+h||d+h>=b))for(var i=-1;1>=i;i++)0>e+i||e+i>=b||(0!=h||0!=i)&&g==a.isDark(d+h,e+i)&&f++;f>5&&(c+=3+f-5)}for(var d=0;b-1>d;d++)for(var e=0;b-1>e;e++){var j=0;a.isDark(d,e)&&j++,a.isDark(d+1,e)&&j++,a.isDark(d,e+1)&&j++,a.isDark(d+1,e+1)&&j++,(0==j||4==j)&&(c+=3)}for(var d=0;b>d;d++)for(var e=0;b-6>e;e++)a.isDark(d,e)&&!a.isDark(d,e+1)&&a.isDark(d,e+2)&&a.isDark(d,e+3)&&a.isDark(d,e+4)&&!a.isDark(d,e+5)&&a.isDark(d,e+6)&&(c+=40);for(var e=0;b>e;e++)for(var d=0;b-6>d;d++)a.isDark(d,e)&&!a.isDark(d+1,e)&&a.isDark(d+2,e)&&a.isDark(d+3,e)&&a.isDark(d+4,e)&&!a.isDark(d+5,e)&&a.isDark(d+6,e)&&(c+=40);for(var k=0,e=0;b>e;e++)for(var d=0;b>d;d++)a.isDark(d,e)&&k++;var l=Math.abs(100*k/b/b-50)/5;return c+=10*l}},g={glog:function(a){if(1>a)throw new Error("glog("+a+")");return g.LOG_TABLE[a]},gexp:function(a){for(;0>a;)a+=255;for(;a>=256;)a-=255;return g.EXP_TABLE[a]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},h=0;8>h;h++)g.EXP_TABLE[h]=1<h;h++)g.EXP_TABLE[h]=g.EXP_TABLE[h-4]^g.EXP_TABLE[h-5]^g.EXP_TABLE[h-6]^g.EXP_TABLE[h-8];for(var h=0;255>h;h++)g.LOG_TABLE[g.EXP_TABLE[h]]=h;i.prototype={get:function(a){return this.num[a]},getLength:function(){return this.num.length},multiply:function(a){for(var b=new Array(this.getLength()+a.getLength()-1),c=0;cf;f++)for(var g=c[3*f+0],h=c[3*f+1],i=c[3*f+2],k=0;g>k;k++)e.push(new j(h,i));return e},j.getRsBlockTable=function(a,b){switch(b){case d.L:return j.RS_BLOCK_TABLE[4*(a-1)+0];case d.M:return j.RS_BLOCK_TABLE[4*(a-1)+1];case d.Q:return j.RS_BLOCK_TABLE[4*(a-1)+2];case d.H:return j.RS_BLOCK_TABLE[4*(a-1)+3];default:return void 0}},k.prototype={get:function(a){var b=Math.floor(a/8);return 1==(1&this.buffer[b]>>>7-a%8)},put:function(a,b){for(var c=0;b>c;c++)this.putBit(1==(1&a>>>b-c-1))},getLengthInBits:function(){return this.length},putBit:function(a){var b=Math.floor(this.length/8);this.buffer.length<=b&&this.buffer.push(0),a&&(this.buffer[b]|=128>>>this.length%8),this.length++}};var l=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]],o=function(){var a=function(a,b){this._el=a,this._htOption=b};return a.prototype.draw=function(a){function g(a,b){var c=document.createElementNS("http://www.w3.org/2000/svg",a);for(var d in b)b.hasOwnProperty(d)&&c.setAttribute(d,b[d]);return c}var b=this._htOption,c=this._el,d=a.getModuleCount();Math.floor(b.width/d),Math.floor(b.height/d),this.clear();var h=g("svg",{viewBox:"0 0 "+String(d)+" "+String(d),width:"100%",height:"100%",fill:b.colorLight});h.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink"),c.appendChild(h),h.appendChild(g("rect",{fill:b.colorDark,width:"1",height:"1",id:"template"}));for(var i=0;d>i;i++)for(var j=0;d>j;j++)if(a.isDark(i,j)){var k=g("use",{x:String(i),y:String(j)});k.setAttributeNS("http://www.w3.org/1999/xlink","href","#template"),h.appendChild(k)}},a.prototype.clear=function(){for(;this._el.hasChildNodes();)this._el.removeChild(this._el.lastChild)},a}(),p="svg"===document.documentElement.tagName.toLowerCase(),q=p?o:m()?function(){function a(){this._elImage.src=this._elCanvas.toDataURL("image/png"),this._elImage.style.display="block",this._elCanvas.style.display="none"}function d(a,b){var c=this;if(c._fFail=b,c._fSuccess=a,null===c._bSupportDataURI){var d=document.createElement("img"),e=function(){c._bSupportDataURI=!1,c._fFail&&_fFail.call(c)},f=function(){c._bSupportDataURI=!0,c._fSuccess&&c._fSuccess.call(c)};return d.onabort=e,d.onerror=e,d.onload=f,d.src="data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",void 0}c._bSupportDataURI===!0&&c._fSuccess?c._fSuccess.call(c):c._bSupportDataURI===!1&&c._fFail&&c._fFail.call(c)}if(this._android&&this._android<=2.1){var b=1/window.devicePixelRatio,c=CanvasRenderingContext2D.prototype.drawImage;CanvasRenderingContext2D.prototype.drawImage=function(a,d,e,f,g,h,i,j){if("nodeName"in a&&/img/i.test(a.nodeName))for(var l=arguments.length-1;l>=1;l--)arguments[l]=arguments[l]*b;else"undefined"==typeof j&&(arguments[1]*=b,arguments[2]*=b,arguments[3]*=b,arguments[4]*=b);c.apply(this,arguments)}}var e=function(a,b){this._bIsPainted=!1,this._android=n(),this._htOption=b,this._elCanvas=document.createElement("canvas"),this._elCanvas.width=b.width,this._elCanvas.height=b.height,a.appendChild(this._elCanvas),this._el=a,this._oContext=this._elCanvas.getContext("2d"),this._bIsPainted=!1,this._elImage=document.createElement("img"),this._elImage.style.display="none",this._el.appendChild(this._elImage),this._bSupportDataURI=null};return e.prototype.draw=function(a){var b=this._elImage,c=this._oContext,d=this._htOption,e=a.getModuleCount(),f=d.width/e,g=d.height/e,h=Math.round(f),i=Math.round(g);b.style.display="none",this.clear();for(var j=0;e>j;j++)for(var k=0;e>k;k++){var l=a.isDark(j,k),m=k*f,n=j*g;c.strokeStyle=l?d.colorDark:d.colorLight,c.lineWidth=1,c.fillStyle=l?d.colorDark:d.colorLight,c.fillRect(m,n,f,g),c.strokeRect(Math.floor(m)+.5,Math.floor(n)+.5,h,i),c.strokeRect(Math.ceil(m)-.5,Math.ceil(n)-.5,h,i)}this._bIsPainted=!0},e.prototype.makeImage=function(){this._bIsPainted&&d.call(this,a)},e.prototype.isPainted=function(){return this._bIsPainted},e.prototype.clear=function(){this._oContext.clearRect(0,0,this._elCanvas.width,this._elCanvas.height),this._bIsPainted=!1},e.prototype.round=function(a){return a?Math.floor(1e3*a)/1e3:a},e}():function(){var a=function(a,b){this._el=a,this._htOption=b};return a.prototype.draw=function(a){for(var b=this._htOption,c=this._el,d=a.getModuleCount(),e=Math.floor(b.width/d),f=Math.floor(b.height/d),g=[''],h=0;d>h;h++){g.push("");for(var i=0;d>i;i++)g.push('');g.push("")}g.push("
"),c.innerHTML=g.join("");var j=c.childNodes[0],k=(b.width-j.offsetWidth)/2,l=(b.height-j.offsetHeight)/2;k>0&&l>0&&(j.style.margin=l+"px "+k+"px")},a.prototype.clear=function(){this._el.innerHTML=""},a}();QRCode=function(a,b){if(this._htOption={width:256,height:256,typeNumber:4,colorDark:"#000000",colorLight:"#ffffff",correctLevel:d.H},"string"==typeof b&&(b={text:b}),b)for(var c in b)this._htOption[c]=b[c];"string"==typeof a&&(a=document.getElementById(a)),this._android=n(),this._el=a,this._oQRCode=null,this._oDrawing=new q(this._el,this._htOption),this._htOption.text&&this.makeCode(this._htOption.text)},QRCode.prototype.makeCode=function(a){this._oQRCode=new b(r(a,this._htOption.correctLevel),this._htOption.correctLevel),this._oQRCode.addData(a),this._oQRCode.make(),this._el.title=a,this._oDrawing.draw(this._oQRCode),this.makeImage()},QRCode.prototype.makeImage=function(){"function"==typeof this._oDrawing.makeImage&&(!this._android||this._android>=3)&&this._oDrawing.makeImage()},QRCode.prototype.clear=function(){this._oDrawing.clear()},QRCode.CorrectLevel=d}(); \ No newline at end of file