/user/willmoffat/apps/d_simple_map rename
author:
contributor:
published:
updated:
source uri:
Summary
acre.load('libWill','http://www.freebase.com/api/trans/raw/user/willmoffat/apps/libWill');
// set...
// set...
Content
acre.load('libWill','http://www.freebase.com/api/trans/raw/user/willmoffat/apps/libWill');
// set query from url
var data = acre.mqlread(JSON.parse(query));
var h=[];
function infoHtml(item) {
//search_img(item,item);
return '' + item.name + ''; //TODO: link
// return ''+escape(item.name)+'http://www.freebase.com/view' + item.id + '';
}
function listItem(item,owner) {
if (!item) { return; }
if (item.name) { owner=item; }
search_location(item,owner);
for (prop in item) {
var val = item[prop];
if (val) { listItem(val,owner); }
}
}
function search_img(item,owner) {
var img = item.image || item['/common/topic/image'] || null;
if (!img) { return; }
if ("length" in img) {
for (var i=0;i Missing image'); }
h.push('');
}
var header = [
'',
' ',
' Map of Stuff',
' ',
' .box { float:left; width:10em; height:10em; text-align:center; } a { text-decoration:none; } a img { border:none; }',
' .missing { width:5em; height:5em; margin:auto; background:lightgrey }',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
''];
if (data) {
listItem(data); // fills h[]
} else {
h=['ERROR - mql query has no data']
}
var htmlList = header.concat(h, footer);
var html = htmlList.join('\n');
acre.start_response(200, { 'content-type': 'text/html; charset="UTF-8"' });
acre.write(html);
function escape(str) { return str.replace(/&/g,'&'); }
function Q(str) { if (!str) { str=''; } return "'" + str.replace(/'/g,"\\'") + "'"; }
// set query from url
var data = acre.mqlread(JSON.parse(query));
var h=[];
function infoHtml(item) {
//search_img(item,item);
return '' + item.name + ''; //TODO: link
// return ''+escape(item.name)+'http://www.freebase.com/view' + item.id + '';
}
function listItem(item,owner) {
if (!item) { return; }
if (item.name) { owner=item; }
search_location(item,owner);
for (prop in item) {
var val = item[prop];
if (val) { listItem(val,owner); }
}
}
function search_img(item,owner) {
var img = item.image || item['/common/topic/image'] || null;
if (!img) { return; }
if ("length" in img) {
for (var i=0;i Missing image'); }
h.push('');
}
var header = [
'',
' ',
' Map of Stuff',
' ',
' .box { float:left; width:10em; height:10em; text-align:center; } a { text-decoration:none; } a img { border:none; }',
' .missing { width:5em; height:5em; margin:auto; background:lightgrey }',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
''];
if (data) {
listItem(data); // fills h[]
} else {
h=['ERROR - mql query has no data']
}
var htmlList = header.concat(h, footer);
var html = htmlList.join('\n');
acre.start_response(200, { 'content-type': 'text/html; charset="UTF-8"' });
acre.write(html);
function escape(str) { return str.replace(/&/g,'&'); }
function Q(str) { if (!str) { str=''; } return "'" + str.replace(/'/g,"\\'") + "'"; }
Created by:
willmoffat
Apr 12, 2008
Last edited by:
Constant Gardener Process
Aug 18, 2009
Recent Discussions about None
There is no discussion about this document.
Start the Discussion »