try to set size constraints, but firefox fails; show attachment size
This commit is contained in:
@@ -47,6 +47,27 @@ function pad(n) {
|
||||
return n<10 ? '0'+n : n
|
||||
}
|
||||
|
||||
/// Convert number of bytes to readable text
|
||||
function size(num) {
|
||||
if (num>0.6*1024) {
|
||||
if (num>0.6*1024*1024) {
|
||||
if (num>0.6*1024*1024*1024) {
|
||||
if (num>0.6*1024*1024*1024*1024) {
|
||||
return Math.round(num/1024/1024/1024/1024)+"TB";
|
||||
} else {
|
||||
return Math.round(num/1024/1024/1024)+"GB";
|
||||
}
|
||||
} else {
|
||||
return Math.round(num/1024/1024)+"MB";
|
||||
}
|
||||
} else {
|
||||
return Math.round(num/1024)+"kB";
|
||||
}
|
||||
} else {
|
||||
return num+"B";
|
||||
}
|
||||
}
|
||||
|
||||
var reboottimer = null;
|
||||
/// Show error messsage
|
||||
/** Fades in an error message and logs to console.
|
||||
@@ -396,18 +417,19 @@ function recordvideo() {
|
||||
$("#videorecorder").show();
|
||||
recorder = new MediaStreamRecorder({
|
||||
video: {
|
||||
mandatory: {
|
||||
maxWidth: 400,
|
||||
maxHeight: 400
|
||||
}
|
||||
width: {ideal: 180},
|
||||
height: {ideal: 160}
|
||||
},
|
||||
audio: true
|
||||
});
|
||||
recorder.on("ready", function() {
|
||||
$("#videorecorder video").attr("src", recorder.preview());
|
||||
$("#videorecorder video").css("width", 180);
|
||||
$("#videorecorder video").css("height", 160);
|
||||
$("#videorecorder video").attr("width", 180);
|
||||
$("#videorecorder video").attr("height", 160);
|
||||
recorder.start();
|
||||
});
|
||||
recorder.on('')
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
error("cannot access camera", true);
|
||||
@@ -440,8 +462,8 @@ function previewfile(content, type, name) {
|
||||
$("#preview").append(img);
|
||||
success('image is ready to be sent');
|
||||
}
|
||||
img.title = name;
|
||||
img.src = canvas.toDataURL(file.type);
|
||||
img.title = name+"\n"+size(img.src.length);
|
||||
}
|
||||
img.src=content;
|
||||
} else if (type.match('^video/')) {
|
||||
@@ -450,13 +472,13 @@ function previewfile(content, type, name) {
|
||||
video.setAttribute("controls", "controls");
|
||||
video.setAttribute("loop", "loop");
|
||||
video.setAttribute("src", content);
|
||||
video.setAttribute("title", name);
|
||||
video.setAttribute("title", name+"\n"+size(content.length));
|
||||
$("#preview").append(video);
|
||||
} else {
|
||||
filecontent.push({name: name, type: type, content: content});
|
||||
var img = document.createElement("img");
|
||||
img.src = "images/Document_sans_PICOL-PIctorial-COmmunication-Language.svg";
|
||||
img.title = name;
|
||||
img.title = name+"\n"+size(content.length);
|
||||
$("#preview").append(img);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user