Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

61 lines (56 sloc) 1.518 kb
<html>
<head><title>Linode</title></head>
<script src="jquery-datalink/jquery.js"></script>
<script src="jquery.json.js"></script>
<script src="linode-javascript/linode.api.js"></script>
<script src="linode-javascript/linode.cache.js"></script>
<script type="text/javascript">
if(typeof(String.prototype.trim) === "undefined")
{
String.prototype.trim = function()
{
return String(this).replace(/^\s+|\s+$/g, '');
};
}
// Saves options to localStorage.
function save_options() {
var keys = []
var instances = []
$('.api_key').each(function(i, v) {
var key = $(v).val().toString()
if(key && key.trim().length){
key = key.trim()
keys.push(key)
instances.push(new LinodeApi(key))
}
})
chrome.extension.getBackgroundPage().cache = new LinodeCache(instances);
chrome.extension.getBackgroundPage().cache.fill(function(){})
localStorage["api_keys"] = keys
}
function add_key_input(value) {
if(!value) {
value = ''
}
$('#api_keys').append('<input type="text" class="api_key" size="100" value="'+value+'"/><br/>')
}
// Restores select box state to saved value from localStorage.
function restore_options() {
var k = localStorage["api_keys"];
if (!k) {
return;
}
k = k.split(',')
$.each(k, function(i, key) {
add_key_input(key)
})
}
</script>
<body onload="restore_options()">
<div id="api_keys">
API Keys<br/>
</div>
<a href="#" onClick="add_key_input()">Add Another Key</a><br/>
<button onclick="save_options()">Save</button>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.