Created
December 20, 2014 05:46
-
-
Save dckc/b61a11a537c1ed52fc15 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>ETA Config</title> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" /> | |
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> | |
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script> | |
</head> | |
<body> | |
<div data-role="page" id="main"> | |
<div data-role="header" class="jqm-header"> | |
<h1>ETA Config</h1> | |
</div> | |
<div data-role="content"> | |
<div data-role="fieldcontain"> | |
<label for="addr">Address:</label> | |
<textarea cols="40" rows="8" name="addr" id="addr"></textarea> | |
</div> | |
<div data-role="fieldcontain"> | |
<label for="addr">Maps API Key:</label> | |
<input type="text" name="key" id="key"></textarea> | |
</div> | |
<div class="ui-body ui-body-b"> | |
<fieldset class="ui-grid-a"> | |
<div class="ui-block-a"><button type="submit" data-theme="d" id="b-cancel">Cancel</button></div> | |
<div class="ui-block-b"><button type="submit" data-theme="a" id="b-submit">Submit</button></div> | |
</fieldset> | |
</div> | |
</div> | |
</div> | |
</div> | |
<script> | |
function saveOptions() { | |
var options = {} | |
//Add all textual values | |
$('textarea, select, [type="hidden"], [type="password"], [type="text"]').each(function(){options[$(this).attr('id')] = $(this).val();}) | |
//Add all checkbox type values | |
$('[type="radio"], [type="checkbox"]').each(function(){options[$(this).attr('id')] = $(this).is(':checked');}) | |
return options; | |
} | |
$().ready(function() { | |
$("#b-cancel").click(function() { | |
console.log("Cancel"); | |
document.location = "pebblejs://close"; | |
}); | |
$("#b-submit").click(function() { | |
console.log("Submit"); | |
var location = "pebblejs://close#" + encodeURIComponent(JSON.stringify(saveOptions())); | |
console.log("Warping to: " + location); | |
console.log(location); | |
document.location = location; | |
}); | |
//Set form values to whatever is passed in. | |
var obj = jQuery.parseJSON(decodeURIComponent(window.location.search.substring(1))); | |
for(key in obj) { | |
$("#"+[key]).val(obj[key]); | |
$("#"+[key]).val(obj[key]).slider("refresh"); | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment