function getFileExt(filename) {
return filename.split('.').pop();
}
(function( $, window, undefined ) {
$.danidemo = $.extend( {}, {
addLog: function(id, status, str){
var d = new Date();
var li = $('
', {'class': 'demo-' + status});
var message = '[' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds() + '] ';
message += str;
li.html(message);
$(id).prepend(li);
},
addFile: function(id, i, file){
i = counter++;
console.log('addFile i:'+ i);
g_filenamelist[i] = file.name;
g_tmpaddfile++;
rightcorner = "";
action = '';
var colorclass = '';
if(g_def.def_color == 'Color'){
colorclass = ' label-danger';
}
if(g_mobile){
action = ''+L(g_def.def_colorl)+' \
'+L(g_def.def_duplexl)+' \
'+L('more')+' \
'+L('delete')+' ';
} else {
rightcorner = ' \
'+L('preview')+' \
'+L('delete')+' ';
action = ' \
'+L(g_def.def_colorl)+' \
'+L(g_def.def_duplexl)+' \
';
//if( (getFileExt(file.name).toUpperCase() == 'JPG') || (getFileExt(file.name).toUpperCase() == 'PNG')){
action += ''+show_size+' ';
//} else {
// action += ''+L('Auto')+' ';
//}
action += ' \ \
\
\
\
\
'+L('range')+' \
\
\
\
\ \
';
if( (getFileExt(file.name).toUpperCase() == 'XLS') || (getFileExt(file.name).toUpperCase() == 'XLSX')){
action += '\
\
'+L('all_sheets')+'\
\
\
\ ';
} else if(getFileExt(file.name).toUpperCase() == 'PDF'){
action += '\
\
'+L('printasimage')+'\
\
\
\ ';
}
}
var template =
' \
\
\
\
'+file.name+' - 1้กต \
'+rightcorner+'
\
\
\
\
';
$(id).prepend(template);
},
updateFileStatus: function(i, status, message){
$('#demo-file' + i).find('span.demo-file-status').html(message).addClass('demo-file-status-' + status);
},
updateFileProgress: function(i, percent){
$('#demo-file' + i).find('div.progress-bar').width(percent);
$('#demo-file' + i).find('span.sr-only').html(percent + ' Complete');
},
humanizeSize: function(size) {
var i = Math.floor( Math.log(size) / Math.log(1024) );
return ( size / Math.pow(1024, i) ).toFixed(2) * 1 + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i];
}
}, $.danidemo);
})(jQuery, this);