2024-01-18 17:35:42 +00:00
|
|
|
function get_target_area_with_order(settings, matched_block)
|
|
|
|
{
|
|
|
|
//console.log(settings);
|
2024-02-07 08:30:17 +00:00
|
|
|
let target_area = null;
|
2024-01-18 17:35:42 +00:00
|
|
|
|
2024-02-07 08:30:17 +00:00
|
|
|
if(matched_block.length) {
|
|
|
|
let last_index = matched_block.length-1
|
2024-04-07 05:13:31 +00:00
|
|
|
let center_index = 0;
|
|
|
|
let random_index = 0;
|
|
|
|
if(matched_block.length>1) {
|
|
|
|
center_index = parseInt(last_index/2);
|
|
|
|
random_index = getRandom(0,last_index)
|
|
|
|
}
|
2024-02-07 08:30:17 +00:00
|
|
|
if(settings.area_auto_select.mode=="from top to bottom")
|
|
|
|
target_area = matched_block[0];
|
|
|
|
if(settings.area_auto_select.mode=="from bottom to top")
|
|
|
|
target_area = matched_block[last_index];
|
|
|
|
if(settings.area_auto_select.mode=="center")
|
|
|
|
target_area = matched_block[center_index];
|
|
|
|
if(settings.area_auto_select.mode=="random")
|
2024-04-07 05:13:31 +00:00
|
|
|
target_area = matched_block[random_index];
|
2024-02-07 08:30:17 +00:00
|
|
|
}
|
2024-01-18 17:35:42 +00:00
|
|
|
return target_area;
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_target_date_with_order(settings, matched_block)
|
|
|
|
{
|
|
|
|
//console.log(settings);
|
2024-02-07 08:30:17 +00:00
|
|
|
let target_area = null;
|
2024-01-18 17:35:42 +00:00
|
|
|
|
2024-02-07 08:30:17 +00:00
|
|
|
if(matched_block.length) {
|
|
|
|
let last_index = matched_block.length-1
|
2024-04-07 05:13:31 +00:00
|
|
|
let center_index = 0;
|
|
|
|
let random_index = 0;
|
|
|
|
if(matched_block.length>1) {
|
|
|
|
center_index = parseInt(last_index/2);
|
|
|
|
random_index = getRandom(0,last_index)
|
|
|
|
}
|
2024-02-07 08:30:17 +00:00
|
|
|
if(settings.date_auto_select.mode=="from top to bottom")
|
|
|
|
target_area = matched_block[0];
|
|
|
|
if(settings.date_auto_select.mode=="from bottom to top")
|
|
|
|
target_area = matched_block[last_index];
|
|
|
|
if(settings.date_auto_select.mode=="center")
|
|
|
|
target_area = matched_block[center_index];
|
|
|
|
if(settings.date_auto_select.mode=="random")
|
2024-04-07 05:13:31 +00:00
|
|
|
target_area = matched_block[random_index];
|
2024-02-07 08:30:17 +00:00
|
|
|
}
|
2024-01-18 17:35:42 +00:00
|
|
|
|
|
|
|
return target_area;
|
2024-04-07 05:13:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getRandom(min,max){
|
|
|
|
return Math.floor(Math.random()*(max-min+1))+min;
|
|
|
|
};
|