From 1a53e67dcd327f45a4673d8744413f8608c3680f Mon Sep 17 00:00:00 2001 From: koplenov Date: Sun, 17 Aug 2025 02:10:39 +0300 Subject: [PATCH] added buld_add action --- app/app.view.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/app.view.ts b/app/app.view.ts index 8df8507..f5c46e8 100644 --- a/app/app.view.ts +++ b/app/app.view.ts @@ -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, '')) + } + } } }