').html(date.getHours() + ':' + ((date.getMinutes().toString().length < 2) ? ('0' + date.getMinutes().toString()) : (date.getMinutes().toString()))));
// Comment text
$commentTemplate.find('.text').append($('').html(escapeHtml(wsMessage.text)));
// Author
@@ -297,8 +302,8 @@ $(document).ready(function() {
$commentTemplate.find('.info a').attr('href', userLink).children('img.avatar').attr('src', userAvatar + '/24');
// Post and comment ID's link
$commentTemplate.find('.clearfix .post-id a').attr('href', commentLink).html('#' + wsMessage.post_id + '/' + wsMessage.comment_id)
- // Adding answer label
- .after((wsMessage.to_comment_id !== null) ? (' в ответ на /' + wsMessage.to_comment_id + '') : (''));
+ // Adding answer label
+ .after((wsMessage.to_comment_id !== null) ? (' в ответ на /' + wsMessage.to_comment_id + '') : (''));
// Setting action labels and other attributes
$commentTemplate.find('.action-labels .reply-label').attr('for', 'reply-' + wsMessage.post_id + '_' + wsMessage.comment_id);
$commentTemplate.find('.action-labels .more-label').attr('for', 'action-' + wsMessage.post_id + '_' + wsMessage.comment_id);
@@ -344,13 +349,13 @@ $(document).ready(function() {
// Adding anchor
$commentTemplate.before($anchor);
-
+
// Fading out highlight if needed
if (options.option_ws_comments_color_fadeout == true) {
console.log('Fading out the highlight');
$commentTemplate.children('.pp-highlight').fadeOut(20000);
}
-
+
// Desktop notifications
if (options.option_ws_comments_notifications == true) {
console.log('Showing desktop notification');
@@ -362,38 +367,38 @@ $(document).ready(function() {
text: wsMessage.text
});
}
-
+
console.groupEnd();
});
-
+
+ break;
+
+ // Posts
+ case 'post':
+ console.group('ws-post #%s', wsMessage.post_id);
+
+ console.debug(wsMessage);
+
+ console.groupEnd();
+ break;
+
+ // Recommendation
+ case 'ok':
+ console.group('ws-recommendation #%s/%s', wsMessage.post_id, wsMessage.comment_id);
+
+ console.debug(wsMessage);
+
+ console.groupEnd();
+ break;
+
+ default:
+ console.group('ws-other');
+
+ console.log(wsMessage);
+
+ console.groupEnd();
break;
- // Posts
- case 'post':
- console.group('ws-post #%s', wsMessage.post_id);
-
- console.debug(wsMessage);
-
- console.groupEnd();
- break;
-
- // Recommendation
- case 'ok':
- console.group('ws-recommendation #%s/%s', wsMessage.post_id, wsMessage.comment_id);
-
- console.debug(wsMessage);
-
- console.groupEnd();
- break;
-
- default:
- console.group('ws-other');
-
- console.log(wsMessage);
-
- console.groupEnd();
- break;
-
}
}
@@ -406,7 +411,7 @@ $(document).ready(function() {
}
;
};
- }
+ }
// Font size
if ((options.option_enlarge_font == true) && (options.option_enlarge_font_size !== undefined)) {
$('body').css('font-size', (options.option_enlarge_font_size / 100) + 'em');
@@ -420,14 +425,17 @@ $(document).ready(function() {
}
// Hightlight post with new comments
- if (options.option_other_hightlight_post_comments == true){
+ if (options.option_other_hightlight_post_comments == true) {
mark_unread_post();
}
// Show recommendation count and unique commentators count
- if (options.option_other_show_recommendation_count == true){
+ if (options.option_other_show_recommendation_count == true) {
set_posts_count_label();
}
+ if (options.option_other_scroll_space_key == true){
+ set_space_key_skip_handler();
+ }
});
@@ -437,12 +445,12 @@ $(document).ready(function() {
function escapeHtml(text) {
return text
- .replace(/&/g, "&")
- .replace(//g, ">")
- .replace(/"/g, """)
- .replace(/'/g, "'")
- .replace(/\n/g, "
");
+ .replace(/&/g, "&")
+ .replace(//g, ">")
+ .replace(/"/g, """)
+ .replace(/'/g, "'")
+ .replace(/\n/g, "
");
}
// Monts for Date.getMonth()
@@ -580,6 +588,38 @@ function parse_webm() {
});
}
+function parse_all_videos() {
+ $('a').each(function (num, obj) {
+ if ($(obj).hasClass('booru_pic')) {
+ return;
+ }
+
+ var href = obj.href;
+ var n = null;
+
+ if (n = href.match(new RegExp('\\.(webm|avi|mp4)(\\?.+)?$', 'i'))) {
+ var player = document.createElement('video');
+ var mime = video_extension_to_mime(n[1]);
+ $(player).html('').attr('controls', 'controls').css({
+ 'display': 'block',
+ 'max-width': '95%'
+ }).addClass('parsed-webm-link');
+
+ obj.parentElement.insertBefore(player, obj);
+ }
+ });
+}
+
+function video_extension_to_mime(extension) {
+ switch(extension){
+ case 'webm':return 'video/webm; codecs="vp8, vorbis';
+ case 'avi' :return 'video/avi;';// @hint Хотя сомнительно
+ case 'mp4' :return 'video/mp4;';
+ }
+
+}
+
+
// Плашки у постов
function set_posts_count_label() {
var ids = [];
@@ -606,7 +646,9 @@ function set_posts_count_label() {
}
var e1 = document.createElement('span');
- if (typeof(answer.list[id])=='undefined'){return;}
+ if (typeof(answer.list[id]) == 'undefined') {
+ return;
+ }
$(e1).addClass('authors_unique_count').html(answer.list[id].count_comment_unique).attr('title', 'Количество комментаторов');
postid.appendChild(e1);
@@ -620,11 +662,11 @@ function set_posts_count_label() {
}
-function parse_pleercom_links(){
- chrome.storage.sync.get(ppOptions, function(options) {
- if (options.option_embedding_pleercom_nokita_server){
+function parse_pleercom_links() {
+ chrome.storage.sync.get(ppOptions, function (options) {
+ if (options.option_embedding_pleercom_nokita_server) {
parse_pleercom_links_nokita();
- }else{
+ } else {
parse_pleercom_links_ajax();
}
});
@@ -643,8 +685,8 @@ function parse_pleercom_links_nokita() {
'preload': 'none'
});
- var player_div=document.createElement('div');
- $(player_div).addClass('embeded_audio').addClass('embeded_audio_'+n[1]);
+ var player_div = document.createElement('div');
+ $(player_div).addClass('embeded_audio').addClass('embeded_audio_' + n[1]);
player_div.appendChild(player);
obj.parentElement.insertBefore(player_div, obj);
@@ -652,28 +694,28 @@ function parse_pleercom_links_nokita() {
});
}
-function parse_pleercom_links_ajax(){
+function parse_pleercom_links_ajax() {
$('a').each(function (num, obj) {
var href = obj.href;
var n = null;
if (n = href.match(new RegExp('^https?:\\/\\/pleer\\.com\\/tracks\\/([0-9a-z]+)', 'i'))) {
- var player_div=document.createElement('div');
- $(player_div).addClass('embeded_audio').addClass('embeded_audio_'+n[1]);
+ var player_div = document.createElement('div');
+ $(player_div).addClass('embeded_audio').addClass('embeded_audio_' + n[1]);
obj.parentElement.insertBefore(player_div, obj);
create_pleercom_ajax(n[1]);
}
});
}
-function create_pleercom_ajax(id){
+function create_pleercom_ajax(id) {
$ajax({
- 'url':'https://pleer.com/site_api/files/get_url',
- 'type':'post',
- 'postdata':'action=download&id='+id,
- 'dont_set_content_type':true,
- 'pleer_id':id,
- 'headers':[['Accept','*'],['Content-Type','application/x-www-form-urlencoded; charset=UTF-8']],
+ 'url': 'https://pleer.com/site_api/files/get_url',
+ 'type': 'post',
+ 'postdata': 'action=download&id=' + id,
+ 'dont_set_content_type': true,
+ 'pleer_id': id,
+ 'headers': [['Accept', '*'], ['Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8']],
'success': function (a) {
var answer = JSON.parse(a);
var player = document.createElement('audio');
@@ -683,13 +725,63 @@ function create_pleercom_ajax(id){
'controls': 'controls',
'preload': 'auto'
});
- $('.embeded_audio_'+this.settings.pleer_id)[0].appendChild(player);
+ $('.embeded_audio_' + this.settings.pleer_id)[0].appendChild(player);
},
- 'error':function(){
+ 'error': function () {
console.log('Can not get url');
- setTimeout(new Function('create_pleercom_ajax("'+this.settings.pleer_id+'");'), 1000);
+ setTimeout(new Function('create_pleercom_ajax("' + this.settings.pleer_id + '");'), 1000);
}
});
+}
+
+// Проставляем теги у постов
+function create_tag_system() {
+ $('.post').each(function () {
+ var tags = $(this).find('div.tags a.tag');
+ for (var i = 0; i < tags.length; i++) {
+ var tag_name = $(tags[i]).html().toLowerCase();
+ $(this).addClass('post-tag-' + tag_name);
+ }
+ });
+}
+
+// Скролл по пробелу
+function set_space_key_skip_handler(){
+ if ($('#comments').length>0){
+ return;
+ }
+
+ // @todo Свериться с Best-practice биндинга функций. Мб там on или bind
+ $(document.body).keydown(function(e){
+ // @todo Я хотел по отпусканию кнопки, но там уже скролл срабатывает
+ // проверяем фокус
+ if ($(':focus').length>0) {
+ return;
+ }
+
+ var k=event.keyCode;
+ if (k==32){
+ space_key_event();
+ return false;
+ }
+ });
+}
+
+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 posts=$('.post');
+ for(var i=0;iscroll_real){
+ $('body').animate({
+ 'scrollTop':this_top_px
+ }, 200);
+ return;
+ }
+ }
}
\ No newline at end of file
diff --git a/chrome_point_plus/manifest.json b/chrome_point_plus/manifest.json
index 8f24022..230be18 100644
--- a/chrome_point_plus/manifest.json
+++ b/chrome_point_plus/manifest.json
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Point+",
- "version": "1.13.0",
+ "version": "1.14.0",
"default_locale": "ru",
"author": "__MSG_ext_author__",
"homepage_url": "https://bitbucket.org/skobkin/chrome_point_plus",
diff --git a/chrome_point_plus/options.html b/chrome_point_plus/options.html
index 7921687..90c8dda 100644
--- a/chrome_point_plus/options.html
+++ b/chrome_point_plus/options.html
@@ -51,6 +51,10 @@