Browse Source

Fix upload error display

master v0.2.0
clsr 6 years ago
parent
commit
e247aa4e05
  1. 1
      .gitignore
  2. 6
      pages/index.html
  3. 19
      static/pomf.js

1
.gitignore vendored

@ -2,3 +2,4 @@ @@ -2,3 +2,4 @@
/gomf
/*.go
/*.txt
/upload/

6
pages/index.html

@ -25,6 +25,12 @@ @@ -25,6 +25,12 @@
<span class="file-name">{{ .Name }}</span>
<span class="file-url"><a href="{{ .Url }}" target="_blank">{{ .Url }}</a></span>
</li>{{ end }}
{{ if or .Files .Description }}<li class="file total" data-filename="">
<span class="file-name">{{ if .Description }}{{ .Description }}{{ else }}Done!{{ end }}</span>
<span class="file-url"></span>
</li>{{ end }}
</ul>{{ end }}
</div>

19
static/pomf.js

@ -74,22 +74,15 @@ document.addEventListener('DOMContentLoaded', function() { @@ -74,22 +74,15 @@ document.addEventListener('DOMContentLoaded', function() {
row.appendChild(url);
var link = document.createElement('a');
var response = JSON.parse(xhr.responseText);
if (respStatus === 200) {
var response = JSON.parse(xhr.responseText);
if (response.success) {
link.textContent = response.files[0].url.replace(/.*?:\/\//g, "");
link.href = response.files[0].url;
url.appendChild(link);
} else {
bar.innerHTML = 'Error: ' + response.reason;
}
} else if (respStatus === 413) {
link.textContent = 'File Too big!';
url.appendChild(link);
link.textContent = response.files[0].url.replace(/.*?:\/\//g, "");
link.href = response.files[0].url;
} else {
link.textContent = 'Server error!';
url.appendChild(link);
link.textContent = response.description || 'Server error!';
bar.innerHTML = 'Error: ' + response.description;
}
url.appendChild(link);
}
function uploadFile(file, row) {

Loading…
Cancel
Save