Commit b115aa32 authored by Siltaar's avatar Siltaar
Browse files

merge

parents 6430cf1e f3bd6d21
......@@ -967,7 +967,8 @@ Meta-Press.es setting page.`))
console.log(i, new Date() - src_query_start_date, 'ms',
mp_req.running_query_countdown, '/', current_source_nb, ':', res_nb, 'res')
}).catch( (exc) => {
update_search_query_countdown(i)
if(document.getElementById('mp_running_stats').style.display != 'none')
update_search_query_countdown(i)
if (exc.name == 'AbortError') console.log(`${i} IS ABORTED`)
else error.push(.create_error(.error_code.ERROR, n.tags.name, exc, .error_status.ERROR, 'test_src', {'article': i}))
})
......@@ -1547,19 +1548,11 @@ Meta-Press.es setting page.`))
let cur_sel_items = []
let rm_selec_src = ''
let add_selec_src = ''
for (const i of tag_select_multiple.remove_source_selection)
rm_selec_src += `"${i}",`
rm_selec_src = rm_selec_src.substring(0, rm_selec_src.length - 1); // rm last ,
for (const i of add_source_selection)
add_selec_src += `"${i}",`
add_selec_src = add_selec_src.substring(0, add_selec_src.length - 1); // rm last ,
for (let i of mp_req.findingList.matchingItems)
cur_sel_items.push(i.values())
let json_str = `{
"filters": ${JSON.stringify(tags_toJSON())},
"findings": ${JSON.stringify(cur_sel_items)},
"remove_source_selection": [${rm_selec_src}],
"add_source_selection": [${add_selec_src}],
"meta_findings": ${JSON.stringify(mp_req.metaFindingsList.toJSON())},
"search_terms": ${JSON.stringify(document.getElementById('mp_query').value)}
}`
......@@ -2193,7 +2186,6 @@ Meta-Press.es setting page.`))
} else {
empty_sel(opt)
}
update_nb_src()
}
function empty_sel(opt) {
......@@ -2204,14 +2196,16 @@ Meta-Press.es setting page.`))
set_default_tags()
}
add_source_selection = []
tag_select_multiple.remove_source_selection = []
//tag_select_multiple.remove_source_selection = []
on_tag_sel({})
}
function tags_toJSON() {
function tags_toJSON(id) {
let tags = {}
for (let t of Object.keys(tag_select_multiple)) {
if ('remove_source_selection' === t) continue
else tags[t] = tag_select_multiple[t].getValue(true)
else{
tags[t] = tag_select_multiple[t].getValue(true)
}
}
return tags
}
......@@ -2228,7 +2222,7 @@ Meta-Press.es setting page.`))
if ('ATOM' === type) tags += `<category term='${v}' label='mp__${t}' />\n`
else tags += `<category>mp__${t}__${v}</category>\n`
}
for (const i of tag_select_multiple.remove_source_selection) {
/*for (const i of tag_select_multiple.remove_source_selection) {
if ('ATOM' === type)
tags += `<category term='${i}' label='mp__remove_source_selection' />\n`
else
......@@ -2239,7 +2233,7 @@ Meta-Press.es setting page.`))
tags += `<category term='${i}' label='mp__add_source_selection' />\n`
else
tags += `<category>mp__${i}__add_source_selection</category>\n`
}
}*/
return tags
}
function tags_fromCSV(line) {
......@@ -2346,8 +2340,7 @@ Meta-Press.es setting page.`))
'themes': [],
'src_type': ['Press'],
'res_type': [],
'name': [],
'remove_source_selection': []
'name': []
}
}
/**
......@@ -2358,10 +2351,9 @@ Meta-Press.es setting page.`))
if (typeof(stored_tags) === 'object' && typeof(stored_tags.filters) === 'object') {
tags_fromJSON(stored_tags.filters)
}
if (is_virgin_tags())
set_default_tags()
if (is_advanced_search() && document.getElementById('tags_row').style.display === 'none')
if (is_advanced_search() && document.getElementById('tags_row').style.display !== 'block')
document.getElementById('tags_handle').click()
document.getElementById('mp_loaded_source_total').textContent = sources_keys.length - 2
document.getElementById('mp_loaded_source_countries').textContent =
......@@ -2430,8 +2422,9 @@ Meta-Press.es setting page.`))
evt = evt.target
evt.textContent = evt.textContent === '+' ? '-' : '+'
btn_src_text.style.display = evt.textContent === '+' ? 'none' : 'block'
if(btn_src_text.style.display === 'none')
btn_src_text.textContent = ''
for(let c of btn_src_text.children){
c.style.display = btn_src_text.style.display
}
})
function is_tag_in_querystring(cur_querystring) {
for (let t of Object.keys(tag_select_multiple))
......@@ -2606,7 +2599,7 @@ Meta-Press.es setting page.`))
* @param {string} src_name The name of the soure to get
* @param {boolean} build If we need to rebuild the sources before import
*/
async function update_source_objs(src_name="", build=false, init=true) {
async function update_source_objs(src_name="", build=false, init=true, reload=false) {
if (visibility_status === 0 && init) {
visibility_status++
return
......@@ -2614,16 +2607,22 @@ Meta-Press.es setting page.`))
if (build) res = await .exec_in_background('build_src')
sources_objs = await .exec_in_background('get_prov_src', [src_name])
update_current_sources(sources_objs)
if (typeof (mp_i18n) !== 'undefined') {
if (typeof (mp_i18n) !== 'undefined') {
let old = await browser.storage.sync.get('filters')
if (!init && is_tag_in_querystring(cur_querystring))
if(reload) {
let id_tabs = await browser.tabs.getCurrent().then((e)=>{return e.id})
old['filters'] = (await browser.storage.sync.get(`filters_${id_tabs}`))[`filters_${id_tabs}`]
browser.storage.sync.remove(`filters_${id_tabs}`)
}
if (!init && is_tag_in_querystring(cur_querystring)){
old = {filters: querystring_to_json(cur_querystring)}
}
if (typeof (tag_select_multiple.collection) === 'object' && init)
for (const i of Object.keys(tag_select_multiple)) {
if ('remove_source_selection' === i) continue
tag_select_multiple[i].destroy()
}
populate_tags(current_source_selection).then(() => {load_stored_tags(old)})
await populate_tags(current_source_selection).then(() => {load_stored_tags(old)})
document.getElementById('cur_tag_perm_nb').onclick = () => {
let search_src = {}
for (const i of current_source_selection)
......@@ -2651,8 +2650,13 @@ Meta-Press.es setting page.`))
var mp_i18n = await g.gettext_html_auto(userLang) // must be before populate tags
var LANG = await lang_names.json() // must be before populate tags
await update_source_objs("", false, false) // New Features
document.onvisibilitychange = evt => {
update_source_objs()
document.onvisibilitychange = async(evt) => {
update_source_objs("", false, false, true)
await browser.tabs.getCurrent().then((tabInfo)=>{
let obj = {}
obj[`filters_${tabInfo.id}`] = tags_toJSON()
browser.storage.sync.set(obj)
})
}
// load_source_objs(await browser.storage.sync.get('custom_src'))
let is_launch_test = cur_querystring.get('launch_test')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment