mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
display on progress uploading files, show PUT error
This commit is contained in:
parent
dfcd42e917
commit
92e2cf3b96
4 changed files with 33 additions and 11 deletions
|
|
@ -18,16 +18,18 @@ function uploadFile(files, nr, uri) {
|
||||||
xhr.onreadystatechange = function () {
|
xhr.onreadystatechange = function () {
|
||||||
if (xhr.readyState === 4) {
|
if (xhr.readyState === 4) {
|
||||||
var newHash = xhr.responseText;
|
var newHash = xhr.responseText;
|
||||||
|
console.log("New hash - " + newHash);
|
||||||
if (newHash.length != 64) {
|
if (newHash.length != 64) {
|
||||||
// something wrong
|
// something wrong
|
||||||
console.log("Something wrong on uploading");
|
console.log("Something wrong on uploading");
|
||||||
console.log(newHash);
|
alert('Oh, error on PUT file to BZZ. See log for more information.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("new hash - " + newHash);
|
insertImage(files, nr, newHash, currentFile.name, function () {
|
||||||
insertImage(files, nr, newHash, currentFile.name);
|
uploadFile(files, nr + 1, "/bzz:/" + newHash + "/");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.open("PUT", uri + "imgs/" + currentFile.name, true);
|
xhr.open("PUT", uri + "imgs/" + currentFile.name, true);
|
||||||
|
|
@ -48,7 +50,7 @@ function readFile(file, onComplete) {
|
||||||
reader.readAsArrayBuffer(file);
|
reader.readAsArrayBuffer(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
function insertImage(files, nr, newHash, fileName) {
|
function insertImage(files, nr, newHash, fileName, onComplete) {
|
||||||
// insert image into index
|
// insert image into index
|
||||||
var img = new Image();
|
var img = new Image();
|
||||||
img.onload = function () {
|
img.onload = function () {
|
||||||
|
|
@ -68,16 +70,24 @@ function insertImage(files, nr, newHash, fileName) {
|
||||||
} else {
|
} else {
|
||||||
// square
|
// square
|
||||||
thumbData[0] = imageToUrl(img, thumbSize, thumbSize);
|
thumbData[0] = imageToUrl(img, thumbSize, thumbSize);
|
||||||
thumbData[1] = [w, thumbSize];
|
thumbData[1] = [thumbSize, thumbSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jQuery('#currentPreview').attr('src', thumbData[0]);
|
||||||
// update index
|
// update index
|
||||||
var imgData = [];
|
var imgData = [];
|
||||||
imgData[0] = "imgs/" + fileName;
|
imgData[0] = "imgs/" + fileName;
|
||||||
imgData[1] = [img.naturalWidth, img.naturalHeight];
|
imgData[1] = [img.naturalWidth, img.naturalHeight];
|
||||||
imgs.data.splice(eidx, 0, {img: imgData, thumb: thumbData, blur: blur});
|
imgs.data.splice(eidx, 0, {img: imgData, thumb: thumbData, blur: blur});
|
||||||
console.log("this one");
|
if (onComplete) {
|
||||||
uploadFile(files, nr + 1, "/bzz:/" + newHash + "/");
|
onComplete();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
img.onerror = function () {
|
||||||
|
if (onComplete) {
|
||||||
|
onComplete();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
img.src = "/bzz:/" + newHash + "/imgs/" + fileName;
|
img.src = "/bzz:/" + newHash + "/imgs/" + fileName;
|
||||||
|
|
|
||||||
|
|
@ -289,3 +289,7 @@ img
|
||||||
{
|
{
|
||||||
background: url(cut-mov.png) top left repeat-y, url(cut-mov.png) top right repeat-y;
|
background: url(cut-mov.png) top left repeat-y, url(cut-mov.png) top right repeat-y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#currentPreview {
|
||||||
|
max-height: 120px;
|
||||||
|
}
|
||||||
|
|
@ -12,9 +12,9 @@
|
||||||
<script src="mootools-more-1.4.js" type="text/javascript"></script>
|
<script src="mootools-more-1.4.js" type="text/javascript"></script>
|
||||||
<script src="mootools-idle.js" type="text/javascript"></script>
|
<script src="mootools-idle.js" type="text/javascript"></script>
|
||||||
<script src="mootools-mooswipe.js" type="text/javascript"></script>
|
<script src="mootools-mooswipe.js" type="text/javascript"></script>
|
||||||
|
|
||||||
<script src="index.js" type="text/javascript"></script>
|
|
||||||
<script src="file-manager.js" type="text/javascript"></script>
|
<script src="file-manager.js" type="text/javascript"></script>
|
||||||
|
<script src="index.js" type="text/javascript"></script>
|
||||||
|
|
||||||
<link href="index.css" rel="stylesheet" type="text/css"/>
|
<link href="index.css" rel="stylesheet" type="text/css"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@
|
||||||
// Copyright(c) 2003-2014 by wave++ "Yuri D'Elia" <wavexx@thregr.org>
|
// Copyright(c) 2003-2014 by wave++ "Yuri D'Elia" <wavexx@thregr.org>
|
||||||
// Distributed under GPL2 (see COPYING) WITHOUT ANY WARRANTY.
|
// Distributed under GPL2 (see COPYING) WITHOUT ANY WARRANTY.
|
||||||
var datafile = 'data.json';
|
var datafile = 'data.json';
|
||||||
var padding = 22;
|
var padding = 100;
|
||||||
|
var marginTop = 50;
|
||||||
var duration = 500;
|
var duration = 500;
|
||||||
var thrdelay = 1500;
|
var thrdelay = 1500;
|
||||||
var hidedelay = 3000;
|
var hidedelay = 3000;
|
||||||
|
|
@ -41,6 +42,7 @@ var eback; // background
|
||||||
var enoise; // additive noise
|
var enoise; // additive noise
|
||||||
var eflash; // flashing object
|
var eflash; // flashing object
|
||||||
var ehdr; // header
|
var ehdr; // header
|
||||||
|
var progress; // progress
|
||||||
var elist; // thumbnail list
|
var elist; // thumbnail list
|
||||||
var fscr; // thumbnail list scroll fx
|
var fscr; // thumbnail list scroll fx
|
||||||
var econt; // picture container
|
var econt; // picture container
|
||||||
|
|
@ -231,7 +233,7 @@ function resizeMainImg(img)
|
||||||
img.setStyles(
|
img.setStyles(
|
||||||
{
|
{
|
||||||
'position': 'absolute',
|
'position': 'absolute',
|
||||||
'top': contSize.y / 2 - img.height / 2,
|
'top': (contSize.y / 2 - img.height / 2) + marginTop,
|
||||||
'left': contSize.x / 2 - img.width / 2
|
'left': contSize.x / 2 - img.width / 2
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -362,6 +364,9 @@ function onMainReady()
|
||||||
ehdr.set('html', dsc.join(' '));
|
ehdr.set('html', dsc.join(' '));
|
||||||
ehdr.setStyle('display', (dsc.length? 'block': 'none'));
|
ehdr.setStyle('display', (dsc.length? 'block': 'none'));
|
||||||
|
|
||||||
|
progress.set('html', '<img id="currentPreview">');
|
||||||
|
progress.set('style', 'text-align: center; padding-top: 20px');
|
||||||
|
|
||||||
// complete thumbnails
|
// complete thumbnails
|
||||||
var d = duration;
|
var d = duration;
|
||||||
if(first !== false)
|
if(first !== false)
|
||||||
|
|
@ -596,6 +601,9 @@ function initGallery(data)
|
||||||
ehdr = new Element('div', { id: 'header' });
|
ehdr = new Element('div', { id: 'header' });
|
||||||
ehdr.inject(econt);
|
ehdr.inject(econt);
|
||||||
|
|
||||||
|
progress = new Element('div', { id: 'progress' });
|
||||||
|
progress.inject(econt);
|
||||||
|
|
||||||
elist = new Element('div', { id: 'list' });
|
elist = new Element('div', { id: 'list' });
|
||||||
elist.inject(emain);
|
elist.inject(emain);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue