Browse Source

remove marquee

Joe Richardson 6 months ago
parent
commit
16d5d14979
3 changed files with 28 additions and 70 deletions
  1. 8
    10
      index.html
  2. 19
    41
      js/main.js
  3. 1
    19
      scss/style.scss

+ 8
- 10
index.html View File

@@ -52,27 +52,25 @@
52 52
         </div>
53 53
       </div>
54 54
 
55
-      <ul class="block block-half">
56
-        <li class="header">~ Notes</li>
57
-        <textarea id="storage"></textarea>
55
+      <ul class="block block-half" id="news">
56
+        <li class="header">~ World News</li>
58 57
       </ul>
59 58
 
60 59
       <ul class="block block-half" id="hn">
61 60
         <li class="header">~ Hacker News</li>
62 61
       </ul>
63 62
 
64
-      <ul class="block block-flush block-full">
65
-        <marquee id="sports" scrollamount="10"></marquee>
63
+      <ul class="block block-half">
64
+        <li class="header">~ Picture of the Day</li>
65
+        <!-- Add RSS feed here -->
66
+        <img src="https://i.redd.it/p5tqb9hbc8w31.jpg" width="100%" height="auto" id="picture">
66 67
       </ul>
67 68
 
68 69
       <ul class="block block-half">
69
-        <li class="header">~ NASA</li>
70
-        <img width="100%" height="auto" id="nasa">
70
+        <li class="header">~ Notes</li>
71
+        <textarea id="storage"></textarea>
71 72
       </ul>
72 73
 
73
-      <ul class="block block-half" id="music">
74
-        <li class="header">~ Music</li>
75
-      </ul>
76 74
     </div>
77 75
   </div>
78 76
   <script src="js/moment.js"></script>

+ 19
- 41
js/main.js View File

@@ -3,13 +3,11 @@ const API_KEY = `c17b224e52a70e931ce9dfad435ee274`;
3 3
 const APP_ID = `fd8f5fd1`;
4 4
 const WEATHER_URL = `http://api.weatherunlocked.com/api/current/52.7721,1.2062?app_id=${APP_ID}&app_key=${API_KEY}`;
5 5
 
6
-const NEWS_URL = `https://api.rss2json.com/v1/api.json?rss_url=https%3A%2F%2Fnews.ycombinator.com%2Frss`;
6
+const HN_URL = `https://api.rss2json.com/v1/api.json?rss_url=https%3A%2F%2Fnews.ycombinator.com%2Frss`;
7 7
 
8
-const SPORTS_URL = `https://cors-anywhere.herokuapp.com/https://livescore-api.com/api-client/scores/live.json?key=OA2ITWWU33fWx7dD&secret=vN3cFHIpCa955krUUtCNqzIuCXqa5ENB`;
8
+// const PICTURE_URL = `https://api.rss2json.com/v1/api.json?rss_url=https%3A%2F%2Fwww.reddit.com%2Fr%2Funixporn%2F.rss`;
9 9
 
10
-const NASA_URL = `https://api.rss2json.com/v1/api.json?rss_url=https%3A%2F%2Fwww.nasa.gov%2Frss%2Fdyn%2Flg_image_of_the_day.rss`;
11
-
12
-const MUSIC_URL = `https://api.rss2json.com/v1/api.json?rss_url=https%3A%2F%2Fwww.rap-up.com%2Ffeed%2F`;
10
+const NEWS_URL = `https://api.rss2json.com/v1/api.json?rss_url=https%3A%2F%2Fnews.google.com%2Frss%3Fx%3D1571747254.2933%26hl%3Den-GB%26gl%3DGB%26ceid%3DGB%3Aen`;
13 11
 
14 12
 let icon = document.querySelector(".icon");
15 13
 let temp = document.querySelector(".temp");
@@ -18,8 +16,8 @@ let type = document.querySelector(".type");
18 16
 const hn = document.getElementById(`hn`);
19 17
 const sports = document.getElementById(`sports`);
20 18
 const storage = document.getElementById(`storage`);
21
-const nasa = document.getElementById(`nasa`);
22
-const music = document.getElementById(`music`);
19
+// const picture = document.getElementById(`picture`);
20
+const news = document.getElementById(`news`);
23 21
 
