var h = require('hyperscript') var pull = require('pull-stream') var sbot = require('./scuttlebot') var human = require('human-time') var id = require('./keys').id var mentions = require('ssb-mentions') var avatar = require('./avatar') var tools = require('./tools') var mime = require('simple-mime')('application/octect-stream') var split = require('split-buffer') var route = require('./views') function file_input (onAdded) { return h('label.btn', 'Upload file', h('input', { type: 'file', hidden: true, onchange: function (ev) { var file = ev.target.files[0] if (!file) return var reader = new FileReader() reader.onload = function () { pull( pull.values(split(new Buffer(reader.result), 64*1024)), sbot.addblob(function (err, blob) { if(err) return console.error(err) onAdded({ link: blob, name: file.name, size: reader.result.length || reader.result.byteLength, type: mime(file.name) }) }) ) } reader.readAsArrayBuffer(file) } })) } module.exports = function (opts, fallback) { var files = [] var filesById = {} var composer = h('div.composer') var container = h('div.container') if (opts.boostAuthor) { var boostName = avatar.cachedName(opts.boostAuthor) } if (opts.boostContent) { var textarea = h('textarea.compose', 'Blah') var str = opts.boostContent var lines = str.split("\n") for(var i=0; i