--- /dev/null
+mkws.registerWidgetType('Reference', function() {
+ mkws.promotionFunction('Record').call(this);
+ if (!this.config.target) this.config.target = 'wikimedia_wikipedia_single_result';
+ if (!this.config.template) this.config.template = 'Reference';
+
+ this.team.registerTemplate('Reference', '\
+<a href="{{md-electronic-url}}">\
+ <h1>{{md-title}}</h1>\
+</a>\
+{{#if md-title-remainder}}\
+ <b>{{md-title-remainder}}</b>\
+{{/if}}\
+{{#if md-title-responsibility}}\
+ <i>{{md-title-responsibility}}</i>\
+{{/if}}\
+ <p>\
+ <img style="float:right; margin: 0 0 1em 3em" src="{{md-thumburl}}" alt="{{md-title}}">\
+ {{md-description}}\
+ </p>\
+');
+
+ var that = this;
+ this.team.queue("record").subscribe(function(data) {
+ that.log("got data " + $.toJSON(data));
+ });
+});
--- /dev/null
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>MKWS demo: Reference Universe widget</title>
+ <link rel="stylesheet" type="text/css" href="//mkws.indexdata.com/mkws.css" />
+ <script type="text/javascript">
+ var mkws_config = { service_proxy_auth: "//mkws.indexdata.com/service-proxy-testauth" };
+ </script>
+ <script type="text/javascript" src="//mkws.indexdata.com/mkws-complete.js"></script>
+ <script type="text/javascript" src="mkws-widget-reference.js"></script>
+ </head>
+ <body>
+ <div class='mkwsReference' autosearch='!param!q'>result will appear here</div>
+ </body>
+</html>
"last": $.now()
};
var m_paz; // will be initialised below
- var m_template = {};
+ var m_tempateText = {}; // widgets can register tempates to be compiled
+ var m_template = {}; // compiled templates, from any source
var m_config = mkws.objectInheritingFrom(mkws.config);
var m_widgets = {}; // Maps widget-type to object
that.renderDetails = renderDetails;
+ that.registerTemplate = function(name, text) {
+ m_tempateText[name] = text;
+ };
+
+
function loadTemplate(name) {
var template = m_template[name];
}
if (!source) {
+ source = m_tempateText[name];
+ }
+ if (!source) {
source = defaultTemplate(name);
}
var html = [];
for (var i = 0; i < data.hits.length; i++) {
var hit = data.hits[i];
+ that.team.queue("record").publish(hit);
var divId = team.recordElementId(hit.recid[0]);
html.push('<div class="record mkwsTeam_' + team.name() + ' ' + divId + '">', renderSummary(hit), '</div>');
// ### At some point, we may be able to move the