var img = document.createElement("img");
img.className = "icon";
img.src = "https://www.google.com/s2/favicons?domain=" + url;
- img.alt = extractDomain(url, 1);
var link = document.createElement("a");
link.className = "item";
<!DOCTYPE html>
<html>
+
<head>
+
<title>New Tab</title>
<meta charset="utf-8">
<meta name=viewport content="width=device-width, initial-scale=1">
- <script type="text/javascript" src="sites.js" ></script>
<script type="text/javascript" src="main.js" ></script>
- <script type="text/javascript" src="colours.js" ></script>
<script type="text/javascript" src="sortable.min.js"></script>
<link rel="stylesheet" href="style.css">
+
</head>
<body>
+
<span id="edit">e</span>
<span id="addcol">+</span>
- <div class="favorites" id="links" style="min-height: 283px;"></div>
+
+ <div id="links"></div>
+
</body>
+
</html>
+++ /dev/null
-function extractDomain(url, y) {
- var domain;
-
- //remove protocol
- if (url.indexOf("://") > -1) {
- domain = url.split('/')[2];
- }
- else {
- domain = url.split('/')[0];
- }
-
- //remove port number
- domain = domain.split(':')[0];
-
- if (y == 1) {
-
- d = splitHostname(domain);
-
- if (d.subdomain != "www" && d.subdomain != "") {
- return d.subdomain;
- }
- else {
- return d.domain;
- }
-
- } else {
- return domain;
- }
-}
-
-function addhttp(url) {
- if (!/^(f|ht)tps?:\/\//i.test(url)) {
- url = "http://" + url;
- }
- return url;
-}
-
-function splitHostname(h) {
- var result = {};
- var urlParts = new RegExp('([a-z\-0-9]{2,63})\.([a-z\.]{2,5})$').exec(h);
- if (urlParts == null) {
- console.log("Error formatting link " + h);
- return "";
- }
- result.domain = urlParts[1];
- result.type = urlParts[2];
- result.subdomain = h.replace(result.domain + '.' + result.type, '').slice(0, -1);;
- return result;
-}