From 08a51af8eafabc6c074ca5a924d86a48280a7357 Mon Sep 17 00:00:00 2001 From: clsr Date: Fri, 9 Dec 2016 13:55:09 +0100 Subject: Initial commit --- .gitignore | 9 +++ pages/index.html | 40 ++++++++++++ static/gomf.css | 159 +++++++++++++++++++++++++++++++++++++++++++++++ static/gomf.js | 184 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 392 insertions(+) create mode 100644 .gitignore create mode 100644 pages/index.html create mode 100644 static/gomf.css create mode 100644 static/gomf.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fbd7d54 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*.swp +/gomf +/*.go +/*.txt +/upload/ +/run-gomf.bash +/gomf-modpanel +/deleted.log.json +/log/ diff --git a/pages/index.html b/pages/index.html new file mode 100644 index 0000000..f27d46d --- /dev/null +++ b/pages/index.html @@ -0,0 +1,40 @@ + + + + + {{.SiteName}} + + + + + + +

{{.SiteName}}

+ +
+

Maximum file size: {{.MaxSize}}.

+
+
+ Select file + +
+ +
+ {{with .Result}}{{end}} +
+ + + + diff --git a/static/gomf.css b/static/gomf.css new file mode 100644 index 0000000..5b34792 --- /dev/null +++ b/static/gomf.css @@ -0,0 +1,159 @@ +html, body, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, address, cite, +code, b, u, i, form, label, article, aside, footer, header, menu, nav, section { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} + +article, aside, footer, header, menu, nav, section { + display: block; +} + +body { + line-height: 1.25; + padding: 1em; + color: #000; + background-color: #fff; + max-width: 800px; + margin-left: auto; + margin-right: auto; +} + +html { + font-family: "DejaVu Sans", sans-serif; +} + +h1 { + font-size: 200%; + font-weight: bold; + border-bottom: 1px solid black; + margin-bottom: 0.5em; +} + +input, select, textarea, code { + border: 1px solid black; + background: inherit; + font: inherit; + font-family: "DejaVu Sans Mono", monospace; +} + +progress { + appearance: none; + background-color: inherit; + color: inherit; + border: 1px solid black; + font: inherit; +} + +input, select { + font: inherit; + cursor: pointer; +} + +.file span { + padding-left: 0.25em; + padding-right: 0.25em; + padding-top: 2em; + padding-bottom: 2em; + overflow: hidden; + width: 100%; + text-align: center; +} + +.file { + padding-top: 2em; + padding-bottom: 2em; + height: 22px; + min-height: 22px; + position: relative; + border: 1px solid black; + margin-right: 0.2em; + width: 100%; +} + +main form { + margin-top: 1em; + margin-bottom: 1em; + display: flex; +} + +.file input[type=file] { + margin-top: -2em; + padding-top: 2em; + padding-bottom: 2em; + position: relative; + text-align: right; + opacity: 0; + filter: alpha(opacity: 0); + -moz-opacity: 0; + z-index: 2; + width: 100%; +} + +.file span { + position: absolute; + top: 0px; + left: 0px; + z-index: 1; +} + +.file:hover { + background-color: #eee; +} + +input:disabled { + background-color: #ddd; +} + +b { + font-weight: bold; +} + +i { + font-style: italic; +} + +nav { + margin-top: 2em; + list-style-type: none; + font-size: 80%; + text-align: center; + font-weight: bold; +} + +nav a { + display: inline; + cursor: pointer; + font-weight: normal; + border: none; + background: inherit; + color: inherit; + padding: 0; + font: inherit; + font-weight: normal; + text-decoration: none; +} + +nav a:hover { + text-decoration: underline; +} + +nav li { + display: inline-block; +} + +nav li:after { + content: " | "; + white-space: pre; + cursor: default; + text-decoration: none; + display: inline-block; + font-weight: normal; +} + +nav li:last-child:after { + content: ""; +} diff --git a/static/gomf.js b/static/gomf.js new file mode 100644 index 0000000..da14d14 --- /dev/null +++ b/static/gomf.js @@ -0,0 +1,184 @@ +(function() { + var gomfload = function() { + "use strict"; + + var required = ['FormData', 'XMLHttpRequest']; + for (var i=0; i maxSize) { + alert('File ' + files[i].name + ' too large, maximum allowed size is ' + humanize(maxSize)); + fileInput.value = ''; + updateName(); + return; + } + } + + for (var i=0; i= 1024 && i < units.length-1) { + n /= 1024; + ++i; + } + return (Math.round(n*10)/10) + ' ' + units[i]; + }; + + var submit = function(e) { + upload(fileInput.files); + e.preventDefault(); + }; + + var updateName = function(files) { + files = files || fileInput.files; + if (files.length > 0) { + if (files.length == 1) { + fileName.textContent = files[0].name; + } else { + fileName.textContent = files.length + ' files selected'; + } + } else { + fileName.textContent = fileName.originalText; + } + }; + + var dragenter = function(e) { + e.stopPropagation(); + e.preventDefault(); + }; + + var drop = function(e) { + e.stopPropagation(); + e.preventDefault(); + upload(e.dataTransfer.files); + }; + + fileInput.addEventListener('change', submit); + fileInput.addEventListener('dragenter', dragenter); + fileInput.addEventListener('dragover', dragenter); + fileInput.addEventListener('drop', drop); + + fileName.textContent = 'Select or drop files here'; + fileName.originalText = fileName.textContent; + fileDiv.className = 'file'; + fileInput.multiple = 'multiple'; + fileSubmit.style.display = 'none'; + + updateName(); + }; + + if (document.readyState !== 'loading') { + gomfload(); + } else { + document.addEventListener('DOMContentLoaded', gomfload); + } +})(); -- cgit