[pm-h] Perl in background

George S. Baugh doge at teodesian.net
Mon Mar 7 18:08:15 PST 2016


Like Brett mentioned, this can't be done without doing some kind of
XMLHttpRequest, e.g. jQuery.ajax() or whatever equivalent in your JS
framework of choice.  You'll have this sitting in a setTimeout loop
polling as long as the page is up.

From there you'll have to make some HTTP backend script (perl, or
whatever) that returns a JSON string of the file list every time it's
called by said XMLHttpRequest.

The callback fired after said XHR succeeds then decodes this JSON into
an array (can be done automatically in jQuery, otherwise use
JSON.parse()). You can tell which files are new (or gone) by getting the
disjunction of the lists.

You would then likely add an <img> node somewhere in your player with
your new images (and whack the gone ones), or if you don't care about
interrupting the user, just reload the page via
window.location.reload().

If it's a cross-domain request, be-ware that you'll either have to do
JSONP or learn about CORS (which may finally work these days).  Also
remember to not load mixed (insecure) content if the page is SSL.

GSB

On Mon, 2016-03-07 at 12:08 -0600, Fraser Baker via Houston wrote:
> my latest project. I am trying to accommodate 
> the situation when a client uploads a new image to the disk the
> player 
> will reset so as to include the new image. So what I am considering
> is 
> to use Perl to determine the number of images and cause the viewer to 
> reset when the number of images has changed. I am assuming this can be
> a 
> call to a Perl script that determines the number of images without 
> interrupting the viewer and sends a JavaScript call back to the
> viewer 
> to reset when the number of images has changed.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4966 bytes
Desc: not available
URL: <http://mail.pm.org/pipermail/houston/attachments/20160307/6d30f5ff/attachment.bin>


More information about the Houston mailing list