add support for user profiles
This commit is contained in:
@@ -120,6 +120,10 @@ textarea {
|
||||
padding: 10px 15px;
|
||||
}
|
||||
|
||||
#box4{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#box3 .label, #messages li {
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
|
||||
@@ -108,6 +108,10 @@ haste.prototype.setTitle = function(ext) {
|
||||
document.title = title;
|
||||
};
|
||||
|
||||
haste.prototype.init = function(){
|
||||
document.body.addEventListener('document.user-loaded', this.userLoaded.bind(this))
|
||||
this.user.get(null)
|
||||
}
|
||||
// Show a message box
|
||||
haste.prototype.showMessage = function(msg, cls) {
|
||||
var msgBox = $('<li class="'+(cls || 'info')+'">'+msg+'</li>');
|
||||
@@ -343,6 +347,29 @@ haste.prototype.configureButton = function(options) {
|
||||
$('#pointer').hide();
|
||||
});
|
||||
};
|
||||
haste.prototype.user = {
|
||||
get: function(id){
|
||||
if(!id){
|
||||
id = 'me'
|
||||
}
|
||||
$.ajax('/users/' + id , {
|
||||
success:
|
||||
function(res){
|
||||
document.body.dispatchEvent(new CustomEvent('document.user-loaded', {'detail': {user: res}}))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
haste.prototype.userLoaded = function(e){
|
||||
console.log(e.detail.user);
|
||||
if(! (e.detail.user && e.detail.user.photos.length > 0)){
|
||||
throw "error reading user photo"
|
||||
}
|
||||
var user = e.detail.user;
|
||||
var image = user.photos[0].value;
|
||||
$('#box4').append('<p><img src="' + image + '" width="50"></p>')
|
||||
}
|
||||
|
||||
// Configure keyboard shortcuts for the textarea
|
||||
haste.prototype.configureShortcuts = function() {
|
||||
|
||||
2
static/application.min.js
vendored
2
static/application.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -34,6 +34,9 @@
|
||||
app = new haste('hastebin', { twitter: true });
|
||||
handlePop({ target: window });
|
||||
});
|
||||
$(document).ready(function(){
|
||||
app.init();
|
||||
});
|
||||
</script>
|
||||
|
||||
</head>
|
||||
@@ -57,6 +60,7 @@
|
||||
<div class="label"></div>
|
||||
<div class="shortcut"></div>
|
||||
</div>
|
||||
<div id="box4"></div>
|
||||
</div>
|
||||
|
||||
<div id="linenos"></div>
|
||||
|
||||
Reference in New Issue
Block a user