Linggo, Marso 13, 2011

And the ball rolls on (Edit content view - Finish!)

Weew, after 8.5 hours, by the grace and mercy of Our Lord, the Edit content view function is finished. Got delayed on one variable passing and the way <img> doesn't center automatically like <div> background-image (which I presumed both acted the same way. *shame on me.) which lead me to backtrack and check the code and variable, sure enough it was passing right, so had to read up on <img>. The thing was it seems <img> can be a real pain to center automatically, had to re-write a whole function and re-think the algorithm on some steps. Any who take a gander on the result below.


The image on the top is the same image at the center of the gallery, it auto resizes and center when clicked.


added  an additional 61 lines of codes to project and here they are.

function editContent(itemIndex){
   var iIndex = itemIndex;
   var currentPageIndex = checkWhichButtonOn("");
   var imgPath = searchArray[currentPageIndex][itemIndex][1];
   var editImgBox = new Image();
   editImgBox.src = imgPath;
   if (editImgBox.complete) {
    var imgOrientation = checkImgOrientation(editImgBox);
    var imgNewDimension = imgScaler(imgOrientation, editImgBox.height, editImgBox.width);
    var editImgBoxConfiguration = new Array(4);
    editImgBoxConfiguration = configureEditImgBox(imgNewDimension,imgOrientation);
    displayEditBox(editImgBoxConfiguration[0], editImgBoxConfiguration[1], editImgBoxConfiguration[2], editImgBoxConfiguration[3], editImgBox.src);
   }
   else{
    editContentTimer = setTimeout("editContent(\'"+iIndex+"\')",1200);
    imgBoxPathTransferTimer = true;
   }
  }
  
  function imgScaler(imgOrientation, imgHeight, imgWidth){
   if (imgBoxPathTransferTimer) {
    setTimeout(editContentTimer);
   }
   
   if (imgOrientation == "orientationPortrait"){
    var computeScaledDimension = Math.ceil((192*imgHeight)/imgWidth);
   }
   
   if (imgOrientation == "orientationLandscape"){
    var computeScaledDimension = Math.ceil((192*imgWidth)/imgHeight);
   } 
   
   return computeScaledDimension;          
  }
  
  function configureEditImgBox(imgNewDimension,imgOrientation){
   var editImgBoxConfiguration = new Array(4);
   
   if (imgOrientation=="orientationPortrait"){
    var imgWidth = "192";
    var imgHeight = imgNewDimension;
    var imgLeft = 0;
    var imgTop = -1*((imgHeight/2)-96);
    
   }else{
    var imgWidth = imgNewDimension;
    var imgHeight = "192";
    var imgLeft = -1*((imgWidth/2)-96);
    var imgTop = 0;
   }
   editImgBoxConfiguration = [imgWidth,imgHeight,imgLeft,imgTop]
   return editImgBoxConfiguration;
  }
  
  function displayEditBox(imgWidth,imgHeight,imgLeft,imgTop,src){
   var editImgBox = document.getElementById('imgBox');
   editImgBox.style.width = imgWidth+"px";
   editImgBox.style.height = imgHeight+"px";
   editImgBox.style.left = imgLeft+"px";
   editImgBox.style.top = imgTop+"px";
   editImgBox.src = src;
  }


Ill be doing the pure edit-area functions, 1st would be the information display function and then the content-edit functions.

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

Miyerkules, Marso 9, 2011

Initial Layout

Got the initial divs to layout as they should. the lite blue, blue and dark yellow orange divs are supposed to be fixed in size and position while the brown one should be fixed in height but dynamic in width. The page is supposed to have a minimum working width of 768px, that was decided because one of the target devices for this projects are tablets and with the recent upgrades in tablets resolutions is up to 1024x768 or higher depending on the hardware and OS. So only the blue divs and yellow orange divs are really critical for site usage and will carry the most function, whilst the brown one has optional information display.

1st day on the Blog

User Page Layout Plan
User Content Gallery Layout Plan
This is my very first entry here, anyways am still doing my thesis and I am currently working on the user page, I'm still on the design stage (UI,algorithms,DB,components) but basically I've narrowed it down into 3 major parts. The first part is the content edit area, the second is the user content galley and the last would be a status news feed. I'm probably going to make the content gallery first since most the codes in that part are already finished, followed by the content edit area and finishing off with the status news feed.