* * Выбор парсинга ссылок на видео через радио-батон - Оп-па, сишкостайл. Меня подзаебало, что на странице chrome://extensions/ какое-то говно в опциях + Переменная current_options, в которой содержится текущее (на момент загрузки) содержимое опций. Нечего дуплиться в асинхронное обращение к опциям * Поправил селекторы. Я такой наркоман был что ли?

This commit is contained in:
Nokita Kaze 2014-11-26 23:48:08 +03:00
parent 3aad05956e
commit d14e69c7b5
4 changed files with 52 additions and 35 deletions

View File

@ -56,11 +56,17 @@
"option_images_load_booru": {
"message": "Load pictures from Booru, Tumblr and some other sites"
},
"option_videos_parse_webm": {
"message": "Parse webm-links and create video instead"
"option_videos_parse_links": {
"message": "Parse video links and create video instead"
},
"option_videos_parse_all_videos": {
"message": "Parse all links to videos and create video instead"
"option_videos_parse_webm": {
"message": "Only webm"
},
"option_videos_parse_all_links": {
"message": "Parse all links"
},
"option_videos_parse_leave_links": {
"message": "Don't delete link itself"
},
"option_embedding_soundcloud": {
"message": "Soundcloud ▼"

View File

@ -56,11 +56,17 @@
"option_images_load_booru": {
"message": "Загружать картинки с Booru, Tumblr и других сайтов"
},
"option_videos_parse_webm": {
"message": "Оборачивать ссылки на webm в тег <video>"
"option_videos_parse_links": {
"message": "Превращать ссылки на видео в видео"
},
"option_videos_parse_all_videos": {
"message": "Оборачивать ссылки на всё видео в тег <video>"
"option_videos_parse_webm": {
"message": "Только webm"
},
"option_videos_parse_all_links": {
"message": "Все ссылки на видео"
},
"option_videos_parse_leave_links": {
"message": "Оставлять ссылку на видео"
},
"option_embedding_soundcloud": {
"message": "Soundcloud ▼"

View File

@ -26,9 +26,9 @@ $(document).ready(function() {
// Loading options
chrome.storage.sync.get('options', function(sync_data) {
var options = sync_data.options;
// Options debug
console.debug('Options loaded: %O', options);
console.debug('Options loaded: '+options);
create_tag_system();
@ -39,8 +39,8 @@ $(document).ready(function() {
load_all_booru_images();
}
// Parse webm-links and create video instead
if (options.option_videos_parse_webm.value == true) {
if (options.option_videos_parse_all_videos.value == true) {
if (options.option_videos_parse_links.value == true) {
if (options.option_videos_parse_links_type.value == "all") {
parse_all_videos();
} else {
parse_webm();
@ -81,7 +81,8 @@ $(document).ready(function() {
});
}
// Parse webm-links and create video instead
// Parse pleer.com links and create audio instead
if (options.option_embedding_pleercom.value == true) {
parse_pleercom_links();
}
@ -545,11 +546,13 @@ var months = [
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
];
// Копия опций
var current_options;
// Картинки с бурятников
var booru_picture_count = 0;
function load_all_booru_images() {
$('a').each(function(num, obj) {
$('.post-content a').each(function(num, obj) {
if ($(obj).hasClass('booru_pic')) {
return;
}
@ -652,7 +655,7 @@ function mark_unread_post() {
// Webm
function parse_webm() {
$('a').each(function(num, obj) {
$('.post-content a').each(function(num, obj) {
if ($(obj).hasClass('booru_pic')) {
return;
}
@ -669,12 +672,16 @@ function parse_webm() {
}).addClass('parsed-webm-link');
obj.parentElement.insertBefore(player, obj);
if (current_options.option_videos_parse_leave_links.value == false) {
$(obj).hide();
}
}
});
}
function parse_all_videos() {
$('a').each(function(num, obj) {
$('.post-content a').each(function(num, obj) {
if ($(obj).hasClass('booru_pic')) {
return;
}
@ -691,6 +698,10 @@ function parse_all_videos() {
}).addClass('parsed-webm-link');
obj.parentElement.insertBefore(player, obj);
if (current_options.option_videos_parse_leave_links.value == false) {
$(obj).hide();
}
}
});
}
@ -751,17 +762,15 @@ function set_posts_count_label() {
}
function parse_pleercom_links() {
chrome.storage.sync.get(ppOptions, function(options) {
if (options.option_embedding_pleercom_nokita_server) {
parse_pleercom_links_nokita();
} else {
parse_pleercom_links_ajax();
}
});
if (current_options.option_embedding_pleercom_nokita_server.value) {
parse_pleercom_links_nokita();
} else {
parse_pleercom_links_ajax();
}
}
function parse_pleercom_links_nokita() {
$('a').each(function(num, obj) {
$('.post-content a').each(function(num, obj) {
var href = obj.href;
var n = null;
@ -783,7 +792,7 @@ function parse_pleercom_links_nokita() {
}
function parse_pleercom_links_ajax() {
$('a').each(function(num, obj) {
$('.post-content a').each(function(num, obj) {
var href = obj.href;
var n = null;
@ -816,7 +825,7 @@ function create_pleercom_ajax(id) {
$('.embeded_audio_' + this.settings.pleer_id)[0].appendChild(player);
},
'error': function() {
console.log('Can not get url');
console.log('Can not get pleer.com url');
setTimeout(new Function('create_pleercom_ajax("' + this.settings.pleer_id + '");'), 1000);
}

View File

@ -50,20 +50,16 @@
</div>
<div class="option-node">
<!--
<input type="checkbox" class="option-boolean" id="option-videos-parse-webm"><label for="option-videos-parse-webm" data-i18n="option_videos_parse_webm"></label>
<div class="option-node">
<input type="checkbox" class="option-boolean" id="option-videos-parse-all-videos"><label for="option-videos-parse-all-videos" data-i18n="option_videos_parse_all_videos"></label>
</div>
-->
<input type="checkbox" class="option-boolean" id="option-videos-parse-links"><label for="option-videos-parse-links" data-i18n="option_videos_parse_links"></label>
<div class="option-node">
<input type="radio" class="option-enum" name="option-videos-parse-links" id="option-videos-parse-webm" value="webm" checked="checked"><label for="option-videos-parse-webm" data-i18n="option_videos_parse_webm"></label>
<input type="radio" class="option-enum" name="option-videos-parse-links" id="option-videos-parse-all-links" value="all"><label for="option-videos-parse-all-links" data-i18n="option_videos_parse_all_links"></label>
<input type="radio" class="option-enum" name="option-videos-parse-links-type" id="option-videos-parse-webm" value="webm" ><label for="option-videos-parse-webm" data-i18n="option_videos_parse_webm"></label>
<input type="radio" class="option-enum" name="option-videos-parse-links-type" id="option-videos-parse-all-links" value="all" checked="checked"><label for="option-videos-parse-all-links" data-i18n="option_videos_parse_all_links"></label>
</div>
<div class="option-node">
<input type="checkbox" class="option-boolean" id="option-videos-parse-leave-links"><label for="option-videos-parse-leave-links" data-i18n="option_videos_parse_leave_links"></label>
</div>
</div>
<div class="option-node">