pyc-website

main website for pyc inc.

git clone https://9o.is/git/pyc-website.git

commit 4029605e47a639599bbc895650f77c727919f9bf
parent fc49f74af5365fcce5d6828b882248f8adf9e1a8
Author: Jul <jul@9o.is>
Date:   Mon, 19 May 2014 18:56:59 -0400

added comet restart to comet ajax (but still doesnt fix issue #22)

Diffstat:
Msrc/main/scala/inc/pyc/lib/NgUIRouter.scala | 15++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/main/scala/inc/pyc/lib/NgUIRouter.scala b/src/main/scala/inc/pyc/lib/NgUIRouter.scala @@ -107,7 +107,7 @@ trait NgUIRouterSnip extends SnippetHelper { """var promises = angular.element(document.querySelectorAll(".lift-promise"));"""+ """for (var i=0;i<promises.length;++i) { eval(promises[i].innerHTML) };""" - val liftCometEntry = """window.liftComet.lift_handlerSuccessFunc();""" + val liftCometStart = """window.liftComet.lift_cometRestart();""" val log = if(Props.devMode) "console.log('$viewContentLoaded is running now ... ');" else "" @@ -130,7 +130,7 @@ trait NgUIRouterSnip extends SnippetHelper { def func(body: String): String = "(function() {"+body+"});" s"""// <![CDATA[ - ${init + app + config + onViewContentLoaded(log, ifStateNotVisited(updateLiftWatch, evalRenderedJS, liftCometEntry))}; + ${init + app + config + onViewContentLoaded(log, ifStateNotVisited(updateLiftWatch, evalRenderedJS, liftCometStart))}; $cometScript //]]>""" } @@ -140,6 +140,7 @@ trait NgUIRouterSnip extends SnippetHelper { */ private def cometScript: String = """ (function() { + var currentCometRequest = null; window.liftComet = { lift_handlerSuccessFunc: function() { setTimeout("liftComet.lift_cometEntry();",100); @@ -167,12 +168,20 @@ trait NgUIRouterSnip extends SnippetHelper { }, lift_sessionLost: function() { window.location = '/' }, + + lift_cometRestart: function() { + if (currentCometRequest) { + currentCometRequest.abort(); + } + + liftComet.lift_handlerSuccessFunc(); + }, lift_cometEntry: function() { var isEmpty = function(){for (var i in lift_toWatch) {return false} return true}(); if (!isEmpty) { liftAjax.lift_uriSuffix = undefined; - """ + + currentCometRequest = """ + LiftRules.jsArtifacts.comet(AjaxInfo(JE.JsRaw("lift_toWatch"), "GET", LiftRules.cometGetTimeout,