From 8bc04fdd2f6b6bb46aaa527faf68a97a9f267213 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Sat, 5 Apr 2014 01:12:11 +0400 Subject: [PATCH] - Delegated events for comments loaded through WebSocket (bugfix) - Manifest reading. getVersion() function added --- chrome_point_plus/js/point-plus.js | 15 +++++++++++++-- chrome_point_plus/manifest.json | 3 ++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index d0294a0..a558e41 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -2,6 +2,8 @@ $(document).ready(function() { // Grouping console log console.group('point-plus'); + console.info('Point+ %s', getVersion()); + // Loading options chrome.storage.sync.get(ppOptions, function(options) { // Options debug @@ -44,14 +46,15 @@ $(document).ready(function() { // Send by CTRL+Enter if (options.option_ctrl_enter == true) { // Reply - $('.reply-form textarea').keydown(function(e) { + // Delegated event for all comments + $('.content-wrap #comments').on('keydown.point_plus', '.reply-form textarea', function(e) { if (e.ctrlKey && (e.keyCode == 10 || e.keyCode == 13)) { e.preventDefault(); $(this).parent('.reply-form').submit(); } }); // New post - $('#new-post-form #text-input,#new-post-form #tags-input').keydown(function(e) { + $('#new-post-form #text-input,#new-post-form #tags-input').on('keydown.point_plus', function(e) { if (e.ctrlKey && (e.keyCode == 10 || e.keyCode == 13)) { e.preventDefault(); $(this).parent('#new-post-form').submit(); @@ -322,6 +325,14 @@ function escapeHtml(text) { .replace(/\n/g, "
"); } +function getVersion() { + var xhr = new XMLHttpRequest(); + xhr.open('GET', chrome.extension.getURL('manifest.json'), false); + xhr.send(null); + var manifest = JSON.parse(xhr.responseText); + return manifest.version; +} + // Monts for Date.getMonth() var months = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', diff --git a/chrome_point_plus/manifest.json b/chrome_point_plus/manifest.json index 24374e6..e94c9e8 100644 --- a/chrome_point_plus/manifest.json +++ b/chrome_point_plus/manifest.json @@ -42,7 +42,8 @@ ], "web_accessible_resources": [ "images/*", - "includes/*" + "includes/*", + "manifest.json" ], "background": { "scripts": ["js/background.js"]