Anyways I did create something that processes the same but I am still getting the loading error (prolly due to the fact that I am still loading them incorrectly).
HTML:
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Basic Outline</title>
<link rel="stylesheet" href="css/main.css" />
<script src="js/jquery.js"></script>
<script src="js/loader.js"></script>
<script src="js/createdfunctions.js"></script>
<script src="js/functions.js"></script>
<script src="js/eventfunctions.js"></script>
</head>
<body>
<div id="progressBar"><div class="s"></div></div>
<div id="testDiv"></div>
</body>
</html>
CSS:
Code:
* { padding:0px; margin:0 auto;}
#progressBar { width:100%; margin-top:2px; border:2px solid black; height:20px; position:relative;}
.s { height:100%; width:0%; position:absolute; left:0px; top:0px; background-color:#000000;}
JQUERY:
Code:
$(function(){
$('#testDiv').createGallery(['grabgallery.php','galleries', false])
})
$.fn.createGallery = function(args){
var $id = this;
$.ajax({
type: 'POST',
async: false,
url: args[0],
data: {location: args[1]},
dataType: "json",
success: function(response){
$id.loadGallery(response, args[1], args[2])
}//if success
})
}
var loaded = 0;
var maxloaded = 0;
var images = Array()
var folder = ""
$.fn.loadGallery = function(imageList, dir, rot){
var $id = $(this)
folder = imageList[0];
images = imageList[1][0];
maxloaded = images.length;
$.each(images, function(i){
loadImage(folder+'/'+images[i], 200, 200, $id)
})
}
function loadImage(img, w, h, id){
$("<img />").attr('src', img).on('load',function() {
if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
alert('broken image!');
} else {
loaded++;
id.html(loaded)
if(loaded==maxloaded){
id.html('')
$.each(images, function(i){
$(id).append('<img src="'+folder+'/'+images[i]+'" style="width:200px; height:200px;"></img><br />');
})
}
$('#progressBar').children('.s').animate({'width':parseInt(loaded/maxloaded*100)+'%'},0)
//$(this).width(w).height(h).appendTo(id);
}
});
}
Bookmarks