Changed how the username is requested.

parent afe34ad6
Pipeline #196 skipped
......@@ -3,19 +3,20 @@ $(function() {
var $commentsContainer = $('#comments-container'),
$comments = $('.comments');
if(storedUserName==undefined){
$commentsContainer.hide();
var $userNameForm = $('<div><label for="username">Username</label>' +
if(storedUserName==undefined|| storedUserName==null){
var $userNameForm = $('<div>Please add your username in order to add comments</div><div>' +
'<label for="username">Username:</label>' +
'<input type="text" id="username" name="username">' +
'<button id="saveUsername">Save</button>' +
'</div>');
$comments.append($userNameForm);
$comments.prepend($userNameForm);
$userNameForm.on('click', '#saveUsername', function(){
window.username = $('#username').val();
localStorage.setItem('username', window.username);
$userNameForm.remove();
$commentsContainer.show();
options.readOnly = false;
$commentsContainer.removeClass('read-only');
})
}else{
window.username = storedUserName;
......@@ -23,18 +24,17 @@ $(function() {
var server = '//increments.coko.foundation:3000/api/comments';
//var server = '//localhost:3000/api/comments';
$commentsContainer.comments({
var options = {
fieldMappings: {
fullname: 'user'
},
profilePictureURL: 'https://viima-app.s3.amazonaws.com/media/user_profiles/user-icon.png',
roundProfilePictures: true,
readOnly: storedUserName ? false: true,
textareaRows: 1,
enableAttachments: true,
textareaRows: 1,
highlightColor: '#7E0700',
deleteButtonColor: '#D89100',
enableAttachments: true,
getComments: function(success, error) {
$.get(server + '?url='+window.location.pathname, function(resp){
success(resp);
......@@ -84,5 +84,6 @@ $(function() {
success(dataArray);
}, 500);
}
});
};
$commentsContainer.comments(options);
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment