aboutsummaryrefslogtreecommitdiff
path: root/Main/wwwroot/scripts
diff options
context:
space:
mode:
authorAryadev Chavali <aryadevchavali1@gmail.com>2019-02-21 15:48:41 +0000
committerAryadev Chavali <aryadevchavali1@gmail.com>2019-02-21 15:48:41 +0000
commit0c1eafe2c8d55c76a9756d722ef8c6cce065cc10 (patch)
tree4e5231af5975db6543b008443545642eb9d19c55 /Main/wwwroot/scripts
parent450bcb83ee18e78941324657c0e471f8b5e6ffb4 (diff)
downloadnewsaggregator-0c1eafe2c8d55c76a9756d722ef8c6cce065cc10.tar.gz
newsaggregator-0c1eafe2c8d55c76a9756d722ef8c6cce065cc10.tar.bz2
newsaggregator-0c1eafe2c8d55c76a9756d722ef8c6cce065cc10.zip
Moved website frontend to wwwroot - a problem for another day
Diffstat (limited to 'Main/wwwroot/scripts')
-rw-r--r--Main/wwwroot/scripts/main.ts49
1 files changed, 49 insertions, 0 deletions
diff --git a/Main/wwwroot/scripts/main.ts b/Main/wwwroot/scripts/main.ts
new file mode 100644
index 0000000..e68bc97
--- /dev/null
+++ b/Main/wwwroot/scripts/main.ts
@@ -0,0 +1,49 @@
+class Article {
+ Container: HTMLElement;
+ Title: HTMLElement;
+ Image: HTMLElement;
+
+ constructor(title: string, description: string, article_link: string, image_link: string) {
+ // object initialisation
+ this.Container = document.createElement('div');
+ this.Title = document.createElement('h1');
+ this.Image = new Image();
+ let link = document.createElement('a');
+
+ // attributes
+ link.innerText = title;
+ link.setAttribute('href', article_link);
+ this.Image.setAttribute('src', image_link);
+ this.Image.setAttribute('title', description);
+ this.Container.className = "Frame";
+
+ // make unit
+ this.Title.appendChild(link);
+ this.Container.appendChild(this.Title);
+ this.Container.appendChild(this.Image);
+ }
+
+ visualise(root: HTMLElement): void {
+ // visualise the article for document
+ root.appendChild(this.Container);
+ }
+}
+
+let root = document.getElementById('root');
+
+let title = "Amazon reconsiders building new headquarters in New York City: WaPo";
+let description = "Description";
+let article = "https://www.wikipedia.org/";
+let image = "https://s.abcnews.com/images/Business/long-island-city-gty-jc-181112_hpMain_4x3t_384.jpg";
+
+let articles: Array<Article> = [
+ new Article(title, description, article, image),
+ new Article(title, description, article, image),
+ new Article(title, description, article, image),
+ new Article(title, description, article, image),
+ new Article(title, description, article, image),
+ new Article(title, description, article, image),
+ new Article(title, description, article, image)
+];
+
+articles.forEach(article => article.visualise(root));