Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Souravirus/dbc9bb14ddd8f83cd9e1d48e7b06cbd2 to your computer and use it in GitHub Desktop.
Save Souravirus/dbc9bb14ddd8f83cd9e1d48e7b06cbd2 to your computer and use it in GitHub Desktop.
Commands for public lab editor
editor = new PL.Editor ({
lat: 34.1,
lon: 32.1,
textarea: $('.ple-textarea')[0],
destination: '/notes/create?rich=true',
format: 'publiclab',
mapModule: true,
richTextModule: {
authorsAutocomplete: false,
tagsAutocomplete: false,
formats: ['jpg', 'jpeg', 'png', 'gif'],
attachmentFormats: ['csv', 'xls', 'zip', 'kml', 'kmz', 'gpx', 'lut', 'stl', 'dxf', 'txt', 'pdf', 'svg', 'doc', 'ppt', 'docx', 'bmp', 'obj', 'json']
//formats: ['csv', 'xls', 'zip', 'kml', 'kmz', 'gpx', 'lut', 'stl', 'dxf', 'txt', 'pdf', 'svg', 'doc', 'ppt', 'docx', 'bmp', 'obj', 'json', 'jpg', 'jpeg', 'png', 'gif']
},
titleModule: {
suggestRelated: true,
fetchRelated: debounce(function(show) {
$.getJSON("/api/srch/notes?query=" + editor.titleModule.value(), function(response) {
/* API provides:
{"items":[{
"doc_id":14022,
"doc_type":"file",
"doc_url":"/notes/liz/03-15-2017/host-a-balloon-mapping-workshop",
"doc_title":"Host a balloon mapping workshop",
"doc_score":0}
]}
*/
// But we need: [{ id: 1, title: 'A related post', url: '/', author: 'eustatic'}, ... ]
var formatted = [];
if (response['items']) {
response['items'].forEach(function(item) {
var formattedItem = {};
formattedItem.id = item.doc_id;
formattedItem.title = item.doc_title;
formattedItem.url = item.doc_url;
formattedItem.author = item.doc_url.split('/')[2];
formatted.push(formattedItem);
});
show(formatted);
}
});
}, 1000)
},
tagsModule: {
remote: {
url: "/tag/suggested/test",
prepare: function prepareRemote(x) {
return "/tag/suggested/" + x
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment