mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-08-26 22:02:18 +00:00
restyling of js/interface_profile-edit.js
This commit is contained in:
parent
058e24ba6a
commit
3fdfe0f33f
@ -15,14 +15,14 @@ function initProfileEdit() {
|
|||||||
|
|
||||||
initInterfaceCommon();
|
initInterfaceCommon();
|
||||||
|
|
||||||
$(".profile-card-photo.forEdition").click( function() { $('#avatar-file').click(); } );
|
$('.profile-card-photo.forEdition').on('click', function() { $('#avatar-file').click(); });
|
||||||
$("#avatar-file").bind( "change", handleAvatarFileSelect);
|
$('#avatar-file').on('change', handleAvatarFileSelect);
|
||||||
$(".submit-changes").click( saveProfile );
|
$('.submit-changes').on('click', saveProfile);
|
||||||
$(".cancel-changes").click( $.MAL.goHome );
|
$('.cancel-changes').on('click', $.MAL.goHome);
|
||||||
|
|
||||||
initUser( function() {
|
initUser(function() {
|
||||||
if( !defaultScreenName ) {
|
if (!defaultScreenName) {
|
||||||
alert(polyglot.t("username_undefined"));
|
alert(polyglot.t('username_undefined'));
|
||||||
$.MAL.goLogin();
|
$.MAL.goLogin();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -35,90 +35,85 @@ function initProfileEdit() {
|
|||||||
initDMsCount();
|
initDMsCount();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".profile-card-main h2").text("@" + defaultScreenName);
|
$('.profile-card-main h2').text('@' + defaultScreenName);
|
||||||
loadAvatarForEdit();
|
loadAvatarForEdit();
|
||||||
loadProfileForEdit();
|
loadProfileForEdit();
|
||||||
|
|
||||||
$(".secret-key-container").hide();
|
$('.secret-key-container').hide();
|
||||||
|
|
||||||
$(".toggle-priv-key").click(function () {
|
$('.toggle-priv-key').on('click', function () {
|
||||||
if ($(".secret-key-container").is(":visible")) {
|
if ($('.secret-key-container').is(':visible')) {
|
||||||
$(".secret-key-container").fadeOut(function () {
|
$('.secret-key-container').fadeOut(function () {
|
||||||
$(".secret-key").text('');
|
$('.secret-key').text('');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
dumpPrivkey(defaultScreenName, function(args, key) {
|
dumpPrivkey(defaultScreenName, function(args, key) {
|
||||||
$(".secret-key").text(key);
|
$('.secret-key').text(key);
|
||||||
$(".secret-key-container").fadeIn();
|
$('.secret-key-container').fadeIn();
|
||||||
}, {});
|
}, {});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAvatarFileSelect(evt) {
|
function handleAvatarFileSelect(event) {
|
||||||
var files = evt.target.files; // FileList object
|
var files = event.target.files; // FileList object
|
||||||
var f = files[0];
|
var file = files[0];
|
||||||
|
|
||||||
// Only process image files.
|
// Only process image files.
|
||||||
if (f.type.match('image.*')) {
|
if (file.type.match('image.*')) {
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
|
|
||||||
reader.onload=function(e){
|
reader.onload = function(event) {
|
||||||
var img=new Image();
|
var img = new Image();
|
||||||
img.onload=function(){
|
img.onload = function() {
|
||||||
var MAXWidthHeight=64;
|
var MAXWidthHeight = 64;
|
||||||
var r=MAXWidthHeight/Math.max(this.width,this.height),
|
var ratio = MAXWidthHeight / Math.max(this.width, this.height);
|
||||||
w=Math.round(this.width*r),
|
var canvas = document.createElement('canvas');
|
||||||
h=Math.round(this.height*r),
|
canvas.width = Math.round(this.width * ratio);
|
||||||
c=document.createElement("canvas");
|
canvas.height = Math.round(this.height * ratio);
|
||||||
c.width=w;c.height=h;
|
canvas.getContext('2d').drawImage(this, 0, 0, canvas.width, canvas.height);
|
||||||
c.getContext("2d").drawImage(this,0,0,w,h);
|
|
||||||
|
|
||||||
var imgURL = undefined;
|
var imgURL = undefined;
|
||||||
for(var q = 0.9; (!imgURL || imgURL.length > 4096) && q > 0.1; q -= 0.01) {
|
for (var quality = 1.0; (!imgURL || imgURL.length > 4096) && quality > 0.1; quality -= 0.01) {
|
||||||
imgURL = c.toDataURL("image/jpeg", q);
|
imgURL = canvas.toDataURL('image/jpeg', quality);
|
||||||
}
|
}
|
||||||
$(".profile-card-photo.forEdition").attr("src", imgURL );
|
$('.profile-card-photo.forEdition').attr('src', imgURL);
|
||||||
}
|
}
|
||||||
img.src=e.target.result;
|
img.src = event.target.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read in the image file as a data URL.
|
// Read in the image file as a data URL.
|
||||||
reader.readAsDataURL(f);
|
reader.readAsDataURL(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function verifyUserAlreadyInBlockchain()
|
function verifyUserAlreadyInBlockchain() {
|
||||||
{
|
$.MAL.disableButton($('.submit-changes'));
|
||||||
$.MAL.disableButton($(".submit-changes"));
|
|
||||||
|
|
||||||
dumpPubkey(defaultScreenName, function(args, pubkey) {
|
dumpPubkey(defaultScreenName, function(args, pubkey) {
|
||||||
//pubkey = "";
|
if (pubkey.length > 0) {
|
||||||
if( pubkey.length > 0 ) {
|
|
||||||
follow('twister', true, function() {
|
follow('twister', true, function() {
|
||||||
$.MAL.enableButton($(".submit-changes"));
|
$.MAL.enableButton($('.submit-changes'));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if( !newUserWarnDisplayed ) {
|
if (!newUserWarnDisplayed) {
|
||||||
alert(polyglot.t("user_not_yet_accepted"));
|
alert(polyglot.t('user_not_yet_accepted'));
|
||||||
newUserWarnDisplayed = true;
|
newUserWarnDisplayed = true;
|
||||||
}
|
}
|
||||||
setTimeout("verifyUserAlreadyInBlockchain()", 5000);
|
setTimeout(verifyUserAlreadyInBlockchain, 5000);
|
||||||
}
|
}
|
||||||
}, {} );
|
}, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
function localizePlaceholders()
|
function localizePlaceholders() {
|
||||||
{
|
$('.input-name').attr('placeholder', polyglot.t('Full name here'));
|
||||||
$(".input-name").attr("placeholder",polyglot.t("Full name here"));
|
$('.input-description').attr('placeholder', polyglot.t('Describe yourself'));
|
||||||
$(".input-description").attr("placeholder",polyglot.t("Describe yourself"));
|
$('.input-city').attr('placeholder', polyglot.t('Location'));
|
||||||
$(".input-city").attr("placeholder",polyglot.t("Location"));
|
$('.input-website').attr('placeholder', polyglot.t('website'));
|
||||||
$(".input-website").attr("placeholder",polyglot.t("website"));
|
$('.input-tox').attr('placeholder', polyglot.t('Tox address'));
|
||||||
$(".input-tox").attr("placeholder",polyglot.t("Tox address"));
|
$('.input-bitmessage').attr('placeholder', polyglot.t('Bitmessage address'));
|
||||||
$(".input-bitmessage").attr("placeholder",polyglot.t("Bitmessage address"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(localizePlaceholders);
|
$(document).ready(localizePlaceholders);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user