Acme-MUDLike
view release on metacpan or search on metacpan
lib/Acme/MUDLike.pm view on Meta::CPAN
alert("AJAX Error:\r\n" + req.statusText);
}
}
}
req.open("GET", url, true);
req.send("");
}
}
function setup_poll() {
setTimeout('poll_server()', 1000);
}
function poll_server() {
var nick = document.getElementById("nick").value;
var admin = document.getElementById("admin").value;
document.getElementById('status').innerHTML = 'Polling ('+(poll_count++)+')...';
do_request('/pushstream/?nick=' + nick + '&admin=' + admin, got_update);
}
function got_update(txt) {
lib/Acme/MUDLike.pm view on Meta::CPAN
type: "POST",
url: url,
data: data,
success: callback,
dataType: type
});
},
// timeout (ms)
//timeout: 0,
ajaxTimeout: function( timeout ) {
jQuery.ajaxSettings.timeout = timeout;
},
ajaxSetup: function( settings ) {
jQuery.extend( jQuery.ajaxSettings, settings );
},
ajaxSettings: {
global: true,
type: "GET",
timeout: 0,
lib/Acme/MUDLike.pm view on Meta::CPAN
xml.setRequestHeader("Connection", "close");
// Allow custom headers/mimetypes
if( s.beforeSend )
s.beforeSend(xml);
if ( s.global )
jQuery.event.trigger("ajaxSend", [xml, s]);
// Wait for a response to come back
var onreadystatechange = function(isTimeout){
// The transfer is complete and the data is available, or the request timed out
if ( xml && (xml.readyState == 4 || isTimeout == "timeout") ) {
requestDone = true;
// clear poll interval
if (ival) {
clearInterval(ival);
ival = null;
}
var status;
try {
status = jQuery.httpSuccess( xml ) && isTimeout != "timeout" ?
s.ifModified && jQuery.httpNotModified( xml, s.url ) ? "notmodified" : "success" : "error";
// Make sure that the request was successful or notmodified
if ( status != "error" ) {
// Cache Last-Modified header, if ifModified mode.
var modRes;
try {
modRes = xml.getResponseHeader("Last-Modified");
} catch(e) {} // swallow exception thrown by FF if header is not available
if ( s.ifModified && modRes )
lib/Acme/MUDLike.pm view on Meta::CPAN
// Stop memory leaks
if(s.async)
xml = null;
}
};
// don't attach the handler to the request, just poll it instead
var ival = setInterval(onreadystatechange, 13);
// Timeout checker
if ( s.timeout > 0 )
setTimeout(function(){
// Check to see if the request is still happening
if ( xml ) {
// Cancel the request
xml.abort();
if( !requestDone )
onreadystatechange( "timeout" );
}
}, s.timeout);
lib/Acme/MUDLike.pm view on Meta::CPAN
return s.join("&");
},
// evalulates a script in global context
// not reliable for safari
globalEval: function( data ) {
if ( window.execScript )
window.execScript( data );
else if ( jQuery.browser.safari )
// safari doesn't provide a synchronous global eval
window.setTimeout( data, 0 );
else
eval.call( window, data );
}
});
jQuery.fn.extend({
show: function(speed,callback){
var hidden = this.filter(":hidden");
speed ?
( run in 0.222 second using v1.01-cache-2.11-cpan-4d50c553e7e )