whyisjake

Jake Spurlock

Mar 17th, 2010
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ADMIN FUNCTIONS
  2. // not used on front end
  3. function confirmRemove(eid)
  4. {
  5.     if (confirm('Are you sure you want to remove this item? '))
  6.     {
  7.         document.location = 'delete_promotion.php?record_id=' + eid;
  8.     }
  9.  
  10.     return false;
  11. }
  12.  
  13. function loadEdit(eid)
  14. {
  15.     title = document.getElementById('title' + eid).innerHTML;
  16.     link = document.getElementById('link' + eid).innerHTML;
  17.     teaser = document.getElementById('teaser' + eid).innerHTML;
  18.  
  19.     document.getElementById('title').value = title;
  20.     document.getElementById('link').value = link;
  21.     document.getElementById('teaser').value = teaser;
  22.     document.getElementById('record').value = eid;
  23. }
  24.  
  25. lastKey = 0;
  26. function imposeMaxLength(Object, MaxLen)
  27. {
  28.     if (lastKey != 8)
  29.     {
  30.         return (Object.value.length < MaxLen);
  31.     }
  32. }
  33.  
  34. // FRONT END FUNCTIONS
  35.  
  36. // This is an event handler that tests to see what key was pressed
  37. function KeyCheck(e)
  38. {
  39.     var KeyID = (window.event) ? event.keyCode : e.keyCode;
  40.  
  41.     lastKey = KeyID;
  42. }
  43.  
  44. // This registers the KeyCheck handler (above) with the onkeyup event, so it will execute the function each time a key is pressed and released
  45. document.onkeyup = KeyCheck;
  46. // This just sets a boolean (true/false) flag to tell the widget whether or not to rotate
  47. rotate = 1;
  48. // This loads up a particular item (promo) into the widget based on a JavaScript array of items.
  49. // The JavaScript array is built dynamically in the promos.php code by querying the database for active promos and looping the results
  50. function loadPromo(promoIndex, auto)
  51. {
  52.     if (rotate || !auto)
  53.     {
  54.         pageNumber = promoIndex + 1;
  55.         document.getElementById('page').innerHTML = pageNumber;
  56.         document.getElementById('title').innerHTML = promos[promoIndex][0];
  57.         document.getElementById('teaser').innerHTML = promos[promoIndex][1];
  58.         document.getElementById('link').href = promos[promoIndex][2];
  59.         document.getElementById('promoimg').src = "" + promos[promoIndex][3];
  60.     }
  61.  
  62.     if (auto)
  63.     {
  64.         if (pageNumber < 5)
  65.         {
  66.             setTimeout('loadPromo(' + pageNumber + ', true)', 7000);
  67.         }
  68.         else
  69.         {
  70.             setTimeout('loadPromo(0, false)', 7000);
  71.         }
  72.     }
  73. }
  74.  
  75. // This is for controlling the navigation through the items, so when the user clicks one of the direction arrows, the proper item will load
  76. function getPromoIndex(direction)
  77. {
  78.     promoIndex = parseInt(document.getElementById('page').innerHTML) - 1;
  79.  
  80.     switch (direction)
  81.     {
  82.         case 'down':
  83.             promoIndex -= 1;
  84.             break;
  85.  
  86.         case 'up':
  87.             promoIndex += 1;
  88.             break;
  89.  
  90.         case 'hold':
  91.             break;
  92.     }
  93.  
  94.     if (promoIndex < 0)
  95.     {
  96.         promoIndex = 4;
  97.     }
  98.     else if (promoIndex > 4)
  99.     {
  100.         promoIndex = 0;
  101.     }
  102.  
  103.     return promoIndex;
  104. }
  105.  
  106. // This just tells the widget to stop rotating through items
  107. function promoStop()
  108. {
  109.     rotate = 0;
  110. }
Add Comment
Please, Sign In to add comment