24 22
 fetch(WEATHER_URL)
25 23
   .then(function(response) {
@@ -37,7 +35,7 @@ fetch(WEATHER_URL)
37 35
     icon.src = image;
38 36
   });
39 37
 
40
-fetch(NEWS_URL)
38
+fetch(HN_URL)
41 39
   .then(function(response) {
42 40
     return response.json();
43 41
   })
@@ -47,7 +45,7 @@ fetch(NEWS_URL)
47 45
       return `
48 46
         <a class="limit" href="${item.link}" title="${item.title}">
49 47
           <span class="op5">${moment(item.pubDate).format(`D/M/YY`)}</span>
50
-          ${item.title.length > 65 ? item.title.substring(0, 65 - 3) + "..." : item.title}
48
+          ${item.title}
51 49
         </a>
52 50
       `;
53 51
     };
@@ -68,37 +66,17 @@ if (localStorage.getItem(`newTabNotes`)) {
68 66
   storage.innerText = localStorage.getItem(`newTabNotes`);
69 67
 }
70 68
 
71
-fetch(SPORTS_URL)
72
-  .then(function(response) {
73
-    return response.json();
74
-  })
75
-  .then(function(res) {
76
-    const items = res.data.match;
77
-    const template = function(item) {
78
-      return `
79
-        <span><i>${item.home_name}</i> ${item.score} <i>${item.away_name}</i> (${item.time})</span>
80
-      `;
81
-    };
69
+// fetch(PICTURE_URL)
70
+//   .then(function(response) {
71
+//     return response.json();
72
+//   })
73
+//   .then(function(res) {
74
+//     res.items.splice(0, 2)
75
+//     picture.src = res.items[Math.floor(Math.random() * 11)].thumbnail;
76
+//     picture.title = res.items[Math.floor(Math.random() * 11)].title;
77
+//   });
82 78
 
83
-    items.map(function(item) {
84
-      const listItem = document.createElement(`li`);
85
-      listItem.innerHTML = template(item);
86
-      listItem.style.display = `inline-block`;
87
-      listItem.style.marginRight = `15px`;
88
-      sports.appendChild(listItem);
89
-    });
90
-  });
91
-
92
-fetch(NASA_URL)
93
-  .then(function(response) {
94
-    return response.json();
95
-  })
96
-  .then(function(res) {
97
-    nasa.src = res.items[Math.floor(Math.random() * 11)].enclosure.link;
98
-    nasa.title = res.items[Math.floor(Math.random() * 11)].title;
99
-  });
100
-
101
-fetch(MUSIC_URL)
79
+fetch(NEWS_URL)
102 80
   .then(function(response) {
103 81
     return response.json();
104 82
   })
@@ -108,7 +86,7 @@ fetch(MUSIC_URL)
108 86
       return `
109 87
         <a class="limit" href="${item.link}" title="${item.title}">
110 88
           <span class="op5">${moment(item.pubDate).format(`D/M/YY`)}</span>
111
-          ${item.title.length > 65 ? item.title.substring(0, 65 - 3) + "..." : item.title}
89
+          ${item.title}
112 90
         </a>
113 91
       `;
114 92
     };
@@ -117,6 +95,6 @@ fetch(MUSIC_URL)
117 95
       const listItem = document.createElement(`li`);
118 96
       listItem.innerHTML = template(item);
119 97
       listItem.style.marginBottom = `5px`;
120
-      music.appendChild(listItem);
98
+      news.appendChild(listItem);
121 99
     });
122 100
   });

+ 1
- 19
scss/style.scss View File

@@ -118,22 +118,4 @@ textarea {
118 118
 .op5 {
119 119
   opacity: 0.5;
120 120
   font-size: 12px;
121
-}
122
-
123
-marquee {
124
-  color: $block-link;
125
-  padding: 10px;
126
-  display: block;
127
-
128
-  li:after {
129
-    display: inline-block;
130
-    content: " | ";
131
-    opacity: 0.4;
132
-  }
133
-
134
-  li:last-of-type {
135
-    &:after {
136
-      display: none;
137
-    }
138
-  }
139
-}
121
+}