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",