Skip to content

Instantly share code, notes, and snippets.

@daemonfire300
Created May 26, 2012 12:00
Show Gist options
  • Save daemonfire300/2793681 to your computer and use it in GitHub Desktop.
Save daemonfire300/2793681 to your computer and use it in GitHub Desktop.
html blargh for marcel
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<body>
<form>
<label for="image">URL: </label><input style="width: 400px;" name="image" value="" id="image_url" type="text" /><input type="submit" />
</form>
<div></div>
<script type="text/javascript">
$(function() {
function listImages(){
var image_list = JSON.parse(localStorage.getItem("image_list"));
console.log(image_list);
if(image_list){
for(var i=0;i<image_list.length;i++){
$("div").append('<br /><img src="'+ image_list[i] +'" /><br /><input style="width: 600px;" type="text" value="'+ image_list[i] +'" /><br />');
}
}
}
function addImage(url){
var image_list = JSON.parse(localStorage.getItem("image_list"));
if(image_list){
image_list.push(url);
}
else{
image_list = new Array();
image_list.push(url);
}
console.log(image_list);
localStorage.setItem("image_list", JSON.stringify(image_list));
window.location.reload();
}
listImages();
$('form').submit(function(event){
event.preventDefault();
var url = $(this).find("input").val();
console.log(url);
addImage(url);
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment