KXStudio Website https://kx.studio/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.6KB

  1. function fileQueueError(file, errorCode, message) {
  2. try {
  3. if (errorCode === SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
  4. alert("You have attempted to queue too many files.\n" + (message === 0 ? "You have reached the upload limit." : "You may select " + (message > 1 ? "up to " + message + " files." : "one file.")));
  5. return;
  6. }
  7. switch (errorCode) {
  8. case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
  9. this.debug("Error Code: File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
  10. break;
  11. case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
  12. this.debug("Error Code: Zero byte file, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
  13. break;
  14. case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
  15. this.debug("Error Code: Invalid File Type, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
  16. break;
  17. default:
  18. this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
  19. break;
  20. }
  21. } catch (ex) {
  22. this.debug(ex);
  23. }
  24. }
  25. function fileDialogComplete(numFilesSelected, numFilesQueued) {
  26. try {
  27. this.startUpload();
  28. } catch (ex) {
  29. this.debug(ex);
  30. }
  31. }
  32. function uploadStart(file) {
  33. $("#progress").css("display", "block")
  34. $("input.swfupload_button").remove()
  35. $("#publish, #save").attr("disabled", "disabled").addClass("disabled")
  36. }
  37. function uploadProgress(file, bytesLoaded, bytesTotal) {
  38. try {
  39. var full_px = $("#progress .back").width()
  40. var percent = (bytesLoaded / bytesTotal) * full_px;
  41. if (percent == full_px)
  42. uploadComplete();
  43. $("#progress .fill").css("width", percent)
  44. } catch (ex) {
  45. this.debug(ex);
  46. }
  47. }
  48. function uploadSuccess(file, serverData) {
  49. try {
  50. if (/HEY_JAVASCRIPT_THIS_IS_AN_ERROR_JUST_SO_YOU_KNOW$/m.test(serverData))
  51. alert(serverData.replace(/(HEY_JAVASCRIPT_THIS_IS_AN_ERROR_JUST_SO_YOU_KNOW|<([^>]+)>\n?)/gm, ""))
  52. else
  53. $('<input type="hidden" name="filename" value="'+serverData+'" />').insertAfter("#progress")
  54. return true;
  55. } catch (ex) {
  56. this.debug(ex);
  57. }
  58. }
  59. function uploadError(file, errorCode, message) {
  60. try {
  61. switch (errorCode) {
  62. case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
  63. this.debug("Error Code: HTTP Error, File name: " + file.name + ", Message: " + message);
  64. break;
  65. case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
  66. this.debug("Error Code: Upload Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
  67. break;
  68. case SWFUpload.UPLOAD_ERROR.IO_ERROR:
  69. this.debug("Error Code: IO Error, File name: " + file.name + ", Message: " + message);
  70. break;
  71. case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
  72. this.debug("Error Code: Security Error, File name: " + file.name + ", Message: " + message);
  73. break;
  74. case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
  75. this.debug("Error Code: Upload Limit Exceeded, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
  76. break;
  77. case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
  78. this.debug("Error Code: File Validation Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
  79. break;
  80. case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
  81. break;
  82. case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
  83. break;
  84. default:
  85. this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
  86. break;
  87. }
  88. } catch (ex) {
  89. this.debug(ex);
  90. }
  91. }
  92. function uploadComplete(file) {
  93. $("#progress").addClass("done")
  94. $("#publish, #save").removeAttr("disabled").removeClass("disabled")
  95. }