Apache-UploadMeter

 view release on metacpan or  search on metacpan

lib/Apache/UploadMeter/Resources/JavaScript.pm  view on Meta::CPAN

      if (typeof responder[callback] == 'function') {
        try {
          responder[callback].apply(responder, [meter, status, laststatus]);
        } catch (e) {}
      }
    });
};
Object.extend(UploadMeter.Responders, Enumerable);

var Util = {
    formatTime: function(timestamp) {
        if (isNaN(timestamp)) {
            return timestamp;
        }
        
        if (!(isFinite(timestamp))) {
            return "Unknown";
        }
        
        var oH, oM, oS, str;
        
        str = "";
        oS = Math.floor(timestamp % 60);
        oM = Math.floor((timestamp / 60) % 60);
        oH = Math.floor(timestamp / 60 / 60);       
        
        if (oH > 0) {
            str = oH + ":";
        } 
        
        str = str + ((oM == 0) ? "00:" : ((oM < 10) ? "0" + oM + ":" : oM + ":"));
        str = str + ((oS == 0) ? "00" : ((oS < 10) ? "0" + oS : oS));
        
        return str;
    },
    formatDec: function (val) {
        sign = val < 0 ? "-":"";
        rval = Math.abs(Math.round(val*100));
        str = rval.toString();
        if(rval < 10) str = "0.0"+str;
        else if(rval < 100) str = "0."+str;
        else str = str.substring(0, str.length-2)
           + "." + str.substring(str.length-2, str.length);
        return sign+str;
    }
};

// Default behavior code
var aum_el;

function addMeterURL(url) {
    try {
      if (url.indexOf('?') >= 0) {
          return url + "&meter_id=" + meter_id;
      } else {
          return url + "?meter_id=" + meter_id;
      }
    } catch (e) {}
}

function aum_popup() {
    var aum = window.open(meter_url + "/styles/aum_popup.html" ,"_new","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizeable=no,width=450,height=240");
    // Pass our info to the child window's global obj
    Object.extend(aum, {'meter_id': meter_id, 'meter_url': meter_url});
}

var rules={
    '.uploadform':function(el) {
      el.action = addMeterURL(el.action);
      aum_el = $(el); // Put this in a global so we can unregister later, if needed
      Event.observe(aum_el, 'submit', aum_popup);
    }
};
Behaviour.register(rules);

AUM-END
    $r->print($output);
    return Apache2::Const::OK;
}

1;



( run in 1.214 second using v1.01-cache-2.11-cpan-364913b4093 )