From 3d9e54b62df8226a6f4e37e5d88e4db3055c5f03 Mon Sep 17 00:00:00 2001 From: Nokita Kaze Date: Mon, 24 Nov 2014 16:20:19 +0300 Subject: [PATCH] =?UTF-8?q?*=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20debug-=D0=BF=D0=BB=D0=B0=D1=88=D0=BA=D1=83=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20Point+=20+=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=B0=D0=B2=D1=82=D0=BE=D1=81=D0=BE=D1=85=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=87=D0=B5=D1=80=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=B8=D0=BA=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chrome_point_plus/css/point-plus.css | 31 +++++++++++---- chrome_point_plus/js/point-plus.js | 57 ++++++++++++++++++++++++++-- chrome_point_plus/manifest.json | 2 +- 3 files changed, 77 insertions(+), 13 deletions(-) diff --git a/chrome_point_plus/css/point-plus.css b/chrome_point_plus/css/point-plus.css index 7ede9c6..5957d16 100644 --- a/chrome_point_plus/css/point-plus.css +++ b/chrome_point_plus/css/point-plus.css @@ -215,14 +215,10 @@ div#markItUpText-input { /* point-plus-debug */ .point-plus-debug{ - position: absolute; - padding: 10px 20px; - top: 60px; - left: 20px; - border-radius: 3px; - border: 1px solid #333;/* @todo Сделать не такой галимый */ - background-color: #ddd;/* @todo Аналогично */ - z-index: 11; + float: right; + display: block; + color: rgba(255,255,255,.75); + padding: 10px 0px; } .post-tag-nsfw.hide-nsfw-posts, @@ -230,3 +226,22 @@ div#markItUpText-input { display: none; } +/* Черновики */ +#new-post-form #text-input{ + height: 30em !important; +} + +#new-post-form .draft_save_status{ + display: none; + padding: 3px 5px; + color: green; +} + + + + + + + + + diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index fe57b71..b7c7ef7 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -14,11 +14,17 @@ $(document).ready(function() { } point_plus_debug = null; var new_div = document.createElement('div'); - document.body.appendChild(new_div); $(new_div).attr({ - 'data-point-plus-version':getVersion() - }).addClass('point-plus-debug').html('Point+ v' + getVersion() + ' loading...').hide(); + 'data-point-plus-version': getVersion() + }).addClass('point-plus-debug').html('Point+ v' + getVersion() + ' loading...'); + var obj = $('#user-menu-cb')[0]; + obj.parentElement.insertBefore(new_div, obj); new_div = null; + obj = null; + + // Черновики. Ставим хандлер и восстанавливаем предыдущее состояние + draft_set_save_handler(); + draft_restore(); // Loading options chrome.storage.sync.get('options', function(options_data) { @@ -894,4 +900,47 @@ function space_key_event() { return; } } -} \ No newline at end of file +} + +/* Автосохранение черновиков */ +var draft_last_text = '';// Последний зафиксированный текст +function draft_restore() { + chrome.storage.sync.get('point_draft_text', function(items) { + $('#new-post-form #text-input').val(items.point_draft_text); + draft_last_text=items.point_draft_text; + }); +} + +function draft_set_save_handler() { + setInterval(draft_save_check, 5000); + $('#new-post-wrap .footnote').html($('#new-post-wrap .footnote').html() + '
'); +} + +var draft_save_busy = false; +function draft_save_check() { + if (draft_save_busy) { + return; + } + draft_save_busy = true; + + // Видишь поиск id внутри id?.. ненавидишь меня? + var current_text = $('#new-post-form #text-input').val(); + if (draft_last_text == current_text) { + draft_save_busy = false; + return; + } + // @todo i18n + $('.draft_save_status').html('Сохраняем черновик...').show(); + + // Сохраняем + draft_last_text=current_text; + // Save it using the Chrome extension storage API. + chrome.storage.sync.set({'point_draft_text': draft_last_text}, function() { + // Notify that we saved. + draft_save_busy=false; + $('.draft_save_status').html('Черновик сохранён...'); + setTimeout(function(){ + $('.draft_save_status').fadeOut(500); + }, 1000); + }); +} diff --git a/chrome_point_plus/manifest.json b/chrome_point_plus/manifest.json index 58c27d9..213ad92 100644 --- a/chrome_point_plus/manifest.json +++ b/chrome_point_plus/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Point+", - "version": "1.15.1", + "version": "1.16.0", "default_locale": "ru", "author": "__MSG_ext_author__", "homepage_url": "https://bitbucket.org/skobkin/chrome_point_plus",