Skip to content

Instantly share code, notes, and snippets.

@levity
Last active January 4, 2016 08:19
Show Gist options
  • Save levity/8594322 to your computer and use it in GitHub Desktop.
Save levity/8594322 to your computer and use it in GitHub Desktop.
editing a page with VoodooPad API
var Page = function(key) {
var page = document.pageForKey(key),
data = page.dataAsAttributedString(),
text = data.mutableString(),
changed = false;
this.write = function(msg) {
changed = true;
text.appendString(msg);
};
this.save = function() {
if (changed)
page.setDataWithAttributedString(data);
};
return this;
};
var Log = {
write: function(msg) {
NSApplication.sharedApplication().delegate().console(msg);
}
};
function testTimestampChange() {
Log.write(document.pageForKey('test').modifiedDate());
var page = new Page('test');
page.write("foo");
page.save();
Log.write(document.pageForKey('test').modifiedDate()); // it changes
}
function main() {
testTimestampChange();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment