From 429c432dc599adbbc19fd341ec8936f9f040dcc1 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Tue, 27 Jan 2015 02:55:15 +0300 Subject: [PATCH 1/6] =?UTF-8?q?=D0=92=D1=81=D1=82=D1=80=D0=B0=D0=B8=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B5=20Instagram=20=D0=B8=D0=B7=20pull=20re?= =?UTF-8?q?quest=20#25.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chrome_point_plus/_locales/en/messages.json | 6 +++ chrome_point_plus/_locales/ru/messages.json | 6 +++ chrome_point_plus/css/point-plus.css | 4 +- chrome_point_plus/js/bquery_ajax.js | 18 +++++++ chrome_point_plus/js/point-plus.js | 52 +++++++++++++++++++++ chrome_point_plus/manifest.json | 1 + chrome_point_plus/options.html | 10 ++++ 7 files changed, 95 insertions(+), 2 deletions(-) diff --git a/chrome_point_plus/_locales/en/messages.json b/chrome_point_plus/_locales/en/messages.json index 4871642..28ec701 100644 --- a/chrome_point_plus/_locales/en/messages.json +++ b/chrome_point_plus/_locales/en/messages.json @@ -95,6 +95,12 @@ "option_embedding_twitter_tweets": { "message": "Twitter" }, + "option_embedding_instagram_posts": { + "message": "Instagram" + }, + "option_embedding_instagram_posts_orig_link": { + "message": "Leave original link" + }, "option_nsfw": { "message": "NSFW content filtering" }, diff --git a/chrome_point_plus/_locales/ru/messages.json b/chrome_point_plus/_locales/ru/messages.json index 8d6b14d..deab3f5 100644 --- a/chrome_point_plus/_locales/ru/messages.json +++ b/chrome_point_plus/_locales/ru/messages.json @@ -95,6 +95,12 @@ "option_embedding_twitter_tweets": { "message": "Twitter" }, + "option_embedding_instagram_posts": { + "message": "Instagram" + }, + "option_embedding_instagram_posts_orig_link": { + "message": "Не убирать ссылку" + }, "option_nsfw": { "message": "Фильтрация NSFW-контента" }, diff --git a/chrome_point_plus/css/point-plus.css b/chrome_point_plus/css/point-plus.css index 5c7ab56..dd943dc 100644 --- a/chrome_point_plus/css/point-plus.css +++ b/chrome_point_plus/css/point-plus.css @@ -28,12 +28,12 @@ div#markItUpText-input { } /* Auto-loaded Booru pictures */ -.booru_pic { +.booru_pic, .instagram-post-embedded { display: block !important; float: none !important; } -.booru_pic img { +.booru_pic img, .instagram-post-embedded img { border: none; max-width: 60%; max-height: 300px; diff --git a/chrome_point_plus/js/bquery_ajax.js b/chrome_point_plus/js/bquery_ajax.js index 553c39c..72a7603 100644 --- a/chrome_point_plus/js/bquery_ajax.js +++ b/chrome_point_plus/js/bquery_ajax.js @@ -1,3 +1,6 @@ +/** + * @deprecated since 1.36.0 + */ function $ajax_prot(settings){ if (settings==undefined){return;} if (settings['url'] ==undefined){return;}this.url=settings['url']; @@ -46,8 +49,14 @@ $ajax_prot.prototype={ $ajax=function (settings){return new $ajax_prot(settings);} +/** + * @deprecated since 1.36.0 + */ function urlencode(text){return encodeURIComponent(text);} +/** + * @deprecated since 1.36.0 + */ function sad_safe_reg(text){ var ar='.-\\/[]{}?+'; var s=''; for (var i=0;i + +
+ + + + +
From 684f6c15fe4131ad5a5e2f91ccbffc875eb3885f Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Tue, 27 Jan 2015 03:55:15 +0300 Subject: [PATCH 2/6] Post draft saving with option and some optimization. --- chrome_point_plus/_locales/en/messages.json | 10 +- chrome_point_plus/_locales/ru/messages.json | 10 +- chrome_point_plus/js/point-plus.js | 108 ++++++++++++++++---- chrome_point_plus/options.html | 5 + 4 files changed, 108 insertions(+), 25 deletions(-) diff --git a/chrome_point_plus/_locales/en/messages.json b/chrome_point_plus/_locales/en/messages.json index 28ec701..d4d86ca 100644 --- a/chrome_point_plus/_locales/en/messages.json +++ b/chrome_point_plus/_locales/en/messages.json @@ -178,10 +178,13 @@ "message": "Your hints about users" }, "option_other_comments_count_refresh":{ - "message": "Refresh unread posts and comments count in left menu" + "message": "Refresh unread posts and comments count in the sidebar" }, "option_other_comments_count_refresh_title":{ - "message": "Show counts in the title of tabs" + "message": "Page title" + }, + "option_other_post_draft_save":{ + "message": "Save post drafts" }, "options_feedback_text": { @@ -191,5 +194,8 @@ "msg_comment_send_failed":{ "message": "Comment send error:" + }, + "msg_saving_post_draft":{ + "message": "Saving the post..." } } diff --git a/chrome_point_plus/_locales/ru/messages.json b/chrome_point_plus/_locales/ru/messages.json index deab3f5..9bab77a 100644 --- a/chrome_point_plus/_locales/ru/messages.json +++ b/chrome_point_plus/_locales/ru/messages.json @@ -178,10 +178,13 @@ "message": "Заметки о пользователях на полях" }, "option_other_comments_count_refresh":{ - "message": "Обновляем количество непрочитанных комментариев и постов в ленте" + "message": "Обновление количества непрочитанных постов и комментариев в сайдбаре" }, "option_other_comments_count_refresh_title":{ - "message": "Указываем кол-во комментариев и сообщений в заголовке страницы" + "message": "В заголовке страницы" + }, + "option_other_post_draft_save":{ + "message": "Сохранение черновика поста" }, @@ -192,5 +195,8 @@ "msg_comment_send_failed":{ "message": "Ошибка отправки комментария:" + }, + "msg_saving_post_draft":{ + "message": "Сохранение поста..." } } diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index a9699c8..d166d63 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -33,11 +33,6 @@ function PointPlus(ppVersion) { }).text('Point+ ' + ppVersion + ' loading...') .insertBefore('#user-menu-cb'); - // Черновики. Ставим хандлер и восстанавливаем предыдущее состояние - draft_set_save_handler(); - draft_restore(); - - // Loading options chrome.storage.sync.get('options', function(sync_data) { var options = new OptionsManager(sync_data.options); @@ -616,6 +611,12 @@ function PointPlus(ppVersion) { if (options.is('option_embedding_twitter_tweets')) { twitter_tweet_embedding_init(); } + + // Post drafts + if (options.is('option_other_post_draft_save')) { + draft_set_save_handler(); + draft_restore(); + } $('#point-plus-debug').fadeOut(1000); }); @@ -1104,50 +1105,115 @@ function space_key_event() { } } -/* Автосохранение черновиков */ -var draft_last_text = ''; // Последний зафиксированный текст -// Восстанавливаем черновик +/** + * Last draft text + * @type {string} + */ +var draft_last_text = ''; + +/** + * Last draft tags + * @type {string} + */ +var draft_last_tags = ''; + +/** + * Is extension now saving draft + * @type {boolean} + */ +var draft_save_busy = false; + +/** + * Last draft saving time + * @type {Date|null} + */ +var draft_save_last_time = null; + +/** + * Is draft now saving or not + * @type {boolean} + */ +var draft_save_busy = false; + +/** + * Is there any setTimeout'ed handlers + * @type {boolean} + */ +var draft_waiting = false; + +/** + * Restore draft from localStorage + */ function draft_restore() { - chrome.storage.local.get('point_draft_text', function(items) { - if ($('#new-post-form #text-input').val() == '') { + chrome.storage.local.get(['point_draft_text', 'point_draft_tags'], function(items) { + if ($('#new-post-form #text-input').val() === '') { $('#new-post-form #text-input').val(items.point_draft_text); draft_last_text = items.point_draft_text; } + if ($('#new-post-form #tags-input').val() === '') { + $('#new-post-form #tags-input').val(items.point_draft_tags); + draft_last_tags = items.point_draft_tags; + } }); } -// Установка хандлера +/** + * Set draft save handler + */ function draft_set_save_handler() { - // Господи, прости меня грешного за эту строку. Меня вынудили - $('#text-input').on('keyup', function(){ + $('#text-input, #tags-input').on('keyup', function() { draft_save_check(); + // For last keyup + if (!draft_waiting) { + setTimeout(draft_save_check, 3000); + draft_waiting = true; + } }); + // Adding span indicator $('#new-post-wrap .footnote').append($('')); } -var draft_save_busy = false; -// Фукнция, дёргающаяся по крону, проверяющая надо ли сохранять черновик +/** + * Check if we can save the draft now + */ function draft_save_check() { if (draft_save_busy) { return; } - draft_save_busy = true; + + if (draft_save_last_time !== null) { + if ((new Date()).getTime() < draft_save_last_time.getTime() + 3000) { + return; + } + } var current_text = $('#new-post-form #text-input').val(); - if (draft_last_text == current_text) { + var current_tags = $('#new-post-form #tags-input').val(); + + if ((draft_last_text === current_text) && (draft_last_tags === current_tags)) { draft_save_busy = false; return; } + + draft_save_busy = true; + draft_save_last_time = new Date(); + // @todo i18n - $('#draft-save-status').text('Сохраняем черновик...').show(); + $('#draft-save-status').text(chrome.i18n.getMessage('msg_saving_post_draft')).show(); - // Сохраняем + // Saving current data draft_last_text = current_text; + draft_last_tags = current_tags; + // Save it using the Chrome extension storage API. - chrome.storage.local.set({'point_draft_text': draft_last_text}, function() { + chrome.storage.local.set({ + point_draft_text: draft_last_text, + point_draft_tags: draft_last_tags + }, function() { // Notify that we saved. draft_save_busy = false; - $('#draft-save-status').text('Черновик сохранён...'); + draft_waiting = false; + setTimeout(function() { $('#draft-save-status').fadeOut(1000); }, 1000); diff --git a/chrome_point_plus/options.html b/chrome_point_plus/options.html index e8bb3d7..6297b72 100644 --- a/chrome_point_plus/options.html +++ b/chrome_point_plus/options.html @@ -256,6 +256,11 @@ + +
From aa7b9649d170706b8295341437bd00abd640a847 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Tue, 27 Jan 2015 03:59:05 +0300 Subject: [PATCH 3/6] Twitter fix. --- chrome_point_plus/js/point-plus.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index d166d63..464867b 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -1592,25 +1592,21 @@ function twitter_tweet_embedding_wait_for_ready_injected() { function twitter_tweet_embedding_parse_links() { // Обрабатываем все твиты var twitter_tweet_count = 0; - $('.post-content a').each(function(num, obj) { - if ($(obj).hasClass('booru_pic')) { - return; - } - + $('.post-content a').not('.booru_pic').each(function(num, obj) { var href = obj.href; var n; if (n = href.match(new RegExp('^https?://(www\\.)?twitter\\.com/[^/]+/status/([0-9]+)', 'i'))) { - var image = document.createElement('div'); - $(image).attr({ + var tweet = document.createElement('div'); + $(tweet).attr({ 'id': 'tweet-' + twitter_tweet_count, 'data-tweet-id': n[2] }).addClass('twitter-tweet-embedded'); - obj.parentElement.insertBefore(image, obj); + obj.parentElement.insertBefore(tweet, obj); window.twttr.widgets.createTweet( n[2], - image, + tweet, { 'lang': 'ru' } From 3e6e3d58555f715aafc93178494aa2474654a15b Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Tue, 27 Jan 2015 04:02:48 +0300 Subject: [PATCH 4/6] Space key fix from pull request #25. --- chrome_point_plus/js/point-plus.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index 464867b..7bac73b 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -1089,14 +1089,12 @@ function set_space_key_skip_handler() { } function space_key_event() { - var scroll_current = $('body').scrollTop(); - var scroll_step_size = 0; - var scroll_real = Math.max(scroll_current - scroll_step_size, 0); + var scroll_current = Math.floor($('body').scrollTop()); var posts = $('.content-wrap > .post'); for (var i = 0; i < posts.length; i++) { - var this_top_px = $(posts[i]).offset().top; - if (this_top_px > scroll_real) { + var this_top_px = Math.floor($(posts[i]).offset().top); + if (this_top_px > scroll_current) { $('body').animate({ 'scrollTop': this_top_px }, 200); From f7d399c41a1f1128db8ca550f15755664c705f98 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Tue, 27 Jan 2015 04:10:13 +0300 Subject: [PATCH 5/6] i18n for options page title. --- chrome_point_plus/_locales/en/messages.json | 5 ++++- chrome_point_plus/_locales/ru/messages.json | 5 ++++- chrome_point_plus/options.html | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/chrome_point_plus/_locales/en/messages.json b/chrome_point_plus/_locales/en/messages.json index d4d86ca..2cd4fe4 100644 --- a/chrome_point_plus/_locales/en/messages.json +++ b/chrome_point_plus/_locales/en/messages.json @@ -6,9 +6,12 @@ "message": "Alexey Skobkin" }, "ext_page_action_title": { - "message": "Point+ settings" + "message": "Settings" }, + "options_page_title": { + "message": "Point+ settings" + }, "options_text_saved": { "message": "Reload page to apply changes." diff --git a/chrome_point_plus/_locales/ru/messages.json b/chrome_point_plus/_locales/ru/messages.json index 9bab77a..2be940c 100644 --- a/chrome_point_plus/_locales/ru/messages.json +++ b/chrome_point_plus/_locales/ru/messages.json @@ -6,9 +6,12 @@ "message": "Алексей Скобкин" }, "ext_page_action_title": { - "message": "Настройки Point+" + "message": "Настройки" }, + "options_page_title": { + "message": "Настройки Point+" + }, "options_text_saved": { "message": "Для применения изменений перезагрузите страницу." diff --git a/chrome_point_plus/options.html b/chrome_point_plus/options.html index 6297b72..b388067 100644 --- a/chrome_point_plus/options.html +++ b/chrome_point_plus/options.html @@ -1,8 +1,8 @@ - Point Plus options + From eb6b67f61294700320eb5792d20bffba1eb15ef7 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Sat, 31 Jan 2015 08:10:54 +0300 Subject: [PATCH 6/6] Some fixes. --- chrome_point_plus/js/point-plus.js | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index 7bac73b..30b9824 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -719,10 +719,7 @@ function create_comment_elements(commentData, onCommentCreated) { // Картинки с бурятников var booru_picture_count = 0; function load_all_booru_images() { - $('.post-content a').each(function(num, obj) { - if ($(obj).hasClass('booru_pic')) { - return; - } + $('.post-content a:not(.booru_pic)').each(function(num, obj) { var href = obj.href; var n = null; @@ -822,10 +819,7 @@ function mark_unread_post() { // Webm function parse_webm(current_options) { - $('.post-content a').each(function(num, obj) { - if ($(obj).hasClass('booru_pic')) { - return; - } + $('.post-content a:not(.booru_pic)').each(function(num, obj) { var href = obj.href; var n = null; @@ -849,10 +843,7 @@ function parse_webm(current_options) { // Видео function parse_all_videos(current_options) { - $('.post-content a').each(function(num, obj) { - if ($(obj).hasClass('booru_pic')) { - return; - } + $('.post-content a:not(.booru_pic)').each(function(num, obj) { var href = obj.href; var n = null; @@ -1093,7 +1084,7 @@ function space_key_event() { var posts = $('.content-wrap > .post'); for (var i = 0; i < posts.length; i++) { - var this_top_px = Math.floor($(posts[i]).offset().top); + var this_top_px = Math.floor(posts.eq(i).offset().top); if (this_top_px > scroll_current) { $('body').animate({ 'scrollTop': this_top_px @@ -1127,12 +1118,6 @@ var draft_save_busy = false; */ var draft_save_last_time = null; -/** - * Is draft now saving or not - * @type {boolean} - */ -var draft_save_busy = false; - /** * Is there any setTimeout'ed handlers * @type {boolean} @@ -1590,7 +1575,7 @@ function twitter_tweet_embedding_wait_for_ready_injected() { function twitter_tweet_embedding_parse_links() { // Обрабатываем все твиты var twitter_tweet_count = 0; - $('.post-content a').not('.booru_pic').each(function(num, obj) { + $('.post-content a:not(.booru_pic)').each(function(num, obj) { var href = obj.href; var n; @@ -1622,7 +1607,7 @@ function twitter_tweet_embedding_parse_links() { function instagram_posts_embedding_init(options) { var regex = new RegExp('^https?://(www\\.)?instagram\\.com/p/([\\w-]+)/?', 'i'); - $('.post-content a').not('.booru_pic').each(function(num, $link) { + $('.post-content a:not(.booru_pic)').each(function(num, $link) { var href = $link.href; var n;