+ Парсер coub.com

This commit is contained in:
Nokita Kaze 2014-11-25 16:43:21 +03:00
parent 817ef68473
commit 4b13936dfa
4 changed files with 53 additions and 2 deletions

View file

@ -83,6 +83,9 @@
"option_embedding_pleercom_nokita_server": { "option_embedding_pleercom_nokita_server": {
"message": "Use Nokita's server instead of AJAX to get mp3 link" "message": "Use Nokita's server instead of AJAX to get mp3 link"
}, },
"option_embedding_coubcom": {
"message": "Coub.com ▼"
},
"option_nsfw": { "option_nsfw": {
"message": "NSFW content filtering" "message": "NSFW content filtering"
}, },

View file

@ -83,6 +83,9 @@
"option_embedding_pleercom_nokita_server": { "option_embedding_pleercom_nokita_server": {
"message": "Использовать сервер @NokitaKaze вместо AJAX-запроса для получения mp3" "message": "Использовать сервер @NokitaKaze вместо AJAX-запроса для получения mp3"
}, },
"option_embedding_coubcom": {
"message": "Coub.com ▼"
},
"option_nsfw": { "option_nsfw": {
"message": "Фильтрация NSFW-контента" "message": "Фильтрация NSFW-контента"
}, },

View file

@ -28,8 +28,11 @@ $(document).ready(function() {
var options = sync_data.options; var options = sync_data.options;
// Options debug // Options debug
console.debug('Options loaded: '+options); try {
console.debug('Options loaded: %O', current_options);
}catch(e){
console.error("Я идиот, убейте меня кто-нибудь: %O", e);
}
create_tag_system(); create_tag_system();
// Embedding // Embedding
@ -92,6 +95,11 @@ $(document).ready(function() {
if (options.option_embedding_pleercom.value == true) { if (options.option_embedding_pleercom.value == true) {
parse_pleercom_links(); parse_pleercom_links();
} }
// Parse coub.com links and create iframe instead
if (options.option_embedding_coubcom.value == true) {
parse_coub_links();
}
} }
// Fancybox // Fancybox
@ -1016,3 +1024,32 @@ function draft_save_check() {
}, 1000); }, 1000);
}); });
} }
// Парсим ссылки на coub
function parse_coub_links() {
$('.post-content a').each(function(num, obj) {
var href = obj.href;
var n = null;
if (n = href.match(new RegExp('^https?:\\/\\/coub\\.com\\/view\\/([0-9a-z]+)', 'i'))) {
var player = document.createElement('iframe');
var parent_width = $(obj.parentElement).width();
$(player).attr({
'src': 'https://coub.com/embed/' + n[1] + '?muted=false&autostart=false&originalSize=false&hideTopBar=false&startWithHD=true',
'allowfullscreen': 'true'
}).css({
'max-width': '640px',
'border': 'none',
'width': Math.floor(parent_width * 0.9),
'height': Math.ceil(parent_width * 0.9 * 480 / 640)
}).addClass('embeded_video').addClass('embeded_video_' + n[1]);
obj.parentElement.insertBefore(player, obj);
if (current_options.option_embedding_coubcom_orig_link.value == false) {
$(obj).hide();
}
}
});
}

View file

@ -89,6 +89,14 @@
<input type="checkbox" class="option-boolean" id="option-embedding-pleercom-orig-link"><label for="option-embedding-pleercom-orig-link" data-i18n="option_embedding_soundcloud_orig_link"></label> <input type="checkbox" class="option-boolean" id="option-embedding-pleercom-orig-link"><label for="option-embedding-pleercom-orig-link" data-i18n="option_embedding_soundcloud_orig_link"></label>
</div> </div>
</div> </div>
<div class="option-node">
<input type="checkbox" class="option-boolean" id="option-embedding-coubcom"><label for="option-embedding-coubcom" data-i18n="option_embedding_coubcom"></label>
<div class="option-node">
<input type="checkbox" class="option-boolean" id="option-embedding-coubcom-orig-link"><label for="option-embedding-coubcom-orig-link" data-i18n="option_embedding_soundcloud_orig_link"></label>
</div>
</div>
</div> </div>
<div class="option-node"> <div class="option-node">