2018-08-05 04:09:33 +00:00
|
|
|
/* just for testing rn */
|
|
|
|
Block.getBlocks({'type' : 'onionr-post', 'signed' : true, 'reverse' : true}, function(data) {
|
|
|
|
for(var i = 0; i < data.length; i++) {
|
|
|
|
try {
|
|
|
|
var block = data[i];
|
|
|
|
|
2018-09-02 22:44:23 +00:00
|
|
|
var finished = false;
|
2018-09-03 05:08:12 +00:00
|
|
|
User.getUser(new String(block.getHeader('signer', 'unknown')), function(user) {
|
2018-09-02 22:44:23 +00:00
|
|
|
var post = new Post();
|
|
|
|
|
|
|
|
var blockContent = JSON.parse(block.getContent());
|
|
|
|
|
2018-09-08 05:47:56 +00:00
|
|
|
// just ignore anything shorter than 280 characters
|
2018-09-30 03:13:30 +00:00
|
|
|
if(String(blockContent['content']).length <= 280 && block.getParent() === null) {
|
2018-09-08 05:47:56 +00:00
|
|
|
post.setContent(blockContent['content']);
|
|
|
|
post.setPostDate(block.getDate());
|
|
|
|
post.setUser(user);
|
2018-08-05 04:09:33 +00:00
|
|
|
|
2018-09-08 05:47:56 +00:00
|
|
|
post.setHash(block.getHash());
|
|
|
|
|
|
|
|
document.getElementById('onionr-timeline-posts').innerHTML += post.getHTML();
|
|
|
|
}
|
2018-08-05 04:09:33 +00:00
|
|
|
|
2018-09-02 22:44:23 +00:00
|
|
|
finished = true;
|
|
|
|
});
|
2018-08-05 04:09:33 +00:00
|
|
|
|
2018-09-02 22:44:23 +00:00
|
|
|
while(!finished);
|
2018-08-05 04:09:33 +00:00
|
|
|
} catch(e) {
|
2018-09-03 05:08:12 +00:00
|
|
|
console.log('Troublemaker block: ' + data[i].getHash());
|
2018-08-05 04:09:33 +00:00
|
|
|
console.log(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2018-08-04 02:52:45 +00:00
|
|
|
|
2018-09-08 06:45:33 +00:00
|
|
|
function toggleLike(hash) {
|
|
|
|
var post = getPostMap(hash);
|
|
|
|
if(post === null || !getPostMap()[hash]['liked']) {
|
|
|
|
console.log('Liking ' + hash + '...');
|
|
|
|
|
|
|
|
if(post === null)
|
|
|
|
getPostMap()[hash] = {};
|
|
|
|
|
|
|
|
getPostMap()[hash]['liked'] = true;
|
|
|
|
|
|
|
|
set('postmap', JSON.stringify(getPostMap()));
|
|
|
|
|
|
|
|
var block = new Block();
|
|
|
|
|
|
|
|
block.setType('onionr-post-like');
|
|
|
|
block.setContent(JSON.stringify({'hash' : hash}));
|
|
|
|
block.save(true, function(hash) {});
|
|
|
|
} else {
|
|
|
|
console.log('Unliking ' + hash + '...');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-08 05:47:56 +00:00
|
|
|
function postCreatorChange() {
|
|
|
|
var content = document.getElementById('onionr-post-creator-content').value;
|
|
|
|
var message = '';
|
|
|
|
|
2018-09-13 05:30:49 +00:00
|
|
|
var maxlength = 280;
|
|
|
|
|
2018-09-08 05:47:56 +00:00
|
|
|
var disable = true;
|
2018-09-13 05:30:49 +00:00
|
|
|
var warn = false;
|
2018-09-08 05:47:56 +00:00
|
|
|
|
|
|
|
if(content.length !== 0) {
|
|
|
|
if(content.length - content.replaceAll('\n', '').length > 16) {
|
|
|
|
// 16 max newlines
|
|
|
|
message = 'Please use less than 16 newlines';
|
2018-09-13 05:30:49 +00:00
|
|
|
} else if(content.length <= maxlength) {
|
2018-09-08 05:47:56 +00:00
|
|
|
// 280 max characters
|
|
|
|
message = '%s characters remaining'.replaceAll('%s', (280 - content.length));
|
|
|
|
disable = false;
|
2018-09-13 05:30:49 +00:00
|
|
|
|
|
|
|
if(maxlength - content.length < maxlength / 4) {
|
|
|
|
warn = true;
|
|
|
|
}
|
2018-09-08 05:47:56 +00:00
|
|
|
} else {
|
2018-09-13 05:30:49 +00:00
|
|
|
message = '%s characters over maximum'.replaceAll('%s', (content.length - maxlength));
|
2018-09-08 05:47:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var element = document.getElementById('onionr-post-creator-content-message');
|
|
|
|
var button = document.getElementById("onionr-post-creator-create");
|
|
|
|
|
|
|
|
if(message === '')
|
2018-09-08 06:45:33 +00:00
|
|
|
element.style.visibility = 'hidden';
|
2018-09-08 05:47:56 +00:00
|
|
|
else {
|
2018-09-08 06:45:33 +00:00
|
|
|
element.style.visibility = 'visible';
|
2018-09-08 05:47:56 +00:00
|
|
|
|
|
|
|
element.innerHTML = message;
|
|
|
|
|
|
|
|
if(disable)
|
|
|
|
element.style.color = 'red';
|
2018-09-13 05:30:49 +00:00
|
|
|
else if(warn)
|
|
|
|
element.style.color = '#FF8C00';
|
2018-09-08 05:47:56 +00:00
|
|
|
else
|
|
|
|
element.style.color = 'gray';
|
|
|
|
}
|
|
|
|
|
|
|
|
if(disable)
|
|
|
|
button.disabled = true;
|
|
|
|
else
|
|
|
|
button.disabled = false;
|
|
|
|
}
|
|
|
|
|
2018-09-30 03:13:30 +00:00
|
|
|
function replyCreatorChange() {
|
|
|
|
var content = document.getElementById('onionr-reply-creator-content').value;
|
|
|
|
var message = '';
|
|
|
|
|
|
|
|
var maxlength = 280;
|
|
|
|
|
|
|
|
var disable = true;
|
|
|
|
var warn = false;
|
|
|
|
|
|
|
|
if(content.length !== 0) {
|
|
|
|
if(content.length - content.replaceAll('\n', '').length > 16) {
|
|
|
|
// 16 max newlines
|
|
|
|
message = 'Please use less than 16 newlines';
|
|
|
|
} else if(content.length <= maxlength) {
|
|
|
|
// 280 max characters
|
|
|
|
message = '%s characters remaining'.replaceAll('%s', (280 - content.length));
|
|
|
|
disable = false;
|
|
|
|
|
|
|
|
if(maxlength - content.length < maxlength / 4) {
|
|
|
|
warn = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
message = '%s characters over maximum'.replaceAll('%s', (content.length - maxlength));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var element = document.getElementById('onionr-reply-creator-content-message');
|
|
|
|
var button = document.getElementById("onionr-reply-creator-create");
|
|
|
|
|
|
|
|
if(message === '')
|
|
|
|
element.style.visibility = 'hidden';
|
|
|
|
else {
|
|
|
|
element.style.visibility = 'visible';
|
|
|
|
|
|
|
|
element.innerHTML = message;
|
|
|
|
|
|
|
|
if(disable)
|
|
|
|
element.style.color = 'red';
|
|
|
|
else if(warn)
|
|
|
|
element.style.color = '#FF8C00';
|
|
|
|
else
|
|
|
|
element.style.color = 'gray';
|
|
|
|
}
|
|
|
|
|
|
|
|
if(disable)
|
|
|
|
button.disabled = true;
|
|
|
|
else
|
|
|
|
button.disabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function focusReplyCreatorChange() {
|
|
|
|
var content = document.getElementById('onionr-post-focus-reply-creator-content').value;
|
|
|
|
var message = '';
|
|
|
|
|
|
|
|
var maxlength = 280;
|
|
|
|
|
|
|
|
var disable = true;
|
|
|
|
var warn = false;
|
|
|
|
|
|
|
|
if(content.length !== 0) {
|
|
|
|
if(content.length - content.replaceAll('\n', '').length > 16) {
|
|
|
|
// 16 max newlines
|
|
|
|
message = 'Please use less than 16 newlines';
|
|
|
|
} else if(content.length <= maxlength) {
|
|
|
|
// 280 max characters
|
|
|
|
message = '%s characters remaining'.replaceAll('%s', (280 - content.length));
|
|
|
|
disable = false;
|
|
|
|
|
|
|
|
if(maxlength - content.length < maxlength / 4) {
|
|
|
|
warn = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
message = '%s characters over maximum'.replaceAll('%s', (content.length - maxlength));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var element = document.getElementById('onionr-post-focus-reply-creator-content-message');
|
|
|
|
var button = document.getElementById("onionr-post-focus-reply-creator-create");
|
|
|
|
|
|
|
|
if(message === '')
|
|
|
|
element.style.visibility = 'hidden';
|
|
|
|
else {
|
|
|
|
element.style.visibility = 'visible';
|
|
|
|
|
|
|
|
element.innerHTML = message;
|
|
|
|
|
|
|
|
if(disable)
|
|
|
|
element.style.color = 'red';
|
|
|
|
else if(warn)
|
|
|
|
element.style.color = '#FF8C00';
|
|
|
|
else
|
|
|
|
element.style.color = 'gray';
|
|
|
|
}
|
|
|
|
|
|
|
|
if(disable)
|
|
|
|
button.disabled = true;
|
|
|
|
else
|
|
|
|
button.disabled = false;
|
|
|
|
}
|
|
|
|
|
2018-07-30 00:43:28 +00:00
|
|
|
function viewProfile(id, name) {
|
2018-09-02 22:44:23 +00:00
|
|
|
id = decodeURIComponent(id);
|
2018-08-05 04:16:42 +00:00
|
|
|
document.getElementById("onionr-profile-username").innerHTML = Sanitize.html(decodeURIComponent(name));
|
2018-09-02 22:44:23 +00:00
|
|
|
|
2018-09-03 05:08:12 +00:00
|
|
|
User.getUser(id, function(data) {
|
2018-09-02 22:44:23 +00:00
|
|
|
if(data !== null) {
|
|
|
|
document.getElementById("onionr-profile-user-icon").src = "data:image/jpeg;base64," + Sanitize.html(data.getIcon());
|
2018-09-03 05:08:12 +00:00
|
|
|
document.getElementById("onionr-profile-user-icon").b64 = Sanitize.html(data.getIcon());
|
2018-09-13 05:30:49 +00:00
|
|
|
document.getElementById("onionr-profile-username").innerHTML = Sanitize.html(Sanitize.username(data.getName()));
|
|
|
|
document.getElementById("onionr-profile-username").title = Sanitize.html(data.getID());
|
|
|
|
document.getElementById("onionr-profile-description").innerHTML = Sanitize.html(Sanitize.description(data.getDescription()));
|
2018-09-02 22:44:23 +00:00
|
|
|
}
|
|
|
|
});
|
2018-07-30 00:43:28 +00:00
|
|
|
}
|
2018-09-03 05:08:12 +00:00
|
|
|
|
|
|
|
function updateUser() {
|
|
|
|
toggleSaveButton(false);
|
|
|
|
|
2018-09-13 05:30:49 +00:00
|
|
|
// jQuery('#modal').modal('show');
|
2018-09-03 05:08:12 +00:00
|
|
|
|
|
|
|
var name = jQuery('#onionr-profile-username').text();
|
|
|
|
var id = document.getElementById("onionr-profile-username").title;
|
|
|
|
var icon = document.getElementById("onionr-profile-user-icon").b64;
|
2018-09-13 05:30:49 +00:00
|
|
|
var description = jQuery("#onionr-profile-description").text();
|
2018-09-03 05:08:12 +00:00
|
|
|
|
|
|
|
var user = new User();
|
|
|
|
|
|
|
|
user.setName(name);
|
|
|
|
user.setID(id);
|
|
|
|
user.setIcon(icon);
|
2018-09-13 05:30:49 +00:00
|
|
|
user.setDescription(Sanitize.description(description));
|
2018-09-03 05:08:12 +00:00
|
|
|
|
|
|
|
user.remember();
|
2018-09-13 05:30:49 +00:00
|
|
|
user.save(function() {
|
|
|
|
setCurrentUser(user);
|
2018-09-03 05:08:12 +00:00
|
|
|
|
2018-09-13 05:30:49 +00:00
|
|
|
window.location.reload();
|
|
|
|
});
|
2018-09-03 05:08:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function cancelUpdate() {
|
|
|
|
toggleSaveButton(false);
|
|
|
|
|
|
|
|
var name = jQuery('#onionr-profile-username').text();
|
|
|
|
var id = document.getElementById("onionr-profile-username").title;
|
|
|
|
|
|
|
|
viewProfile(id, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggleSaveButton(show) {
|
2018-09-13 05:30:49 +00:00
|
|
|
document.getElementById("onionr-profile-edit").style.display = (show ? 'block' : 'none');
|
2018-09-03 05:08:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function makePost() {
|
|
|
|
var content = document.getElementById("onionr-post-creator-content").value;
|
|
|
|
|
2018-09-07 04:37:39 +00:00
|
|
|
if(content.trim() !== '') {
|
|
|
|
var post = new Post();
|
2018-09-03 05:08:12 +00:00
|
|
|
|
2018-09-07 04:37:39 +00:00
|
|
|
post.setUser(getCurrentUser());
|
|
|
|
post.setContent(content);
|
|
|
|
post.setPostDate(new Date());
|
2018-09-03 05:08:12 +00:00
|
|
|
|
2018-09-07 04:37:39 +00:00
|
|
|
post.save(function(data) {}); // async, but no function
|
2018-09-03 05:08:12 +00:00
|
|
|
|
2018-09-07 04:37:39 +00:00
|
|
|
document.getElementById('onionr-timeline-posts').innerHTML = post.getHTML() + document.getElementById('onionr-timeline-posts').innerHTML;
|
2018-09-03 05:08:12 +00:00
|
|
|
|
2018-09-07 04:37:39 +00:00
|
|
|
document.getElementById("onionr-post-creator-content").value = "";
|
2018-09-13 05:30:49 +00:00
|
|
|
document.getElementById("onionr-post-creator-content").focus();
|
2018-09-08 06:45:33 +00:00
|
|
|
postCreatorChange();
|
2018-09-07 04:37:39 +00:00
|
|
|
} else {
|
|
|
|
console.log('Not making empty post.');
|
|
|
|
}
|
2018-09-03 05:08:12 +00:00
|
|
|
}
|
|
|
|
|
2018-09-30 03:13:30 +00:00
|
|
|
function getReplies(id, callback) {
|
|
|
|
Block.getBlocks({'type' : 'onionr-post', 'parent' : id, 'signed' : true, 'reverse' : true}, callback);
|
|
|
|
}
|
|
|
|
|
2018-09-27 00:40:02 +00:00
|
|
|
function focusPost(id) {
|
2018-09-30 03:13:30 +00:00
|
|
|
viewReplies(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
function viewRepliesMobile(id) {
|
|
|
|
var post = document.getElementById('onionr-post-' + id);
|
|
|
|
|
|
|
|
var user_name = '';
|
|
|
|
var user_id = '';
|
|
|
|
var user_id_trunc = '';
|
|
|
|
var user_icon = '';
|
|
|
|
var post_content = '';
|
|
|
|
|
|
|
|
if(post !== null && post !== undefined) {
|
|
|
|
// if the post is in the timeline, get the data from it
|
|
|
|
user_name = post.getElementsByClassName('onionr-post-user-name')[0].innerHTML;
|
|
|
|
user_id = post.getElementsByClassName('onionr-post-user-id')[0].title;
|
|
|
|
user_id_trunc = post.getElementsByClassName('onionr-post-user-id')[0].innerHTML;
|
|
|
|
user_icon = post.getElementsByClassName('onionr-post-user-icon')[0].src;
|
|
|
|
post_content = post.getElementsByClassName('onionr-post-content')[0].innerHTML;
|
|
|
|
} else {
|
|
|
|
// otherwise, fetch the data
|
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById('onionr-post-focus-user-icon').src = user_icon;
|
|
|
|
document.getElementById('onionr-post-focus-user-name').innerHTML = user_name;
|
|
|
|
document.getElementById('onionr-post-focus-user-id').innerHTML = user_id_trunc;
|
|
|
|
document.getElementById('onionr-post-focus-user-id').title = user_id;
|
|
|
|
document.getElementById('onionr-post-focus-content').innerHTML = post_content;
|
|
|
|
|
|
|
|
document.getElementById('onionr-post-focus-reply-creator-user-name').innerHTML = Sanitize.html(Sanitize.username(getCurrentUser().getName()));
|
|
|
|
document.getElementById('onionr-post-focus-reply-creator-user-icon').src = "data:image/jpeg;base64," + Sanitize.html(getCurrentUser().getIcon());
|
|
|
|
document.getElementById('onionr-post-focus-reply-creator-content').value = '';
|
|
|
|
document.getElementById('onionr-post-focus-reply-creator-content-message').value = '';
|
2018-09-27 00:40:02 +00:00
|
|
|
|
|
|
|
jQuery('#onionr-post-focus').modal('show');
|
|
|
|
}
|
|
|
|
|
2018-09-30 03:13:30 +00:00
|
|
|
function viewReplies(id) {
|
|
|
|
document.getElementById('onionr-replies-title').innerHTML = 'Replies';
|
|
|
|
document.getElementById('onionr-reply-creator-panel').originalPost = id;
|
|
|
|
document.getElementById('onionr-reply-creator-panel').innerHTML = '<!-- POST REPLIES -->\
|
|
|
|
<div class="onionr-post-creator">\
|
|
|
|
<div class="row">\
|
|
|
|
<div class="onionr-reply-creator container">\
|
|
|
|
<div class="row">\
|
|
|
|
<div class="col-3">\
|
|
|
|
<img class="onionr-post-creator-user-icon" id="onionr-reply-creator-user-icon">\
|
|
|
|
</div>\
|
|
|
|
<div class="col-9">\
|
|
|
|
<div class="row">\
|
|
|
|
<div class="col col-auto">\
|
|
|
|
<a class="onionr-post-creator-user-name" id="onionr-reply-creator-user-name" href="#!" onclick="viewProfile(\'$user-id-url\', \'$user-name-url\')"></a>\
|
|
|
|
<a class="onionr-post-creator-user-id" id="onionr-reply-creator-user-id" href="#!" onclick="viewProfile(\'$user-id-url\', \'$user-name-url\')" data-placement="top" data-toggle="tooltip" title="$user-id">you</a>\
|
|
|
|
</div>\
|
|
|
|
</div>\
|
|
|
|
\
|
|
|
|
<textarea class="onionr-post-creator-content" id="onionr-reply-creator-content" oninput="replyCreatorChange()"></textarea>\
|
|
|
|
\
|
|
|
|
<div class="onionr-post-creator-content-message" id="onionr-reply-creator-content-message"></div>\
|
|
|
|
\
|
|
|
|
<input type="button" onclick="makeReply()" title="Reply" value="Reply" id="onionr-reply-creator-create" class="onionr-post-creator-create" />\
|
|
|
|
</div>\
|
|
|
|
</div>\
|
|
|
|
</div>\
|
|
|
|
</div>\
|
|
|
|
</div>\
|
|
|
|
\
|
|
|
|
<div class="row">\
|
|
|
|
<div id="onionr-replies"></div>\
|
|
|
|
</div>\
|
|
|
|
<!-- END POST REPLIES -->\
|
|
|
|
';
|
|
|
|
|
|
|
|
document.getElementById('onionr-reply-creator-content').innerHTML = '';
|
|
|
|
document.getElementById("onionr-reply-creator-content").placeholder = "Enter a message here...";
|
|
|
|
document.getElementById('onionr-reply-creator-user-name').innerHTML = Sanitize.html(Sanitize.username(getCurrentUser().getName()));
|
|
|
|
document.getElementById('onionr-reply-creator-user-icon').src = "data:image/jpeg;base64," + Sanitize.html(getCurrentUser().getIcon());
|
|
|
|
|
|
|
|
document.getElementById('onionr-replies').innerHTML = '';
|
|
|
|
getReplies(id, function(data) {
|
|
|
|
var replies = document.getElementById('onionr-replies');
|
|
|
|
|
|
|
|
replies.innerHTML = '';
|
|
|
|
|
|
|
|
for(var i = 0; i < data.length; i++) {
|
|
|
|
try {
|
|
|
|
var block = data[i];
|
|
|
|
|
|
|
|
var finished = false;
|
|
|
|
User.getUser(new String(block.getHeader('signer', 'unknown')), function(user) {
|
|
|
|
var post = new Post();
|
|
|
|
|
|
|
|
var blockContent = JSON.parse(block.getContent());
|
|
|
|
|
|
|
|
// just ignore anything shorter than 280 characters
|
|
|
|
if(String(blockContent['content']).length <= 280) {
|
|
|
|
post.setContent(blockContent['content']);
|
|
|
|
post.setPostDate(block.getDate());
|
|
|
|
post.setUser(user);
|
|
|
|
|
|
|
|
post.setHash(block.getHash());
|
|
|
|
|
|
|
|
replies.innerHTML += post.getHTML('reply');
|
|
|
|
}
|
|
|
|
|
|
|
|
finished = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
while(!finished);
|
|
|
|
} catch(e) {
|
|
|
|
console.log('Troublemaker block: ' + data[i].getHash());
|
|
|
|
console.log(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function makeReply() {
|
|
|
|
var content = document.getElementById("onionr-reply-creator-content").value;
|
|
|
|
|
|
|
|
if(content.trim() !== '') {
|
|
|
|
var post = new Post();
|
|
|
|
|
|
|
|
var originalPost = document.getElementById('onionr-reply-creator-panel').originalPost;
|
|
|
|
|
|
|
|
console.log('Original post hash: ' + originalPost);
|
|
|
|
|
|
|
|
post.setUser(getCurrentUser());
|
|
|
|
post.setParent(originalPost);
|
|
|
|
post.setContent(content);
|
|
|
|
post.setPostDate(new Date());
|
|
|
|
|
|
|
|
post.save(function(data) {}); // async, but no function
|
|
|
|
|
|
|
|
document.getElementById('onionr-replies').innerHTML = post.getHTML('reply') + document.getElementById('onionr-replies').innerHTML;
|
|
|
|
|
|
|
|
document.getElementById("onionr-reply-creator-content").value = "";
|
|
|
|
document.getElementById("onionr-reply-creator-content").focus();
|
|
|
|
replyCreatorChange();
|
|
|
|
} else {
|
|
|
|
console.log('Not making empty reply.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-13 05:30:49 +00:00
|
|
|
jQuery('body').on('click', '[data-editable]', function() {
|
2018-09-03 05:08:12 +00:00
|
|
|
var el = jQuery(this);
|
|
|
|
var txt = el.text();
|
2018-09-13 05:30:49 +00:00
|
|
|
var maxlength = el.attr("maxlength");
|
2018-09-03 05:08:12 +00:00
|
|
|
|
|
|
|
var input = jQuery('<input/>').val(txt);
|
2018-09-13 05:30:49 +00:00
|
|
|
input.attr('maxlength', maxlength);
|
2018-09-03 05:08:12 +00:00
|
|
|
el.replaceWith(input);
|
|
|
|
|
|
|
|
var save = function() {
|
|
|
|
var newTxt = input.val();
|
2018-09-13 05:30:49 +00:00
|
|
|
|
|
|
|
if(el.attr('id') === 'onionr-profile-username')
|
|
|
|
newTxt = Sanitize.username(newTxt);
|
|
|
|
if(el.attr('id') === 'onionr-profile-description')
|
|
|
|
newTxt = Sanitize.description(newTxt);
|
|
|
|
|
|
|
|
var p = el.text(newTxt);
|
|
|
|
|
2018-09-03 05:08:12 +00:00
|
|
|
input.replaceWith(p);
|
|
|
|
|
|
|
|
if(newTxt !== txt)
|
|
|
|
toggleSaveButton(true);
|
|
|
|
};
|
|
|
|
|
2018-09-13 05:30:49 +00:00
|
|
|
var saveEnter = function(event) {
|
|
|
|
console.log(event);
|
|
|
|
console.log(event.keyCode);
|
|
|
|
if (event.keyCode === 13)
|
|
|
|
save();
|
|
|
|
};
|
|
|
|
|
|
|
|
input.one('blur', save).bind('keyup', saveEnter).focus();
|
2018-09-03 05:08:12 +00:00
|
|
|
});
|
2018-09-27 00:40:02 +00:00
|
|
|
//viewProfile('$user-id-url', '$user-name-url')
|
2018-09-30 03:13:30 +00:00
|
|
|
// jQuery('#onionr-post-user-id').on('click', function(e) { alert(3);});
|
2018-09-27 00:40:02 +00:00
|
|
|
//jQuery('#onionr-post *').on('click', function(e) { e.stopPropagation(); });
|
2018-09-30 03:13:30 +00:00
|
|
|
// jQuery('#onionr-post').click(function(e) { alert(1); });
|
2018-09-03 05:08:12 +00:00
|
|
|
|
2018-09-08 06:45:33 +00:00
|
|
|
currentUser = getCurrentUser();
|
2018-09-13 05:30:49 +00:00
|
|
|
if(currentUser !== undefined && currentUser !== null) {
|
|
|
|
document.getElementById("onionr-post-creator-user-name").innerHTML = Sanitize.html(currentUser.getName());
|
|
|
|
document.getElementById("onionr-post-creator-user-id").innerHTML = "you";
|
|
|
|
document.getElementById("onionr-post-creator-user-icon").src = "data:image/jpeg;base64," + Sanitize.html(currentUser.getIcon());
|
|
|
|
document.getElementById("onionr-post-creator-user-id").title = currentUser.getID();
|
2018-09-30 03:13:30 +00:00
|
|
|
|
2018-09-13 05:30:49 +00:00
|
|
|
document.getElementById("onionr-post-creator-content").placeholder = "Enter a message here...";
|
2018-09-30 03:13:30 +00:00
|
|
|
document.getElementById("onionr-post-focus-reply-creator-content").placeholder = "Enter a message here...";
|
|
|
|
|
|
|
|
document.getElementById("onionr-post-focus-reply-creator-user-id").innerHTML = "you";
|
2018-09-13 05:30:49 +00:00
|
|
|
}
|
2018-09-03 05:08:12 +00:00
|
|
|
|
|
|
|
viewCurrentProfile = function() {
|
|
|
|
viewProfile(encodeURIComponent(currentUser.getID()), encodeURIComponent(currentUser.getName()));
|
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById("onionr-post-creator-user-id").onclick = viewCurrentProfile;
|
|
|
|
document.getElementById("onionr-post-creator-user-name").onclick = viewCurrentProfile;
|
2018-09-08 05:47:56 +00:00
|
|
|
|
|
|
|
// on some browsers it saves the user input on reload. So, it should also recheck the input.
|
|
|
|
postCreatorChange();
|