|
|
@ -47,6 +47,27 @@ function pad(n) { |
|
|
|
return n<10 ? '0'+n : 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; |
|
|
|
var reboottimer = null; |
|
|
|
/// Show error messsage
|
|
|
|
/// Show error messsage
|
|
|
|
/** Fades in an error message and logs to console. |
|
|
|
/** Fades in an error message and logs to console. |
|
|
@ -396,18 +417,19 @@ function recordvideo() { |
|
|
|
$("#videorecorder").show(); |
|
|
|
$("#videorecorder").show(); |
|
|
|
recorder = new MediaStreamRecorder({ |
|
|
|
recorder = new MediaStreamRecorder({ |
|
|
|
video: { |
|
|
|
video: { |
|
|
|
mandatory: { |
|
|
|
width: {ideal: 180}, |
|
|
|
maxWidth: 400, |
|
|
|
height: {ideal: 160} |
|
|
|
maxHeight: 400 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
audio: true |
|
|
|
audio: true |
|
|
|
}); |
|
|
|
}); |
|
|
|
recorder.on("ready", function() { |
|
|
|
recorder.on("ready", function() { |
|
|
|
$("#videorecorder video").attr("src", recorder.preview()); |
|
|
|
$("#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.start(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
recorder.on('') |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
console.log(e); |
|
|
|
console.log(e); |
|
|
|
error("cannot access camera", true); |
|
|
|
error("cannot access camera", true); |
|
|
@ -440,8 +462,8 @@ function previewfile(content, type, name) { |
|
|
|
$("#preview").append(img); |
|
|
|
$("#preview").append(img); |
|
|
|
success('image is ready to be sent'); |
|
|
|
success('image is ready to be sent'); |
|
|
|
} |
|
|
|
} |
|
|
|
img.title = name; |
|
|
|
|
|
|
|
img.src = canvas.toDataURL(file.type); |
|
|
|
img.src = canvas.toDataURL(file.type); |
|
|
|
|
|
|
|
img.title = name+"\n"+size(img.src.length); |
|
|
|
} |
|
|
|
} |
|
|
|
img.src=content; |
|
|
|
img.src=content; |
|
|
|
} else if (type.match('^video/')) { |
|
|
|
} else if (type.match('^video/')) { |
|
|
@ -450,13 +472,13 @@ function previewfile(content, type, name) { |
|
|
|
video.setAttribute("controls", "controls"); |
|
|
|
video.setAttribute("controls", "controls"); |
|
|
|
video.setAttribute("loop", "loop"); |
|
|
|
video.setAttribute("loop", "loop"); |
|
|
|
video.setAttribute("src", content); |
|
|
|
video.setAttribute("src", content); |
|
|
|
video.setAttribute("title", name); |
|
|
|
video.setAttribute("title", name+"\n"+size(content.length)); |
|
|
|
$("#preview").append(video); |
|
|
|
$("#preview").append(video); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
filecontent.push({name: name, type: type, content: content}); |
|
|
|
filecontent.push({name: name, type: type, content: content}); |
|
|
|
var img = document.createElement("img"); |
|
|
|
var img = document.createElement("img"); |
|
|
|
img.src = "images/Document_sans_PICOL-PIctorial-COmmunication-Language.svg"; |
|
|
|
img.src = "images/Document_sans_PICOL-PIctorial-COmmunication-Language.svg"; |
|
|
|
img.title = name; |
|
|
|
img.title = name+"\n"+size(content.length); |
|
|
|
$("#preview").append(img); |
|
|
|
$("#preview").append(img); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|