PageBus is an event and message bus implemented in JavaScript that enables disparate Ajax elements in a Web page to broadcast and listen for events and messages published on topic names. In addition to basic publish and subscribe APIs, PageBus supports hierarchical topic names and the use of token wildcards within those hierarchical topic names providing a rich means to listen for both general as well as specific information.
PageBus is open source software by TIBCO. It is included with MindTouch Deki and does not need to be downloaded separately.
Inside Deki, you can connect a component (such as a Google map) to a PageBus channel, and then publish information to that channel (such as map co-ordinates), which will then cause anything listening to the channel to update (draw the new location on the map).
| Vendor | MindTouch |
| Type | Script |
| Categories | Advanced |
| Requires | MindTouch Deki 1.8.3 or later |
| Status | Stable |
| License | Free/Open Source |
| Manifest | http://scripts.mindtouch.com/pagebus.xml |
Table of Contents
This extension contains functions for interacting with the PageBus.
See also How to add a script, Using the Extension Dialog, Learn about DekiScript, Extensions Directory.
Show messages on a channel in an alert window.
Parameters:
| Name | Type | Description |
| subscribe | str | (optional) Subscribe to channel. (default: "*") |
| title | str | (optional) Dialog title. (default: nil) |
Filter messages before copying them to another channel.
Parameters:
| Name | Type | Description |
| subscribe | str | Subscribe to channel. |
| publish | str | Publish on channel. |
| field | str | Field to test. |
| pattern | str | Regular expression pattern to use for test. |
Publish a message on a channel.
Parameters:
| Name | Type | Description |
| channel | str | Channel to publish mesage on. |
| message | any | Message to send. |
Publish a list of messages on a channel.
Parameters:
| Name | Type | Description |
| channel | str | Channel to publish mesages on. |
| messages | list | List of messages to send. |
Republish messages to another channel.
Parameters:
| Name | Type | Description |
| subscribe | str | Subscribe to channel. |
| publish | str | Publish on channel. |
| copy | map | (optional) Fields to copy. (default: all) |
| add | map | (optional) Fields to add. (default: none) |
<extension>
<title>MindTouch PageBus Extension</title>
<copyright>Copyright (c) 2006-2009 MindTouch, Inc.</copyright>
<uri.help>http://wiki.developer.mindtouch.com/MindTouch_Deki/Extensions/PageBus</uri.help>
<label>PageBus</label>
<namespace>pagebus</namespace>
<description>This extension contains functions for interacting with the PageBus.</description>
<function>
<name>alert</name>
<description>Show messages on a channel in an alert window.</description>
<param name="subscribe" type="str" optional="true">Subscribe to channel. (default: "*")</param>
<param name="title" type="str" optional="true">Dialog title. (default: nil)</param>
<return>
<html xmlns:eval="http://mindtouch.com/2007/dekiscript">
<head>
<script type="text/javascript">
DekiWiki.subscribe(<eval:js>args.subscribe ?? '*'</eval:js>, null, function(c, m, d) { var s = ''; for(var f in m) s += f + ': ' + m[f] + '\n'; alert(<eval:js>args.title ?? 'Alert Box'</eval:js> + '\nchannel: [' + c + ']\n' + s); });
</script>
</head>
</html>
</return>
</function>
<function>
<name>republish</name>
<description>Republish messages to another channel.</description>
<param name="subscribe" type="str">Subscribe to channel.</param>
<param name="publish" type="str">Publish on channel.</param>
<param name="copy" type="map" optional="true">Fields to copy. (default: all)</param>
<param name="add" type="map" optional="true">Fields to add. (default: none)</param>
<return>
<html xmlns:eval="http://mindtouch.com/2007/dekiscript">
<head>
<script type="text/javascript">
DekiWiki.subscribe(<eval:js>args.subscribe</eval:js>, null, function(c, m, d) {
var result = m;
if(d.copy) {
result = { };
for(var key in d.copy) result[key] = m[d.copy[key]];
}
if(d.add) for(var key in d.add) result[key] = d.add[key];
DekiWiki.publish(<eval:js>args.publish</eval:js>, result);
}, { copy: <eval:js>args.copy</eval:js>, add: <eval:js>args.add</eval:js> });
</script>
</head>
</html>
</return>
</function>
<function>
<name>filter</name>
<description>Filter messages before copying them to another channel.</description>
<param name="subscribe" type="str">Subscribe to channel.</param>
<param name="publish" type="str">Publish on channel.</param>
<param name="field" type="str">Field to test.</param>
<param name="pattern" type="str">Regular expression pattern to use for test.</param>
<return>
<html xmlns:eval="http://mindtouch.com/2007/dekiscript">
<head>
<script type="text/javascript">
DekiWiki.subscribe(<eval:js>args.subscribe</eval:js>, null, function(c, m, d) {
if(DekiWiki.hasValue(m[<eval:js>args.field</eval:js>]) && d.regex.test(m[<eval:js>args.field</eval:js>])) {
DekiWiki.publish(<eval:js>args.publish</eval:js>, m);
}
}, { regex: new RegExp(<eval:js>args.pattern</eval:js>) });
</script>
</head>
</html>
</return>
</function>
<function>
<name>publish</name>
<description>Publish a message on a channel.</description>
<param name="channel" type="str">Channel to publish mesage on.</param>
<param name="message" type="any">Message to send.</param>
<return>
<html xmlns:eval="http://mindtouch.com/2007/dekiscript">
<tail>
<script type="text/javascript">
DekiWiki.publish(<eval:js>args.channel</eval:js>, <eval:js>args.message</eval:js>);
</script>
</tail>
</html>
</return>
</function>
<function>
<name>publishmany</name>
<description>Publish a list of messages on a channel.</description>
<param name="channel" type="str">Channel to publish mesages on.</param>
<param name="messages" type="list">List of messages to send.</param>
<return>
<html xmlns:eval="http://mindtouch.com/2007/dekiscript">
<tail>
<script type="text/javascript">
<eval:foreach var="message" in="args.messages">DekiWiki.publish(<eval:js>args.channel</eval:js>, <eval:js>message</eval:js>);</eval:foreach>
</script>
</tail>
</html>
</return>
</function>
</extension>
http://wiki.developer.mindtouch.com/MindTouch_Deki/Extensions/DHtml
http://wiki.developer.mindtouch.com/index.php?title=MindTouch_Deki/FAQ/Extensions/How_do_I...Take_advantage_of_the_Dapper_extension%3F/Dapper_%26_PageBus