本文整理汇总了Python中nevow.livepage.js函数的典型用法代码示例。如果您正苦于以下问题:Python js函数的具体用法?Python js怎么用?Python js使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了js函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: tor_update
def tor_update(self, percent, tag, summary):
if self.ctx is None:
print "I have no Web client yet, but got a Tor update:", percent, tag, summary
return
client = livepage.IClientHandle(self.ctx)
point = int(300 * (float(percent) / 100.0))
self.client.send(livepage.js("""document.getElementById('progress_done').style.width = "%dpx";""" % point))
if percent == 100:
## done, turn message box green too
self.client.send(livepage.js("""document.getElementById("status").style.backgroundColor="#aaffaa";"""))
if self.continuous_update:
## add a text node for each update, creating a continuous list
self.client.send(
livepage.js(
"""var newNode = document.createElement('div');
newNode.appendChild(document.createTextNode("%d%% -- %s"));
document.getElementById('status').appendChild(newNode);"""
% (percent, summary)
)
)
else:
self.client.send(livepage.set("status", "%d%% — %s" % (percent, summary)))
开发者ID:narastabbocchi,项目名称:txtorcon,代码行数:27,代码来源:webui_server.py
示例2: __getitem__
def __getitem__(self, key):
if key == 'init':
def _init(value):
return livepage.js("livetags[%r] = %s;"%(self.name,value))
return _init
if key == 'delete':
return livepage.js("delComponent(%r);"%self.name)
return livepage.js("livetags[%r].%s"%(self.name, key))
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:8,代码来源:livetags.py
示例3: checkException
def checkException(self):
def continueTests(ctx, status):
if status == 'passed':
self.passed()
else:
self.failed()
continuer = self.handle.transient(continueTests)
return livepage.anonymous(
[livepage.js("if (testFrameNode.contentDocument.title != 'Exception') {\n\t"),
continuer('passed'),
livepage.js("\n} else {\n\t"),
continuer('failed'),
livepage.js("\n}")])
开发者ID:comfuture,项目名称:numbler,代码行数:14,代码来源:livetest.py
示例4: recieveFieldData
def recieveFieldData(self, client, fieldId, value, total, onDone=None):
"""
Called by client to give us a value from a certain field
"""
total = int(total)
self.fieldsReceived.add(fieldId)
obj, name = self.fieldId2obj(fieldId)
# Decode the value
decoded = ''
toSearch = value
def getMatch():
if toSearch and toSearch[0] == '%':
match1 = self.reUni.search(toSearch)
match2 = self.reChr.search(toSearch)
if match1 and match2:
if match1.start() < match2.start():
return match1
else:
return match2
else:
return match1 or match2
else:
return self.reRaw.search(toSearch)
match = getMatch()
while match:
num = match.groups()[-1]
if len(num) > 1:
decoded += unichr(int(num, 16))
else:
decoded += num
toSearch = toSearch[match.end():]
match = getMatch()
# Check the field type
if fieldId in self.booleanFieldNames:
setattr(obj, name, decoded[0].lower() == 't')
elif fieldId in self.imgFieldNames:
if not decoded.startswith("resources"):
setattr(obj, name, toUnicode(decoded))
else:
# Must be a string
setattr(obj, name, toUnicode(decoded))
client.sendScript(js(
'document.getElementById("%s").style.color = "black"' % fieldId))
if len(self.fieldsReceived) == total:
self.fieldsReceived = set()
client.sendScript(js.alert(
(u"%s" % _('Settings saved')).encode('utf8')))
if onDone:
client.sendScript(js(onDone))
开发者ID:luisgg,项目名称:iteexe,代码行数:49,代码来源:propertiespage.py
示例5: test_js
def test_js(self):
foo = livepage.js("foo")
self.livepage.call("alert", foo("1"))
self.assertEquals(self.livepage.sent, "alert(foo('1'));")
self.livepage.sendScript(foo(1))
self.assertEquals(self.livepage.sent, "foo(1)")
window = livepage.js("window")
self.livepage.sendScript(window.open("http://google.com"))
self.assertEquals(self.livepage.sent, "window.open('http://google.com')")
array = livepage.js("array")
self.livepage.sendScript(array[5])
self.assertEquals(self.livepage.sent, "array[5]")
self.livepage.sendScript(livepage.js[1, 2, 3])
self.assertEquals(self.livepage.sent, "[1,2,3]")
开发者ID:RichDijk,项目名称:eXe,代码行数:15,代码来源:test_livepage.py
示例6: test_normal
def test_normal(self):
"""No quoting at all happens when we are in a JavascriptContext
which is not in a single quoted string or a double quoted string.
"""
ctx = makeCtx()
self.assertEquals(flat.flatten("foo", ctx), "'foo'")
self.assertEquals(flat.flatten(livepage.js("1 < 2 & 3"), ctx), "1 < 2 & 3")
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:7,代码来源:test_livepage.py
示例7: inlineJSSerializer
def inlineJSSerializer(original, ctx):
from nevow import livepage
from nevow.tags import script, xml
theJS = livepage.js(original.children)
new = livepage.JavascriptContext(ctx, invisible[theJS])
return serialize(script(type="text/javascript")[
xml('\n//<![CDATA[\n'),
serialize(theJS, new),
xml('\n//]]>\n')], ctx)
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:9,代码来源:flatstan.py
示例8: test_callWithJS
def test_callWithJS(self):
self.livepage.call("add", 1, 2)
self.assertEquals(self.livepage.sent, "add(1,2)")
self.livepage.call("amIEvil", True)
self.assertEquals(self.livepage.sent, "amIEvil(true)")
self.livepage.call("add", 1.4, 2.4)
self.assertEquals(self.livepage.sent, "add(1.4,2.4)")
self.livepage.call('alert', livepage.js('document.title'))
self.assertEquals(self.livepage.sent, 'alert(document.title)')
self.livepage.call('alert', livepage.document.title)
self.assertEquals(self.livepage.sent, 'alert(document.title)')
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:11,代码来源:test_livepage.py
示例9: action_post
def action_post(self, action, target, parameter, callWhenDone=None):
if callWhenDone is None:
callWhenDone = "function (){}"
def observePosting(client, location, destination):
if location.endswith(destination):
self.passed()
else:
self.failed()
return [
"var targetForm = ", contentDocument[target], ";",
"var postTarget = ", js.targetForm.action, ";",
[(js.targetForm[key].value, ' = "', value, '";')
for (key, value) in parameter.items()],
"addLoadObserver(function () {",
livepage.handler(
observePosting,
contentDocument.location,
js.postTarget),
"});",
js.sendSubmitEvent(js.targetForm, js(callWhenDone))]
开发者ID:KatiaBorges,项目名称:exeLearning,代码行数:20,代码来源:livetest.py
示例10: handle_workloadClass
def handle_workloadClass(self, ctx, wlc):
if wlc in self.workloadClasses:
self.workloadClasses.remove(wlc)
action = "remove"
else:
self.workloadClasses.append(wlc)
action = "add"
rawClasses = set(self.workloadClasses)
yield livepage.js('document.getElementById("wlc_%s").classList.%s("active")' % (wlc, action)), livepage.eol
self.wltTable.prefilteredData = [wlc
for wlc
in self.wltTable.rawData
if wlc['rawClasses'] & rawClasses]
self.wltTable.filteredData = self.wltTable.prefilteredData
self.wltTable.setPage(0)
yield self.wltTable.update(ctx)
开发者ID:myaut,项目名称:tsload,代码行数:20,代码来源:agent.py
示例11: onCommand
from twisted.python import util
from nevow import rend, loaders, inevow, livepage
getValue = livepage.js('getValue')
changeLabel = livepage.js('changeLabel')
def onCommand(client, text):
client.sendScript(changeLabel(text))
class XulApp(livepage.LivePage):
addSlash = True
docFactory = loaders.xmlfile(util.sibpath(__file__, 'xul_example.xul'))
def locateChild(self, ctx, segments):
inevow.IRequest(ctx).setHeader("Content-Type", "application/vnd.mozilla.xul+xml; charset=UTF-8")
return rend.Page.locateChild(self, ctx, segments)
def render_btn(self, ctx, data):
return ctx.tag(oncommand=livepage.server.handle('onCommand', getValue('some-text')))
def handle_onCommand(self, ctx, text):
return changeLabel(text)
def createResource():
return XulApp()
开发者ID:exarkun,项目名称:nevow,代码行数:29,代码来源:xul_nevow.py
示例12: _passHandle
def _passHandle(self, ctx, name):
"""Ties up a handler for the promote, demote,
up and down buttons. (Called by below funcs)"""
attr = getattr(self.outlinePane, 'handle%s' % name)
return ctx.tag(oncommand=handler(attr, js('currentOutlineId()')))
开发者ID:giorgil2,项目名称:eXe,代码行数:5,代码来源:mainpage.py
示例13: render_delNode
def render_delNode(self, ctx, data):
"""Fills in the oncommand handler for the
delete child button and short cut key"""
return ctx.tag(oncommand=handler(self.outlinePane.handleDelNode,
js("confirmDelete()"),
js('currentOutlineId()')))
开发者ID:giorgil2,项目名称:eXe,代码行数:6,代码来源:mainpage.py
示例14: render_addChild
def render_addChild(self, ctx, data):
"""Fills in the oncommand handler for the
add child button and short cut key"""
return ctx.tag(oncommand=handler(self.outlinePane.handleAddChild,
js('currentOutlineId()')))
开发者ID:giorgil2,项目名称:eXe,代码行数:5,代码来源:mainpage.py
示例15: _init
def _init(value):
return livepage.js("livetags[%r] = %s;"%(self.name,value))
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:2,代码来源:livetags.py
示例16: _searchNotify
def _searchNotify(self, notification):
visibility = 'visible' if notification else 'hidden'
visJS = "document.getElementById('searchNotification').style.visibility='%s'" % visibility
yield livepage.set('searchNotification', notification), livepage.eol
yield livepage.js(visJS), livepage.eol
开发者ID:myaut,项目名称:tsload,代码行数:6,代码来源:pagination.py
注:本文中的nevow.livepage.js函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论