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
Showing
3 changed files
with
74 additions
and
0 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,21 @@ | |||
/* | |||
maximumAge = Cache expiration | |||
timeout = Time allowed to request location | |||
enableHighAccuracy = Requests a more precise location (can cause faster battery consumption) | |||
*/ | |||
|
|||
if (navigator.geolocation) { | |||
var currentPosition = navigator.geolocation.getCurrentPosition(function(pos) { | |||
return [pos.coords.latitude, pos.coords.longitude]; | |||
}); | |||
var glocWatch = navigator.geolocation.watchPosition(function(pos) { | |||
// Successfully changed position | |||
currentPosition = [pos.coords.latitude, pos.coords.longitude]; | |||
}, function(error) { | |||
// Error | |||
console.log(error); | |||
}, { enableHighAccuracy: true, maximumAge: 30000, timeout: 27000 }); | |||
|
|||
} else { | |||
// Geolocation not supported | |||
} |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
/* | |||
HTTP vs. HTTPS localstorage - store seperately (including incognito for chrome) | |||
No default expiration. | |||
Only support strings as values | |||
SUPPORT: All modern browsers and IE8+ | |||
*/ | |||
|
|||
// Check if localStorage is available | |||
if (typeof window.localStorage == 'object' && window.localStorage != null) { | |||
var store = window.localStorage; | |||
var myObject = {} | |||
var status = document.getElementById('status'); | |||
var newObj; | |||
|
|||
try { | |||
store.setItem('myKey', 'value'); | |||
store['myObject'] = JSON.stringify(myObject); | |||
} catch(e) { | |||
if (e == QUOTA_EXCEEDED_ERR) { | |||
console.log('ERROR: Local Storage is out of space!'); | |||
} | |||
} | |||
|
|||
// Change status text | |||
// status.innerText = store.getItem('myKey'); | |||
// status.innerText = store['myKey']; | |||
status.innerText = store.myKey; | |||
|
|||
// Retrieve my Object | |||
newobj = JSON.parse(store.myObject); | |||
} |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,22 @@ | |||
/* | |||
querySelector returns only the first element | |||
querySelector/querySelectorAll can be applied to the document or narrowed down to an element | |||
*/ | |||
// Get all menu items | |||
var items = document.querySelectorAll('.menu li'); | |||
// jQuery version: $('.menu li'); | |||
|
|||
// Sub Items of the first menu item | |||
var subItems = items[0].querySelectorAll('li'); | |||
// jQuery version: $('.menu li').find('li') | |||
|
|||
// Find the latest tweet | |||
var latestTweet = document.querySelector('#latest-tweet'); | |||
// jQuery version: $('#latest-tweet').first(); | |||
|
|||
for item in items { | |||
// Log the content of element | |||
console.log(item.innerHTML); | |||
// Output the style object | |||
console.log(item.style); | |||
} |