Skip to content

Instantly share code, notes, and snippets.

@neil-s
Last active August 29, 2015 14:06
Show Gist options
  • Save neil-s/873a5c2bbe7e578048fa to your computer and use it in GitHub Desktop.
Save neil-s/873a5c2bbe7e578048fa to your computer and use it in GitHub Desktop.
This is the faulty code trying to secure the doorbell widget.
window.doorbellOptions = {
appKey: MY_APP_KEY
};
jQuery.ajax({
url: "/get-doorbell-secret/",
success: function (data) {
$.each(data, function (key, val){
window.doorbellOptions[key] = val
})
},
async: false
});
(function(d, t) {
var g = d.createElement(t);g.id = 'doorbellScript';g.type = 'text/javascript';g.async = true;g.src = 'https://doorbell.io/button/362';(d.getElementsByTagName('head')[0]||d.getElementsByTagName('body')[0]).appendChild(g);
}(document, 'script'));
window.doorbellOptions = {
appKey: MY_APP_KEY
};
(function(d, t) {
var g = d.createElement(t);g.id = 'doorbellScript';g.type = 'text/javascript';g.async = true;g.src = 'https://doorbell.io/button/362';(d.getElementsByTagName('head')[0]||d.getElementsByTagName('body')[0]).appendChild(g);
}(document, 'script'));
$.getJSON("/get-doorbell-secret/", function (data) {
$.each(data, function(key, val){
window.doorbell.setOption(key,val)
})
});
@neil-s
Copy link
Author

neil-s commented Sep 24, 2014

I also tried shuffling the order around, such as setting the options before the function that writes the HTML, and even simply pushing the values into the doorbellOptions array before the function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment