git ssb

7+

dinoworm 🐛 / patchcore



Commit 9e85f1068f54ff3bc4458e10ee35cd4f89c31434

standardize!

Matt McKegg committed on 7/8/2018, 2:52:20 AM
Parent: a25ce72e2aaed3ec44c050011d9394502c4cc797

Files changed

blob/html/input.jschanged
message/html/markdown.jschanged
blob/html/input.jsView
@@ -27,22 +27,19 @@
2727
2828 var mimeType = mime(file.name)
2929 var fileName = file.name
3030
31- getFileData(file, function(fileData) {
32- var orientation = 0;
33- if (mimeType == "image/jpeg") {
31 + getFileData(file, function (fileData) {
32 + var orientation = 0
33 + if (mimeType === 'image/jpeg') {
3434 try {
3535 orientation = getOrientation(fileData)
3636
37- if ((typeof opts.removeExif == 'function' && opts.removeExif()) ||
38- opts.removeExif === true)
39- fileData = removeExif(fileData, orientation)
37 + if ((typeof opts.removeExif === 'function' && opts.removeExif()) ||
38 + opts.removeExif === true) { fileData = removeExif(fileData, orientation) }
39 + } catch (ex) {
40 + console.log('exif exception:', ex)
4041 }
41- catch (ex)
42- {
43- console.log("exif exception:", ex)
44- }
4542 }
4643
4744 // handle exif orientation data and resize
4845 if (orientation >= 3 || opts.resize) {
@@ -67,17 +64,17 @@
6764 next(dataURItoBlob(fileData))
6865 }
6966 })
7067
71- function dataURItoBlob(dataURI) {
72- var byteString = atob(dataURI.split(',')[1]);
68 + function dataURItoBlob (dataURI) {
69 + var byteString = window.atob(dataURI.split(',')[1])
7370 var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]
74- var ab = new ArrayBuffer(byteString.length);
75- var ia = new Uint8Array(ab);
71 + var ab = new ArrayBuffer(byteString.length)
72 + var ia = new Uint8Array(ab)
7673 for (var i = 0; i < byteString.length; i++) {
77- ia[i] = byteString.charCodeAt(i);
74 + ia[i] = byteString.charCodeAt(i)
7875 }
79- return new Blob([ab], {type: mimeString});
76 + return new window.Blob([ab], {type: mimeString})
8077 }
8178
8279 function next (file) {
8380 var reader = new global.FileReader()
@@ -136,10 +133,9 @@
136133 ctx.drawImage(image, -offsetX, -offsetY, finalWidth, finalHeight)
137134 return canvas
138135 }
139136
140-function getFileData(file, cb)
141-{
137 +function getFileData (file, cb) {
142138 var reader = new global.FileReader()
143139 reader.onload = function (e) {
144140 cb(e.target.result)
145141 }
@@ -147,21 +143,21 @@
147143 }
148144
149145 function removeExif (fileData, orientation) {
150146 var clean = piexif.remove(fileData)
151- if (orientation != undefined) { // preserve
152- var exifData = { "0th": {} }
153- exifData["0th"][piexif.ImageIFD.Orientation] = orientation
147 + if (orientation !== undefined) { // preserve
148 + var exifData = { '0th': {} }
149 + exifData['0th'][piexif.ImageIFD.Orientation] = orientation
154150 var exifStr = piexif.dump(exifData)
155151 return piexif.insert(exifStr, clean)
152 + } else {
153 + return clean
156154 }
157- else
158- return clean
159155 }
160156
161157 function getOrientation (fileData) {
162- var exif = piexif.load(fileData);
163- return exif["0th"][piexif.ImageIFD.Orientation]
158 + var exif = piexif.load(fileData)
159 + return exif['0th'][piexif.ImageIFD.Orientation]
164160 }
165161
166162 function rotate (img, orientation) {
167163 var canvas = document.createElement('canvas')
message/html/markdown.jsView
@@ -3,9 +3,9 @@
33 const ref = require('ssb-ref')
44 const nest = require('depnest')
55 var htmlEscape = require('html-escape')
66 var watch = require('mutant/watch')
7-const querystring = require('querystring');
7 +const querystring = require('querystring')
88
99 exports.needs = nest({
1010 'blob.sync.url': 'first',
1111 'blob.obs.has': 'first',
@@ -37,9 +37,9 @@
3737 }
3838 }
3939 })
4040 }
41-
41 +
4242 return h('Markdown', {
4343 hooks: [
4444 LoadingBlobHook(api.blob.obs.has)
4545 ],

Built with git-ssb-web