mirror of
https://bitbucket.org/skobkin/chrome_point_plus.git
synced 2024-11-23 18:56:04 +00:00
- Delegated events for comments loaded through WebSocket (bugfix)
- Manifest reading. getVersion() function added
This commit is contained in:
parent
2a1493fc2a
commit
8bc04fdd2f
|
@ -2,6 +2,8 @@ $(document).ready(function() {
|
||||||
// Grouping console log
|
// Grouping console log
|
||||||
console.group('point-plus');
|
console.group('point-plus');
|
||||||
|
|
||||||
|
console.info('Point+ %s', getVersion());
|
||||||
|
|
||||||
// Loading options
|
// Loading options
|
||||||
chrome.storage.sync.get(ppOptions, function(options) {
|
chrome.storage.sync.get(ppOptions, function(options) {
|
||||||
// Options debug
|
// Options debug
|
||||||
|
@ -44,14 +46,15 @@ $(document).ready(function() {
|
||||||
// Send by CTRL+Enter
|
// Send by CTRL+Enter
|
||||||
if (options.option_ctrl_enter == true) {
|
if (options.option_ctrl_enter == true) {
|
||||||
// Reply
|
// 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)) {
|
if (e.ctrlKey && (e.keyCode == 10 || e.keyCode == 13)) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$(this).parent('.reply-form').submit();
|
$(this).parent('.reply-form').submit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// New post
|
// 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)) {
|
if (e.ctrlKey && (e.keyCode == 10 || e.keyCode == 13)) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$(this).parent('#new-post-form').submit();
|
$(this).parent('#new-post-form').submit();
|
||||||
|
@ -322,6 +325,14 @@ function escapeHtml(text) {
|
||||||
.replace(/\n/g, "<br>");
|
.replace(/\n/g, "<br>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
// Monts for Date.getMonth()
|
||||||
var months = [
|
var months = [
|
||||||
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
|
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
|
||||||
|
|
|
@ -42,7 +42,8 @@
|
||||||
],
|
],
|
||||||
"web_accessible_resources": [
|
"web_accessible_resources": [
|
||||||
"images/*",
|
"images/*",
|
||||||
"includes/*"
|
"includes/*",
|
||||||
|
"manifest.json"
|
||||||
],
|
],
|
||||||
"background": {
|
"background": {
|
||||||
"scripts": ["js/background.js"]
|
"scripts": ["js/background.js"]
|
||||||
|
|
Loading…
Reference in a new issue