Skip to content

Instantly share code, notes, and snippets.

@barnabywalters barnabywalters/opd.js

Last active Dec 21, 2015
Embed
What would you like to do?
Original Post Discovery minimal client side implementation. Requires promisejs (HTTP) and bean (events)
// Original post discovery (in progress)
var noteForms = document.querySelectorAll('.note-post-form');
if (noteForms.length > 0) {
for (var i = 0;i < noteForms.length;i++) {
var form = noteForms[i];
var inReplyToField = form.querySelector('.in-reply-to');
bean.on(inReplyToField, 'blur', function(event) {
var url = event.target.value;
// TODO: Start loading indicator
promise.get('/services/original-post', {'url': url}).then(function (error, text, xhr) {
// TODO: Stop loading indicator
if (error) return;
inReplyToField.value = text;
});
});
if (inReplyToField.value !== '')
bean.fire(inReplyToField, 'blur');
}
}
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.