diff --git a/js/interface_localization.js b/js/interface_localization.js index 7eb855f..7af4233 100644 --- a/js/interface_localization.js +++ b/js/interface_localization.js @@ -43,6 +43,7 @@ if(preferredLanguage == "en"){ "Block generation": "Block generation ", "busted_oh": "oh noes!", "busted_avowal": "I\'m busted trying inject this suspicious stuff here", + "btn_ok": "Okay", "Cancel": "Cancel", "Confirm": "Confirm", "сonfirm_group_leaving_header": "Confirm group leaving", @@ -203,6 +204,8 @@ if(preferredLanguage == "en"){ "Terminate Daemon:": "Terminate Daemon:", "Exit": "Exit", "Save Changes": "Save Changes", + "profile_saved": "Profile data has been saved to DHT.", + "profile_not_saved": "Profile data has been not saved.", "Secret key:": "Secret key:", "You have to log in to post messages.": "You have to log in to post messages.", "You have to log in to post replies.": "You have to log in to post replies.", @@ -360,6 +363,7 @@ if(preferredLanguage == "es"){ "Block generation": "Generación de bloques ", "busted_oh": "oh noes!", "busted_avowal": "I\'m busted trying inject this suspicious stuff here", + "btn_ok": "Okay", "Cancel": "Cancelar", "Confirm": "Confirm", "сonfirm_group_leaving_header": "Confirm group leaving", @@ -520,6 +524,8 @@ if(preferredLanguage == "es"){ "Terminate Daemon:": "Terminar Demonio:", "Exit": "Salir", "Save Changes": "Guardar cambios", + "profile_saved": "Profile data has been saved to DHT.", + "profile_not_saved": "Profile data has been not saved.", "Secret key:": "Clave secreta:", "You have to log in to post messages.": "Debes estar logueado para escribir mensajes.", "You have to log in to post replies.": "Debes estar logueado para escribir respuestas.", @@ -661,6 +667,7 @@ if(preferredLanguage == "uk"){ "Block generation": "Генерація блоку ", "busted_oh": "oh noes!", "busted_avowal": "I\'m busted trying inject this suspicious stuff here", + "btn_ok": "Okay", "Cancel": "Відміна", "Confirm": "Confirm", "сonfirm_group_leaving_header": "Confirm group leaving", @@ -818,6 +825,8 @@ if(preferredLanguage == "uk"){ "Terminate Daemon:": "Зупинити Twister:", "Exit": "Вихід", "Save Changes": "Зберегти зміни", + "profile_saved": "Profile data has been saved to DHT.", + "profile_not_saved": "Profile data has been not saved.", "Secret key:": "Секретний ключ:", "You have to log in to post messages.": "Ви повинні увійти для публікації повідомлень.", "You have to log in to post replies.": "Ви повинні увійти для публікації відповідей.", @@ -961,6 +970,7 @@ if(preferredLanguage == "zh-CN"){ "Block generation": "区块生成器", "busted_oh": "噢,阻挡!", "busted_avowal": "系统检测到此用户试图在这里注入恶意代码", + "btn_ok": "Okay", "Cancel": "取消", "Confirm": "Confirm", "сonfirm_group_leaving_header": "Confirm group leaving", @@ -1120,6 +1130,8 @@ if(preferredLanguage == "zh-CN"){ "Terminate Daemon:": "终止后台进程:", "Exit": "退出", "Save Changes": "保存更改", + "profile_saved": "Profile data has been saved to DHT.", + "profile_not_saved": "Profile data has been not saved.", "Secret key:": "私钥:", "You have to log in to post messages.": "你必须登录才能发送信息。", "You have to log in to post replies.": "你必须登录才能发送回复。", @@ -1278,6 +1290,7 @@ if(preferredLanguage == "nl"){ "Block generation": "Block productie", "busted_oh": "oh noes!", "busted_avowal": "I\'m busted trying inject this suspicious stuff here", + "btn_ok": "Okay", "Cancel": "Annuleren", "Confirm": "Confirm", "сonfirm_group_leaving_header": "Confirm group leaving", @@ -1438,6 +1451,8 @@ if(preferredLanguage == "nl"){ "Terminate Daemon:": "Daemon beëindigen", "Exit": "Beëindigen", "Save Changes": "Opslaan", + "profile_saved": "Profile data has been saved to DHT.", + "profile_not_saved": "Profile data has been not saved.", "Secret key:": "Geheime sleutel:", "You have to log in to post messages.": "You have to log in to post messages.", "You have to log in to post replies.": "You have to log in to post replies.", @@ -1579,6 +1594,7 @@ if(preferredLanguage == "it"){ "Block generation": "Generatore di blocchi:", "busted_oh": "oh noes!", "busted_avowal": "I\'m busted trying inject this suspicious stuff here", + "btn_ok": "Okay", "Cancel": "Cancella", "Confirm": "Confirm", "сonfirm_group_leaving_header": "Confirm group leaving", @@ -1736,6 +1752,8 @@ if(preferredLanguage == "it"){ "Terminate Daemon:": "Terminate Daemon:", "Exit": "Exit", "Save Changes": "Save Changes", + "profile_saved": "Profile data has been saved to DHT.", + "profile_not_saved": "Profile data has been not saved.", "Secret key:": "Secret key:", "You have to log in to post messages.": "You have to log in to post messages.", "You have to log in to post replies.": "You have to log in to post replies.", @@ -1877,6 +1895,7 @@ if(preferredLanguage == "fr"){ "Block generation": "Production de blocs", "busted_oh": "oh noes!", "busted_avowal": "I\'m busted trying inject this suspicious stuff here", + "btn_ok": "Okay", "Cancel": "Annuler", "Confirm": "Confirm", "сonfirm_group_leaving_header": "Confirm group leaving", @@ -2037,6 +2056,8 @@ if(preferredLanguage == "fr"){ "Terminate Daemon:": "Tuer le démon:", "Exit": "Quitter", "Save Changes": "Sauvegarder les changements", + "profile_saved": "Profile data has been saved to DHT.", + "profile_not_saved": "Profile data has been not saved.", "Secret key:": "Clef secrète:", "You have to log in to post messages.": "You have to log in to post messages.", "You have to log in to post replies.": "You have to log in to post replies.", @@ -2180,6 +2201,7 @@ if(preferredLanguage == "ru"){ "Block generation": "Майнинг блоков ", "busted_oh": "о нет!", "busted_avowal": "я пойман на попытке вставить этот подозрительный код здесь", + "btn_ok": "Лады́", "Cancel": "Отмена", "Confirm": "Несомненно", "сonfirm_group_leaving_header": "Подтверждение ухода из группы", @@ -2340,6 +2362,8 @@ if(preferredLanguage == "ru"){ "Terminate Daemon:": "Остановить twister:", "Exit": "Выход", "Save Changes": "Сохранить изменения", + "profile_saved": "Данные профайла сохранены в DHT.", + "profile_not_saved": "Данные профайла не сохранены.", "Secret key:": "Секретный ключ:", "You have to log in to post messages.": "Войдите, чтобы отправлять сообщения.", "You have to log in to post replies.": "Войдите, чтобы отвечать на сообщения.", @@ -2486,6 +2510,7 @@ if(preferredLanguage == "de"){ "Block generation": "Block-Generierung ", "busted_oh": "Oh nein!", "busted_avowal": "Ich bin ertappt, habe versucht, hier Schadcode einzugeben!", + "btn_ok": "Okay", "Cancel": "Abbrechen", "Confirm": "Confirm", "сonfirm_group_leaving_header": "Confirm group leaving", @@ -2647,6 +2672,8 @@ if(preferredLanguage == "de"){ "Terminate Daemon:": "Daemon beenden:", "Exit": "Beenden", "Save Changes": "Änderungen speichern", + "profile_saved": "Profile data has been saved to DHT.", + "profile_not_saved": "Profile data has been not saved.", "Secret key:": "Privater Schlüssel:", "You have to log in to post messages.": "You have to log in to post messages.", "You have to log in to post replies.": "You have to log in to post replies.", @@ -2789,6 +2816,7 @@ if(preferredLanguage == "ja"){ "Block generation": "ブロック生成", "busted_oh": "oh noes!", "busted_avowal": "I\'m busted trying inject this suspicious stuff here", + "btn_ok": "Okay", "Cancel": "キャンセル", "Confirm": "Confirm", "сonfirm_group_leaving_header": "Confirm group leaving", @@ -2946,6 +2974,8 @@ if(preferredLanguage == "ja"){ "Terminate Daemon:": "デーモンを終了する:", "Exit": "終了", "Save Changes": "変更を保存", + "profile_saved": "Profile data has been saved to DHT.", + "profile_not_saved": "Profile data has been not saved.", "Secret key:": "シークレットキー:", "You have to log in to post messages.": "You have to log in to post messages.", "You have to log in to post replies.": "You have to log in to post replies.", @@ -3088,6 +3118,7 @@ if(preferredLanguage == "pt-BR"){ "Block generation": "Geração de blocos ", "busted_oh": "oh noes!", "busted_avowal": "I\'m busted trying inject this suspicious stuff here", + "btn_ok": "Okay", "Cancel": "Cancelar", "Confirm": "Confirm", "сonfirm_group_leaving_header": "Confirm group leaving", @@ -3249,6 +3280,8 @@ if(preferredLanguage == "pt-BR"){ "Terminate Daemon:": "Encerrar a execução do Cliente do Twister", "Exit": "Sair", "Save Changes": "Salvar Alterações", + "profile_saved": "Profile data has been saved to DHT.", + "profile_not_saved": "Profile data has been not saved.", "Secret Key": "Chave Secreta", // não existia "Secret key:": "Chave secreta:", "You have to log in to post messages.": "You have to log in to post messages.", @@ -3391,6 +3424,7 @@ if(preferredLanguage == "tr"){ "Block generation": "Blok üretimi ", "busted_oh": "oh noes!", "busted_avowal": "I\'m busted trying inject this suspicious stuff here", + "btn_ok": "Okay", "Cancel": "İptal", "Confirm": "Confirm", "сonfirm_group_leaving_header": "Confirm group leaving", @@ -3550,6 +3584,8 @@ if(preferredLanguage == "tr"){ "Terminate Daemon:": "Servisi Durdur:", "Exit": "Çıkış", "Save Changes": "Değişiklikleri Kaydet", + "profile_saved": "Profile data has been saved to DHT.", + "profile_not_saved": "Profile data has been not saved.", "Secret key:": "Gizli anahtar:", "Options": "Ayarlar", "Switch to Promoted posts": "Destekli Mesajlara Geç", @@ -3691,6 +3727,7 @@ if(preferredLanguage == "cs"){ "Block generation": "Generování bloků ", "busted_oh": "oh noes!", "busted_avowal": "I\'m busted trying inject this suspicious stuff here", + "btn_ok": "Okay", "Cancel": "Zrušit", "Confirm": "Confirm", "сonfirm_group_leaving_header": "Confirm group leaving", @@ -3849,6 +3886,8 @@ if(preferredLanguage == "cs"){ "Terminate Daemon:": "Ukončit server:", "Exit": "Konec", "Save Changes": "Uložit změny", + "profile_saved": "Profile data has been saved to DHT.", + "profile_not_saved": "Profile data has been not saved.", "Secret key:": "Tajný klíč:", "You have to log in to post messages.": "Pro vkládání příspěvků je třeba se přihlásit.", "You have to log in to post replies.": "Pro vkládání odpovědí je třeba se přihlásit.", diff --git a/js/twister_user.js b/js/twister_user.js index 002a51c..c154de9 100644 --- a/js/twister_user.js +++ b/js/twister_user.js @@ -261,24 +261,59 @@ function loadProfileForEdit() { }, {} ); } -function saveProfile(e) -{ - var profile = {}; - profile["fullname"] = $(".input-name").val(); - profile["bio"] = $(".input-description").val(); - profile["location"] = $(".input-city").val(); - profile["url"] = $(".input-website").val(); - var tox = $(".input-tox").val(); - if( tox.length ) - profile["tox"] = tox; - var bitmessage = $(".input-bitmessage").val(); - if( bitmessage.length ) - profile["bitmessage"] = bitmessage; - dhtput( defaultScreenName, "profile", "s", - profile, defaultScreenName, ++profileSeqNum ); - var avatarData = $(".profile-card-photo.forEdition").attr("src"); - dhtput( defaultScreenName, "avatar", "s", - avatarData, defaultScreenName, ++avatarSeqNum ); - clearAvatarAndProfileCache(defaultScreenName); +function saveProfile(e) { + function saveAvatar(req, isProfileDataSaved) { + dhtput(defaultScreenName, 'avatar', 's', + req.avatarImgSrc, + defaultScreenName, ++avatarSeqNum, + completeProfileSaving, {isProfileDataSaved: isProfileDataSaved} + ); + } + + function completeProfileSaving(req, isAvatarDataSaved) { + if (req.isProfileDataSaved && isAvatarDataSaved) { + clearAvatarAndProfileCache(defaultScreenName); + var titleTxt = ''; + var messageTxt = polyglot.t('profile_saved'); + } else { + var titleTxt = polyglot.t('error', {error: ''}); + var messageTxt = polyglot.t('profile_not_saved'); + } + confirmPopup(null, { + titleTxt: titleTxt, + messageTxt: messageTxt, + confirmTxt: polyglot.t('btn_ok'), + confirmFunc: $.MAL.enableButton, + confirmFuncArgs: $('.submit-changes'), + closeFunc: 'confirmFunc', + removeCancel: true + }); + } + + $.MAL.disableButton($('.submit-changes')); + + dhtput(defaultScreenName, 'profile', 's', + setObjPropFromElemVal({}, { + fullname: '.input-name', + bio: '.input-description', + location: '.input-city', + url: '.input-website', + tox: '.input-tox', + bitmessage: '.input-bitmessage' + }), + defaultScreenName, ++profileSeqNum, + saveAvatar, {avatarImgSrc: $('.profile-card-photo.forEdition').attr('src')} + ); } +function setObjPropFromElemVal(object, req) { + var props = Object.getOwnPropertyNames(req); // req's props names will be object's props names + + for (var i = 0; i < props.length; i++) { + elem = $(req[props[i]]); // req's props values are elements selectors + if (elem.length && elem.val()) + object[props[i]] = elem.val(); + } + + return object; +} diff --git a/profile-edit.html b/profile-edit.html index 3335852..5217f7c 100644 --- a/profile-edit.html +++ b/profile-edit.html @@ -27,8 +27,8 @@
- - + +