example.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. function $(id) {
  2. return document.getElementById(id);
  3. }
  4. // Default upload start function.
  5. uploadStart = function(fileObj) {
  6. $("filesDisplay").style.display = "block";
  7. var li = document.createElement("li");
  8. var txt = document.createTextNode(fileObj.name);
  9. li.className = "uploading";
  10. li.id = fileObj.name;
  11. var prg = document.createElement("span");
  12. prg.id = "progress";
  13. prg.className = "progressBar"
  14. li.appendChild(txt);
  15. li.appendChild(prg);
  16. $("mmUploadFileListing").appendChild(li);
  17. }
  18. uploadProgress = function(fileObj, bytesLoaded) {
  19. var progress = $("progress");
  20. var percent = Math.ceil((bytesLoaded / fileObj.size) * 100);
  21. console.log(fileObj);
  22. if(fileObj.type==".xlsx"){
  23. var k=100-percent;
  24. progress.style.backgroundImage = "URL(/global/js/SWFUpload/images/progressbar.png) no-repeat -" + k + "px 0";
  25. }
  26. //progress.style.background = "#999";
  27. }
  28. uploadComplete = function(fileObj) {
  29. if(fileObj.type==".xlsx"){
  30. document.getElementById('path').value=fileObj.name;
  31. $(fileObj.name).className = "uploadDone";
  32. $(fileObj.name).innerHTML += " " + (Math.ceil(fileObj.size / 1000)) + " kb";
  33. }else{
  34. $(fileObj.name).innerHTML="请上传符合文件";
  35. }
  36. }
  37. uploadCancel = function() {
  38. //alert("You pressed cancel!");
  39. }