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 = ' \ \ \ '; } else { rightcorner = ' \ \   '; action = ' \ \ \ '; //if( (getFileExt(file.name).toUpperCase() == 'JPG') || (getFileExt(file.name).toUpperCase() == 'PNG')){ action += ''; //} else { // action += ''; //} action += ' \ \
    \ '+L('copy')+' \ \
    \ \ \
    \
    \ \ \
    \ '+L('range')+' \ \
    \ \ \ \ '; if( (getFileExt(file.name).toUpperCase() == 'XLS') || (getFileExt(file.name).toUpperCase() == 'XLSX')){ action += '
    \ \
    \ \ '; } else if(getFileExt(file.name).toUpperCase() == 'PDF'){ action += '
    \ \
    \ \ '; } } var template = ' \
    \
    \ '+rightcorner+'
    \ '+file.name+' - 1้กต \
    \
    \
    \ '+action+'
    \
    \
    \ '; $(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);