added buld_add action
This commit is contained in:
parent
fc8d23d326
commit
1a53e67dcd
1 changed files with 14 additions and 4 deletions
|
|
@ -39,21 +39,24 @@ namespace $.$$ {
|
|||
add_submit() {
|
||||
const url = this.add_url().trim()
|
||||
if (url == "") throw "Empty url!"
|
||||
|
||||
if (this.is_valid_http_url(url) == false) throw "Not valid url!"
|
||||
|
||||
|
||||
let title = this.add_title().trim()
|
||||
if (title == "") title = url.replace(/(^https?:\/\/)|(\/+$)/g, '');
|
||||
|
||||
const new_site = this.home().Sites(null)!.make({ '': $hyoo_crus_rank_rule })
|
||||
new_site.url(null)!.val(url)
|
||||
new_site.title(null)!.val(title)
|
||||
this.add_site(url, title)
|
||||
|
||||
this.add_url('');
|
||||
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) {
|
||||
const current = this.home().Sites(null)!.items_vary()
|
||||
const new_list = current.filter(item => item != prop.ref())
|
||||
|
|
@ -90,5 +93,12 @@ namespace $.$$ {
|
|||
|
||||
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, ''))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue