App-XUL
view release on metacpan or search on metacpan
misc/AppXUL.js view on Meta::CPAN
if (xhr.readyState == 4) {
if (xhr.status == 200) {
if (success_cb)
success_cb(xhr.responseText);
} else {
if (failure_cb)
failure_cb(xhr.status, xhr.statusText);
}
}
};
xhr.open("GET", url+"?data="+escape(string), true);
xhr.send(null);
},
// updates the DOM based on a change description
update: function (description) {
if (description.action == 'update') {
if ($(description.id)) {
// update attributes
for (var attr in description.attributes) {
//dbg(description.id+"."+attr+" = '"+description.attributes[attr]+"'");
misc/AppXUL.js view on Meta::CPAN
function () { // wait
//dbg("Waiting for server...");
}
);
},
// processess an async message sent from a server
async: function (string) {
string = string.split(/\r?\n\r?/)[0];
string = unescape(string.replace(/^GET \/\?data\=(.*) HTTP.*$/, '$1'));
//dbg("async: "+string);
var result = '{"content":""}';
try {
var action;
eval("action = "+string);
// perform action
if (action.action == 'child') {
if (action.id && (""+action.number).match(/^\d+$/)) {
misc/server.pl view on Meta::CPAN
#!/usr/bin/perl
package main;
use strict;
use warnings;
use Socket;
use IO::Socket;
use LWP::Simple qw(get);
use URI::Escape qw(uri_escape);
use JSON qw(to_json from_json);
use Data::Dumper;
# get commandline arguments
my ($ModulesPath, $Port) = @ARGV;
# load user-defined event handlers
unshift @INC, $ModulesPath;
eval('use Eventhandlers;');
my $Eventhandlers = Eventhandlers::get();
misc/server.pl view on Meta::CPAN
exit if $quit;
}
################################################################################
# this pushes some action to the client to be performed and
# returns after the client answers
sub push
{
my ($action) = @_;
my $url = 'http://localhost:3001/?data='.uri_escape(to_json($action));
my $content = get($url);
#print STDERR "sending async ".Dumper($action)."\nurl = $url\n";
#print STDERR "-> $content\n\n";
my $info = from_json($content);
return $info->{'content'};
}
# this binds a coderef to an id+event name to be triggered
# by the client (XUL app)
sub bind
( run in 0.453 second using v1.01-cache-2.11-cpan-5467b0d2c73 )