diff --git a/html/image_galleries.html b/html/image_galleries.html index bf83390..2af3880 100644 --- a/html/image_galleries.html +++ b/html/image_galleries.html @@ -21,11 +21,11 @@ padding: 10px; } - #loaded_counter { + #loaded_counter_row { color: Green; } - #failed_counter { + #failed_counter_row { color: Red; } @@ -78,6 +78,23 @@ document.getElementById('img_scale_value').innerText = `${current_img_scale}%`; } + function is_any_radio_checked(radio_name) { + if (document.querySelector(`input[name="${radio_name}"]:checked`) != null) { + return true; + } + else { + return false; + } + } + + function get_checked_radio_value(radio_name) { + for (var i = 0; i < document.getElementsByName(radio_name).length; i++) { + if (document.getElementsByName(radio_name)[i].checked) { + return document.getElementsByName(radio_name)[i].value; + } + } + } + function get_last_img_index() { return document.images.length; } @@ -88,17 +105,30 @@ } } - function show_image_options(img_num) { + function handle_loaded_image(img_num, search_option) { document.images[img_num].style.border = '1px solid Black'; get_image_size(img_num); document.getElementsByClassName('open_image_button')[img_num].hidden = false; document.getElementsByClassName('copy_image_url_button')[img_num].hidden = false; + + if (search_option) { + document.getElementsByClassName('search_image_button')[img_num].hidden = false; + } } function open_image(img_url) { window.open(img_url, '_blank'); } + function search_image(img_url, search_engine) { + if (search_engine == 'google') { + window.open(`https://lens.google.com/uploadbyurl?url=${img_url}`, '_blank'); + } + else if (search_engine == 'yandex') { + window.open(`https://ya.ru/images/search?rpt=imageview&url=${img_url}`, '_blank'); + } + } + function blur_image(image, radius) { if (image.style.filter == 'none') { image.style.filter = `blur(${radius}px)`; @@ -126,11 +156,13 @@ } function load_gallery() { - if (document.getElementById('base_link').value != '' && document.getElementById('images_amount').value != '' && document.querySelector('input[name="file_format"]:checked') != null) { + if (document.getElementById('base_link').value != '' && document.getElementById('images_amount').value != '' && is_any_radio_checked('file_format')) { var image_id = ''; var image_url = ''; var image_item = ''; + document.getElementById('loading_progress').hidden = true; + document.getElementById('statistics').hidden = true; document.getElementById('scale_control').hidden = false; document.getElementById('output').hidden = false; @@ -139,26 +171,20 @@ // Required fields var base_link = document.getElementById('base_link').value; var images_amount = document.getElementById('images_amount').value; - var file_format = document.getElementsByName('file_format'); + var file_format = get_checked_radio_value('file_format'); // Optional fields var start_id = document.getElementById('start_id').value; var id_length = document.getElementById('id_length').value; var id_additional = document.getElementById('id_additional').value; var id_step = document.getElementById('id_step').value; + var search_engine = get_checked_radio_value('search_engine'); var hide_failed_images = document.getElementsByName('hide_failed_images')[0].checked; var blur_images = document.getElementsByName('blur_images')[0].checked; var show_statistics = document.getElementsByName('show_statistics')[0].checked; var final_id = images_amount; - // File format - for (var i = 0; i < file_format.length; i++) { - if (file_format[i].checked) { - file_format = file_format[i].value; - } - } - // Start ID if (start_id == '') { start_id = 1; @@ -187,14 +213,30 @@ final_id = start_id + ((images_amount - 1) * id_step); } - reset_statistics(); + reset_statistics('gallery'); if (show_statistics) { + document.getElementById('loading_progress').hidden = false; document.getElementById('statistics').hidden = false; - document.getElementById('total_counter').innerText = images_amount; - } - else { - document.getElementById('statistics').hidden = true; + + var loading_progress = document.getElementById('loading_progress_value'); + + // Gallery + var loaded_counter_gallery = document.getElementById('loaded_counter_gallery'); + var failed_counter_gallery = document.getElementById('failed_counter_gallery'); + var total_counter_gallery = document.getElementById('total_counter_gallery'); + var loaded_rate_gallery = document.getElementById('loaded_rate_gallery'); + + // All + var loaded_counter_all = document.getElementById('loaded_counter_all'); + var failed_counter_all = document.getElementById('failed_counter_all'); + var total_counter_all = document.getElementById('total_counter_all'); + var loaded_rate_all = document.getElementById('loaded_rate_all'); + + var galleries_counter = document.getElementById('galleries_counter'); + + total_counter_gallery.innerText = images_amount; + total_counter_all.innerText = parseInt(total_counter_all.innerText, 10) + parseInt(total_counter_gallery.innerText, 10); } clear_output(); @@ -204,11 +246,12 @@ image_url = `${base_link}${image_id}${id_additional}${file_format}`; image_item = `
-
+
+
+
+ Google
+ Yandex
+
@@ -321,9 +401,40 @@
- L/F/T - 0/0/0 (0%) + 0%
++ | Gallery | +All | +
---|---|---|
Loaded | +0 | +0 | +
Failed | +0 | +0 | +
Total | +0 | +0 | +
Loaded rate | +0% | +0% | +
Galleries loaded: 0
+