Last active
December 21, 2015 23:09
-
-
Save barnabywalters/6380386 to your computer and use it in GitHub Desktop.
Original Post Discovery minimal client side implementation. Requires promisejs (HTTP) and bean (events)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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