Development

Changeset 24364

You must first sign up to be able to contribute.

Changeset 24364

Show
Ignore:
Timestamp:
11/25/09 02:09:07 (3 years ago)
Author:
Crafty_Shadow
Message:

[sfImaginablePlugin] Removed garbage files

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfImaginablePlugin/branches/experimental

    • Property tsvn:logtemplate set to [sfImaginablePlugin]
  • plugins/sfImaginablePlugin/branches/experimental/web/css/default.css

    r24360 r24364  
     1code { 
     2  display: block; 
     3  background:#edffb8 none repeat scroll 0%; 
     4  border-color:#b2da3a; 
     5  border-style:solid; 
     6  border-width:1px 0; 
     7  font-size: 1em; 
     8  margin: 1em 0pt; 
     9  overflow:auto; 
     10  padding: 0.3em 0.4em; 
     11  white-space:pre; 
     12} 
     13 
    114/* -- Layout ------------------------------- */ 
     15  /* hide link text */ 
     16  #logo a { 
     17    display: block; 
     18    color: #fff; 
     19    text-indent: -5000px; 
     20    overflow: hidden; 
     21    height: 106px; 
     22    width: 272px; 
     23  } 
     24   
     25  #version { 
     26    color: #fff; 
     27    position: absolute; 
     28    right: 20px; 
     29    top: 85px; 
     30  } 
     31 
     32 
     33#content { width: 680px;} 
     34#content { margin: 20px 90px; } 
     35 
     36 
     37 
     38 
     39/* -- Form Styles ------------------------------- */ 
     40form {   
     41  margin: 0; 
     42  padding: 0; 
     43} 
    244 
    345 
     
    5294  display:block; 
    5395  margin-right: 5px; 
    54 }                                
    55  
    56  
    57  
    58 /* 
    59 Default style definitions for: 
    60  
    61 Uploadify v1.6.2 
    62 Copyright (C) 2009 by Ronnie Garcia 
    63 Co-developed by Travis Nickels 
    64 */ 
    65 .fileUploadQueueItem { 
    66   font: 11px Verdana, Geneva, sans-serif; 
    67   background-color: #F5F5F5; 
    68   border: 3px solid #E5E5E5; 
    69   margin-top: 5px; 
    70   padding: 10px; 
    71   width: 300px; 
    72 
    73 .fileUploadQueueItem .cancel { 
     96
     97 
     98#btnSubmit { margin: 0 0 0 155px ; } 
     99 
     100/* -- Table Styles ------------------------------- */ 
     101td { 
     102  font: 10pt Helvetica, Arial, sans-serif; 
     103  vertical-align: top; 
     104
     105 
     106.progressWrapper { 
     107  width: 357px; 
     108  overflow: hidden; 
     109
     110 
     111.progressContainer { 
     112  margin: 5px; 
     113  padding: 4px; 
     114  border: solid 1px #E8E8E8; 
     115  background-color: #F7F7F7; 
     116  overflow: hidden; 
     117
     118/* Message */ 
     119.message { 
     120  margin: 1em 0; 
     121  padding: 10px 20px; 
     122  border: solid 1px #FFDD99; 
     123  background-color: #FFFFCC; 
     124  overflow: hidden; 
     125
     126/* Error */ 
     127.red { 
     128  border: solid 1px #B50000; 
     129  background-color: #FFEBEB; 
     130
     131 
     132/* Current */ 
     133.green { 
     134  border: solid 1px #DDF0DD; 
     135  background-color: #EBFFEB; 
     136
     137 
     138/* Complete */ 
     139.blue { 
     140  border: solid 1px #CEE2F2; 
     141  background-color: #F0F5FF; 
     142
     143 
     144.progressName { 
     145  font-size: 8pt; 
     146  font-weight: 700; 
     147  color: #555; 
     148  width: 323px; 
     149  height: 14px; 
     150  text-align: left; 
     151  white-space: nowrap; 
     152  overflow: hidden; 
     153
     154 
     155.progressBarInProgress, 
     156.progressBarComplete, 
     157.progressBarError { 
     158  font-size: 0; 
     159  width: 0%; 
     160  height: 2px; 
     161  background-color: blue; 
     162  margin-top: 2px; 
     163
     164 
     165.progressBarComplete { 
     166  width: 100%; 
     167  background-color: green; 
     168  visibility: hidden; 
     169
     170 
     171.progressBarError { 
     172  width: 100%; 
     173  background-color: red; 
     174  visibility: hidden; 
     175
     176 
     177.progressBarStatus { 
     178  margin-top: 2px; 
     179  width: 337px; 
     180  font-size: 7pt; 
     181  font-family: Arial; 
     182  text-align: left; 
     183  white-space: nowrap; 
     184
     185 
     186a.progressCancel { 
     187  font-size: 0; 
     188  display: block; 
     189  height: 14px; 
     190  width: 14px; 
     191  background-image: url(../images/cancelbutton.gif); 
     192  background-repeat: no-repeat; 
     193  background-position: -14px 0px; 
    74194  float: right; 
    75195} 
    76 .fileUploadProgress { 
    77   background-color: #FFFFFF; 
    78   border-top: 1px solid #808080; 
    79   border-left: 1px solid #808080; 
    80   border-right: 1px solid #C5C5C5; 
    81   border-bottom: 1px solid #C5C5C5; 
    82   margin-top: 10px; 
    83   width: 100%; 
    84 
    85 .fileUploadProgressBar { 
    86   background-color: #0099FF; 
    87 
    88  
    89  
    90  
    91  
    92 /* 
    93   sfImaginable extra styles 
    94 */ 
    95  
    96 #indicator{ 
    97   display:none;  
    98   margin: auto;  
    99   vertical-align:middle; 
    100 
    101  
    102 .loading-error{ 
    103   background-color: #FFFF66;  
    104   border-top: solid 4px #FF9966;  
    105   border-bottom: solid 4px #FF9966;  
    106   margin: 10px 25px;  
    107   padding: 10px 15px; 
    108 
    109  
    110 div.loading-error{ 
    111     display: none;   
    112 
    113  
    114 div.sfImaginable_list_record{ 
    115   width: 100%;  
    116   height: 97px; 
    117 
    118  
    119 div.sfImaginable_list_record-highlight{ 
    120   width: 100%;  
    121   height: 97px; 
    122   background-color: #FFFF66;  
    123 
    124  
    125 div.sfImaginable_list_record p{ 
    126   margin-left: 90px;  
    127   margin-bottom: 10px 
    128 
     196 
     197a.progressCancel:hover { 
     198  background-position: 0px 0px; 
     199
     200 
     201 
     202/* -- SWFUpload Object Styles ------------------------------- */ 
     203.swfupload { 
     204  vertical-align: top; 
     205
  • plugins/sfImaginablePlugin/branches/experimental/web/js/fileprogress.js

    r24360 r24364  
    11/* 
    2   A simple class for displaying file information and progress 
    3   Note: This is a demonstration only and not part of SWFUpload. 
    4   Note: Some have had problems adapting this class in IE7. It may not be suitable for your application. 
     2 A simple class for displaying file information and progress 
     3 Note: This is a demonstration only and not part of SWFUpload. 
     4 Note: Some have had problems adapting this class in IE7. It may not be suitable for your application. 
    55*/ 
    66 
     
    1010// Instantiating a new FileProgress object with an existing file will reuse/update the existing DOM elements 
    1111function FileProgress(file, targetID) { 
    12   this.fileProgressID = file.id; 
    13  
    14   this.opacity = 100; 
    15   this.height = 0; 
    16    
    17  
    18   this.fileProgressWrapper = document.getElementById(this.fileProgressID); 
    19   if (!this.fileProgressWrapper) { 
    20     this.fileProgressWrapper = document.createElement("div"); 
    21     this.fileProgressWrapper.className = "progressWrapper"; 
    22     this.fileProgressWrapper.id = this.fileProgressID; 
    23  
    24     this.fileProgressElement = document.createElement("div"); 
    25     this.fileProgressElement.className = "progressContainer"; 
    26  
    27     var progressCancel = document.createElement("a"); 
    28     progressCancel.className = "progressCancel"; 
    29     progressCancel.href = "#"; 
    30     progressCancel.style.visibility = "hidden"; 
    31     progressCancel.appendChild(document.createTextNode(" ")); 
    32  
    33     var progressText = document.createElement("div"); 
    34     progressText.className = "progressName"; 
    35     progressText.appendChild(document.createTextNode(file.name)); 
    36  
    37     var progressBar = document.createElement("div"); 
    38     progressBar.className = "progressBarInProgress"; 
    39  
    40     var progressStatus = document.createElement("div"); 
    41     progressStatus.className = "progressBarStatus"; 
    42     progressStatus.innerHTML = " "; 
    43  
    44     this.fileProgressElement.appendChild(progressCancel); 
    45     this.fileProgressElement.appendChild(progressText); 
    46     this.fileProgressElement.appendChild(progressStatus); 
    47     this.fileProgressElement.appendChild(progressBar); 
    48  
    49     this.fileProgressWrapper.appendChild(this.fileProgressElement); 
    50  
    51     document.getElementById(targetID).appendChild(this.fileProgressWrapper); 
    52   } else { 
    53     this.fileProgressElement = this.fileProgressWrapper.firstChild; 
    54     this.reset(); 
    55  
    56  
    57   this.height = this.fileProgressWrapper.offsetHeight; 
    58   this.setTimer(null); 
     12 this.fileProgressID = file.id; 
     13 
     14 this.opacity = 100; 
     15 this.height = 0; 
     16   
     17 
     18 this.fileProgressWrapper = document.getElementById(this.fileProgressID); 
     19 if (!this.fileProgressWrapper) { 
     20   this.fileProgressWrapper = document.createElement("div"); 
     21   this.fileProgressWrapper.className = "progressWrapper"; 
     22   this.fileProgressWrapper.id = this.fileProgressID; 
     23 
     24   this.fileProgressElement = document.createElement("div"); 
     25   this.fileProgressElement.className = "progressContainer"; 
     26 
     27   var progressCancel = document.createElement("a"); 
     28   progressCancel.className = "progressCancel"; 
     29   progressCancel.href = "#"; 
     30   progressCancel.style.visibility = "hidden"; 
     31   progressCancel.appendChild(document.createTextNode(" ")); 
     32 
     33   var progressText = document.createElement("div"); 
     34   progressText.className = "progressName"; 
     35   progressText.appendChild(document.createTextNode(file.name)); 
     36 
     37   var progressBar = document.createElement("div"); 
     38   progressBar.className = "progressBarInProgress"; 
     39 
     40   var progressStatus = document.createElement("div"); 
     41   progressStatus.className = "progressBarStatus"; 
     42   progressStatus.innerHTML = " "; 
     43 
     44   this.fileProgressElement.appendChild(progressCancel); 
     45   this.fileProgressElement.appendChild(progressText); 
     46   this.fileProgressElement.appendChild(progressStatus); 
     47   this.fileProgressElement.appendChild(progressBar); 
     48 
     49   this.fileProgressWrapper.appendChild(this.fileProgressElement); 
     50 
     51   document.getElementById(targetID).appendChild(this.fileProgressWrapper); 
     52 } else { 
     53   this.fileProgressElement = this.fileProgressWrapper.firstChild; 
     54   this.reset(); 
     55
     56 
     57 this.height = this.fileProgressWrapper.offsetHeight; 
     58 this.setTimer(null); 
    5959 
    6060 
     
    6262 
    6363FileProgress.prototype.setTimer = function (timer) { 
    64   this.fileProgressElement["FP_TIMER"] = timer; 
     64 this.fileProgressElement["FP_TIMER"] = timer; 
    6565}; 
    6666FileProgress.prototype.getTimer = function (timer) { 
    67   return this.fileProgressElement["FP_TIMER"] || null; 
     67 return this.fileProgressElement["FP_TIMER"] || null; 
    6868}; 
    6969 
    7070FileProgress.prototype.reset = function () { 
    71   this.fileProgressElement.className = "progressContainer"; 
    72  
    73   this.fileProgressElement.childNodes[2].innerHTML = " "; 
    74   this.fileProgressElement.childNodes[2].className = "progressBarStatus"; 
    75    
    76   this.fileProgressElement.childNodes[3].className = "progressBarInProgress"; 
    77   this.fileProgressElement.childNodes[3].style.width = "0%"; 
    78    
    79   this.appear();   
     71 this.fileProgressElement.className = "progressContainer"; 
     72 
     73 this.fileProgressElement.childNodes[2].innerHTML = " "; 
     74 this.fileProgressElement.childNodes[2].className = "progressBarStatus"; 
     75   
     76 this.fileProgressElement.childNodes[3].className = "progressBarInProgress"; 
     77 this.fileProgressElement.childNodes[3].style.width = "0%"; 
     78   
     79  this.appear();   
    8080}; 
    8181 
    8282FileProgress.prototype.setProgress = function (percentage) { 
    83   this.fileProgressElement.className = "progressContainer green"; 
    84   this.fileProgressElement.childNodes[3].className = "progressBarInProgress"; 
    85   this.fileProgressElement.childNodes[3].style.width = percentage + "%"; 
    86  
    87   this.appear();   
     83 this.fileProgressElement.className = "progressContainer green"; 
     84 this.fileProgressElement.childNodes[3].className = "progressBarInProgress"; 
     85 this.fileProgressElement.childNodes[3].style.width = percentage + "%"; 
     86 
     87  this.appear();   
    8888}; 
    8989FileProgress.prototype.setComplete = function () { 
    90   this.fileProgressElement.className = "progressContainer blue"; 
    91   this.fileProgressElement.childNodes[3].className = "progressBarComplete"; 
    92   this.fileProgressElement.childNodes[3].style.width = ""; 
    93  
    94   var oSelf = this; 
    95   this.setTimer(setTimeout(function () { 
    96     oSelf.disappear(); 
    97   }, 10000)); 
     90 this.fileProgressElement.className = "progressContainer blue"; 
     91 this.fileProgressElement.childNodes[3].className = "progressBarComplete"; 
     92 this.fileProgressElement.childNodes[3].style.width = ""; 
     93 
     94 var oSelf = this; 
     95 this.setTimer(setTimeout(function () { 
     96   oSelf.disappear(); 
     97 }, 10000)); 
    9898}; 
    9999FileProgress.prototype.setError = function () { 
    100   this.fileProgressElement.className = "progressContainer red"; 
    101   this.fileProgressElement.childNodes[3].className = "progressBarError"; 
    102   this.fileProgressElement.childNodes[3].style.width = ""; 
    103  
    104   var oSelf = this; 
    105   this.setTimer(setTimeout(function () { 
    106     oSelf.disappear(); 
    107   }, 5000)); 
     100 this.fileProgressElement.className = "progressContainer red"; 
     101 this.fileProgressElement.childNodes[3].className = "progressBarError"; 
     102 this.fileProgressElement.childNodes[3].style.width = ""; 
     103 
     104 var oSelf = this; 
     105 this.setTimer(setTimeout(function () { 
     106   oSelf.disappear(); 
     107 }, 5000)); 
    108108}; 
    109109FileProgress.prototype.setCancelled = function () { 
    110   this.fileProgressElement.className = "progressContainer"; 
    111   this.fileProgressElement.childNodes[3].className = "progressBarError"; 
    112   this.fileProgressElement.childNodes[3].style.width = ""; 
    113  
    114   var oSelf = this; 
    115   this.setTimer(setTimeout(function () { 
    116     oSelf.disappear(); 
    117   }, 2000)); 
     110 this.fileProgressElement.className = "progressContainer"; 
     111 this.fileProgressElement.childNodes[3].className = "progressBarError"; 
     112 this.fileProgressElement.childNodes[3].style.width = ""; 
     113 
     114 var oSelf = this; 
     115 this.setTimer(setTimeout(function () { 
     116   oSelf.disappear(); 
     117 }, 2000)); 
    118118}; 
    119119FileProgress.prototype.setStatus = function (status) { 
    120   this.fileProgressElement.childNodes[2].innerHTML = status; 
     120 this.fileProgressElement.childNodes[2].innerHTML = status; 
    121121}; 
    122122 
    123123// Show/Hide the cancel button 
    124124FileProgress.prototype.toggleCancel = function (show, swfUploadInstance) { 
    125   this.fileProgressElement.childNodes[0].style.visibility = show ? "visible" : "hidden"; 
    126   if (swfUploadInstance) { 
    127     var fileID = this.fileProgressID; 
    128     this.fileProgressElement.childNodes[0].onclick = function () { 
    129       swfUploadInstance.cancelUpload(fileID); 
    130       return false; 
    131     }; 
    132  
     125 this.fileProgressElement.childNodes[0].style.visibility = show ? "visible" : "hidden"; 
     126 if (swfUploadInstance) { 
     127   var fileID = this.fileProgressID; 
     128   this.fileProgressElement.childNodes[0].onclick = function () { 
     129     swfUploadInstance.cancelUpload(fileID); 
     130     return false; 
     131   }; 
     132
    133133}; 
    134134 
    135135FileProgress.prototype.appear = function () { 
    136   if (this.getTimer() !== null) { 
    137     clearTimeout(this.getTimer()); 
    138     this.setTimer(null); 
    139  
    140    
    141   if (this.fileProgressWrapper.filters) { 
    142     try { 
    143       this.fileProgressWrapper.filters.item("DXImageTransform.Microsoft.Alpha").opacity = 100; 
    144     } catch (e) { 
    145       // If it is not set initially, the browser will throw an error.  This will set it if it is not set yet. 
    146       this.fileProgressWrapper.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)"; 
    147    
    148   } else { 
    149     this.fileProgressWrapper.style.opacity = 1; 
    150  
    151      
    152   this.fileProgressWrapper.style.height = ""; 
    153    
    154   this.height = this.fileProgressWrapper.offsetHeight; 
    155   this.opacity = 100; 
    156   this.fileProgressWrapper.style.display = ""; 
    157    
     136 if (this.getTimer() !== null) { 
     137   clearTimeout(this.getTimer()); 
     138   this.setTimer(null); 
     139
     140   
     141 if (this.fileProgressWrapper.filters) { 
     142   try { 
     143     this.fileProgressWrapper.filters.item("DXImageTransform.Microsoft.Alpha").opacity = 100; 
     144   } catch (e) { 
     145     // If it is not set initially, the browser will throw an error.  This will set it if it is not set yet. 
     146     this.fileProgressWrapper.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)"; 
     147   
     148 } else { 
     149   this.fileProgressWrapper.style.opacity = 1; 
     150
     151     
     152 this.fileProgressWrapper.style.height = ""; 
     153   
     154 this.height = this.fileProgressWrapper.offsetHeight; 
     155 this.opacity = 100; 
     156 this.fileProgressWrapper.style.display = ""; 
     157   
    158158}; 
    159159 
     
    161161FileProgress.prototype.disappear = function () { 
    162162 
    163   var reduceOpacityBy = 15; 
    164   var reduceHeightBy = 4; 
    165   var rate = 30;  // 15 fps 
    166  
    167   if (this.opacity > 0) { 
    168     this.opacity -= reduceOpacityBy; 
    169     if (this.opacity < 0) { 
    170       this.opacity = 0; 
    171    
    172  
    173     if (this.fileProgressWrapper.filters) { 
    174       try { 
    175         this.fileProgressWrapper.filters.item("DXImageTransform.Microsoft.Alpha").opacity = this.opacity; 
    176       } catch (e) { 
    177         // If it is not set initially, the browser will throw an error.  This will set it if it is not set yet. 
    178         this.fileProgressWrapper.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + this.opacity + ")"; 
    179      
    180     } else { 
    181       this.fileProgressWrapper.style.opacity = this.opacity / 100; 
    182    
    183  
    184  
    185   if (this.height > 0) { 
    186     this.height -= reduceHeightBy; 
    187     if (this.height < 0) { 
    188       this.height = 0; 
    189    
    190  
    191     this.fileProgressWrapper.style.height = this.height + "px"; 
    192  
    193  
    194   if (this.height > 0 || this.opacity > 0) { 
    195     var oSelf = this; 
    196     this.setTimer(setTimeout(function () { 
    197       oSelf.disappear(); 
    198     }, rate)); 
    199   } else { 
    200     this.fileProgressWrapper.style.display = "none"; 
    201     this.setTimer(null); 
    202  
    203 }; 
     163 var reduceOpacityBy = 15; 
     164 var reduceHeightBy = 4; 
     165 var rate = 30;  // 15 fps 
     166 
     167 if (this.opacity > 0) { 
     168   this.opacity -= reduceOpacityBy; 
     169   if (this.opacity < 0) { 
     170     this.opacity = 0; 
     171   
     172 
     173   if (this.fileProgressWrapper.filters) { 
     174     try { 
     175       this.fileProgressWrapper.filters.item("DXImageTransform.Microsoft.Alpha").opacity = this.opacity; 
     176     } catch (e) { 
     177       // If it is not set initially, the browser will throw an error.  This will set it if it is not set yet. 
     178       this.fileProgressWrapper.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + this.opacity + ")"; 
     179     
     180   } else { 
     181     this.fileProgressWrapper.style.opacity = this.opacity / 100; 
     182   
     183
     184 
     185 if (this.height > 0) { 
     186   this.height -= reduceHeightBy; 
     187   if (this.height < 0) { 
     188     this.height = 0; 
     189   
     190 
     191   this.fileProgressWrapper.style.height = this.height + "px"; 
     192
     193 
     194 if (this.height > 0 || this.opacity > 0) { 
     195   var oSelf = this; 
     196   this.setTimer(setTimeout(function () { 
     197     oSelf.disappear(); 
     198   }, rate)); 
     199 } else { 
     200   this.fileProgressWrapper.style.display = "none"; 
     201   this.setTimer(null); 
     202
     203}; 
  • plugins/sfImaginablePlugin/branches/experimental/web/js/handlers.js

    r24360 r24364  
    1 queueComplete = function (event, data){ 
    2   ajaxUpdateImageList();   
     1/* Demo Note:  This demo uses a FileProgress class that handles the UI for displaying the file name and percent complete. 
     2The FileProgress class is not part of SWFUpload. 
     3*/ 
     4 
     5 
     6/* ********************** 
     7   Event Handlers 
     8   These are my custom event handlers to make my 
     9   web application behave the way I went when SWFUpload 
     10   completes different tasks.  These aren't part of the SWFUpload 
     11   package.  They are part of my application.  Without these none 
     12   of the actions SWFUpload makes will show up in my application. 
     13   ********************** */ 
     14 
     15function swfUploadPreLoad() { 
     16  var self = this; 
     17  var loading = function () { 
     18    //document.getElementById("divSWFUploadUI").style.display = "none"; 
     19    document.getElementById("divLoadingContent").style.display = ""; 
     20 
     21    var longLoad = function () { 
     22      document.getElementById("divLoadingContent").style.display = "none"; 
     23      document.getElementById("divLongLoading").style.display = ""; 
     24    }; 
     25    this.customSettings.loadingTimeout = setTimeout(function () { 
     26        longLoad.call(self) 
     27      }, 
     28      15 * 1000 
     29    ); 
     30  }; 
     31   
     32  this.customSettings.loadingTimeout = setTimeout(function () { 
     33      loading.call(self); 
     34    }, 
     35    1*1000 
     36  ); 
     37
     38function swfUploadLoaded() { 
     39  var self = this; 
     40  clearTimeout(this.customSettings.loadingTimeout); 
     41  //document.getElementById("divSWFUploadUI").style.visibility = "visible"; 
     42  //document.getElementById("divSWFUploadUI").style.display = "block"; 
     43  document.getElementById("divLoadingContent").style.display = "none"; 
     44  document.getElementById("divLongLoading").style.display = "none"; 
     45  document.getElementById("divAlternateContent").style.display = "none"; 
     46   
     47  //document.getElementById("btnBrowse").onclick = function () { self.selectFiles(); }; 
     48  document.getElementById("btnCancel").onclick = function () { self.cancelQueue(); }; 
     49
     50    
     51function swfUploadLoadFailed() { 
     52  clearTimeout(this.customSettings.loadingTimeout); 
     53  //document.getElementById("divSWFUploadUI").style.display = "none"; 
     54  document.getElementById("divLoadingContent").style.display = "none"; 
     55  document.getElementById("divLongLoading").style.display = "none"; 
     56  document.getElementById("divAlternateContent").style.display = ""; 
     57
     58    
     59    
     60function fileQueued(file) { 
     61  try { 
     62    var progress = new FileProgress(file, this.customSettings.progressTarget); 
     63    progress.setStatus("Pending..."); 
     64    progress.toggleCancel(true, this); 
     65 
     66  } catch (ex) { 
     67    this.debug(ex); 
     68  } 
     69 
     70
     71 
     72function fileQueueError(file, errorCode, message) { 
     73  try { 
     74    if (errorCode === SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) { 
     75      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."))); 
     76      return; 
     77    } 
     78 
     79    var progress = new FileProgress(file, this.customSettings.progressTarget); 
     80    progress.setError(); 
     81    progress.toggleCancel(false); 
     82 
     83    switch (errorCode) { 
     84    case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT: 
     85      progress.setStatus("File is too big."); 
     86      this.debug("Error Code: File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 
     87      break; 
     88    case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE: 
     89      progress.setStatus("Cannot upload Zero Byte files."); 
     90      this.debug("Error Code: Zero byte file, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 
     91      break; 
     92    case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE: 
     93      progress.setStatus("Invalid File Type."); 
     94      this.debug("Error Code: Invalid File Type, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 
     95      break; 
     96    default: 
     97      if (file !== null) { 
     98        progress.setStatus("Unhandled Error"); 
     99      } 
     100      this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 
     101      break; 
     102    } 
     103  } catch (ex) { 
     104        this.debug(ex); 
     105    } 
     106
     107 
     108function fileDialogComplete(numFilesSelected, numFilesQueued) { 
     109  try { 
     110    if (numFilesSelected > 0) { 
     111      document.getElementById(this.customSettings.cancelButtonId).disabled = false; 
     112    } 
     113     
     114    /* I want auto start the upload and I can do that here */ 
     115    this.startUpload(); 
     116  } catch (ex)  { 
     117        this.debug(ex); 
     118  } 
     119
     120 
     121function uploadStart(file) { 
     122  try { 
     123    /* I don't want to do any file validation or anything,  I'll just update the UI and 
     124    return true to indicate that the upload should start. 
     125    It's important to update the UI here because in Linux no uploadProgress events are called. The best 
     126    we can do is say we are uploading. 
     127     */ 
     128    var progress = new FileProgress(file, this.customSettings.progressTarget); 
     129    progress.setStatus("Uploading..."); 
     130    progress.toggleCancel(true, this); 
     131  } 
     132  catch (ex) {} 
     133   
     134  return true; 
     135
     136 
     137function uploadProgress(file, bytesLoaded, bytesTotal) { 
     138  try { 
     139    var percent = Math.ceil((bytesLoaded / bytesTotal) * 100); 
     140 
     141    var progress = new FileProgress(file, this.customSettings.progressTarget); 
     142    progress.setProgress(percent); 
     143    progress.setStatus("Uploading..."); 
     144  } catch (ex) { 
     145    this.debug(ex); 
     146  } 
     147
     148 
     149function uploadSuccess(file, serverData) { 
     150  try { 
     151    var progress = new FileProgress(file, this.customSettings.progressTarget); 
     152    progress.setComplete(); 
     153    progress.setStatus("Complete."); 
     154    progress.toggleCancel(false); 
     155 
     156  } catch (ex) { 
     157    this.debug(ex); 
     158  } 
     159
     160 
     161function uploadError(file, errorCode, message) { 
     162  try { 
     163    var progress = new FileProgress(file, this.customSettings.progressTarget); 
     164    progress.setError(); 
     165    progress.toggleCancel(false); 
     166 
     167    switch (errorCode) { 
     168    case SWFUpload.UPLOAD_ERROR.HTTP_ERROR: 
     169      progress.setStatus("Upload Error: " + message); 
     170      this.debug("Error Code: HTTP Error, File name: " + file.name + ", Message: " + message); 
     171      break; 
     172    case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED: 
     173      progress.setStatus("Upload Failed."); 
     174      this.debug("Error Code: Upload Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 
     175      break; 
     176    case SWFUpload.UPLOAD_ERROR.IO_ERROR: 
     177      progress.setStatus("Server (IO) Error"); 
     178      this.debug("Error Code: IO Error, File name: " + file.name + ", Message: " + message); 
     179      break; 
     180    case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR: 
     181      progress.setStatus("Security Error"); 
     182      this.debug("Error Code: Security Error, File name: " + file.name + ", Message: " + message); 
     183      break; 
     184    case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED: 
     185      progress.setStatus("Upload limit exceeded."); 
     186      this.debug("Error Code: Upload Limit Exceeded, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 
     187      break; 
     188    case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED: 
     189      progress.setStatus("Failed Validation.  Upload skipped."); 
     190      this.debug("Error Code: File Validation Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 
     191      break; 
     192    case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED: 
     193      // If there aren't any files left (they were all cancelled) disable the cancel button 
     194      if (this.getStats().files_queued === 0) { 
     195        document.getElementById(this.customSettings.cancelButtonId).disabled = true; 
     196      } 
     197      progress.setStatus("Cancelled"); 
     198      progress.setCancelled(); 
     199      break; 
     200    case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED: 
     201      progress.setStatus("Stopped");                                                      
     202      break; 
     203    default: 
     204      progress.setStatus("Unhandled Error: " + errorCode); 
     205      this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 
     206      break; 
     207    } 
     208  } catch (ex) { 
     209        this.debug(ex); 
     210    } 
     211
     212 
     213function uploadComplete(file) { 
     214  if (this.getStats().files_queued === 0) { 
     215    document.getElementById(this.customSettings.cancelButtonId).disabled = true; 
     216  } 
     217
     218 
     219// This event comes from the Queue Plugin 
     220function queueComplete(numFilesUploaded) { 
     221  var status = document.getElementById("divStatus"); 
     222  status.innerHTML = numFilesUploaded + " file" + (numFilesUploaded === 1 ? "" : "s") + " uploaded."; 
     223  ajaxUpdateImageList(); 
    3224}; 
    4225 
    5 function echoInfo(event, queueID, fileObj, response, data) 
    6 
    7   alert('lol'); 
    8   alert(response); 
    9 }  
    10       /* 
     226 
    11227function ajaxUpdateImageList() { 
    12   //new Ajax.Updater('ajax-image-list', '/backend.php/sfImaginable/ajaxList', {asynchronous:true, evalScripts:true, parameters:'object_class=' + object_class + '&object_id=' + object_id }); 
    13   jQuery('#ajax-image-list').load('/backend.php/sfImaginable/ajaxList', {'object_class' = object_class, 'object_id' = object_id}); 
     228  new Ajax.Updater('ajax-image-list', ajax_url, {asynchronous:true, evalScripts:true, parameters:'object_class=' + object_class + '&object_id=' + object_id }); 
    14229  return false; 
    15230}; 
    16 */ 
  • plugins/sfImaginablePlugin/branches/experimental/web/js/swfupload.js

    r24360 r24364  
    44 * mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/,  http://www.vinterwebb.se/ 
    55 * 
    6  * SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilz?n and Mammon Media and is released under the MIT License: 
     6 * SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilz�and Mammon Media and is released under the MIT License: 
    77 * http://www.opensource.org/licenses/mit-license.php 
    88 * 
     
    1919 
    2020if (SWFUpload == undefined) { 
    21   SWFUpload = function (settings) { 
    22     this.initSWFUpload(settings); 
    23   }; 
     21 SWFUpload = function (settings) { 
     22   this.initSWFUpload(settings); 
     23 }; 
    2424} 
    2525 
    2626SWFUpload.prototype.initSWFUpload = function (settings) { 
    27   try { 
    28     this.customSettings = {};  // A container where developers can place their own settings associated with this instance. 
    29     this.settings = settings; 
    30     this.eventQueue = []; 
    31     this.movieName = "SWFUpload_" + SWFUpload.movieCount++; 
    32     this.movieElement = null; 
    33  
    34  
    35     // Setup global control tracking 
    36     SWFUpload.instances[this.movieName] = this; 
    37  
    38     // Load the settings.  Load the Flash movie. 
    39     this.initSettings(); 
    40     this.loadFlash(); 
    41     this.displayDebugInfo(); 
    42   } catch (ex) { 
    43     delete SWFUpload.instances[this.movieName]; 
    44     throw ex; 
    45  
     27 try { 
     28   this.customSettings = {}; // A container where developers can place their own settings associated with this instance. 
     29   this.settings = settings; 
     30   this.eventQueue = []; 
     31   this.movieName = "SWFUpload_" + SWFUpload.movieCount++; 
     32   this.movieElement = null; 
     33 
     34 
     35   // Setup global control tracking 
     36   SWFUpload.instances[this.movieName] = this; 
     37 
     38   // Load the settings.  Load the Flash movie. 
     39   this.initSettings(); 
     40   this.loadFlash(); 
     41   this.displayDebugInfo(); 
     42 } catch (ex) { 
     43   delete SWFUpload.instances[this.movieName]; 
     44   throw ex; 
     45
    4646}; 
    4747 
     
    5353SWFUpload.version = "2.2.0 2009-03-25"; 
    5454SWFUpload.QUEUE_ERROR = { 
    55   QUEUE_LIMIT_EXCEEDED        : -100, 
    56   FILE_EXCEEDS_SIZE_LIMIT      : -110, 
    57   ZERO_BYTE_FILE            : -120, 
    58   INVALID_FILETYPE          : -130 
     55 QUEUE_LIMIT_EXCEEDED        : -100, 
     56 FILE_EXCEEDS_SIZE_LIMIT     : -110, 
     57 ZERO_BYTE_FILE            : -120, 
     58 INVALID_FILETYPE          : -130 
    5959}; 
    6060SWFUpload.UPLOAD_ERROR = { 
    61   HTTP_ERROR              : -200, 
    62   MISSING_UPLOAD_URL            : -210, 
    63   IO_ERROR              : -220, 
    64   SECURITY_ERROR            : -230, 
    65   UPLOAD_LIMIT_EXCEEDED        : -240, 
    66   UPLOAD_FAILED            : -250, 
    67   SPECIFIED_FILE_ID_NOT_FOUND    : -260, 
    68   FILE_VALIDATION_FAILED        : -270, 
    69   FILE_CANCELLED            : -280, 
    70   UPLOAD_STOPPED          : -290 
     61 HTTP_ERROR              : -200, 
     62 MISSING_UPLOAD_URL            : -210, 
     63 IO_ERROR              : -220, 
     64 SECURITY_ERROR            : -230, 
     65 UPLOAD_LIMIT_EXCEEDED       : -240, 
     66 UPLOAD_FAILED           : -250, 
     67 SPECIFIED_FILE_ID_NOT_FOUND   : -260, 
     68 FILE_VALIDATION_FAILED        : -270, 
     69 FILE_CANCELLED            : -280, 
     70 UPLOAD_STOPPED          : -290 
    7171}; 
    7272SWFUpload.FILE_STATUS = { 
    73   QUEUED    : -1, 
    74   IN_PROGRESS  : -2, 
    75   ERROR    : -3, 
    76   COMPLETE  : -4, 
    77   CANCELLED  : -5 
     73 QUEUED    : -1, 
     74 IN_PROGRESS : -2, 
     75 ERROR    : -3, 
     76 COMPLETE  : -4, 
     77 CANCELLED : -5 
    7878}; 
    7979SWFUpload.BUTTON_ACTION = { 
    80   SELECT_FILE  : -100, 
    81   SELECT_FILES : -110, 
    82   START_UPLOAD : -120 
     80 SELECT_FILE  : -100, 
     81 SELECT_FILES : -110, 
     82 START_UPLOAD : -120 
    8383}; 
    8484SWFUpload.CURSOR = { 
    85   ARROW : -1, 
    86   HAND : -2 
     85 ARROW : -1, 
     86 HAND : -2 
    8787}; 
    8888SWFUpload.WINDOW_MODE = { 
    89   WINDOW : "window", 
    90   TRANSPARENT : "transparent", 
    91   OPAQUE : "opaque" 
     89 WINDOW : "window", 
     90 TRANSPARENT : "transparent", 
     91 OPAQUE : "opaque" 
    9292}; 
    9393 
     
    9595// using the current site. Only processes the URL if it can, otherwise returns the URL untouched 
    9696SWFUpload.completeURL = function(url) { 
    97   if (typeof(url) !== "string" || url.match(/^https?:\/\//i) || url.match(/^\//)) { 
    98     return url; 
    99  
    100    
    101   var currentURL = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : ""); 
    102    
    103   var indexSlash = window.location.pathname.lastIndexOf("/"); 
    104   if (indexSlash <= 0) { 
    105     path = "/"; 
    106   } else { 
    107     path = window.location.pathname.substr(0, indexSlash) + "/"; 
    108  
    109    
    110   return /*currentURL +*/ path + url; 
    111    
     97 if (typeof(url) !== "string" || url.match(/^https?:\/\//i) || url.match(/^\//)) { 
     98   return url; 
     99
     100   
     101 var currentURL = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : ""); 
     102   
     103 var indexSlash = window.location.pathname.lastIndexOf("/"); 
     104 if (indexSlash <= 0) { 
     105   path = "/"; 
     106 } else { 
     107   path = window.location.pathname.substr(0, indexSlash) + "/"; 
     108
     109   
     110 return /*currentURL +*/ path + url; 
     111   
    112112}; 
    113113 
     
    120120// settings are set, getting a default value if one was not assigned. 
    121121SWFUpload.prototype.initSettings = function () { 
    122   this.ensureDefault = function (settingName, defaultValue) { 
    123     this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName]; 
    124   }; 
    125    
    126   // Upload backend settings 
    127   this.ensureDefault("upload_url", ""); 
    128   this.ensureDefault("preserve_relative_urls", false); 
    129   this.ensureDefault("file_post_name", "Filedata"); 
    130   this.ensureDefault("post_params", {}); 
    131   this.ensureDefault("use_query_string", false); 
    132   this.ensureDefault("requeue_on_error", false); 
    133   this.ensureDefault("http_success", []); 
    134   this.ensureDefault("assume_success_timeout", 0); 
    135    
    136   // File Settings 
    137   this.ensureDefault("file_types", "*.*"); 
    138   this.ensureDefault("file_types_description", "All Files"); 
    139   this.ensureDefault("file_size_limit", 0);  // Default zero means "unlimited" 
    140   this.ensureDefault("file_upload_limit", 0); 
    141   this.ensureDefault("file_queue_limit", 0); 
    142  
    143   // Flash Settings 
    144   this.ensureDefault("flash_url", "swfupload.swf"); 
    145   this.ensureDefault("prevent_swf_caching", true); 
    146    
    147   // Button Settings 
    148   this.ensureDefault("button_image_url", ""); 
    149   this.ensureDefault("button_width", 1); 
    150   this.ensureDefault("button_height", 1); 
    151   this.ensureDefault("button_text", ""); 
    152   this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;"); 
    153   this.ensureDefault("button_text_top_padding", 0); 
    154   this.ensureDefault("button_text_left_padding", 0); 
    155   this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES); 
    156   this.ensureDefault("button_disabled", false); 
    157   this.ensureDefault("button_placeholder_id", ""); 
    158   this.ensureDefault("button_placeholder", null); 
    159   this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW); 
    160   this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW); 
    161    
    162   // Debug Settings 
    163   this.ensureDefault("debug", false); 
    164   this.settings.debug_enabled = this.settings.debug;  // Here to maintain v2 API 
    165    
    166   // Event Handlers 
    167   this.settings.return_upload_start_handler = this.returnUploadStart; 
    168   this.ensureDefault("swfupload_loaded_handler", null); 
    169   this.ensureDefault("file_dialog_start_handler", null); 
    170   this.ensureDefault("file_queued_handler", null); 
    171   this.ensureDefault("file_queue_error_handler", null); 
    172   this.ensureDefault("file_dialog_complete_handler", null); 
    173    
    174   this.ensureDefault("upload_start_handler", null); 
    175   this.ensureDefault("upload_progress_handler", null); 
    176   this.ensureDefault("upload_error_handler", null); 
    177   this.ensureDefault("upload_success_handler", null); 
    178   this.ensureDefault("upload_complete_handler", null); 
    179    
    180   this.ensureDefault("debug_handler", this.debugMessage); 
    181  
    182   this.ensureDefault("custom_settings", {}); 
    183  
    184   // Other settings 
    185   this.customSettings = this.settings.custom_settings; 
    186    
    187   // Update the flash url if needed 
    188   if (!!this.settings.prevent_swf_caching) { 
    189     this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime(); 
    190  
    191    
    192   if (!this.settings.preserve_relative_urls) { 
    193     //this.settings.flash_url = SWFUpload.completeURL(this.settings.flash_url);  // Don't need to do this one since flash doesn't look at it 
    194     this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url); 
    195     this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url); 
    196  
    197    
    198   delete this.ensureDefault; 
     122 this.ensureDefault = function (settingName, defaultValue) { 
     123   this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName]; 
     124 }; 
     125   
     126 // Upload backend settings 
     127 this.ensureDefault("upload_url", ""); 
     128 this.ensureDefault("preserve_relative_urls", false); 
     129 this.ensureDefault("file_post_name", "Filedata"); 
     130 this.ensureDefault("post_params", {}); 
     131 this.ensureDefault("use_query_string", false); 
     132 this.ensureDefault("requeue_on_error", false); 
     133 this.ensureDefault("http_success", []); 
     134 this.ensureDefault("assume_success_timeout", 0); 
     135   
     136 // File Settings 
     137 this.ensureDefault("file_types", "*.*"); 
     138 this.ensureDefault("file_types_description", "All Files"); 
     139 this.ensureDefault("file_size_limit", 0); // Default zero means "unlimited" 
     140 this.ensureDefault("file_upload_limit", 0); 
     141 this.ensureDefault("file_queue_limit", 0); 
     142 
     143 // Flash Settings 
     144 this.ensureDefault("flash_url", "swfupload.swf"); 
     145 this.ensureDefault("prevent_swf_caching", true); 
     146   
     147 // Button Settings 
     148 this.ensureDefault("button_image_url", ""); 
     149 this.ensureDefault("button_width", 1); 
     150 this.ensureDefault("button_height", 1); 
     151 this.ensureDefault("button_text", ""); 
     152 this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;"); 
     153 this.ensureDefault("button_text_top_padding", 0); 
     154 this.ensureDefault("button_text_left_padding", 0); 
     155 this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES); 
     156 this.ensureDefault("button_disabled", false); 
     157 this.ensureDefault("button_placeholder_id", ""); 
     158 this.ensureDefault("button_placeholder", null); 
     159 this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW); 
     160 this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW); 
     161   
     162 // Debug Settings 
     163 this.ensureDefault("debug", false); 
     164 this.settings.debug_enabled = this.settings.debug;  // Here to maintain v2 API 
     165   
     166 // Event Handlers 
     167 this.settings.return_upload_start_handler = this.returnUploadStart; 
     168 this.ensureDefault("swfupload_loaded_handler", null); 
     169 this.ensureDefault("file_dialog_start_handler", null); 
     170 this.ensureDefault("file_queued_handler", null); 
     171 this.ensureDefault("file_queue_error_handler", null); 
     172 this.ensureDefault("file_dialog_complete_handler", null); 
     173   
     174 this.ensureDefault("upload_start_handler", null); 
     175 this.ensureDefault("upload_progress_handler", null); 
     176 this.ensureDefault("upload_error_handler", null); 
     177 this.ensureDefault("upload_success_handler", null); 
     178 this.ensureDefault("upload_complete_handler", null); 
     179   
     180 this.ensureDefault("debug_handler", this.debugMessage); 
     181 
     182 this.ensureDefault("custom_settings", {}); 
     183 
     184 // Other settings 
     185 this.customSettings = this.settings.custom_settings; 
     186   
     187 // Update the flash url if needed 
     188 if (!!this.settings.prevent_swf_caching) { 
     189   this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime(); 
     190
     191   
     192 if (!this.settings.preserve_relative_urls) { 
     193   //this.settings.flash_url = SWFUpload.completeURL(this.settings.flash_url); // Don't need to do this one since flash doesn't look at it 
     194   this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url); 
     195   this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url); 
     196
     197   
     198 delete this.ensureDefault; 
    199199}; 
    200200 
    201201// Private: loadFlash replaces the button_placeholder element with the flash movie. 
    202202SWFUpload.prototype.loadFlash = function () { 
    203   var targetElement, tempParent; 
    204  
    205   // Make sure an element with the ID we are going to use doesn't already exist 
    206   if (document.getElementById(this.movieName) !== null) { 
    207     throw "ID " + this.movieName + " is already in use. The Flash Object could not be added"; 
    208  
    209  
    210   // Get the element where we will be placing the flash movie 
    211   targetElement = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder; 
    212  
    213   if (targetElement == undefined) { 
    214     throw "Could not find the placeholder element: " + this.settings.button_placeholder_id; 
    215  
    216  
    217   // Append the container and load the flash 
    218   tempParent = document.createElement("div"); 
    219   tempParent.innerHTML = this.getFlashHTML();  // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers) 
    220   targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement); 
    221  
    222   // Fix IE Flash/Form bug 
    223   if (window[this.movieName] == undefined) { 
    224     window[this.movieName] = this.getMovieElement(); 
    225  
    226    
     203 var targetElement, tempParent; 
     204 
     205 // Make sure an element with the ID we are going to use doesn't already exist 
     206 if (document.getElementById(this.movieName) !== null) { 
     207   throw "ID " + this.movieName + " is already in use. The Flash Object could not be added"; 
     208
     209 
     210 // Get the element where we will be placing the flash movie 
     211 targetElement = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder; 
     212 
     213 if (targetElement == undefined) { 
     214   throw "Could not find the placeholder element: " + this.settings.button_placeholder_id; 
     215
     216 
     217 // Append the container and load the flash 
     218 tempParent = document.createElement("div"); 
     219 tempParent.innerHTML = this.getFlashHTML(); // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers) 
     220 targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement); 
     221 
     222 // Fix IE Flash/Form bug 
     223 if (window[this.movieName] == undefined) { 
     224   window[this.movieName] = this.getMovieElement(); 
     225
     226   
    227227}; 
    228228 
    229229// Private: getFlashHTML generates the object tag needed to embed the flash in to the document 
    230230SWFUpload.prototype.getFlashHTML = function () { 
    231   // Flash Satay object syntax: http://www.alistapart.com/articles/flashsatay 
    232   return ['<object id="', this.movieName, '" type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">', 
    233         '<param name="wmode" value="', this.settings.button_window_mode, '" />', 
    234         '<param name="movie" value="', this.settings.flash_url, '" />', 
    235         '<param name="quality" value="high" />', 
    236         '<param name="menu" value="false" />', 
    237         '<param name="allowScriptAccess" value="always" />', 
    238         '<param name="flashvars" value="' + this.getFlashVars() + '" />', 
    239         '</object>'].join(""); 
     231 // Flash Satay object syntax: http://www.alistapart.com/articles/flashsatay 
     232 return ['<object id="', this.movieName, '" type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">', 
     233       '<param name="wmode" value="', this.settings.button_window_mode, '" />', 
     234       '<param name="movie" value="', this.settings.flash_url, '" />', 
     235       '<param name="quality" value="high" />', 
     236       '<param name="menu" value="false" />', 
     237       '<param name="allowScriptAccess" value="always" />', 
     238       '<param name="flashvars" value="' + this.getFlashVars() + '" />', 
     239       '</object>'].join(""); 
    240240}; 
    241241 
     
    243243// to flash in the flashvars param. 
    244244SWFUpload.prototype.getFlashVars = function () { 
    245   // Build a string from the post param object 
    246   var paramString = this.buildParamString(); 
    247   var httpSuccessString = this.settings.http_success.join(","); 
    248    
    249   // Build the parameter string 
    250   return ["movieName=", encodeURIComponent(this.movieName), 
    251       "&amp;uploadURL=", encodeURIComponent(this.settings.upload_url), 
    252       "&amp;useQueryString=", encodeURIComponent(this.settings.use_query_string), 
    253       "&amp;requeueOnError=", encodeURIComponent(this.settings.requeue_on_error), 
    254       "&amp;httpSuccess=", encodeURIComponent(httpSuccessString), 
    255       "&amp;assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout), 
    256       "&amp;params=", encodeURIComponent(paramString), 
    257       "&amp;filePostName=", encodeURIComponent(this.settings.file_post_name), 
    258       "&amp;fileTypes=", encodeURIComponent(this.settings.file_types), 
    259       "&amp;fileTypesDescription=", encodeURIComponent(this.settings.file_types_description), 
    260       "&amp;fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit), 
    261       "&amp;fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit), 
    262       "&amp;fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit), 
    263       "&amp;debugEnabled=", encodeURIComponent(this.settings.debug_enabled), 
    264       "&amp;buttonImageURL=", encodeURIComponent(this.settings.button_image_url), 
    265       "&amp;buttonWidth=", encodeURIComponent(this.settings.button_width), 
    266       "&amp;buttonHeight=", encodeURIComponent(this.settings.button_height), 
    267       "&amp;buttonText=", encodeURIComponent(this.settings.button_text), 
    268       "&amp;buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding), 
    269       "&amp;buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding), 
    270       "&amp;buttonTextStyle=", encodeURIComponent(this.settings.button_text_style), 
    271       "&amp;buttonAction=", encodeURIComponent(this.settings.button_action), 
    272       "&amp;buttonDisabled=", encodeURIComponent(this.settings.button_disabled), 
    273       "&amp;buttonCursor=", encodeURIComponent(this.settings.button_cursor) 
    274     ].join(""); 
     245 // Build a string from the post param object 
     246 var paramString = this.buildParamString(); 
     247 var httpSuccessString = this.settings.http_success.join(","); 
     248   
     249 // Build the parameter string 
     250 return ["movieName=", encodeURIComponent(this.movieName), 
     251     "&amp;uploadURL=", encodeURIComponent(this.settings.upload_url), 
     252     "&amp;useQueryString=", encodeURIComponent(this.settings.use_query_string), 
     253     "&amp;requeueOnError=", encodeURIComponent(this.settings.requeue_on_error), 
     254     "&amp;httpSuccess=", encodeURIComponent(httpSuccessString), 
     255     "&amp;assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout), 
     256     "&amp;params=", encodeURIComponent(paramString), 
     257     "&amp;filePostName=", encodeURIComponent(this.settings.file_post_name), 
     258     "&amp;fileTypes=", encodeURIComponent(this.settings.file_types), 
     259     "&amp;fileTypesDescription=", encodeURIComponent(this.settings.file_types_description), 
     260     "&amp;fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit), 
     261     "&amp;fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit), 
     262     "&amp;fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit), 
     263     "&amp;debugEnabled=", encodeURIComponent(this.settings.debug_enabled), 
     264     "&amp;buttonImageURL=", encodeURIComponent(this.settings.button_image_url), 
     265     "&amp;buttonWidth=", encodeURIComponent(this.settings.button_width), 
     266     "&amp;buttonHeight=", encodeURIComponent(this.settings.button_height), 
     267     "&amp;buttonText=", encodeURIComponent(this.settings.button_text), 
     268     "&amp;buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding), 
     269     "&amp;buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding), 
     270     "&amp;buttonTextStyle=", encodeURIComponent(this.settings.button_text_style), 
     271     "&amp;buttonAction=", encodeURIComponent(this.settings.button_action), 
     272     "&amp;buttonDisabled=", encodeURIComponent(this.settings.button_disabled), 
     273     "&amp;buttonCursor=", encodeURIComponent(this.settings.button_cursor) 
     274   ].join(""); 
    275275}; 
    276276 
     
    278278// The element is cached after the first lookup 
    279279SWFUpload.prototype.getMovieElement = function () { 
    280   if (this.movieElement == undefined) { 
    281     this.movieElement = document.getElementById(this.movieName); 
    282  
    283  
    284   if (this.movieElement === null) { 
    285     throw "Could not find Flash element"; 
    286  
    287    
    288   return this.movieElement; 
     280 if (this.movieElement == undefined) { 
     281   this.movieElement = document.getElementById(this.movieName); 
     282
     283 
     284 if (this.movieElement === null) { 
     285   throw "Could not find Flash element"; 
     286
     287   
     288 return this.movieElement; 
    289289}; 
    290290 
     
    292292// and joins them up in to a string formatted "name=value&amp;name=value" 
    293293SWFUpload.prototype.buildParamString = function () { 
    294   var postParams = this.settings.post_params;  
    295   var paramStringPairs = []; 
    296  
    297   if (typeof(postParams) === "object") { 
    298     for (var name in postParams) { 
    299       if (postParams.hasOwnProperty(name)) { 
    300         paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString())); 
    301      
    302    
    303  
    304  
    305   return paramStringPairs.join("&amp;"); 
     294 var postParams = this.settings.post_params;  
     295 var paramStringPairs = []; 
     296 
     297 if (typeof(postParams) === "object") { 
     298   for (var name in postParams) { 
     299     if (postParams.hasOwnProperty(name)) { 
     300       paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString())); 
     301     
     302   
     303
     304 
     305 return paramStringPairs.join("&amp;"); 
    306306}; 
    307307 
     
    311311// Credits: Major improvements provided by steffen 
    312312SWFUpload.prototype.destroy = function () { 
    313   try { 
    314     // Make sure Flash is done before we try to remove it 
    315     this.cancelUpload(null, false); 
    316      
    317  
    318     // Remove the SWFUpload DOM nodes 
    319     var movieElement = null; 
    320     movieElement = this.getMovieElement(); 
    321      
    322     if (movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE 
    323       // Loop through all the movie's properties and remove all function references (DOM/JS IE 6/7 memory leak workaround) 
    324       for (var i in movieElement) { 
    325         try { 
    326           if (typeof(movieElement[i]) === "function") { 
    327             movieElement[i] = null; 
    328          
    329         } catch (ex1) {} 
    330      
    331  
    332       // Remove the Movie Element from the page 
    333       try { 
    334         movieElement.parentNode.removeChild(movieElement); 
    335       } catch (ex) {} 
    336    
    337      
    338     // Remove IE form fix reference 
    339     window[this.movieName] = null; 
    340  
    341     // Destroy other references 
    342     SWFUpload.instances[this.movieName] = null; 
    343     delete SWFUpload.instances[this.movieName]; 
    344  
    345     this.movieElement = null; 
    346     this.settings = null; 
    347     this.customSettings = null; 
    348     this.eventQueue = null; 
    349     this.movieName = null; 
    350      
    351      
    352     return true; 
    353   } catch (ex2) { 
    354     return false; 
    355  
     313 try { 
     314   // Make sure Flash is done before we try to remove it 
     315   this.cancelUpload(null, false); 
     316     
     317 
     318   // Remove the SWFUpload DOM nodes 
     319   var movieElement = null; 
     320   movieElement = this.getMovieElement(); 
     321     
     322   if (movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE 
     323     // Loop through all the movie's properties and remove all function references (DOM/JS IE 6/7 memory leak workaround) 
     324     for (var i in movieElement) { 
     325       try { 
     326         if (typeof(movieElement[i]) === "function") { 
     327           movieElement[i] = null; 
     328         
     329       } catch (ex1) {} 
     330     
     331 
     332     // Remove the Movie Element from the page 
     333     try { 
     334       movieElement.parentNode.removeChild(movieElement); 
     335     } catch (ex) {} 
     336   
     337     
     338   // Remove IE form fix reference 
     339   window[this.movieName] = null; 
     340 
     341   // Destroy other references 
     342   SWFUpload.instances[this.movieName] = null; 
     343   delete SWFUpload.instances[this.movieName]; 
     344 
     345   this.movieElement = null; 
     346   this.settings = null; 
     347   this.customSettings = null; 
     348   this.eventQueue = null; 
     349   this.movieName = null; 
     350     
     351     
     352   return true; 
     353 } catch (ex2) { 
     354   return false; 
     355
    356356}; 
    357357 
     
    362362// SWFUpload in production. 
    363363SWFUpload.prototype.displayDebugInfo = function () { 
    364   this.debug( 
    365    
    366       "---SWFUpload Instance Info---\n", 
    367       "Version: ", SWFUpload.version, "\n", 
    368       "Movie Name: ", this.movieName, "\n", 
    369       "Settings:\n", 
    370       "\t", "upload_url:               ", this.settings.upload_url, "\n", 
    371       "\t", "flash_url:                ", this.settings.flash_url, "\n", 
    372       "\t", "use_query_string:         ", this.settings.use_query_string.toString(), "\n", 
    373       "\t", "requeue_on_error:         ", this.settings.requeue_on_error.toString(), "\n", 
    374       "\t", "http_success:             ", this.settings.http_success.join(", "), "\n", 
    375       "\t", "assume_success_timeout:   ", this.settings.assume_success_timeout, "\n", 
    376       "\t", "file_post_name:           ", this.settings.file_post_name, "\n", 
    377       "\t", "post_params:              ", this.settings.post_params.toString(), "\n", 
    378       "\t", "file_types:               ", this.settings.file_types, "\n", 
    379       "\t", "file_types_description:   ", this.settings.file_types_description, "\n", 
    380       "\t", "file_size_limit:          ", this.settings.file_size_limit, "\n", 
    381       "\t", "file_upload_limit:        ", this.settings.file_upload_limit, "\n", 
    382       "\t", "file_queue_limit:         ", this.settings.file_queue_limit, "\n", 
    383       "\t", "debug:                    ", this.settings.debug.toString(), "\n", 
    384  
    385       "\t", "prevent_swf_caching:      ", this.settings.prevent_swf_caching.toString(), "\n", 
    386  
    387       "\t", "button_placeholder_id:    ", this.settings.button_placeholder_id.toString(), "\n", 
    388       "\t", "button_placeholder:       ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n", 
    389       "\t", "button_image_url:         ", this.settings.button_image_url.toString(), "\n", 
    390       "\t", "button_width:             ", this.settings.button_width.toString(), "\n", 
    391       "\t", "button_height:            ", this.settings.button_height.toString(), "\n", 
    392       "\t", "button_text:              ", this.settings.button_text.toString(), "\n", 
    393       "\t", "button_text_style:        ", this.settings.button_text_style.toString(), "\n", 
    394       "\t", "button_text_top_padding:  ", this.settings.button_text_top_padding.toString(), "\n", 
    395       "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n", 
    396       "\t", "button_action:            ", this.settings.button_action.toString(), "\n", 
    397       "\t", "button_disabled:          ", this.settings.button_disabled.toString(), "\n", 
    398  
    399       "\t", "custom_settings:          ", this.settings.custom_settings.toString(), "\n", 
    400       "Event Handlers:\n", 
    401       "\t", "swfupload_loaded_handler assigned:  ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n", 
    402       "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n", 
    403       "\t", "file_queued_handler assigned:       ", (typeof this.settings.file_queued_handler === "function").toString(), "\n", 
    404       "\t", "file_queue_error_handler assigned:  ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n", 
    405       "\t", "upload_start_handler assigned:      ", (typeof this.settings.upload_start_handler === "function").toString(), "\n", 
    406       "\t", "upload_progress_handler assigned:   ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n", 
    407       "\t", "upload_error_handler assigned:      ", (typeof this.settings.upload_error_handler === "function").toString(), "\n", 
    408       "\t", "upload_success_handler assigned:    ", (typeof this.settings.upload_success_handler === "function").toString(), "\n", 
    409       "\t", "upload_complete_handler assigned:   ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n", 
    410       "\t", "debug_handler assigned:             ", (typeof this.settings.debug_handler === "function").toString(), "\n" 
    411     ].join("") 
    412   ); 
     364 this.debug( 
     365   
     366     "---SWFUpload Instance Info---\n", 
     367     "Version: ", SWFUpload.version, "\n", 
     368     "Movie Name: ", this.movieName, "\n", 
     369     "Settings:\n", 
     370     "\t", "upload_url:               ", this.settings.upload_url, "\n", 
     371     "\t", "flash_url:                ", this.settings.flash_url, "\n", 
     372     "\t", "use_query_string:         ", this.settings.use_query_string.toString(), "\n", 
     373     "\t", "requeue_on_error:         ", this.settings.requeue_on_error.toString(), "\n", 
     374     "\t", "http_success:             ", this.settings.http_success.join(", "), "\n", 
     375     "\t", "assume_success_timeout:   ", this.settings.assume_success_timeout, "\n", 
     376     "\t", "file_post_name:           ", this.settings.file_post_name, "\n", 
     377     "\t", "post_params:              ", this.settings.post_params.toString(), "\n", 
     378     "\t", "file_types:               ", this.settings.file_types, "\n", 
     379     "\t", "file_types_description:   ", this.settings.file_types_description, "\n", 
     380     "\t", "file_size_limit:          ", this.settings.file_size_limit, "\n", 
     381     "\t", "file_upload_limit:        ", this.settings.file_upload_limit, "\n", 
     382     "\t", "file_queue_limit:         ", this.settings.file_queue_limit, "\n", 
     383     "\t", "debug:                    ", this.settings.debug.toString(), "\n", 
     384 
     385     "\t", "prevent_swf_caching:      ", this.settings.prevent_swf_caching.toString(), "\n", 
     386 
     387     "\t", "button_placeholder_id:    ", this.settings.button_placeholder_id.toString(), "\n", 
     388     "\t", "button_placeholder:       ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n", 
     389     "\t", "button_image_url:         ", this.settings.button_image_url.toString(), "\n", 
     390     "\t", "button_width:             ", this.settings.button_width.toString(), "\n", 
     391     "\t", "button_height:            ", this.settings.button_height.toString(), "\n", 
     392     "\t", "button_text:              ", this.settings.button_text.toString(), "\n", 
     393     "\t", "button_text_style:        ", this.settings.button_text_style.toString(), "\n", 
     394     "\t", "button_text_top_padding:  ", this.settings.button_text_top_padding.toString(), "\n", 
     395     "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n", 
     396     "\t", "button_action:            ", this.settings.button_action.toString(), "\n", 
     397     "\t", "button_disabled:          ", this.settings.button_disabled.toString(), "\n", 
     398 
     399     "\t", "custom_settings:          ", this.settings.custom_settings.toString(), "\n", 
     400     "Event Handlers:\n", 
     401     "\t", "swfupload_loaded_handler assigned:  ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n", 
     402     "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n", 
     403     "\t", "file_queued_handler assigned:       ", (typeof this.settings.file_queued_handler === "function").toString(), "\n", 
     404     "\t", "file_queue_error_handler assigned:  ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n", 
     405     "\t", "upload_start_handler assigned:      ", (typeof this.settings.upload_start_handler === "function").toString(), "\n", 
     406     "\t", "upload_progress_handler assigned:   ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n", 
     407     "\t", "upload_error_handler assigned:      ", (typeof this.settings.upload_error_handler === "function").toString(), "\n", 
     408     "\t", "upload_success_handler assigned:    ", (typeof this.settings.upload_success_handler === "function").toString(), "\n", 
     409     "\t", "upload_complete_handler assigned:   ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n", 
     410     "\t", "debug_handler assigned:             ", (typeof this.settings.debug_handler === "function").toString(), "\n" 
     411   ].join("") 
     412 ); 
    413413}; 
    414414 
    415415/* Note: addSetting and getSetting are no longer used by SWFUpload but are included 
    416   the maintain v2 API compatibility 
     416 the maintain v2 API compatibility 
    417417*/ 
    418418// Public: (Deprecated) addSetting adds a setting value. If the value given is undefined or null then the default_value is used. 
     
    422422    } else { 
    423423        return (this.settings[name] = value); 
    424  
     424
    425425}; 
    426426 
     
    429429    if (this.settings[name] != undefined) { 
    430430        return this.settings[name]; 
    431  
     431
    432432 
    433433    return ""; 
     
    440440// bugs in the ExternalInterface library. 
    441441SWFUpload.prototype.callFlash = function (functionName, argumentArray) { 
    442   argumentArray = argumentArray || []; 
    443    
    444   var movieElement = this.getMovieElement(); 
    445   var returnValue, returnString; 
    446  
    447   // Flash's method if calling ExternalInterface methods (code adapted from MooTools). 
    448   try { 
    449     returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>'); 
    450     returnValue = eval(returnString); 
    451   } catch (ex) { 
    452     throw "Call to " + functionName + " failed"; 
    453  
    454    
    455   // Unescape file post param values 
    456   if (returnValue != undefined && typeof returnValue.post === "object") { 
    457     returnValue = this.unescapeFilePostParams(returnValue); 
    458  
    459  
    460   return returnValue; 
     442 argumentArray = argumentArray || []; 
     443   
     444 var movieElement = this.getMovieElement(); 
     445 var returnValue, returnString; 
     446 
     447 // Flash's method if calling ExternalInterface methods (code adapted from MooTools). 
     448 try { 
     449   returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>'); 
     450   returnValue = eval(returnString); 
     451 } catch (ex) { 
     452   throw "Call to " + functionName + " failed"; 
     453
     454   
     455 // Unescape file post param values 
     456 if (returnValue != undefined && typeof returnValue.post === "object") { 
     457   returnValue = this.unescapeFilePostParams(returnValue); 
     458
     459 
     460 return returnValue; 
    461461}; 
    462462 
    463463/* ***************************** 
    464   -- Flash control methods -- 
    465   Your UI should use these 
    466   to operate SWFUpload 
     464 -- Flash control methods -- 
     465 Your UI should use these 
     466 to operate SWFUpload 
    467467   ***************************** */ 
    468468 
     
    471471// dialog only allows 1 file to be selected. 
    472472SWFUpload.prototype.selectFile = function () { 
    473   this.callFlash("SelectFile"); 
     473 this.callFlash("SelectFile"); 
    474474}; 
    475475 
     
    481481// for this bug. 
    482482SWFUpload.prototype.selectFiles = function () { 
    483   this.callFlash("SelectFiles"); 
     483 this.callFlash("SelectFiles"); 
    484484}; 
    485485 
     
    488488// the optional parameter 'fileID' specifies the ID  
    489489SWFUpload.prototype.startUpload = function (fileID) { 
    490   this.callFlash("StartUpload", [fileID]); 
     490 this.callFlash("StartUpload", [fileID]); 
    491491}; 
    492492 
     
    495495// If you do not want the uploadError event to trigger you can specify false for the triggerErrorEvent parameter. 
    496496SWFUpload.prototype.cancelUpload = function (fileID, triggerErrorEvent) { 
    497   if (triggerErrorEvent !== false) { 
    498     triggerErrorEvent = true; 
    499  
    500   this.callFlash("CancelUpload", [fileID, triggerErrorEvent]); 
     497 if (triggerErrorEvent !== false) { 
     498   triggerErrorEvent = true; 
     499
     500 this.callFlash("CancelUpload", [fileID, triggerErrorEvent]); 
    501501}; 
    502502 
     
    504504// If nothing is currently uploading then nothing happens. 
    505505SWFUpload.prototype.stopUpload = function () { 
    506   this.callFlash("StopUpload"); 
     506 this.callFlash("StopUpload"); 
    507507}; 
    508508 
     
    517517// Public: getStats gets the file statistics object. 
    518518SWFUpload.prototype.getStats = function () { 
    519   return this.callFlash("GetStats"); 
     519 return this.callFlash("GetStats"); 
    520520}; 
    521521 
     
    525525// by the upload_limit setting to determine how many files the user may upload. 
    526526SWFUpload.prototype.setStats = function (statsObject) { 
    527   this.callFlash("SetStats", [statsObject]); 
     527 this.callFlash("SetStats", [statsObject]); 
    528528}; 
    529529 
     
    531531// not found then 'null' is returned. 
    532532SWFUpload.prototype.getFile = function (fileID) { 
    533   if (typeof(fileID) === "number") { 
    534     return this.callFlash("GetFileByIndex", [fileID]); 
    535   } else { 
    536     return this.callFlash("GetFile", [fileID]); 
    537  
     533 if (typeof(fileID) === "number") { 
     534   return this.callFlash("GetFileByIndex", [fileID]); 
     535 } else { 
     536   return this.callFlash("GetFile", [fileID]); 
     537
    538538}; 
    539539 
     
    542542// exiting value will be overwritten. 
    543543SWFUpload.prototype.addFileParam = function (fileID, name, value) { 
    544   return this.callFlash("AddFileParam", [fileID, name, value]); 
     544 return this.callFlash("AddFileParam", [fileID, name, value]); 
    545545}; 
    546546 
     
    548548// pair from the specified file. 
    549549SWFUpload.prototype.removeFileParam = function (fileID, name) { 
    550   this.callFlash("RemoveFileParam", [fileID, name]); 
     550 this.callFlash("RemoveFileParam", [fileID, name]); 
    551551}; 
    552552 
    553553// Public: setUploadUrl changes the upload_url setting. 
    554554SWFUpload.prototype.setUploadURL = function (url) { 
    555   this.settings.upload_url = url.toString(); 
    556   this.callFlash("SetUploadURL", [url]); 
     555 this.settings.upload_url = url.toString(); 
     556 this.callFlash("SetUploadURL", [url]); 
    557557}; 
    558558 
    559559// Public: setPostParams changes the post_params setting 
    560560SWFUpload.prototype.setPostParams = function (paramsObject) { 
    561   this.settings.post_params = paramsObject; 
    562   this.callFlash("SetPostParams", [paramsObject]); 
     561 this.settings.post_params = paramsObject; 
     562 this.callFlash("SetPostParams", [paramsObject]); 
    563563}; 
    564564 
    565565// Public: addPostParam adds post name/value pair.  Each name can have only one value. 
    566566SWFUpload.prototype.addPostParam = function (name, value) { 
    567   this.settings.post_params[name] = value; 
    568   this.callFlash("SetPostParams", [this.settings.post_params]); 
     567 this.settings.post_params[name] = value; 
     568 this.callFlash("SetPostParams", [this.settings.post_params]); 
    569569}; 
    570570 
    571571// Public: removePostParam deletes post name/value pair. 
    572572SWFUpload.prototype.removePostParam = function (name) { 
    573   delete this.settings.post_params[name]; 
    574   this.callFlash("SetPostParams", [this.settings.post_params]); 
     573 delete this.settings.post_params[name]; 
     574 this.callFlash("SetPostParams", [this.settings.post_params]); 
    575575}; 
    576576 
    577577// Public: setFileTypes changes the file_types setting and the file_types_description setting 
    578578SWFUpload.prototype.setFileTypes = function (types, description) { 
    579   this.settings.file_types = types; 
    580   this.settings.file_types_description = description; 
    581   this.callFlash("SetFileTypes", [types, description]); 
     579 this.settings.file_types = types; 
     580 this.settings.file_types_description = description; 
     581 this.callFlash("SetFileTypes", [types, description]); 
    582582}; 
    583583 
    584584// Public: setFileSizeLimit changes the file_size_limit setting 
    585585SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) { 
    586   this.settings.file_size_limit = fileSizeLimit; 
    587   this.callFlash("SetFileSizeLimit", [fileSizeLimit]); 
     586 this.settings.file_size_limit = fileSizeLimit; 
     587 this.callFlash("SetFileSizeLimit", [fileSizeLimit]); 
    588588}; 
    589589 
    590590// Public: setFileUploadLimit changes the file_upload_limit setting 
    591591SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) { 
    592   this.settings.file_upload_limit = fileUploadLimit; 
    593   this.callFlash("SetFileUploadLimit", [fileUploadLimit]); 
     592 this.settings.file_upload_limit = fileUploadLimit; 
     593 this.callFlash("SetFileUploadLimit", [fileUploadLimit]); 
    594594}; 
    595595 
    596596// Public: setFileQueueLimit changes the file_queue_limit setting 
    597597SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) { 
    598   this.settings.file_queue_limit = fileQueueLimit; 
    599   this.callFlash("SetFileQueueLimit", [fileQueueLimit]); 
     598 this.settings.file_queue_limit = fileQueueLimit; 
     599 this.callFlash("SetFileQueueLimit", [fileQueueLimit]); 
    600600}; 
    601601 
    602602// Public: setFilePostName changes the file_post_name setting 
    603603SWFUpload.prototype.setFilePostName = function (filePostName) { 
    604   this.settings.file_post_name = filePostName; 
    605   this.callFlash("SetFilePostName", [filePostName]); 
     604 this.settings.file_post_name = filePostName; 
     605 this.callFlash("SetFilePostName", [filePostName]); 
    606606}; 
    607607 
    608608// Public: setUseQueryString changes the use_query_string setting 
    609609SWFUpload.prototype.setUseQueryString = function (useQueryString) { 
    610   this.settings.use_query_string = useQueryString; 
    611   this.callFlash("SetUseQueryString", [useQueryString]); 
     610 this.settings.use_query_string = useQueryString; 
     611 this.callFlash("SetUseQueryString", [useQueryString]); 
    612612}; 
    613613 
    614614// Public: setRequeueOnError changes the requeue_on_error setting 
    615615SWFUpload.prototype.setRequeueOnError = function (requeueOnError) { 
    616   this.settings.requeue_on_error = requeueOnError; 
    617   this.callFlash("SetRequeueOnError", [requeueOnError]); 
     616 this.settings.requeue_on_error = requeueOnError; 
     617 this.callFlash("SetRequeueOnError", [requeueOnError]); 
    618618}; 
    619619 
    620620// Public: setHTTPSuccess changes the http_success setting 
    621621SWFUpload.prototype.setHTTPSuccess = function (http_status_codes) { 
    622   if (typeof http_status_codes === "string") { 
    623     http_status_codes = http_status_codes.replace(" ", "").split(","); 
    624  
    625    
    626   this.settings.http_success = http_status_codes; 
    627   this.callFlash("SetHTTPSuccess", [http_status_codes]); 
     622 if (typeof http_status_codes === "string") { 
     623   http_status_codes = http_status_codes.replace(" ", "").split(","); 
     624
     625   
     626 this.settings.http_success = http_status_codes; 
     627 this.callFlash("SetHTTPSuccess", [http_status_codes]); 
    628628}; 
    629629 
    630630// Public: setHTTPSuccess changes the http_success setting 
    631631SWFUpload.prototype.setAssumeSuccessTimeout = function (timeout_seconds) { 
    632   this.settings.assume_success_timeout = timeout_seconds; 
    633   this.callFlash("SetAssumeSuccessTimeout", [timeout_seconds]); 
     632 this.settings.assume_success_timeout = timeout_seconds; 
     633 this.callFlash("SetAssumeSuccessTimeout", [timeout_seconds]); 
    634634}; 
    635635 
    636636// Public: setDebugEnabled changes the debug_enabled setting 
    637637SWFUpload.prototype.setDebugEnabled = function (debugEnabled) { 
    638   this.settings.debug_enabled = debugEnabled; 
    639   this.callFlash("SetDebugEnabled", [debugEnabled]); 
     638 this.settings.debug_enabled = debugEnabled; 
     639 this.callFlash("SetDebugEnabled", [debugEnabled]); 
    640640}; 
    641641 
    642642// Public: setButtonImageURL loads a button image sprite 
    643643SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) { 
    644   if (buttonImageURL == undefined) { 
    645     buttonImageURL = ""; 
    646  
    647    
    648   this.settings.button_image_url = buttonImageURL; 
    649   this.callFlash("SetButtonImageURL", [buttonImageURL]); 
     644 if (buttonImageURL == undefined) { 
     645   buttonImageURL = ""; 
     646
     647   
     648 this.settings.button_image_url = buttonImageURL; 
     649 this.callFlash("SetButtonImageURL", [buttonImageURL]); 
    650650}; 
    651651 
    652652// Public: setButtonDimensions resizes the Flash Movie and button 
    653653SWFUpload.prototype.setButtonDimensions = function (width, height) { 
    654   this.settings.button_width = width; 
    655   this.settings.button_height = height; 
    656    
    657   var movie = this.getMovieElement(); 
    658   if (movie != undefined) { 
    659     movie.style.width = width + "px"; 
    660     movie.style.height = height + "px"; 
    661  
    662    
    663   this.callFlash("SetButtonDimensions", [width, height]); 
     654 this.settings.button_width = width; 
     655 this.settings.button_height = height; 
     656   
     657 var movie = this.getMovieElement(); 
     658 if (movie != undefined) { 
     659   movie.style.width = width + "px"; 
     660   movie.style.height = height + "px"; 
     661
     662   
     663 this.callFlash("SetButtonDimensions", [width, height]); 
    664664}; 
    665665// Public: setButtonText Changes the text overlaid on the button 
    666666SWFUpload.prototype.setButtonText = function (html) { 
    667   this.settings.button_text = html; 
    668   this.callFlash("SetButtonText", [html]); 
     667 this.settings.button_text = html; 
     668 this.callFlash("SetButtonText", [html]); 
    669669}; 
    670670// Public: setButtonTextPadding changes the top and left padding of the text overlay 
    671671SWFUpload.prototype.setButtonTextPadding = function (left, top) { 
    672   this.settings.button_text_top_padding = top; 
    673   this.settings.button_text_left_padding = left; 
    674   this.callFlash("SetButtonTextPadding", [left, top]); 
     672 this.settings.button_text_top_padding = top; 
     673 this.settings.button_text_left_padding = left; 
     674 this.callFlash("SetButtonTextPadding", [left, top]); 
    675675}; 
    676676 
    677677// Public: setButtonTextStyle changes the CSS used to style the HTML/Text overlaid on the button 
    678678SWFUpload.prototype.setButtonTextStyle = function (css) { 
    679   this.settings.button_text_style = css; 
    680   this.callFlash("SetButtonTextStyle", [css]); 
     679 this.settings.button_text_style = css; 
     680 this.callFlash("SetButtonTextStyle", [css]); 
    681681}; 
    682682// Public: setButtonDisabled disables/enables the button 
    683683SWFUpload.prototype.setButtonDisabled = function (isDisabled) { 
    684   this.settings.button_disabled = isDisabled; 
    685   this.callFlash("SetButtonDisabled", [isDisabled]); 
     684 this.settings.button_disabled = isDisabled; 
     685 this.callFlash("SetButtonDisabled", [isDisabled]); 
    686686}; 
    687687// Public: setButtonAction sets the action that occurs when the button is clicked 
    688688SWFUpload.prototype.setButtonAction = function (buttonAction) { 
    689   this.settings.button_action = buttonAction; 
    690   this.callFlash("SetButtonAction", [buttonAction]); 
     689 this.settings.button_action = buttonAction; 
     690 this.callFlash("SetButtonAction", [buttonAction]); 
    691691}; 
    692692 
    693693// Public: setButtonCursor changes the mouse cursor displayed when hovering over the button 
    694694SWFUpload.prototype.setButtonCursor = function (cursor) { 
    695   this.settings.button_cursor = cursor; 
    696   this.callFlash("SetButtonCursor", [cursor]); 
     695 this.settings.button_cursor = cursor; 
     696 this.callFlash("SetButtonCursor", [cursor]); 
    697697}; 
    698698 
    699699/* ******************************* 
    700   Flash Event Interfaces 
    701   These functions are used by Flash to trigger the various 
    702   events. 
    703    
    704   All these functions a Private. 
    705    
    706   Because the ExternalInterface library is buggy the event calls 
    707   are added to a queue and the queue then executed by a setTimeout. 
    708   This ensures that events are executed in a determinate order and that 
    709   the ExternalInterface bugs are avoided. 
     700 Flash Event Interfaces 
     701 These functions are used by Flash to trigger the various 
     702 events. 
     703   
     704 All these functions a Private. 
     705   
     706 Because the ExternalInterface library is buggy the event calls 
     707 are added to a queue and the queue then executed by a setTimeout. 
     708 This ensures that events are executed in a determinate order and that 
     709 the ExternalInterface bugs are avoided. 
    710710******************************* */ 
    711711 
    712712SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) { 
    713   // Warning: Don't call this.debug inside here or you'll create an infinite loop 
    714    
    715   if (argumentArray == undefined) { 
    716     argumentArray = []; 
    717   } else if (!(argumentArray instanceof Array)) { 
    718     argumentArray = [argumentArray]; 
    719  
    720    
    721   var self = this; 
    722   if (typeof this.settings[handlerName] === "function") { 
    723     // Queue the event 
    724     this.eventQueue.push(function () { 
    725       this.settings[handlerName].apply(this, argumentArray); 
    726     }); 
    727      
    728     // Execute the next queued event 
    729     setTimeout(function () { 
    730       self.executeNextEvent(); 
    731     }, 0); 
    732      
    733   } else if (this.settings[handlerName] !== null) { 
    734     throw "Event handler " + handlerName + " is unknown or is not a function"; 
    735  
     713 // Warning: Don't call this.debug inside here or you'll create an infinite loop 
     714   
     715 if (argumentArray == undefined) { 
     716   argumentArray = []; 
     717 } else if (!(argumentArray instanceof Array)) { 
     718   argumentArray = [argumentArray]; 
     719
     720   
     721 var self = this; 
     722 if (typeof this.settings[handlerName] === "function") { 
     723   // Queue the event 
     724   this.eventQueue.push(function () { 
     725     this.settings[handlerName].apply(this, argumentArray); 
     726   }); 
     727     
     728   // Execute the next queued event 
     729   setTimeout(function () { 
     730     self.executeNextEvent(); 
     731   }, 0); 
     732     
     733 } else if (this.settings[handlerName] !== null) { 
     734   throw "Event handler " + handlerName + " is unknown or is not a function"; 
     735
    736736}; 
    737737 
     
    739739// we must queue them in order to garentee that they are executed in order. 
    740740SWFUpload.prototype.executeNextEvent = function () { 
    741   // Warning: Don't call this.debug inside here or you'll create an infinite loop 
    742  
    743   var  f = this.eventQueue ? this.eventQueue.shift() : null; 
    744   if (typeof(f) === "function") { 
    745     f.apply(this); 
    746  
     741 // Warning: Don't call this.debug inside here or you'll create an infinite loop 
     742 
     743 var  f = this.eventQueue ? this.eventQueue.shift() : null; 
     744 if (typeof(f) === "function") { 
     745   f.apply(this); 
     746
    747747}; 
    748748 
     
    751751// the Flash Component escapes the parameter names and we must unescape again before passing them along. 
    752752SWFUpload.prototype.unescapeFilePostParams = function (file) { 
    753   var reg = /[$]([0-9a-f]{4})/i; 
    754   var unescapedPost = {}; 
    755   var uk; 
    756  
    757   if (file != undefined) { 
    758     for (var k in file.post) { 
    759       if (file.post.hasOwnProperty(k)) { 
    760         uk = k; 
    761         var match; 
    762         while ((match = reg.exec(uk)) !== null) { 
    763           uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16))); 
    764        
    765         unescapedPost[uk] = file.post[k]; 
    766      
    767    
    768  
    769     file.post = unescapedPost; 
    770  
    771  
    772   return file; 
     753 var reg = /[$]([0-9a-f]{4})/i; 
     754 var unescapedPost = {}; 
     755 var uk; 
     756 
     757 if (file != undefined) { 
     758   for (var k in file.post) { 
     759     if (file.post.hasOwnProperty(k)) { 
     760       uk = k; 
     761       var match; 
     762       while ((match = reg.exec(uk)) !== null) { 
     763         uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16))); 
     764       
     765       unescapedPost[uk] = file.post[k]; 
     766     
     767   
     768 
     769   file.post = unescapedPost; 
     770
     771 
     772 return file; 
    773773}; 
    774774 
    775775// Private: Called by Flash to see if JS can call in to Flash (test if External Interface is working) 
    776776SWFUpload.prototype.testExternalInterface = function () { 
    777   try { 
    778     return this.callFlash("TestExternalInterface"); 
    779   } catch (ex) { 
    780     return false; 
    781  
     777 try { 
     778   return this.callFlash("TestExternalInterface"); 
     779 } catch (ex) { 
     780   return false; 
     781
    782782}; 
    783783 
     
    785785// Use the swfupload_loaded_handler event setting to execute custom code when SWFUpload has loaded. 
    786786SWFUpload.prototype.flashReady = function () { 
    787   // Check that the movie element is loaded correctly with its ExternalInterface methods defined 
    788   var movieElement = this.getMovieElement(); 
    789  
    790   if (!movieElement) { 
    791     this.debug("Flash called back ready but the flash movie can't be found."); 
    792     return; 
    793  
    794  
    795   this.cleanUp(movieElement); 
    796    
    797   this.queueEvent("swfupload_loaded_handler"); 
     787 // Check that the movie element is loaded correctly with its ExternalInterface methods defined 
     788 var movieElement = this.getMovieElement(); 
     789 
     790 if (!movieElement) { 
     791   this.debug("Flash called back ready but the flash movie can't be found."); 
     792   return; 
     793
     794 
     795 this.cleanUp(movieElement); 
     796   
     797 this.queueEvent("swfupload_loaded_handler"); 
    798798}; 
    799799 
     
    801801// This function is called by Flash each time the ExternalInterface functions are created. 
    802802SWFUpload.prototype.cleanUp = function (movieElement) { 
    803   // Pro-actively unhook all the Flash functions 
    804   try { 
    805     if (this.movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE 
    806       this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)"); 
    807       for (var key in movieElement) { 
    808         try { 
    809           if (typeof(movieElement[key]) === "function") { 
    810             movieElement[key] = null; 
    811          
    812         } catch (ex) { 
    813        
    814      
    815    
    816   } catch (ex1) { 
    817    
    818  
    819  
    820   // Fix Flashes own cleanup code so if the SWFMovie was removed from the page 
    821   // it doesn't display errors. 
    822   window["__flash__removeCallback"] = function (instance, name) { 
    823     try { 
    824       if (instance) { 
    825         instance[name] = null; 
    826      
    827     } catch (flashEx) { 
    828      
    829    
    830   }; 
     803 // Pro-actively unhook all the Flash functions 
     804 try { 
     805   if (this.movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE 
     806     this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)"); 
     807     for (var key in movieElement) { 
     808       try { 
     809         if (typeof(movieElement[key]) === "function") { 
     810           movieElement[key] = null; 
     811         
     812       } catch (ex) { 
     813       
     814     
     815   
     816 } catch (ex1) { 
     817   
     818
     819 
     820 // Fix Flashes own cleanup code so if the SWFMovie was removed from the page 
     821 // it doesn't display errors. 
     822 window["__flash__removeCallback"] = function (instance, name) { 
     823   try { 
     824     if (instance) { 
     825       instance[name] = null; 
     826     
     827   } catch (flashEx) { 
     828     
     829   
     830 }; 
    831831 
    832832}; 
     
    835835/* This is a chance to do something before the browse window opens */ 
    836836SWFUpload.prototype.fileDialogStart = function () { 
    837   this.queueEvent("file_dialog_start_handler"); 
     837 this.queueEvent("file_dialog_start_handler"); 
    838838}; 
    839839 
     
    841841/* Called when a file is successfully added to the queue. */ 
    842842SWFUpload.prototype.fileQueued = function (file) { 
    843   file = this.unescapeFilePostParams(file); 
    844   this.queueEvent("file_queued_handler", file); 
     843 file = this.unescapeFilePostParams(file); 
     844 this.queueEvent("file_queued_handler", file); 
    845845}; 
    846846 
     
    848848/* Handle errors that occur when an attempt to queue a file fails. */ 
    849849SWFUpload.prototype.fileQueueError = function (file, errorCode, message) { 
    850   file = this.unescapeFilePostParams(file); 
    851   this.queueEvent("file_queue_error_handler", [file, errorCode, message]); 
     850 file = this.unescapeFilePostParams(file); 
     851 this.queueEvent("file_queue_error_handler", [file, errorCode, message]); 
    852852}; 
    853853 
    854854/* Called after the file dialog has closed and the selected files have been queued. 
    855   You could call startUpload here if you want the queued files to begin uploading immediately. */ 
     855 You could call startUpload here if you want the queued files to begin uploading immediately. */ 
    856856SWFUpload.prototype.fileDialogComplete = function (numFilesSelected, numFilesQueued, numFilesInQueue) { 
    857   this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued, numFilesInQueue]); 
     857 this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued, numFilesInQueue]); 
    858858}; 
    859859 
    860860SWFUpload.prototype.uploadStart = function (file) { 
    861   file = this.unescapeFilePostParams(file); 
    862   this.queueEvent("return_upload_start_handler", file); 
     861 file = this.unescapeFilePostParams(file); 
     862 this.queueEvent("return_upload_start_handler", file); 
    863863}; 
    864864 
    865865SWFUpload.prototype.returnUploadStart = function (file) { 
    866   var returnValue; 
    867   if (typeof this.settings.upload_start_handler === "function") { 
    868     file = this.unescapeFilePostParams(file); 
    869     returnValue = this.settings.upload_start_handler.call(this, file); 
    870   } else if (this.settings.upload_start_handler != undefined) { 
    871     throw "upload_start_handler must be a function"; 
    872  
    873  
    874   // Convert undefined to true so if nothing is returned from the upload_start_handler it is 
    875   // interpretted as 'true'. 
    876   if (returnValue === undefined) { 
    877     returnValue = true; 
    878  
    879    
    880   returnValue = !!returnValue; 
    881    
    882   this.callFlash("ReturnUploadStart", [returnValue]); 
     866 var returnValue; 
     867 if (typeof this.settings.upload_start_handler === "function") { 
     868   file = this.unescapeFilePostParams(file); 
     869   returnValue = this.settings.upload_start_handler.call(this, file); 
     870 } else if (this.settings.upload_start_handler != undefined) { 
     871   throw "upload_start_handler must be a function"; 
     872
     873 
     874 // Convert undefined to true so if nothing is returned from the upload_start_handler it is 
     875 // interpretted as 'true'. 
     876 if (returnValue === undefined) { 
     877   returnValue = true; 
     878
     879   
     880 returnValue = !!returnValue; 
     881   
     882 this.callFlash("ReturnUploadStart", [returnValue]); 
    883883}; 
    884884 
     
    886886 
    887887SWFUpload.prototype.uploadProgress = function (file, bytesComplete, bytesTotal) { 
    888   file = this.unescapeFilePostParams(file); 
    889   this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]); 
     888 file = this.unescapeFilePostParams(file); 
     889 this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]); 
    890890}; 
    891891 
    892892SWFUpload.prototype.uploadError = function (file, errorCode, message) { 
    893   file = this.unescapeFilePostParams(file); 
    894   this.queueEvent("upload_error_handler", [file, errorCode, message]); 
     893 file = this.unescapeFilePostParams(file); 
     894 this.queueEvent("upload_error_handler", [file, errorCode, message]); 
    895895}; 
    896896 
    897897SWFUpload.prototype.uploadSuccess = function (file, serverData, responseReceived) { 
    898   file = this.unescapeFilePostParams(file); 
    899   this.queueEvent("upload_success_handler", [file, serverData, responseReceived]); 
     898 file = this.unescapeFilePostParams(file); 
     899 this.queueEvent("upload_success_handler", [file, serverData, responseReceived]); 
    900900}; 
    901901 
    902902SWFUpload.prototype.uploadComplete = function (file) { 
    903   file = this.unescapeFilePostParams(file); 
    904   this.queueEvent("upload_complete_handler", file); 
     903 file = this.unescapeFilePostParams(file); 
     904 this.queueEvent("upload_complete_handler", file); 
    905905}; 
    906906 
     
    908908   internal debug console.  You can override this event and have messages written where you want. */ 
    909909SWFUpload.prototype.debug = function (message) { 
    910   this.queueEvent("debug_handler", message); 
     910 this.queueEvent("debug_handler", message); 
    911911}; 
    912912 
    913913 
    914914/* ********************************** 
    915   Debug Console 
    916   The debug console is a self contained, in page location 
    917   for debug message to be sent.  The Debug Console adds 
    918   itself to the body if necessary. 
    919  
    920   The console is automatically scrolled as messages appear. 
    921    
    922   If you are using your own debug handler or when you deploy to production and 
    923   have debug disabled you can remove these functions to reduce the file size 
    924   and complexity. 
     915 Debug Console 
     916 The debug console is a self contained, in page location 
     917 for debug message to be sent.  The Debug Console adds 
     918 itself to the body if necessary. 
     919 
     920 The console is automatically scrolled as messages appear. 
     921   
     922 If you are using your own debug handler or when you deploy to production and 
     923 have debug disabled you can remove these functions to reduce the file size 
     924 and complexity. 
    925925********************************** */ 
    926926    
     
    929929// check to see if the debug setting is true before outputting debug information. 
    930930SWFUpload.prototype.debugMessage = function (message) { 
    931   if (this.settings.debug) { 
    932     var exceptionMessage, exceptionValues = []; 
    933  
    934     // Check for an exception object and print it nicely 
    935     if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") { 
    936       for (var key in message) { 
    937         if (message.hasOwnProperty(key)) { 
    938           exceptionValues.push(key + ": " + message[key]); 
    939        
    940      
    941       exceptionMessage = exceptionValues.join("\n") || ""; 
    942       exceptionValues = exceptionMessage.split("\n"); 
    943       exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: "); 
    944       SWFUpload.Console.writeLine(exceptionMessage); 
    945     } else { 
    946       SWFUpload.Console.writeLine(message); 
    947    
    948  
     931 if (this.settings.debug) { 
     932   var exceptionMessage, exceptionValues = []; 
     933 
     934   // Check for an exception object and print it nicely 
     935   if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") { 
     936     for (var key in message) { 
     937       if (message.hasOwnProperty(key)) { 
     938         exceptionValues.push(key + ": " + message[key]); 
     939       
     940     
     941     exceptionMessage = exceptionValues.join("\n") || ""; 
     942     exceptionValues = exceptionMessage.split("\n"); 
     943     exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: "); 
     944     SWFUpload.Console.writeLine(exceptionMessage); 
     945   } else { 
     946     SWFUpload.Console.writeLine(message); 
     947   
     948
    949949}; 
    950950 
    951951SWFUpload.Console = {}; 
    952952SWFUpload.Console.writeLine = function (message) { 
    953   var console, documentForm; 
    954  
    955   try { 
    956     console = document.getElementById("SWFUpload_Console"); 
    957  
    958     if (!console) { 
    959       documentForm = document.createElement("form"); 
    960       document.getElementsByTagName("body")[0].appendChild(documentForm); 
    961  
    962       console = document.createElement("textarea"); 
    963       console.id = "SWFUpload_Console"; 
    964       console.style.fontFamily = "monospace"; 
    965       console.setAttribute("wrap", "off"); 
    966       console.wrap = "off"; 
    967       console.style.overflow = "auto"; 
    968       console.style.width = "700px"; 
    969       console.style.height = "350px"; 
    970       console.style.margin = "5px"; 
    971       documentForm.appendChild(console); 
    972    
    973  
    974     console.value += message + "\n"; 
    975  
    976     console.scrollTop = console.scrollHeight - console.clientHeight; 
    977   } catch (ex) { 
    978     alert("Exception: " + ex.name + " Message: " + ex.message); 
    979  
    980 }; 
     953 var console, documentForm; 
     954 
     955 try { 
     956   console = document.getElementById("SWFUpload_Console"); 
     957 
     958   if (!console) { 
     959     documentForm = document.createElement("form"); 
     960     document.getElementsByTagName("body")[0].appendChild(documentForm); 
     961 
     962     console = document.createElement("textarea"); 
     963     console.id = "SWFUpload_Console"; 
     964     console.style.fontFamily = "monospace"; 
     965     console.setAttribute("wrap", "off"); 
     966     console.wrap = "off"; 
     967     console.style.overflow = "auto"; 
     968     console.style.width = "700px"; 
     969     console.style.height = "350px"; 
     970     console.style.margin = "5px"; 
     971     documentForm.appendChild(console); 
     972   
     973 
     974   console.value += message + "\n"; 
     975 
     976   console.scrollTop = console.scrollHeight - console.clientHeight; 
     977 } catch (ex) { 
     978   alert("Exception: " + ex.name + " Message: " + ex.message); 
     979
     980}; 
  • plugins/sfImaginablePlugin/branches/experimental/web/swf/ExternalCall.as

    r24360 r24364  
    2222       
    2323    } 
    24     public static function FileDialogComplete(callback:String, num_files_selected:Number, num_files_queued:Number, total_num_files_queued:Number):void { 
     24    public static function FileDialogComplete(callback:String, num_files_selected:Number, num_files_queued:Number):void { 
    2525       
    26       ExternalInterface.call(callback, EscapeMessage(num_files_selected), EscapeMessage(num_files_queued), EscapeMessage(total_num_files_queued)); 
     26      ExternalInterface.call(callback, EscapeMessage(num_files_selected), EscapeMessage(num_files_queued)); 
    2727       
    2828    } 
     
    3737       
    3838    } 
    39     public static function UploadSuccess(callback:String, file_object:Object, server_data:String, responseReceived:Boolean):void { 
     39    public static function UploadSuccess(callback:String, file_object:Object, server_data:String):void { 
    4040       
    41       ExternalInterface.call(callback, EscapeMessage(file_object), EscapeMessage(server_data), EscapeMessage(responseReceived)); 
     41      ExternalInterface.call(callback, EscapeMessage(file_object), EscapeMessage(server_data)); 
    4242       
    4343    } 
     
    5555       
    5656      ExternalInterface.call(callback, EscapeMessage(message)); 
     57       
    5758    } 
    58      
    59     public static function Bool(callback:String):Boolean { 
    60       return ExternalInterface.call(callback); 
    61     } 
    62      
    6359     
    6460    /* Escapes all the backslashes which are not translated correctly in the Flash -> JavaScript Interface 
  • plugins/sfImaginablePlugin/branches/experimental/web/swf/SWFUpload.as

    r24360 r24364  
    11package { 
    2   import flash.display.BlendMode; 
    32  import flash.display.DisplayObjectContainer; 
    43  import flash.display.Loader; 
     
    2625  import flash.text.TextFormat; 
    2726  import flash.ui.Mouse; 
    28   import flash.utils.Timer; 
    2927 
    3028  import FileItem; 
     
    3836    } 
    3937     
    40     private const build_number:String = "SWFUPLOAD 2.2.0"; 
     38    private const build_number:String = "SWFUPLOAD 2.2.0 Alpha 2008-10-17"; 
    4139     
    4240    // State tracking variables 
     
    5654     
    5755    private var valid_file_extensions:Array = new Array();// Holds the parsed valid extensions. 
    58      
    59     private var serverDataTimer:Timer = null; 
    60     private var assumeSuccessTimer:Timer = null; 
    61      
    62     private var restoreExtIntTimer:Timer; 
    63     private var hasCalledFlashReady:Boolean = false; 
    6456     
    6557    // Callbacks 
     
    7870     
    7971    private var debug_Callback:String; 
    80     private var testExternalInterface_Callback:String; 
    81     private var cleanUp_Callback:String; 
    8272     
    8373    // Values passed in from the HTML 
     
    9383    private var useQueryString:Boolean = false; 
    9484    private var requeueOnError:Boolean = false; 
    95     private var httpSuccess:Array = []; 
    96     private var assumeSuccessTimeout:Number = 0; 
    9785    private var debugEnabled:Boolean; 
    9886 
    9987    private var buttonLoader:Loader; 
    10088    private var buttonTextField:TextField; 
    101     private var buttonCursorSprite:Sprite; 
    10289    private var buttonImageURL:String; 
    10390    private var buttonWidth:Number; 
     
    10895    private var buttonTextLeftPadding:Number; 
    10996    private var buttonAction:Number; 
    110     private var buttonCursor:Number; 
    11197    private var buttonStateOver:Boolean; 
    11298    private var buttonStateMouseDown:Boolean; 
     
    143129    private var BUTTON_ACTION_START_UPLOAD:Number               = -120; 
    144130     
    145     private var BUTTON_CURSOR_ARROW:Number            = -1; 
    146     private var BUTTON_CURSOR_HAND:Number           = -2; 
    147      
    148131    public function SWFUpload() { 
    149132      // Do the feature detection.  Make sure this version of Flash supports the features we need. If not 
     
    153136      } 
    154137 
     138       
    155139      Security.allowDomain("*");  // Allow uploading to any domain 
    156140       
     
    220204      this.stage.addChild(this.buttonTextField); 
    221205       
    222        
    223       this.buttonCursorSprite = new Sprite(); 
    224       this.buttonCursorSprite.graphics.beginFill(0xFFFFFF, 0); 
    225       this.buttonCursorSprite.graphics.drawRect(0, 0, 1, 1); 
    226       this.buttonCursorSprite.graphics.endFill(); 
    227       this.buttonCursorSprite.buttonMode = true; 
    228       this.buttonCursorSprite.x = 0; 
    229       this.buttonCursorSprite.y = 0; 
    230       this.buttonCursorSprite.addEventListener(MouseEvent.CLICK, doNothing); 
    231       this.stage.addChild(this.buttonCursorSprite); 
     206      // FIXME -- figure out about alignment 
    232207       
    233208      // Get the movie name 
     
    255230      this.debug_Callback              = "SWFUpload.instances[\"" + this.movieName + "\"].debug"; 
    256231 
    257       this.testExternalInterface_Callback = "SWFUpload.instances[\"" + this.movieName + "\"].testExternalInterface"; 
    258       this.cleanUp_Callback              = "SWFUpload.instances[\"" + this.movieName + "\"].cleanUp"; 
    259232       
    260233      // Get the Flash Vars 
     
    323296 
    324297      try { 
    325         this.SetHTTPSuccess(String(root.loaderInfo.parameters.httpSuccess)); 
    326       } catch (ex:Object) { 
    327         this.SetHTTPSuccess([]); 
    328       } 
    329  
    330       try { 
    331         this.SetAssumeSuccessTimeout(Number(root.loaderInfo.parameters.assumeSuccessTimeout)); 
    332       } catch (ex:Object) { 
    333         this.SetAssumeSuccessTimeout(0); 
    334       } 
    335  
    336        
    337       try { 
    338298        this.SetButtonDimensions(Number(root.loaderInfo.parameters.buttonWidth), Number(root.loaderInfo.parameters.buttonHeight)); 
    339299      } catch (ex:Object) { 
     
    366326 
    367327      try { 
     328        this.SetButtonTextStyle(String(root.loaderInfo.parameters.buttonTextStyle)); 
     329      } catch (ex:Object) { 
     330        this.SetButtonTextStyle(""); 
     331      } 
     332 
     333      try { 
    368334        this.SetButtonAction(Number(root.loaderInfo.parameters.buttonAction)); 
    369335      } catch (ex:Object) { 
     
    378344       
    379345      try { 
    380         this.SetButtonCursor(Number(root.loaderInfo.parameters.buttonCursor)); 
    381       } catch (ex:Object) { 
    382         this.SetButtonCursor(this.BUTTON_CURSOR_ARROW); 
    383       } 
    384        
    385       this.SetupExternalInterface(); 
    386        
    387       this.Debug("SWFUpload Init Complete"); 
    388       this.PrintDebugInfo(); 
    389  
    390       if (ExternalCall.Bool(this.testExternalInterface_Callback)) { 
    391         ExternalCall.Simple(this.flashReady_Callback); 
    392         this.hasCalledFlashReady = true; 
    393       } 
    394        
    395       // Start periodically checking the external interface 
    396       var oSelf:SWFUpload = this; 
    397       this.restoreExtIntTimer = new Timer(1000, 0); 
    398       this.restoreExtIntTimer.addEventListener(TimerEvent.TIMER, function ():void { oSelf.CheckExternalInterface();} ); 
    399       this.restoreExtIntTimer.start(); 
    400     } 
    401  
    402     // Used to periodically check that the External Interface functions are still working 
    403     private function CheckExternalInterface():void { 
    404       if (!ExternalCall.Bool(this.testExternalInterface_Callback)) { 
    405         this.SetupExternalInterface(); 
    406         this.Debug("ExternalInterface reinitialized"); 
    407         if (!this.hasCalledFlashReady) { 
    408           ExternalCall.Simple(this.flashReady_Callback); 
    409           this.hasCalledFlashReady = true; 
    410         } 
    411       } 
    412     } 
    413      
    414     // Called by JS to see if it can access the external interface 
    415     private function TestExternalInterface():Boolean { 
    416       return true; 
    417     } 
    418      
    419     private function SetupExternalInterface():void { 
    420       try { 
    421         ExternalInterface.addCallback("SelectFile", this.SelectFile); 
    422         ExternalInterface.addCallback("SelectFiles", this.SelectFiles); 
     346        //ExternalInterface.addCallback("SelectFile", this.SelectFile); 
     347        //ExternalInterface.addCallback("SelectFiles", this.SelectFiles); 
    423348        ExternalInterface.addCallback("StartUpload", this.StartUpload); 
    424349        ExternalInterface.addCallback("ReturnUploadStart", this.ReturnUploadStart); 
    425350        ExternalInterface.addCallback("StopUpload", this.StopUpload); 
    426351        ExternalInterface.addCallback("CancelUpload", this.CancelUpload); 
    427         ExternalInterface.addCallback("RequeueUpload", this.RequeueUpload); 
    428352         
    429353        ExternalInterface.addCallback("GetStats", this.GetStats); 
     
    444368        ExternalInterface.addCallback("SetUseQueryString", this.SetUseQueryString); 
    445369        ExternalInterface.addCallback("SetRequeueOnError", this.SetRequeueOnError); 
    446         ExternalInterface.addCallback("SetHTTPSuccess", this.SetHTTPSuccess); 
    447         ExternalInterface.addCallback("SetAssumeSuccessTimeout", this.SetAssumeSuccessTimeout); 
    448370        ExternalInterface.addCallback("SetDebugEnabled", this.SetDebugEnabled); 
    449371 
     
    455377        ExternalInterface.addCallback("SetButtonAction", this.SetButtonAction); 
    456378        ExternalInterface.addCallback("SetButtonDisabled", this.SetButtonDisabled); 
    457         ExternalInterface.addCallback("SetButtonCursor", this.SetButtonCursor); 
    458  
    459         ExternalInterface.addCallback("TestExternalInterface", this.TestExternalInterface); 
    460          
    461379      } catch (ex:Error) { 
    462         this.Debug("Callbacks where not set: " + ex.message); 
     380        this.Debug("Callbacks where not set."); 
    463381        return; 
    464382      } 
    465        
    466       ExternalCall.Simple(this.cleanUp_Callback); 
    467     } 
    468      
     383 
     384      this.Debug("SWFUpload Init Complete"); 
     385      this.PrintDebugInfo(); 
     386 
     387      ExternalCall.Simple(this.flashReady_Callback); 
     388    } 
     389 
    469390    /* ***************************************** 
    470391    * FileReference Event Handlers 
     
    472393    private function DialogCancelled_Handler(event:Event):void { 
    473394      this.Debug("Event: fileDialogComplete: File Dialog window cancelled."); 
    474       ExternalCall.FileDialogComplete(this.fileDialogComplete_Callback, 0, 0, this.queued_uploads); 
     395      ExternalCall.FileDialogComplete(this.fileDialogComplete_Callback, 0, 0); 
    475396    } 
    476397 
     
    486407      var bytesTotal:Number = event.bytesTotal < 0 ? 0 : event.bytesTotal; 
    487408       
    488       // Because Flash never fires a complete event if the server doesn't respond after 30 seconds or on Macs if there 
    489       // is no content in the response we'll set a timer and assume that the upload is successful after the defined amount of 
    490       // time.  If the timeout is zero then we won't use the timer. 
    491       if (bytesLoaded === bytesTotal && bytesTotal > 0 && this.assumeSuccessTimeout > 0) { 
    492         if (this.assumeSuccessTimer !== null) { 
    493           this.assumeSuccessTimer.stop(); 
    494           this.assumeSuccessTimer = null; 
    495         } 
    496          
    497         this.assumeSuccessTimer = new Timer(this.assumeSuccessTimeout * 1000, 1); 
    498         this.assumeSuccessTimer.addEventListener(TimerEvent.TIMER_COMPLETE, AssumeSuccessTimer_Handler); 
    499         this.assumeSuccessTimer.start(); 
    500       } 
    501        
    502409      this.Debug("Event: uploadProgress: File ID: " + this.current_file_item.id + ". Bytes: " + bytesLoaded + ". Total: " + bytesTotal); 
    503410      ExternalCall.UploadProgress(this.uploadProgress_Callback, this.current_file_item.ToJavaScriptObject(), bytesLoaded, bytesTotal); 
    504411    } 
    505      
    506     private function AssumeSuccessTimer_Handler(event:TimerEvent):void { 
    507       this.Debug("Event: AssumeSuccess: " + this.assumeSuccessTimeout + " passed without server response"); 
    508       this.UploadSuccess(this.current_file_item, "", false); 
    509     } 
    510  
    511     private function Complete_Handler(event:Event):void { 
    512       /* Because we can't do COMPLETE or DATA events (we have to do both) we can't 
    513        * just call uploadSuccess from the complete handler, we have to wait for 
    514        * the Data event which may never come. However, testing shows it always comes 
    515        * within a couple milliseconds if it is going to come so the solution is: 
    516        *  
    517        * Set a timer in the COMPLETE event (which always fires) and if DATA is fired 
    518        * it will stop the timer and call uploadComplete 
    519        *  
    520        * If the timer expires then DATA won't be fired and we call uploadComplete 
    521        * */ 
    522        
    523       // Set the timer 
    524       if (serverDataTimer != null) { 
    525         this.serverDataTimer.stop(); 
    526         this.serverDataTimer = null; 
    527       } 
    528        
    529       this.serverDataTimer = new Timer(100, 1); 
    530       //var self:SWFUpload = this; 
    531       this.serverDataTimer.addEventListener(TimerEvent.TIMER, this.ServerDataTimer_Handler); 
    532       this.serverDataTimer.start(); 
    533     } 
    534     private function ServerDataTimer_Handler(event:TimerEvent):void { 
    535       this.UploadSuccess(this.current_file_item, ""); 
    536     } 
    537      
     412 
    538413    private function ServerData_Handler(event:DataEvent):void { 
    539       this.UploadSuccess(this.current_file_item, event.data); 
    540     } 
    541      
    542     private function UploadSuccess(file:FileItem, serverData:String, responseReceived:Boolean = true):void { 
    543       if (this.serverDataTimer !== null) { 
    544         this.serverDataTimer.stop(); 
    545         this.serverDataTimer = null; 
    546       } 
    547       if (this.assumeSuccessTimer !== null) { 
    548         this.assumeSuccessTimer.stop(); 
    549         this.assumeSuccessTimer = null; 
    550       } 
    551  
    552414      this.successful_uploads++; 
    553       file.file_status = FileItem.FILE_STATUS_SUCCESS; 
    554  
    555       this.Debug("Event: uploadSuccess: File ID: " + file.id + " Response Received: " + responseReceived.toString() + " Data: " + serverData); 
    556       ExternalCall.UploadSuccess(this.uploadSuccess_Callback, file.ToJavaScriptObject(), serverData, responseReceived); 
     415      this.current_file_item.file_status = FileItem.FILE_STATUS_SUCCESS; 
     416 
     417      this.Debug("Event: uploadSuccess: File ID: " + this.current_file_item.id + " Data: " + event.data); 
     418      ExternalCall.UploadSuccess(this.uploadSuccess_Callback, this.current_file_item.ToJavaScriptObject(), event.data); 
    557419 
    558420      this.UploadComplete(false); 
     
    561423 
    562424    private function HTTPError_Handler(event:HTTPStatusEvent):void { 
    563       var isSuccessStatus:Boolean = false; 
    564       for (var i:Number = 0; i < this.httpSuccess.length; i++) { 
    565         if (this.httpSuccess[i] === event.status) { 
    566           isSuccessStatus = true; 
    567           break; 
    568         } 
    569       } 
    570        
    571        
    572       if (isSuccessStatus) { 
    573         this.Debug("Event: httpError: Translating status code " + event.status + " to uploadSuccess"); 
    574  
    575         var serverDataEvent:DataEvent = new DataEvent(DataEvent.UPLOAD_COMPLETE_DATA, event.bubbles, event.cancelable, ""); 
    576         this.ServerData_Handler(serverDataEvent); 
    577       } else { 
    578         this.upload_errors++; 
    579         this.current_file_item.file_status = FileItem.FILE_STATUS_ERROR; 
    580  
    581         this.Debug("Event: uploadError: HTTP ERROR : File ID: " + this.current_file_item.id + ". HTTP Status: " + event.status + "."); 
    582         ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_HTTP_ERROR, this.current_file_item.ToJavaScriptObject(), event.status.toString()); 
    583         this.UploadComplete(true);  // An IO Error is also called so we don't want to complete the upload yet. 
    584       } 
     425      this.upload_errors++; 
     426      this.current_file_item.file_status = FileItem.FILE_STATUS_ERROR; 
     427 
     428      this.Debug("Event: uploadError: HTTP ERROR : File ID: " + this.current_file_item.id + ". HTTP Status: " + event.status + "."); 
     429      ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_HTTP_ERROR, this.current_file_item.ToJavaScriptObject(), event.status.toString()); 
     430      this.UploadComplete(true);  // An IO Error is also called so we don't want to complete the upload yet. 
    585431    } 
    586432     
     
    634480          queue_slots_remaining = remaining_uploads; 
    635481        } else if (this.fileQueueLimit < remaining_uploads) { 
    636           queue_slots_remaining = this.fileQueueLimit - this.queued_uploads; 
    637         } 
    638       } 
    639        
    640       if (queue_slots_remaining < 0) queue_slots_remaining = 0; 
     482          queue_slots_remaining = this.fileQueueLimit; 
     483        } 
     484      } 
    641485       
    642486      // Check if the number of files selected is greater than the number allowed to queue up. 
     
    694538       
    695539      this.Debug("Event: fileDialogComplete : Finished processing selected files. Files selected: " + file_reference_list.length + ". Files Queued: " + num_files_queued); 
    696       ExternalCall.FileDialogComplete(this.fileDialogComplete_Callback, file_reference_list.length, num_files_queued, this.queued_uploads); 
     540      ExternalCall.FileDialogComplete(this.fileDialogComplete_Callback, file_reference_list.length, num_files_queued); 
    697541    } 
    698542 
     
    750594        this.current_file_item.file_reference.cancel(); 
    751595 
     596        this.current_file_item.file_status = FileItem.FILE_STATUS_QUEUED; 
     597         
    752598        // Remove the event handlers 
    753599        this.removeFileReferenceEventListeners(this.current_file_item); 
    754600 
    755         this.current_file_item.file_status = FileItem.FILE_STATUS_QUEUED; 
    756601        this.file_queue.unshift(this.current_file_item); 
    757602        var js_object:Object = this.current_file_item.ToJavaScriptObject(); 
     
    774619     * If the file is not currently uploading then only the uploadCancelled event is fired. 
    775620     * */ 
    776     private function CancelUpload(file_id:String, triggerErrorEvent:Boolean = true):void { 
     621    private function CancelUpload(file_id:String):void { 
    777622      var file_item:FileItem = null; 
    778623       
     
    783628          this.upload_cancelled++; 
    784629           
    785           if (triggerErrorEvent) { 
    786             this.Debug("Event: uploadError: File ID: " + this.current_file_item.id + ". Cancelled current upload"); 
    787             ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_FILE_CANCELLED, this.current_file_item.ToJavaScriptObject(), "File Upload Cancelled."); 
    788           } else { 
    789             this.Debug("Event: cancelUpload: File ID: " + this.current_file_item.id + ". Cancelled current upload. Suppressed uploadError event."); 
    790           } 
     630          this.Debug("Event: uploadError: File ID: " + this.current_file_item.id + ". Cancelled current upload"); 
     631          ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_FILE_CANCELLED, this.current_file_item.ToJavaScriptObject(), "File Upload Cancelled."); 
     632 
    791633          this.UploadComplete(false); 
    792634      } else if (file_id) { 
     
    806648            file_item.file_reference = null; 
    807649             
    808             if (triggerErrorEvent) { 
    809               this.Debug("Event: uploadError : " + file_item.id + ". Cancelled queued upload"); 
    810               ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_FILE_CANCELLED, file_item.ToJavaScriptObject(), "File Cancelled"); 
    811             } else { 
    812               this.Debug("Event: cancelUpload: File ID: " + file_item.id + ". Cancelled current upload. Suppressed uploadError event."); 
    813             } 
     650            this.Debug("Event: uploadError : " + file_item.id + ". Cancelled queued upload"); 
     651            ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_FILE_CANCELLED, file_item.ToJavaScriptObject(), "File Cancelled"); 
    814652 
    815653            // Get rid of the file object 
     
    838676          file_item.file_reference = null; 
    839677 
    840           if (triggerErrorEvent) { 
    841             this.Debug("Event: uploadError : " + file_item.id + ". Cancelled queued upload"); 
    842             ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_FILE_CANCELLED, file_item.ToJavaScriptObject(), "File Cancelled"); 
    843           } else { 
    844             this.Debug("Event: cancelUpload: File ID: " + file_item.id + ". Cancelled current upload. Suppressed uploadError event."); 
    845           } 
     678          this.Debug("Event: uploadError : " + file_item.id + ". Cancelled queued upload"); 
     679          ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_FILE_CANCELLED, file_item.ToJavaScriptObject(), "File Cancelled"); 
    846680 
    847681          // Get rid of the file object 
     
    853687    } 
    854688 
    855     /* Requeues the indicated file. Returns true if successful or if the file is 
    856      * already in the queue. Otherwise returns false. 
    857      * */ 
    858     private function RequeueUpload(fileIdentifier:*):Boolean { 
    859       var file:FileItem = null; 
    860       if (typeof(fileIdentifier) === "number") { 
    861         var fileIndex:Number = Number(fileIdentifier); 
    862         if (fileIndex >= 0 && fileIndex < this.file_index.length) { 
    863           file = this.file_index[fileIndex];           
    864         } 
    865       } else if (typeof(fileIdentifier) === "string") { 
    866         file = FindFileInFileIndex(String(fileIdentifier)); 
    867       } else { 
    868         return false; 
    869       } 
    870        
    871       if (file !== null) { 
    872         if (file.file_status === FileItem.FILE_STATUS_IN_PROGRESS || file.file_status === FileItem.FILE_STATUS_NEW) { 
    873           return false; 
    874         } else if (file.file_status !== FileItem.FILE_STATUS_QUEUED) { 
    875           file.file_status = FileItem.FILE_STATUS_QUEUED; 
    876           this.file_queue.unshift(file); 
    877           this.queued_uploads++; 
    878         } 
    879         return true; 
    880       } else { 
    881         return false; 
    882       } 
    883     } 
    884      
    885      
    886689    private function GetStats():Object { 
    887690      return { 
     
    1034837    } 
    1035838     
    1036     private function SetHTTPSuccess(http_status_codes:*):void { 
    1037       this.httpSuccess = []; 
    1038  
    1039       if (typeof http_status_codes === "string") { 
    1040         var status_code_strings:Array = http_status_codes.replace(" ", "").split(","); 
    1041         for each (var http_status_string:String in status_code_strings)  
    1042         { 
    1043           try { 
    1044             this.httpSuccess.push(Number(http_status_string)); 
    1045           } catch (ex:Object) { 
    1046             // Ignore errors 
    1047             this.Debug("Could not add HTTP Success code: " + http_status_string); 
    1048           } 
    1049         } 
    1050       } 
    1051       else if (typeof http_status_codes === "object" && typeof http_status_codes.length === "number") { 
    1052         for each (var http_status:* in http_status_codes)  
    1053         { 
    1054           try { 
    1055             this.Debug("adding: " + http_status); 
    1056             this.httpSuccess.push(Number(http_status)); 
    1057           } catch (ex:Object) { 
    1058             this.Debug("Could not add HTTP Success code: " + http_status); 
    1059           } 
    1060         } 
    1061       } 
    1062     } 
    1063  
    1064     private function SetAssumeSuccessTimeout(timeout_seconds:Number):void { 
    1065       this.assumeSuccessTimeout = timeout_seconds < 0 ? 0 : timeout_seconds; 
    1066     }    
    1067      
    1068839    private function SetDebugEnabled(debug_enabled:Boolean):void { 
    1069840      this.debugEnabled = debug_enabled; 
     
    1129900      this.buttonTextField.width = this.buttonWidth; 
    1130901      this.buttonTextField.height = this.buttonHeight; 
    1131       this.buttonCursorSprite.width = this.buttonWidth; 
    1132       this.buttonCursorSprite.height = this.buttonHeight; 
    1133902       
    1134903      this.UpdateButtonState(); 
     
    1162931    private function SetButtonAction(button_action:Number):void { 
    1163932      this.buttonAction = button_action; 
    1164     } 
    1165      
    1166     private function SetButtonCursor(button_cursor:Number):void { 
    1167       this.buttonCursor = button_cursor; 
    1168        
    1169       this.buttonCursorSprite.useHandCursor = (button_cursor === this.BUTTON_CURSOR_HAND); 
    1170933    } 
    1171934     
     
    1214977        // Trigger the uploadStart event which will call ReturnUploadStart to begin the actual upload 
    1215978        this.Debug("Event: uploadStart : File ID: " + this.current_file_item.id); 
    1216          
    1217         this.current_file_item.file_status = FileItem.FILE_STATUS_IN_PROGRESS; 
    1218979        ExternalCall.UploadStart(this.uploadStart_Callback, this.current_file_item.ToJavaScriptObject()); 
    1219980      } 
     
    1231992        return; 
    1232993      } 
    1233        
    1234       var js_object:Object; 
    1235994       
    1236995      if (start_upload) { 
     
    12421001          this.current_file_item.file_reference.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this.SecurityError_Handler); 
    12431002          this.current_file_item.file_reference.addEventListener(HTTPStatusEvent.HTTP_STATUS, this.HTTPError_Handler); 
    1244           this.current_file_item.file_reference.addEventListener(Event.COMPLETE, this.Complete_Handler); 
    12451003          this.current_file_item.file_reference.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, this.ServerData_Handler); 
    12461004           
     
    12501008          if (this.uploadURL.length == 0) { 
    12511009            this.Debug("Event: uploadError : IO Error : File ID: " + this.current_file_item.id + ". Upload URL string is empty."); 
    1252  
    1253             // Remove the event handlers 
    1254             this.removeFileReferenceEventListeners(this.current_file_item); 
    1255  
    1256             this.current_file_item.file_status = FileItem.FILE_STATUS_QUEUED; 
    1257             this.file_queue.unshift(this.current_file_item); 
    1258             js_object = this.current_file_item.ToJavaScriptObject(); 
    1259             this.current_file_item = null; 
    1260              
    1261             ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_MISSING_UPLOAD_URL, js_object, "Upload URL string is empty."); 
     1010            ExternalCall.UploadError(this.uploadError_Callback, this.ERROR_CODE_MISSING_UPLOAD_URL, this.current_file_item.ToJavaScriptObject(), "Upload URL string is empty."); 
    12621011          } else { 
    12631012            this.Debug("ReturnUploadStart(): File accepted by startUpload event and readied for upload.  Starting upload to " + request.url + " for File ID: " + this.current_file_item.id); 
     
    12831032        // Re-queue the FileItem 
    12841033        this.current_file_item.file_status = FileItem.FILE_STATUS_QUEUED; 
    1285         js_object = this.current_file_item.ToJavaScriptObject(); 
     1034        var js_object:Object = this.current_file_item.ToJavaScriptObject(); 
    12861035        this.file_queue.unshift(this.current_file_item); 
    12871036        this.current_file_item = null; 
     
    12951044 
    12961045    // Completes the file upload by deleting it's reference, advancing the pointer. 
    1297     // Once this event fires a new upload can be started. 
     1046    // Once this event files a new upload can be started. 
    12981047    private function UploadComplete(eligible_for_requeue:Boolean):void { 
    12991048      var jsFileObj:Object = this.current_file_item.ToJavaScriptObject(); 
     
    13051054        this.queued_uploads--; 
    13061055      } else if (this.requeueOnError == true) { 
    1307         this.current_file_item.file_status = FileItem.FILE_STATUS_QUEUED; 
    13081056        this.file_queue.unshift(this.current_file_item); 
    13091057      } 
     
    13191067      Utility Functions 
    13201068    *************************************************************** */ 
    1321  
    1322      
    13231069    // Check the size of the file against the allowed file size. If it is less the return TRUE. If it is too large return FALSE 
    13241070    private function CheckFileSize(file_item:FileItem):Number { 
     
    14271173      debug_info += "File Types String:      " + this.fileTypes + "\n"; 
    14281174      debug_info += "Parsed File Types:      " + this.valid_file_extensions.toString() + "\n"; 
    1429       debug_info += "HTTP Success:           " + this.httpSuccess.join(", ") + "\n"; 
    14301175      debug_info += "File Types Description: " + this.fileTypesDescription + "\n"; 
    14311176      debug_info += "File Size Limit:        " + this.fileSizeLimit + " bytes\n"; 
     
    14441189 
    14451190    private function FindIndexInFileQueue(file_id:String):Number { 
    1446       for (var i:Number = 0; i < this.file_queue.length; i++) { 
     1191      for (var i:Number = 0; i<this.file_queue.length; i++) { 
    14471192        var item:FileItem = this.file_queue[i]; 
    14481193        if (item != null && item.id == file_id) return i;