forked from duckduckgo/iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43ab345
commit 21b80bd
Showing
25 changed files
with
600 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// document.js | ||
// DuckDuckGo | ||
// | ||
// Created by Mia Alexiou on 22/02/2017. | ||
// Copyright © 2017 DuckDuckGo. All rights reserved. | ||
// | ||
|
||
var duckduckgoDocument = function () { | ||
|
||
getHrefFromPoint = function(x, y) { | ||
var element = document.elementFromPoint(x, y); | ||
while (element && !element.href) { | ||
element = element.parentNode | ||
} | ||
return getHrefFromElement(element) | ||
}; | ||
|
||
getHrefFromElement = function(element) { | ||
if (element) { | ||
return element.href | ||
} | ||
return null | ||
}; | ||
|
||
return { | ||
getHrefFromPoint: getHrefFromPoint, | ||
getHrefFromElement: getHrefFromElement | ||
}; | ||
|
||
}(); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* | ||
*/ | ||
|
||
// Adaptation of https://github.com/mozilla-mobile/firefox-ios/blob/master/Client/Assets/Favicons.js | ||
|
||
|
||
var duckduckgoFavicon = function() { | ||
|
||
var selectors = { | ||
"link[rel~='icon']": 0, | ||
"link[rel='apple-touch-icon']": 1, | ||
"link[rel='apple-touch-icon-precomposed']": 2 | ||
}; | ||
|
||
var cachedFavicon = null; | ||
|
||
getFavicon = function() { | ||
if (!cachedFavicon) { | ||
cachedFavicon = findFavicons()[0] | ||
} | ||
return cachedFavicon | ||
}; | ||
|
||
function findFavicons() { | ||
var favicons = [] | ||
for (var selector in selectors) { | ||
var icons = document.head.querySelectorAll(selector); | ||
for (var i = 0; i < icons.length; i++) { | ||
var href = icons[i].href; | ||
favicons.push(href) | ||
} | ||
} | ||
if (favicons.length === 0) { | ||
var href = document.location.origin + "/favicon.ico"; | ||
favicons.push(href) | ||
} | ||
return favicons; | ||
}; | ||
|
||
return { | ||
getFavicon: getFavicon | ||
}; | ||
|
||
}(); |
Oops, something went wrong.