webapp: Adjust longpoll code to work with recent versions of shakespeare-js.

A while ago I added code to support recent versions of shakespeare-js,
(commit fe11b3a940). But it seems that resulted
in quoting of all strings inserted into javascript files, which means it's
now impossible to do the type of metaprogramming that longpolling.julius
relied on. I have found another way to accomplish the same thing without
needing to generate unique function names. Hopefully it's portable.

Opinion of shakespeare-js now at rock bottom. One of these days, this
needs to be redone to use Fay.
This commit is contained in:
Joey Hess 2013-01-09 23:47:24 -04:00
parent ce6e046525
commit c548a6a39c
3 changed files with 19 additions and 8 deletions

2
debian/changelog vendored
View file

@ -9,6 +9,8 @@ git-annex (3.20130108) UNRELEASED; urgency=low
* webapp: Use IP address, rather than localhost, since some systems may
have configuration problems or other issues that prevent web browsers
from connecting to the right localhost IP for the webapp.
* webapp: Adjust longpoll code to work with recent versions of
shakespeare-js.
-- Joey Hess <joeyh@debian.org> Tue, 08 Jan 2013 12:37:38 -0400

View file

@ -25,3 +25,13 @@ Please provide any additional information below.
Javascript console error log says "Syntax error on localhost:5" which is this line:
<link rel="stylesheet" href="/static/css/bootstrap.css"><link rel="stylesheet" href="/static/css/bootstrap-responsive.css"><style>body{padding-top:60px;padding-bottom:40px}.sidebar-nav{padding:9px 0}</style><script src="/static/jquery.full.js"></script><script src="/static/js/bootstrap-dropdown.js"></script><script src="/static/js/bootstrap-modal.js"></script><script src="/static/js/bootstrap-collapse.js"></script><script src="/static/longpolling.js"></script><script>function longpoll_"sidebar"() {
> And the bug is the quoting inside the function name.
>
> I believe this affects all builds done using shakespeare-js 1.0.0.2.
> It may be that some browsers manage to run the javascript despite the
> quoting. Otherwise, I don't know why noone has reported this bug
> before now.
>
> I've fixed this bug in git. Your testing with tomorrow's
> autobuild would be appreciated. [[done]] --[[Joey]]

View file

@ -1,12 +1,11 @@
function longpoll_#{ident}() {
longpoll(longpoll_#{ident}_url, '#{ident}'
, function() { setTimeout(longpoll_#{ident}, #{delay}); }
, function() { webapp_disconnected(); }
);
}
$(function() {
$.get("@{geturl}", function(url){
longpoll_#{ident}_url = url;
setTimeout(longpoll_#{ident}, #{startdelay});
var f = function() {
longpoll(url, '#{ident}'
, function() { setTimeout(f, #{delay}); }
, function() { webapp_disconnected(); }
);
};
setTimeout(f, #{startdelay});
});
});