Sabado, Marso 12, 2011

After countless debug

The gallery part took a lot longer to finish but that was mostly due to debugging, there were a lot of variable passing around and it reached a point were it became very tangled all around and I had to sort out the whole menagerie. Anyway its done and here's 190+ new lines of codes for the project.

9 x 9 User Gallery with Auto Tab Creation


var itemToEdit = new Array(7);
  var pageButtonImageOn = new Image();
  pageButtonImageOn.src = "../Assets/Images/userPageButtonOn.png";
  var pageButtonImageOff = new Image();
  pageButtonImageOff.src = "../Assets/Images/userPageButtonOff.png";
  
  function calculateItemCount(pageIndex,tempArray){
   var totalItemCount = countTotalItems(tempArray);
   var x = pageIndex * 9;
   var n =  totalItemCount - x;
   var z = 9   n;
   if (z >=9){
    var pageItemCount = 9;
   }
   else{
    var pageItemCount = z;
   }
   return pageItemCount;
  }
 
  function setGalleryArray(pageCount,tempArray){
   var counterIndex = 0;
   searchArray = new Array();
   
   for (x = 0; x <= pageCount-1; x  ) {
    var pageItemCount = calculateItemCount(x 1,tempArray)
    searchArray[x] = new Array(pageItemCount-1);
    for(n=0;n<=pageItemCount-1;n  ){
     searchArray[x][n] = new Array(7);
     for(a=0;a<=6;a  ){
      searchArray[x][n][a] = tempArray[counterIndex].slice(a,a 1);
     }
     counterIndex  ;
    }
   }
  }
  
  function AjaxTransactionUsrPgGal(){
   xmlhttp = new XMLHttpRequest();
   xmlhttp.onreadystatechange = function(){
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {     
     if (searchArray.length > 0){
      cleanSearchArray();
     }     
     var tempArray = new Array();
     tempArray = eval(xmlhttp.responseText);     
     galleryPageCount = countPages(tempArray);    
     setGalleryArray(galleryPageCount,tempArray);
     usercontentpagesTrigger(0);
     createPageButtons(galleryPageCount);
     changepagebuttonImageOn(0);
     window.clearTimeout(ajaxTimeout);
    }
   }
   xmlhttp.open("Get","userGallery.php?userid=6be5f0be1f66370d2bcb154b9a5a471e", true);
   xmlhttp.send();
  }
  
  function createPageButtons(pageCount){
   for(x=0;x<=pageCount-1;x  ){
   createElement.DynamicDiv.builder("button" x,"pageButton","buttonPanel");
     createImg.DynamicImg.builder("pagebutton" x,"pageButtonImg","button" x,"../Assets/Images/userPageButtonOff.png");
    createButton.DynamicDivButton.builder("paneltitleSpacer" x,"buttonfaceSpacer","button" x);
    createButton.DynamicDivButton.builder("paneltitleTitle" x,"buttonfaceTitle clickable","button" x,"pagebuttonOnClick(\'" x "\')");
   createElement.DynamicDiv.builder("buttonPanelSpacer","","buttonPanel");
   var buttonTitle = x 1
    document.getElementById("paneltitleTitle" x).innerHTML = buttonTitle;
   }
  }
  
  function pagebuttonOnClick(x){
   changepagebuttonImage(x);
   var prevPageIndex = getPrevButton(x);
   removeUserPageContent(prevPageIndex);
   counterClick(x);
   usercontentpagesTrigger(x);
  }
  
  function getPrevButton(x){
   var exceptThis = x;
   for (x = 0; x <= galleryPageCount - 1; x  ) {
    if (x == exceptThis){
     
    }
    else{
     var getButton = document.getElementById("pagebutton" x);
     if (getButton.src == "http://localhost/TheThesis/Assets/Images/userPageButtonOn.png"){
      return x;
     }
    }
   }
  }
  
  function removeUserPageContent(prevPageIndex){
   var countItems = searchArray[prevPageIndex].length;
   countItems = countItems -1;
   for (x = 0;x<=countItems;x  ) {
    removeChildElement("contentDivMain" x, "galleryDisplay")
   }
  }
  
  function counterClick(x){
   var exceptThis = x;
   for(x=0;x<=galleryPageCount-1;x  ){
    if (x == exceptThis){
     
    }
    else{
     changepagebuttonImageOff(x);
    }
   }
  }
  
  function changepagebuttonImageOff(x){
   var buttonImage = document.getElementById('pagebutton' x);
   buttonImage.src =   pageButtonImageOff.src;
   document.getElementById("paneltitleTitle" x).style.color = "#A7A7A7";
  }
  
  function changepagebuttonImageOn(x){
   var buttonImage = document.getElementById('pagebutton' x);
   buttonImage.src =   pageButtonImageOn.src;
   document.getElementById("paneltitleTitle" x).style.color = "#3c3c3c";
  }
  
  function changepagebuttonImage(x){
   var buttonImage = document.getElementById('pagebutton' x);
   if (buttonImage.src == "http://localhost/TheThesis/Assets/Images/userPageButtonOn.png"){
    changepagebuttonImageOff(x)
   }
   else{
    changepagebuttonImageOn(x) 
   }
  }
  
  function usercontentpagesTrigger(pageIndex){
   if (searchArray){
    displayUserContentPages(pageIndex);
   }
   else{
    usercontentpagesTriggerTimer = setTimeout("usercontentpagesTrigger(\'" x "\')",350);
   }
  }
  
  function displayUserContentPages(pageIndex){
   usercontentpagesTriggerTimer = setTimeout("usercontentpagesTrigger(\'" x "\')",9999);
   clearTimeout(usercontentpagesTriggerTimer);
   var pageitemCount = countPageItems(pageIndex);
   displayGalleryPageTrigger(pageitemCount,pageIndex);
  }
  
  function triggerAjaxGallery(){
   setAjaxTimeout();
   AjaxTransactionUsrPgGal();
  }
  
  function setAjaxTimeout(){
   ajaxTimeout = window.setTimeout("triggerAjaxGallery()",3000);
  }

  function displayGalleryPageTrigger(pageitemCount,pageIndex){
   displayGalleryPageTimer = window.setTimeout("displayGalleryPageTrigger(\'" pageitemCount "\')",3000);
   displayGalleryPage(pageitemCount,pageIndex);
  }
  
  function displayGalleryPage(pageitemCount,pageIndex){
   clearTimeout(displayGalleryPageTimer);
   for(x=0;x<=pageitemCount-1;x  ){
    contentDivPrimer(x,"galleryDisplay");
    contentAreaCreation(searchArray[pageIndex][x][0], searchArray[pageIndex][x][1],"", searchArray[pageIndex][x][3], searchArray[pageIndex][x][4], searchArray[pageIndex][x][5], x);
   }
  }
  
  function countPageItems(pageIndex){  
    var pageitemCount = searchArray[pageIndex].length;
    return pageitemCount;
  }
  
  function countPages(tempArray){
   var pageCount = Math.ceil(tempArray.length/9);
   return pageCount;
  }
  
  function countTotalItems(tempArray){
   var totalItemCount = (tempArray.length);
   return totalItemCount;
  }
  
  function imgScaler(){
   
  }
  
  
   

The content edit component is next, right now am starting to layout the HTML elements that will have direct interaction with the gallery because am going to code those functions first before the exclusive content-edit only functions.

ON TOP: Content Edit Part

Walang komento:

Mag-post ng isang Komento