Acme-MUDLike
view release on metacpan or search on metacpan
lib/Acme/MUDLike.pm view on Meta::CPAN
=item C<continuity>
Optional. Pass in an existing L<Continuity> instance.
Must have been created with the parameter C<< path_session => 1 >>.
=item C<port>
Optional. Defaults to C<2000>.
This and other parameters, such as those documented in L<Continuity>, are passed through
to C<< Continuity->new() >>.
=item C<password>
Optional. Password to use.
Everyone gets the same password, and anyone with the password can log in with any name.
Otherwise one is pseudo-randomly generated and printed to C<stdout>.
=cut
=head1 HISTORY
=over 8
=item 0.01
Original version; created by h2xs 1.23 with options
-A -C -X -b 5.8.0 -c -n Acme::MUDLike
=back
=head1 TODO
(Major items... additional in the source.)
=item Test. Very, very green right now.
=item Telnet in as well as HTTP.
=item JavaScript vi/L<Acme::SubstituteSubs> integration.
=item Multiple rooms. Right now, there's just one.
The JavaScript based vi and file browser I've been using with L<Acme::SubstituteSubs> isn't in any of my modules
yet so development from within isn't really practical using just these modules.
There's some glue missing.
=head1 SEE ALSO
=item L<Continuity>
=item L<Continuity::Monitor>
=item L<Acme::State>
=item L<Acme::SubstituteSubs>
L<Acme::State> preserves state across runs and L<Acme::SubstituteSubs>.
These three modules work on their own but are complimentary to each other.
Using L<Acme::SubstituteSubs>, the program can be modified in-place without being restarted,
so you don't have to log back in again after each change batch of changes to the code.
Code changes take effect immediately.
L<Acme::State> persists variable values when the program is finally stopped and restarted.
L<Acme::State> will also optionally serialize code references to disc, so you can
C<eval> subs into existance and let it save them to disc for you and then later
use L<B::Deparse> to retrieve a version of the source.
The C<Todo> comments near the top of the source.
=head1 AUTHOR
Scott Walters, E<lt>scott@slowass.netE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2009 by Scott Walters
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.9 or,
at your option, any later version of Perl 5 you may have available.
By using this software, you signify that you like llamas.
Includes code by John Resig:
jQuery 1.1.2 - New Wave Javascript
Copyright (c) 2007 John Resig (jquery.com)
Dual licensed under the MIT (MIT-LICENSE.txt)
and GPL (GPL-LICENSE.txt) licenses.
$Date: 2007-02-28 12:03:00 -0500 (Wed, 28 Feb 2007) $
$Rev: 1465 $
Includes code by Awwaiid (Brock Wilcox)
=cut
package Acme::MUDLike::data;
sub chat_js {
return <<'EOF';
var poll_count = 0;
function new_request() {
var req;
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
return req;
}
function do_request(url, callback) {
var req = new_request();
if(req != undefined) {
req.onreadystatechange = function() {
if (req.readyState == 4) { // only if req is "loaded"
if (req.status == 200) { // only if "OK"
if(callback) callback(req.responseText);
} else {
lib/Acme/MUDLike.pm view on Meta::CPAN
dequeue: function(elem,type){
type = type || "fx";
if ( elem.queue && elem.queue[type] ) {
// Remove self
elem.queue[type].shift();
// Get next function
var f = elem.queue[type][0];
if ( f ) f.apply( elem );
}
},
/*
* I originally wrote fx() as a clone of moo.fx and in the process
* of making it small in size the code became illegible to sane
* people. You've been warned.
*/
fx: function( elem, options, prop ){
var z = this;
// The styles
var y = elem.style;
// Store display property
var oldDisplay = jQuery.css(elem, "display");
// Make sure that nothing sneaks out
y.overflow = "hidden";
// Simple function for setting a style value
z.a = function(){
if ( options.step )
options.step.apply( elem, [ z.now ] );
if ( prop == "opacity" )
jQuery.attr(y, "opacity", z.now); // Let attr handle opacity
else if ( parseInt(z.now) ) // My hate for IE will never die
y[prop] = parseInt(z.now) + "px";
y.display = "block"; // Set display property to block for animation
};
// Figure out the maximum number to run to
z.max = function(){
return parseFloat( jQuery.css(elem,prop) );
};
// Get the current size
z.cur = function(){
var r = parseFloat( jQuery.curCSS(elem, prop) );
return r && r > -10000 ? r : z.max();
};
// Start an animation from one number to another
z.custom = function(from,to){
z.startTime = (new Date()).getTime();
z.now = from;
z.a();
z.timer = setInterval(function(){
z.step(from, to);
}, 13);
};
// Simple 'show' function
z.show = function(){
if ( !elem.orig ) elem.orig = {};
// Remember where we started, so that we can go back to it later
elem.orig[prop] = this.cur();
options.show = true;
// Begin the animation
z.custom(0, elem.orig[prop]);
// Stupid IE, look what you made me do
if ( prop != "opacity" )
y[prop] = "1px";
};
// Simple 'hide' function
z.hide = function(){
if ( !elem.orig ) elem.orig = {};
// Remember where we started, so that we can go back to it later
elem.orig[prop] = this.cur();
options.hide = true;
// Begin the animation
z.custom(elem.orig[prop], 0);
};
//Simple 'toggle' function
z.toggle = function() {
if ( !elem.orig ) elem.orig = {};
// Remember where we started, so that we can go back to it later
elem.orig[prop] = this.cur();
if(oldDisplay == "none") {
options.show = true;
// Stupid IE, look what you made me do
if ( prop != "opacity" )
y[prop] = "1px";
// Begin the animation
z.custom(0, elem.orig[prop]);
} else {
options.hide = true;
// Begin the animation
z.custom(elem.orig[prop], 0);
}
};
// Each step of an animation
z.step = function(firstNum, lastNum){
var t = (new Date()).getTime();
if (t > options.duration + z.startTime) {
// Stop the timer
clearInterval(z.timer);
z.timer = null;
z.now = lastNum;
z.a();
if (elem.curAnim) elem.curAnim[ prop ] = true;
var done = true;
for ( var i in elem.curAnim )
if ( elem.curAnim[i] !== true )
done = false;
if ( done ) {
// Reset the overflow
y.overflow = "";
// Reset the display
y.display = oldDisplay;
if (jQuery.css(elem, "display") == "none")
y.display = "block";
// Hide the element if the "hide" operation was done
if ( options.hide )
y.display = "none";
// Reset the properties, if the item has been hidden or shown
if ( options.hide || options.show )
for ( var p in elem.curAnim )
if (p == "opacity")
jQuery.attr(y, p, elem.orig[p]);
else
y[p] = "";
}
// If a callback was provided, execute it
if ( done && jQuery.isFunction( options.complete ) )
// Execute the complete function
options.complete.apply( elem );
} else {
var n = t - this.startTime;
// Figure out where in the animation we are and set the number
var p = n / options.duration;
// If the easing function exists, then use it
z.now = options.easing && jQuery.easing[options.easing] ?
jQuery.easing[options.easing](p, n, firstNum, (lastNum-firstNum), options.duration) :
// else use default linear easing
((-Math.cos(p*Math.PI)/2) + 0.5) * (lastNum-firstNum) + firstNum;
// Perform the next step of the animation
z.a();
}
};
}
});
}
EOF
}
1;
( run in 0.949 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )