presenter_addfiles.js 4.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. function startUpload(id){ ;
  2. if (qSize < uploadLimit)
  3. $('#fileInput').fileUploadStart();
  4. } $(document).ready(function() {
  5. var scriptData = {
  6. 'cmid':cmid,
  7. 'itemid':itemid,
  8. 'signature':signature,
  9. 'signeddata':signeddata
  10. }
  11. //scriptData[ sessioncookiename ] = sessioncookievalue;
  12. $("#uploadButton").hide();$('#fileInput').fileUpload ({'uploader' : 'lib/multiplefileupload/uploader.swf','script' : 'lib/multiplefileupload/upload.php','scriptData' : scriptData,'multi' : true,'cancelImg' : 'lib/multiplefileupload/cancel.png','buttonText': 'Select Files','auto' : false,'folder' : 'uploads','fileDesc' : 'jpg;png;gif;htm;html;mov','fileExt' : '*.jpg;*.png;*.gif;*.htm;*.html;*.mov',onError: function (a, b, c, d) {
  13. if (d.status == 404)
  14. alert('Could not find upload script.');
  15. else if (d.type === "HTTP")
  16. alert('error '+d.type+": "+d.status);
  17. else if (d.type ==="File Size")
  18. alert(c.name+' '+d.type+' Limit: '+Math.round(d.sizeLimit/1024)+'KB');
  19. else
  20. alert('error '+d.type+": "+d.text);
  21. }, 'onAllComplete': function() {uploadArray.sort();var fileDisplayArea = $("#filesUploaded");fileDisplayArea.append($ ('<div id="fileTables"></div>'));var jList = $( "#fileTables" );$.each(uploadArray,function( intIndex, objValue ){var start = objValue.length-4;extension=objValue.substr(start,4);extension=extension.toLowerCase();var fname = objValue.substr(0,objValue.length-4);tableData= '<table ><tr><td width=100>Name:</td><td> <input type="text" id="filename" name="filename[]" value="'+fname.replace(' \(','_\(').replace('\) ','\)_').replace(' ','_').replace(' ','_')+'" size="60" maxlength="255" /></td><td width="100">';if ((extension=='.jpg') || (extension=='.gif') || (extension=='.png')) {tableData += '<label>Type:</label><select name="ftype[]" id="type" size="1"><option name="" value="">image</option></select></td></tr></table>';tableData += '<table ><tr><td><img src="'+uploadWwwDir+objValue.replace(' \(','_\(').replace('\) ','\)_').replace(' ','_')+'" width="100" height="100"></td></tr></table>';} else if (extension=='.mov') {tableData+= '<label>Type:</label><select name="" id="type" size="1"><option name="" value="">video</option></select></td></tr></table>';tableData += '<table ><tr><td><embed src="'+uploadWwwDir+objValue.replace(' \(','_\(').replace('\) ','\)_').replace(' ','_')+'" width="100" height="100" autohref="false"></td></tr></table>'} else if ((extension=='.htm') ||(extension=='html')) {tableData+= '<label>Type:</label><select name="" id="type" size="1"><option name="" value="">web</option></select></td></tr></table>';}tableData+='<table ><tr><td width=100>Url:</td><td><input type="text" id="fileurl" name="fileurl[]" value="'+uploadWwwDir+objValue.replace(' \(','_\(').replace('\) ','\)_').replace(' ','_').replace(' ','_')+'" size="60" maxlength="255" /></td></tr></table><HR>';jList.append($ (tableData)); });jList.append($ ('<input type="submit" value="Add the above files to the presentation" name="fileaddentry" />')); $("#uploadButton").hide(); $("#qSize").hide();qSize=0; }, 'onSelect': function (event,queueID,fileObj){
  22. $("#qSize").show();
  23. qSize += fileObj.size;
  24. if (qSize > uploadLimit){
  25. $("#uploadButton").hide();
  26. $("#qSize").css("color","red");
  27. $("#qSize").text("Error: You have selected "+qSize+ " bytes to upload. Bulk upload size is limited to: "+uploadLimit);
  28. } else
  29. {
  30. $("#uploadButton").show();
  31. $("#qSize").css("color","blue");
  32. $("#qSize").html(qSize+" bytes selected. <b>"+(uploadLimit-qSize) + "</b> bytes available to queue");
  33. }
  34. },
  35. 'onCancel': function (event,queueID,fileObj){
  36. qSize -= fileObj.size;
  37. if (qSize > uploadLimit){
  38. $("#uploadButton").hide();
  39. $("#qSize").css("color","red");
  40. $("#qSize").text("Error: You have selected "+qSize+ " bytes to upload. Bulk upload size is limited to: "+uploadLimit);
  41. } else
  42. {
  43. $("#uploadButton").show();
  44. $("#qSize").css("color","blue");
  45. $("#qSize").html(qSize+" bytes selected. <b>"+(uploadLimit-qSize) + "</b> bytes available to queue");
  46. }
  47. },
  48. 'onComplete': function(event, queueID, fileObj, response, data) {uploadArray[uploadArrayLen]=fileObj.name;uploadArrayLen++;$('#fileTables').remove();} }); });