initial git commit of imapi

This commit is contained in:
2019-04-21 08:15:22 -06:00
commit a4cbf79f57
13 changed files with 325 additions and 0 deletions

15
libs/j/ImageListSelection Normal file
View File

@@ -0,0 +1,15 @@
function ImageListSelection(position) {
var selection = window.curGallery.imageList.slice(position,position+5);
window.curGallery.container.list.innerHTML = "";
selection.forEach( function (e,i) {
var element = elementPlace("#ImageList",e,"thumbnail","li");
element.innerHTML = e;
element.style.backgroundImage = "url("+window.api_url+"?i!"+e+"!"+window.curGallery.Name+"!thumb)";
element.style.backgroundRepeat = "no-repeat";
element.style.backgroundPosition = "center center";
element.onclick = function () {
initImage(window.curGallery.Position+i,window.curGallery.Name);
};
element.innerHTML = e;
});
}

3
libs/j/getGalleries Normal file
View File

@@ -0,0 +1,3 @@
function getGalleries(api_url) {
getData(api_url+"?lg",putGalleries);
}

11
libs/j/getImage Normal file
View File

@@ -0,0 +1,11 @@
function getImage(imageName, galleryName) {
var Image = elementPlace("body",imageName,null,"div");
Image.className = "thumbnail";
Image.innerHTML = imageName;
Image.style.backgroundImage = "url("+window.api_url+"?i!"+imageName+"!"+galleryName+"!thumb)";
Image.style.backgroundRepeat = "no-repeat";
Image.style.backgroundPosition = "center center";
Image.onclick = function () {
showImage(imageName, galleryName);
};
}

3
libs/j/getImageList Normal file
View File

@@ -0,0 +1,3 @@
function getImageList(api_url, gallery) {
getData(api_url+"?gg!"+gallery,putImageList);
}

11
libs/j/imageViewElements Normal file
View File

@@ -0,0 +1,11 @@
function imageViewElements () {
window.curImage.back = elementPlace("body","ImageView_back",null,"div");
window.curImage.container = elementPlace("#ImageView_back","ImageView",null,"div");
window.curImage.controls = elementPlace("#ImageView",null,"Icontrols","div");
window.curImage.controls.previous = elementPlace(".Icontrols",null,"previous button","div");
window.curImage.controls.position = elementPlace(".Icontrols","position",null,"div");
window.curImage.controls.next = elementPlace(".Icontrols", null, "next button", "div");
window.curImage.controls.close = elementPlace(".Icontrols", null, "close button", "div");
window.curImage.container.imagePlace = elementPlace("#ImageView","ImageContainer",null,"div");
window.curImage.container.imagePlace.image = elementPlace("#ImageContainer",null,null,"img");
}

47
libs/j/initGalery Normal file
View File

@@ -0,0 +1,47 @@
function initGalery(galleryName) {
window.curGallery = {};
getImageList(window.api_url, galleryName);
window.curGallery.Position = 0;
window.curGallery.Name = galleryName;
window.curGallery.back = elementPlace("body","ImageGallery_back",null,"div");
window.curGallery.container = elementPlace("#ImageGallery_back","ImageGallery",null,"div");
window.curGallery.controls = elementPlace("#ImageGallery",null,"controls","div");
window.curGallery.controls.previous = elementPlace(".controls",null,"previous button","div");
window.curGallery.controls.previous.innerHTML = "Previous";
window.curGallery.controls.previous.onclick = function () {
window.curGallery.controls.previous.innerHTML = "";
if (window.curGallery.Position < 10) {
window.curGallery.Position = 0;
} else {
window.curGallery.Position -= 5;
window.curGallery.controls.previous.innerHTML = "Previous";
}
window.curGallery.controls.next.innerHTML = "Next";
window.curGallery.controls.position.innerHTML = window.curGallery.Position + " - " + (window.curGallery.Position + 5) + " / " + window.curGallery.imageList.length;
ImageListSelection(window.curGallery.Position);
};
window.curGallery.controls.position = elementPlace(".controls","position",null,"div");
window.curGallery.controls.position.innerHTML = window.curGallery.Position + " - " + (window.curGallery.Position + 5);
window.curGallery.controls.next = elementPlace(".controls",null,"next button","div");
window.curGallery.controls.next.innerHTML = "Next";
window.curGallery.controls.next.onclick = function () {
window.curGallery.controls.next.innerHTML = "";
if (window.curGallery.Position >= window.curGallery.imageList.length - 10) {
window.curGallery.Position = window.curGallery.imageList.length - 5;
} else {
window.curGallery.Position += 5;
window.curGallery.controls.next.innerHTML = "Next";
}
window.curGallery.controls.previous.innerHTML = "Previous";
window.curGallery.controls.position.innerHTML = window.curGallery.Position + " - " + (window.curGallery.Position + 5) + " / " + window.curGallery.imageList.length;
ImageListSelection(window.curGallery.Position);
};
window.curGallery.controls.close = elementPlace(".controls",null,"close button","div");
window.curGallery.controls.close.innerHTML = "Close";
window.curGallery.controls.close.onclick = function () {
var node = window.curGallery.back;
node.parentNode.removeChild(node);
};
window.curGallery.container.list = elementPlace("#ImageGallery","ImageList",null,"ul");
}

