From 0e9d65cd52919df41a7da43d5b0f88242dfc9354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz=20=28arab=2C=20vx?= =?UTF-8?q?p=29?= Date: Wed, 24 Oct 2018 22:10:25 +0200 Subject: [PATCH] js/: split into js/{ext,ui,}. index.html: updates script URIs. --- index.html | 19 ++-- js/{vendor => ext}/FileSaver.js | 0 js/{ => ext}/color.js | 0 js/{vendor => ext}/colorcode.js | 0 js/{vendor => ext}/dataUriToBlob.js | 0 js/{vendor => ext}/oktween.js | 0 js/{ => ext}/png.js | 0 js/{ => ext}/unicode.js | 0 js/{ => ext}/upload.js | 0 js/{ => ext}/user.js | 0 js/vendor/text-encoder-lite.js | 141 ---------------------------- 11 files changed, 9 insertions(+), 151 deletions(-) rename js/{vendor => ext}/FileSaver.js (100%) rename js/{ => ext}/color.js (100%) rename js/{vendor => ext}/colorcode.js (100%) rename js/{vendor => ext}/dataUriToBlob.js (100%) rename js/{vendor => ext}/oktween.js (100%) rename js/{ => ext}/png.js (100%) rename js/{ => ext}/unicode.js (100%) rename js/{ => ext}/upload.js (100%) rename js/{ => ext}/user.js (100%) delete mode 100644 js/vendor/text-encoder-lite.js diff --git a/index.html b/index.html index db26e00..6a8efb6 100644 --- a/index.html +++ b/index.html @@ -126,21 +126,20 @@ // lex.opacity = 1 - - - - - + + + + - - - + + + - - + + diff --git a/js/vendor/FileSaver.js b/js/ext/FileSaver.js similarity index 100% rename from js/vendor/FileSaver.js rename to js/ext/FileSaver.js diff --git a/js/color.js b/js/ext/color.js similarity index 100% rename from js/color.js rename to js/ext/color.js diff --git a/js/vendor/colorcode.js b/js/ext/colorcode.js similarity index 100% rename from js/vendor/colorcode.js rename to js/ext/colorcode.js diff --git a/js/vendor/dataUriToBlob.js b/js/ext/dataUriToBlob.js similarity index 100% rename from js/vendor/dataUriToBlob.js rename to js/ext/dataUriToBlob.js diff --git a/js/vendor/oktween.js b/js/ext/oktween.js similarity index 100% rename from js/vendor/oktween.js rename to js/ext/oktween.js diff --git a/js/png.js b/js/ext/png.js similarity index 100% rename from js/png.js rename to js/ext/png.js diff --git a/js/unicode.js b/js/ext/unicode.js similarity index 100% rename from js/unicode.js rename to js/ext/unicode.js diff --git a/js/upload.js b/js/ext/upload.js similarity index 100% rename from js/upload.js rename to js/ext/upload.js diff --git a/js/user.js b/js/ext/user.js similarity index 100% rename from js/user.js rename to js/ext/user.js diff --git a/js/vendor/text-encoder-lite.js b/js/vendor/text-encoder-lite.js deleted file mode 100644 index 957fd9b..0000000 --- a/js/vendor/text-encoder-lite.js +++ /dev/null @@ -1,141 +0,0 @@ -// taken from https://github.com/coolaj86/TextEncoderLite/blob/master/index.js -// added polyfill at bottom - -function TextEncoderLite() { -} -function TextDecoderLite() { -} - -(function () { -'use strict'; - -// Taken from https://github.com/feross/buffer/blob/master/index.js -// Thanks Feross et al! :-) - -function utf8ToBytes (string, units) { - units = units || Infinity - var codePoint - var length = string.length - var leadSurrogate = null - var bytes = [] - var i = 0 - - for (; i < length; i++) { - codePoint = string.charCodeAt(i) - - // is surrogate component - if (codePoint > 0xD7FF && codePoint < 0xE000) { - // last char was a lead - if (leadSurrogate) { - // 2 leads in a row - if (codePoint < 0xDC00) { - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = codePoint - continue - } else { - // valid surrogate pair - codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000 - leadSurrogate = null - } - } else { - // no lead yet - - if (codePoint > 0xDBFF) { - // unexpected trail - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } else if (i + 1 === length) { - // unpaired lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - continue - } else { - // valid lead - leadSurrogate = codePoint - continue - } - } - } else if (leadSurrogate) { - // valid bmp char, but last char was a lead - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = null - } - - // encode utf8 - if (codePoint < 0x80) { - if ((units -= 1) < 0) break - bytes.push(codePoint) - } else if (codePoint < 0x800) { - if ((units -= 2) < 0) break - bytes.push( - codePoint >> 0x6 | 0xC0, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x10000) { - if ((units -= 3) < 0) break - bytes.push( - codePoint >> 0xC | 0xE0, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else if (codePoint < 0x200000) { - if ((units -= 4) < 0) break - bytes.push( - codePoint >> 0x12 | 0xF0, - codePoint >> 0xC & 0x3F | 0x80, - codePoint >> 0x6 & 0x3F | 0x80, - codePoint & 0x3F | 0x80 - ) - } else { - throw new Error('Invalid code point') - } - } - - return bytes -} - -function utf8Slice (buf, start, end) { - var res = '' - var tmp = '' - end = Math.min(buf.length, end || Infinity) - start = start || 0; - - for (var i = start; i < end; i++) { - if (buf[i] <= 0x7F) { - res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i]) - tmp = '' - } else { - tmp += '%' + buf[i].toString(16) - } - } - - return res + decodeUtf8Char(tmp) -} - -function decodeUtf8Char (str) { - try { - return decodeURIComponent(str) - } catch (err) { - return String.fromCharCode(0xFFFD) // UTF 8 invalid char - } -} - -TextEncoderLite.prototype.encode = function (str) { - var result; - - if ('undefined' === typeof Uint8Array) { - result = utf8ToBytes(str); - } else { - result = new Uint8Array(utf8ToBytes(str)); - } - - return result; -}; - -TextDecoderLite.prototype.decode = function (bytes) { - return utf8Slice(bytes, 0, bytes.length); -} - -}()); - -if (typeof TextEncoder === 'undefined') TextEncoder = TextEncoderLite -if (typeof TextDecoder === 'undefined') TextDecoder = TextDecoderLite