added buld_add action

This commit is contained in:
koplenov 2025-08-17 02:10:39 +03:00
parent fc8d23d326
commit 1a53e67dcd

View file

@ -39,21 +39,24 @@ namespace $.$$ {
add_submit() { add_submit() {
const url = this.add_url().trim() const url = this.add_url().trim()
if (url == "") throw "Empty url!" if (url == "") throw "Empty url!"
if (this.is_valid_http_url(url) == false) throw "Not valid url!" if (this.is_valid_http_url(url) == false) throw "Not valid url!"
let title = this.add_title().trim() let title = this.add_title().trim()
if (title == "") title = url.replace(/(^https?:\/\/)|(\/+$)/g, ''); if (title == "") title = url.replace(/(^https?:\/\/)|(\/+$)/g, '');
const new_site = this.home().Sites(null)!.make({ '': $hyoo_crus_rank_rule }) this.add_site(url, title)
new_site.url(null)!.val(url)
new_site.title(null)!.val(title)
this.add_url(''); this.add_url('');
this.add_title(''); this.add_title('');
} }
add_site(url: string, title: string) {
const new_site = this.home().Sites(null)!.make({ '': $hyoo_crus_rank_rule })
new_site.url(null)!.val(url)
new_site.title(null)!.val(title)
}
target_remove(prop: $hd_canary_app_home_site) { target_remove(prop: $hd_canary_app_home_site) {
const current = this.home().Sites(null)!.items_vary() const current = this.home().Sites(null)!.items_vary()
const new_list = current.filter(item => item != prop.ref()) const new_list = current.filter(item => item != prop.ref())
@ -90,5 +93,12 @@ namespace $.$$ {
return home return home
} }
bulk_add(sites_input: string) {
const sites = sites_input.split(/\r?\n/).map( site => site.trim()).filter(site => site != "")
for (const site of sites) {
this.add_site(site, site.replace(/(^https?:\/\/)|(\/+$)/g, ''))
}
}
} }
} }