diff --git a/onionr/static-data/www/ui/dist/index.html b/onionr/static-data/www/ui/dist/index.html
index 756f8107..90f9a30d 100644
--- a/onionr/static-data/www/ui/dist/index.html
+++ b/onionr/static-data/www/ui/dist/index.html
@@ -43,13 +43,21 @@
-
+
-
diff --git a/onionr/static-data/www/ui/dist/js/main.js b/onionr/static-data/www/ui/dist/js/main.js
index 864b146a..261322eb 100644
--- a/onionr/static-data/www/ui/dist/js/main.js
+++ b/onionr/static-data/www/ui/dist/js/main.js
@@ -51,6 +51,7 @@ function deserializeUser(id) {
user.setName(serialized['name']);
user.setID(serialized['id']);
user.setIcon(serialized['icon']);
+ user.setDescription(serialized['description']);
return user;
}
@@ -148,6 +149,11 @@ class Sanitize {
static username(username) {
return String(username).replace(/[\W_]+/g, " ").substring(0, 25);
}
+
+ /* profile descriptions */
+ static description(description) {
+ return String(description).substring(0, 128);
+ }
}
/* config stuff */
@@ -233,6 +239,7 @@ class User {
}
static getUser(id, callback) {
+ console.log(callback);
var user = deserializeUser(id);
if(user === null) {
Block.getBlocks({'type' : 'onionr-user-info', 'signed' : true, 'reverse' : true}, function(data) {
@@ -245,10 +252,11 @@ class User {
if(userInfo['id'] === id) {
user.setName(userInfo['name']);
user.setIcon(userInfo['icon']);
+ user.setDescription(userInfo['description']);
user.setID(id);
user.remember();
-
+ console.log(callback);
callback(user);
return user;
}
@@ -264,6 +272,7 @@ class User {
}
});
} else {
+ console.log(callback);
callback(user);
return user;
}
@@ -647,6 +656,8 @@ if(getWebPassword() === null) {
}
if(getCurrentUser() === null) {
+ jQuery('#modal').modal('show');
+
var url = '/client/?action=info&token=' + Sanitize.url(getWebPassword()) + '&timingToken=' + Sanitize.url(getTimingToken());
console.log(url);
@@ -655,33 +666,33 @@ if(getCurrentUser() === null) {
// sync
- http.open('GET', url, false);
- http.send(null);
+ http.addEventListener('load', function() {
+ var id = JSON.parse(http.responseText)['pubkey'];
- var id = JSON.parse(http.responseText)['pubkey'];
+ User.getUser(id, function(data) {
+ if(data === null || data === undefined) {
+ var user = new User();
- User.getUser(id, function(data) {
- if(data === null || data === undefined) {
- jQuery('#modal').modal('show');
-
- var user = new User();
-
- user.setName('New User');
- user.setID(id);
- user.setIcon('/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAcFBQYFBAcGBQYIBwcIChELCgkJChUPEAwRGBUaGRgVGBcbHichGx0lHRcYIi4iJSgpKywrGiAvMy8qMicqKyr/2wBDAQcICAoJChQLCxQqHBgcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKir/wAARCACAAIADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDrtTvrlL51jlkyGPANUZNSuvJZ2uJFYHjB6UmpTE6jcZUH5iCR0FQQLHvww3An8K8jmuz0lHQvwXV1gNLcSBmGcZqcXtwo/wBe/X1rzqw1e/stWmaTdKpcl1Le9dqmoJc2qupxnoCOauUWkOzRpnULhsATMPXm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5Cgd65i+tp4dKedQiTsdoLjhfU4716LqGnuVw6MD1VgOlchqFgyXkT3GXVHyA+dufeuedNPU6adS2hxtxFOIS3lsZZASiMvfoGqlNb31g0dtnZu+ZnH3vr9a7V7iKW6WK0ge7nkON5Xauf8BVTW7CSDT5jdkRSS5LSY5I/oPaudw5TrjUuZOnX9lt2G4leUDBO7j8RWxaX1urj/AEWE+jp6+4NcCYDcaiyWaKijptX5vwPua0H0y/gVZcXicfeLZFZSj5mySZ6OmpwiEyRLl1+9C67SP8+tYuo61a6nFJAEktpPQ9DWXpFprGqbbd/MaMcFmToPr1rpD4OijVTN50zDH3RyfxqbtbE8sYvU/9k=\
+ user.setName('New User');
+ user.setID(id);
+ user.setIcon('/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAcFBQYFBAcGBQYIBwcIChELCgkJChUPEAwRGBUaGRgVGBcbHichGx0lHRcYIi4iJSgpKywrGiAvMy8qMicqKyr/2wBDAQcICAoJChQLCxQqHBgcKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKir/wAARCACAAIADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hp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WGBxnmqYjLJlFRycnkcj610F/pmL6Yht+ZCeVqmbGRCHji3EDjCmqtbY5eY5q90gSqBMCfRvSufutJ8uQkKMDuetd5LDPtIuEIwOMLjNY1xGskb79yH+4y0RZdzj7C2WfWI43Xf2KkYr1LTdOe1t1Nv5MSD0QH/CuDhtY49YjZgwU8Y3EE16JptneXMai2sGSMfxyMR+ldtOKauc9WTNq3wIgWcE46CnSBHGSvBGOKsJaSR24MsRYrztVMVMLSQrkLhupXHGD6VvZnNc5XVLdrUSiHJSQ5Cgd65i+tp4dKedQiTsdoLjhfU4716LqGnuVw6MD1VgOlchqFgyXkT3GXVHyA+dufeuedNPU6adS2hxtxFOIS3lsZZASiMvfoGqlNb31g0dtnZu+ZnH3vr9a7V7iKW6WK0ge7nkON5Xauf8BVTW7CSDT5jdkRSS5LSY5I/oPaudw5TrjUuZOnX9lt2G4leUDBO7j8RWxaX1urj/AEWE+jp6+4NcCYDcaiyWaKijptX5vwPua0H0y/gVZcXicfeLZFZSj5mySZ6OmpwiEyRLl1+9C67SP8+tYuo61a6nFJAEktpPQ9DWXpFprGqbbd/MaMcFmToPr1rpD4OijVTN50zDH3RyfxqbtbE8sYvU/9k=\
');
- user.setDescription('A new OnionrUI user');
+ user.setDescription('A new OnionrUI user');
- user.remember();
- user.save();
+ user.remember();
+ user.save();
- setCurrentUser(user);
+ setCurrentUser(user);
+ } else {
+ setCurrentUser(data);
+ }
window.location.reload();
- } else {
- setCurrentUser(data);
- }
- });
+ });
+ }, false);
+
+ http.open('GET', url, true);
+ http.send(null);
}
currentUser = getCurrentUser();
diff --git a/onionr/static-data/www/ui/dist/js/timeline.js b/onionr/static-data/www/ui/dist/js/timeline.js
index 7e90d962..2712cde8 100644
--- a/onionr/static-data/www/ui/dist/js/timeline.js
+++ b/onionr/static-data/www/ui/dist/js/timeline.js
@@ -58,18 +58,25 @@ function postCreatorChange() {
var content = document.getElementById('onionr-post-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 <= 280) {
+ } 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 - 280));
+ message = '%s characters over maximum'.replaceAll('%s', (content.length - maxlength));
}
}
@@ -85,6 +92,8 @@ function postCreatorChange() {
if(disable)
element.style.color = 'red';
+ else if(warn)
+ element.style.color = '#FF8C00';
else
element.style.color = 'gray';
}
@@ -101,10 +110,11 @@ function viewProfile(id, name) {
User.getUser(id, function(data) {
if(data !== null) {
- document.getElementById("onionr-profile-username").innerHTML = Sanitize.html(data.getName());
- document.getElementById("onionr-profile-username").title = Sanitize.html(data.getID());
document.getElementById("onionr-profile-user-icon").src = "data:image/jpeg;base64," + Sanitize.html(data.getIcon());
document.getElementById("onionr-profile-user-icon").b64 = Sanitize.html(data.getIcon());
+ 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()));
}
});
}
@@ -112,24 +122,26 @@ function viewProfile(id, name) {
function updateUser() {
toggleSaveButton(false);
- jQuery('#modal').modal('show');
+ // jQuery('#modal').modal('show');
var name = jQuery('#onionr-profile-username').text();
var id = document.getElementById("onionr-profile-username").title;
var icon = document.getElementById("onionr-profile-user-icon").b64;
- var description = 'todo';
+ var description = jQuery("#onionr-profile-description").text();
var user = new User();
user.setName(name);
user.setID(id);
user.setIcon(icon);
- user.setDescription(description);
+ user.setDescription(Sanitize.description(description));
user.remember();
- user.save();
+ user.save(function() {
+ setCurrentUser(user);
- window.location.reload();
+ window.location.reload();
+ });
}
function cancelUpdate() {
@@ -142,8 +154,7 @@ function cancelUpdate() {
}
function toggleSaveButton(show) {
- document.getElementById("onionr-profile-save").style.display = (show ? 'block' : 'none');
- document.getElementById("onionr-profile-cancel").style.display = (show ? 'block' : 'none');
+ document.getElementById("onionr-profile-edit").style.display = (show ? 'block' : 'none');
}
function makePost() {
@@ -161,38 +172,56 @@ function makePost() {
document.getElementById('onionr-timeline-posts').innerHTML = post.getHTML() + document.getElementById('onionr-timeline-posts').innerHTML;
document.getElementById("onionr-post-creator-content").value = "";
+ document.getElementById("onionr-post-creator-content").focus();
postCreatorChange();
} else {
console.log('Not making empty post.');
}
}
-$('body').on('click', '[data-editable]', function() {
+jQuery('body').on('click', '[data-editable]', function() {
var el = jQuery(this);
var txt = el.text();
+ var maxlength = el.attr("maxlength");
var input = jQuery('').val(txt);
+ input.attr('maxlength', maxlength);
el.replaceWith(input);
var save = function() {
var newTxt = input.val();
- var p = el.text(Sanitize.username(newTxt));
+
+ 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);
+
input.replaceWith(p);
if(newTxt !== txt)
toggleSaveButton(true);
};
- input.one('blur', save).focus();
+ var saveEnter = function(event) {
+ console.log(event);
+ console.log(event.keyCode);
+ if (event.keyCode === 13)
+ save();
+ };
+
+ input.one('blur', save).bind('keyup', saveEnter).focus();
});
currentUser = getCurrentUser();
-
-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();
-document.getElementById("onionr-post-creator-content").placeholder = "Enter a message here...";
+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();
+ document.getElementById("onionr-post-creator-content").placeholder = "Enter a message here...";
+}
viewCurrentProfile = function() {
viewProfile(encodeURIComponent(currentUser.getID()), encodeURIComponent(currentUser.getName()));
diff --git a/onionr/static-data/www/ui/src/index.html b/onionr/static-data/www/ui/src/index.html
index d64a35d0..b794a912 100644
--- a/onionr/static-data/www/ui/src/index.html
+++ b/onionr/static-data/www/ui/src/index.html
@@ -13,13 +13,21 @@
-
+
-
diff --git a/onionr/static-data/www/ui/src/js/main.js b/onionr/static-data/www/ui/src/js/main.js
index a69b31ea..7a67f78f 100644
--- a/onionr/static-data/www/ui/src/js/main.js
+++ b/onionr/static-data/www/ui/src/js/main.js
@@ -51,6 +51,7 @@ function deserializeUser(id) {
user.setName(serialized['name']);
user.setID(serialized['id']);
user.setIcon(serialized['icon']);
+ user.setDescription(serialized['description']);
return user;
}
@@ -148,6 +149,11 @@ class Sanitize {
static username(username) {
return String(username).replace(/[\W_]+/g, " ").substring(0, 25);
}
+
+ /* profile descriptions */
+ static description(description) {
+ return String(description).substring(0, 128);
+ }
}
/* config stuff */
@@ -233,6 +239,7 @@ class User {
}
static getUser(id, callback) {
+ console.log(callback);
var user = deserializeUser(id);
if(user === null) {
Block.getBlocks({'type' : 'onionr-user-info', 'signed' : true, 'reverse' : true}, function(data) {
@@ -245,10 +252,11 @@ class User {
if(userInfo['id'] === id) {
user.setName(userInfo['name']);
user.setIcon(userInfo['icon']);
+ user.setDescription(userInfo['description']);
user.setID(id);
user.remember();
-
+ console.log(callback);
callback(user);
return user;
}
@@ -264,6 +272,7 @@ class User {
}
});
} else {
+ console.log(callback);
callback(user);
return user;
}
@@ -615,6 +624,8 @@ if(getWebPassword() === null) {
}
if(getCurrentUser() === null) {
+ jQuery('#modal').modal('show');
+
var url = '/client/?action=info&token=' + Sanitize.url(getWebPassword()) + '&timingToken=' + Sanitize.url(getTimingToken());
console.log(url);
@@ -623,32 +634,32 @@ if(getCurrentUser() === null) {
// sync
- http.open('GET', url, false);
- http.send(null);
+ http.addEventListener('load', function() {
+ var id = JSON.parse(http.responseText)['pubkey'];
- var id = JSON.parse(http.responseText)['pubkey'];
+ User.getUser(id, function(data) {
+ if(data === null || data === undefined) {
+ var user = new User();
- User.getUser(id, function(data) {
- if(data === null || data === undefined) {
- jQuery('#modal').modal('show');
+ user.setName('New User');
+ user.setID(id);
+ user.setIcon('<$= Template.jsTemplate("default-icon") $>');
+ user.setDescription('A new OnionrUI user');
- var user = new User();
+ user.remember();
+ user.save();
- user.setName('New User');
- user.setID(id);
- user.setIcon('<$= Template.jsTemplate("default-icon") $>');
- user.setDescription('A new OnionrUI user');
-
- user.remember();
- user.save();
-
- setCurrentUser(user);
+ setCurrentUser(user);
+ } else {
+ setCurrentUser(data);
+ }
window.location.reload();
- } else {
- setCurrentUser(data);
- }
- });
+ });
+ }, false);
+
+ http.open('GET', url, true);
+ http.send(null);
}
currentUser = getCurrentUser();
diff --git a/onionr/static-data/www/ui/src/js/timeline.js b/onionr/static-data/www/ui/src/js/timeline.js
index 9bcef854..a5af6d61 100644
--- a/onionr/static-data/www/ui/src/js/timeline.js
+++ b/onionr/static-data/www/ui/src/js/timeline.js
@@ -58,18 +58,25 @@ function postCreatorChange() {
var content = document.getElementById('onionr-post-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 = '<$= LANG.POST_CREATOR_MESSAGE_MAXIMUM_NEWLINES $>';
- } else if(content.length <= 280) {
+ } else if(content.length <= maxlength) {
// 280 max characters
message = '<$= LANG.POST_CREATOR_MESSAGE_REMAINING $>'.replaceAll('%s', (280 - content.length));
disable = false;
+
+ if(maxlength - content.length < maxlength / 4) {
+ warn = true;
+ }
} else {
- message = '<$= LANG.POST_CREATOR_MESSAGE_OVER $>'.replaceAll('%s', (content.length - 280));
+ message = '<$= LANG.POST_CREATOR_MESSAGE_OVER $>'.replaceAll('%s', (content.length - maxlength));
}
}
@@ -85,6 +92,8 @@ function postCreatorChange() {
if(disable)
element.style.color = 'red';
+ else if(warn)
+ element.style.color = '#FF8C00';
else
element.style.color = 'gray';
}
@@ -101,10 +110,11 @@ function viewProfile(id, name) {
User.getUser(id, function(data) {
if(data !== null) {
- document.getElementById("onionr-profile-username").innerHTML = Sanitize.html(data.getName());
- document.getElementById("onionr-profile-username").title = Sanitize.html(data.getID());
document.getElementById("onionr-profile-user-icon").src = "data:image/jpeg;base64," + Sanitize.html(data.getIcon());
document.getElementById("onionr-profile-user-icon").b64 = Sanitize.html(data.getIcon());
+ 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()));
}
});
}
@@ -112,24 +122,26 @@ function viewProfile(id, name) {
function updateUser() {
toggleSaveButton(false);
- jQuery('#modal').modal('show');
+ // jQuery('#modal').modal('show');
var name = jQuery('#onionr-profile-username').text();
var id = document.getElementById("onionr-profile-username").title;
var icon = document.getElementById("onionr-profile-user-icon").b64;
- var description = 'todo';
+ var description = jQuery("#onionr-profile-description").text();
var user = new User();
user.setName(name);
user.setID(id);
user.setIcon(icon);
- user.setDescription(description);
+ user.setDescription(Sanitize.description(description));
user.remember();
- user.save();
+ user.save(function() {
+ setCurrentUser(user);
- window.location.reload();
+ window.location.reload();
+ });
}
function cancelUpdate() {
@@ -142,8 +154,7 @@ function cancelUpdate() {
}
function toggleSaveButton(show) {
- document.getElementById("onionr-profile-save").style.display = (show ? 'block' : 'none');
- document.getElementById("onionr-profile-cancel").style.display = (show ? 'block' : 'none');
+ document.getElementById("onionr-profile-edit").style.display = (show ? 'block' : 'none');
}
function makePost() {
@@ -161,38 +172,56 @@ function makePost() {
document.getElementById('onionr-timeline-posts').innerHTML = post.getHTML() + document.getElementById('onionr-timeline-posts').innerHTML;
document.getElementById("onionr-post-creator-content").value = "";
+ document.getElementById("onionr-post-creator-content").focus();
postCreatorChange();
} else {
console.log('Not making empty post.');
}
}
-$('body').on('click', '[data-editable]', function() {
+jQuery('body').on('click', '[data-editable]', function() {
var el = jQuery(this);
var txt = el.text();
+ var maxlength = el.attr("maxlength");
var input = jQuery('').val(txt);
+ input.attr('maxlength', maxlength);
el.replaceWith(input);
var save = function() {
var newTxt = input.val();
- var p = el.text(Sanitize.username(newTxt));
+
+ 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);
+
input.replaceWith(p);
if(newTxt !== txt)
toggleSaveButton(true);
};
- input.one('blur', save).focus();
+ var saveEnter = function(event) {
+ console.log(event);
+ console.log(event.keyCode);
+ if (event.keyCode === 13)
+ save();
+ };
+
+ input.one('blur', save).bind('keyup', saveEnter).focus();
});
currentUser = getCurrentUser();
-
-document.getElementById("onionr-post-creator-user-name").innerHTML = Sanitize.html(currentUser.getName());
-document.getElementById("onionr-post-creator-user-id").innerHTML = "<$= LANG.POST_CREATOR_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();
-document.getElementById("onionr-post-creator-content").placeholder = "<$= LANG.POST_CREATOR_PLACEHOLDER $>";
+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 = "<$= LANG.POST_CREATOR_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();
+ document.getElementById("onionr-post-creator-content").placeholder = "<$= LANG.POST_CREATOR_PLACEHOLDER $>";
+}
viewCurrentProfile = function() {
viewProfile(encodeURIComponent(currentUser.getID()), encodeURIComponent(currentUser.getName()));