Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A code fragment that gets the myword.io compatible JSON from the bar cursor outline
function opGetBarCursor () { //11/12/14 by DW
return ($(getActiveOutliner ()).concord ().op.getCursorRef ());
}
function dateToNumber (theDate) { //2/15/15 by DW
return (Number (new Date (theDate)));
}
function opGetMywordJstruct (theNode) { //2/15/15 by DW
if (theNode == undefined) {
theNode = opGetBarCursor ();
}
function getImg (headline) {
var urlImg;
headline.visitToSummit (function (theNode) {
var img = theNode.attributes.getOne ("img");
if (img != undefined) {
urlImg = img;
return (false); //stop looking
}
return (true); //keep looking
});
return (urlImg);
}
function notComment (headline) {
return (!getBoolean (headline.attributes.getOne ("isComment")));
}
function addsubs (adrx) {
var theSubs = new Array ();
adrx.visitLevel (function (headline) {
if (notComment (headline)) {
var linetext = headline.getLineText ();
if (headline.countSubs () > 0) {
var sub = new Object ();
sub.title = linetext;
sub.subs = addsubs (headline);
theSubs [theSubs.length] = sub;
}
else {
theSubs [theSubs.length] = linetext;
}
}
});
return (theSubs);
}
var jstruct = new Object (), atts = theNode.attributes.getAll ();
jstruct.title = theNode.getLineText ();
jstruct.description = atts.description;
jstruct.authorname = appPrefs.authorName;
jstruct.when = atts.created;
jstruct.img = getImg (theNode); //walk to summit
jstruct.subs = addsubs (theNode);
return (jstruct);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.