41
libs/j/initImage Normal file
View File

@@ -0,0 +1,41 @@
function initImage(imageIndex, galleryName) {
window.curImage = {};
window.curImage.Position = imageIndex;
window.curImage.Name = window.curGallery.imageList[imageIndex];
imageViewElements();
window.curImage.controls.previous.innerHTML = "Previous";
window.curImage.controls.previous.onclick = function () {
window.curImage.controls.previous.innerHTML = "";
if (window.curImage.Position <= 1) {
window.curImage.Position = 0;
} else {
window.curImage.Position -= 1;
window.curImage.controls.previous.innerHTML = "Previous";
}
refreshImage();
window.curImage.controls.next.innerHTML = "Next";
};
window.curImage.controls.position.innerHTML = window.curImage.Name;
window.curImage.controls.next.innerHTML = "Next";
window.curImage.controls.next.onclick = function () {
window.curImage.controls.next.innerHTML = ""
if (window.curImage.Position >= window.curGallery.imageList.length -2) {
window.curImage.Position = window.curGallery.imageList.length - 1;
} else {
window.curImage.Position += 1;
window.curImage.controls.next.innerHTML = "Next"
}
refreshImage();
window.curImage.controls.previous.innerHTML = "Previous";
};
window.curImage.controls.close.innerHTML = "Close";
window.curImage.controls.close.onclick = function () {
var node = window.curImage.back;
node.parentNode.removeChild(node);
};
window.curImage.container.imagePlace.style.backgroundImage = "url("+window.api_url+"?i!"+window.curImage.Name+"!"+galleryName+"!thumb)";
window.curImage.container.imagePlace.style.backgroundRepeat = "no-repeat";
window.curImage.container.imagePlace.style.backgroundPosition = "center center";
window.curImage.container.imagePlace.style.backgroundSize = "contain";
window.curImage.container.imagePlace.image.src = window.api_url+"?i!"+window.curImage.Name+"!"+galleryName;
}

10
libs/j/listGalleries Normal file
View File

@@ -0,0 +1,10 @@
function listGalleries() {
window.galleryBox = elementPlace("body","GalleryBox",null,"div");
window.galleryList = elementPlace("#GalleryBox","GalleryList",null,"ul");
window.galleryList.innerHTML = "";
window.galleriesList.forEach(function(e) {
var gallery = elementPlace("#GalleryList",null,"Gallery","li");
gallery.innerHTML = e;
gallery.onclick = function () { initGalery(e); };
});
}

4
libs/j/putGalleries Normal file
View File

@@ -0,0 +1,4 @@
function putGalleries(data) {
window.galleriesList = JSON.parse(data).galeries;
listGalleries();
}

5
libs/j/putImageList Normal file
View File

@@ -0,0 +1,5 @@
function putImageList(data) {
window.curGallery.imageList = JSON.parse(data).images;
window.curGallery.controls.position.innerHTML = window.curGallery.Position + " - " + (window.curGallery.Position + 5) + " / " + window.curGallery.imageList.length;
ImageListSelection(0);
}

9
libs/j/refreshImage Normal file
View File

@@ -0,0 +1,9 @@
function refreshImage() {
var galleryName = window.curGallery.Name;
window.curImage.Name = window.curGallery.imageList[window.curImage.Position];
window.curImage.controls.position.innerHTML = window.curImage.Name;
window.curImage.container.imagePlace.style.backgroundImage = "url("+window.api_url+"?i!"+window.curImage.Name+"!"+galleryName+"!thumb)";
window.curImage.container.imagePlace.image.src = "";
window.curImage.container.imagePlace.image.src = window.api_url+"?i!"+window.curImage.Name+"!"+galleryName;
}

15
libs/j/showImage Normal file
View File

@@ -0,0 +1,15 @@
function showImage(imageName, galleryName) {
window.curImage = {};
imageViewElements();
window.curImage.controls.position.innerHTML = imageName;
window.curImage.controls.close.innerHTML = "Close";
window.curImage.controls.close.onclick = function () {
var node = window.curImage.back;
node.parentNode.removeChild(node);
};
window.curImage.container.imagePlace.style.backgroundImage = "url("+window.api_url+"?i!"+imageName+"!"+galleryName+"!thumb)";
window.curImage.container.imagePlace.style.backgroundRepeat = "no-repeat";
window.curImage.container.imagePlace.style.backgroundPosition = "center center";
window.curImage.container.imagePlace.style.backgroundSize = "contain";
window.curImage.container.imagePlace.image.src = window.api_url+"?i!"+imageName+"!"+galleryName;
}