У меня сейчас ощущение как у главного героя первой серии первого сезона Black Mirror после того как он сделал то, что его заставили сделать

This commit is contained in:
Nokita Kaze 2014-12-30 17:57:43 +03:00
parent 96dbb19ea4
commit 17b7274665
1 changed files with 12 additions and 12 deletions

View File

@ -1105,7 +1105,8 @@ function hints_draw_main_user_hint(items) {
current_text = items[current_user_name]; current_text = items[current_user_name];
} }
var text_block = document.createElement('div'); var text_block = document.createElement('div');
$(text_block).addClass('text').html(hints_raw_text_to_html(current_text)); $(text_block).addClass('text');
safe_saned_text(current_text, $(text_block));
current_user_hint_block.appendChild(text_block); current_user_hint_block.appendChild(text_block);
// Рисуем невидимый блок для управления // Рисуем невидимый блок для управления
@ -1116,7 +1117,7 @@ function hints_draw_main_user_hint(items) {
$(change_hint_block).find('.button_save').on('click', function() { $(change_hint_block).find('.button_save').on('click', function() {
$('.current-user-hint .change_hint_block').slideUp(500); $('.current-user-hint .change_hint_block').slideUp(500);
var new_text = $('.current-user-hint .change_hint_block textarea').val(); var new_text = $('.current-user-hint .change_hint_block textarea').val();
$('.current-user-hint > .text').hide().html(hints_raw_text_to_html(new_text)).fadeIn(750); safe_saned_text(new_text, $('.current-user-hint > .text').hide().fadeIn(750));
hints_save_new_hint(current_user_name, new_text); hints_save_new_hint(current_user_name, new_text);
}); });
$(change_hint_block).find('.button_cancel').on('click', function() { $(change_hint_block).find('.button_cancel').on('click', function() {
@ -1125,16 +1126,15 @@ function hints_draw_main_user_hint(items) {
current_user_hint_block.appendChild(change_hint_block); current_user_hint_block.appendChild(change_hint_block);
} }
// Превращаем сырой текст в нормальный, обёрнутый в p // Nokita Kaze снимает с себя все претензии по этому коду, обращайтесь к фаундеру проекта
function hints_raw_text_to_html(text) { function safe_saned_text(text, object) {
text = text var n = text.split(/\r?\n/);
.replace('&', "&") object.text('');
.replace('<', "&lt;") for (var i = 0; i < n.length; i++) {
.replace('>', "&gt;") var d = document.createElement('p');
.replace('"', "&quot;") $(d).text(n[i]);
.replace("'", "&#039;") object[0].appendChild(d);
.replace(/\r?\n/g, "</p><p>") }
return '<p>' + text + '</p>';
} }
// Рисуем title'ы на всех доступных пользователях, точнее на их аватарках // Рисуем title'ы на всех доступных пользователях, точнее на их аватарках