Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ADMIN FUNCTIONS
- // not used on front end
- function confirmRemove(eid)
- {
- if (confirm('Are you sure you want to remove this item? '))
- {
- document.location = 'delete_promotion.php?record_id=' + eid;
- }
- return false;
- }
- function loadEdit(eid)
- {
- title = document.getElementById('title' + eid).innerHTML;
- link = document.getElementById('link' + eid).innerHTML;
- teaser = document.getElementById('teaser' + eid).innerHTML;
- document.getElementById('title').value = title;
- document.getElementById('link').value = link;
- document.getElementById('teaser').value = teaser;
- document.getElementById('record').value = eid;
- }
- lastKey = 0;
- function imposeMaxLength(Object, MaxLen)
- {
- if (lastKey != 8)
- {
- return (Object.value.length < MaxLen);
- }
- }
- // FRONT END FUNCTIONS
- // This is an event handler that tests to see what key was pressed
- function KeyCheck(e)
- {
- var KeyID = (window.event) ? event.keyCode : e.keyCode;
- lastKey = KeyID;
- }
- // This registers the KeyCheck handler (above) with the onkeyup event, so it will execute the function each time a key is pressed and released
- document.onkeyup = KeyCheck;
- // This just sets a boolean (true/false) flag to tell the widget whether or not to rotate
- rotate = 1;
- // This loads up a particular item (promo) into the widget based on a JavaScript array of items.
- // The JavaScript array is built dynamically in the promos.php code by querying the database for active promos and looping the results
- function loadPromo(promoIndex, auto)
- {
- if (rotate || !auto)
- {
- pageNumber = promoIndex + 1;
- document.getElementById('page').innerHTML = pageNumber;
- document.getElementById('title').innerHTML = promos[promoIndex][0];
- document.getElementById('teaser').innerHTML = promos[promoIndex][1];
- document.getElementById('link').href = promos[promoIndex][2];
- document.getElementById('promoimg').src = "" + promos[promoIndex][3];
- }
- if (auto)
- {
- if (pageNumber < 5)
- {
- setTimeout('loadPromo(' + pageNumber + ', true)', 7000);
- }
- else
- {
- setTimeout('loadPromo(0, false)', 7000);
- }
- }
- }
- // This is for controlling the navigation through the items, so when the user clicks one of the direction arrows, the proper item will load
- function getPromoIndex(direction)
- {
- promoIndex = parseInt(document.getElementById('page').innerHTML) - 1;
- switch (direction)
- {
- case 'down':
- promoIndex -= 1;
- break;
- case 'up':
- promoIndex += 1;
- break;
- case 'hold':
- break;
- }
- if (promoIndex < 0)
- {
- promoIndex = 4;
- }
- else if (promoIndex > 4)
- {
- promoIndex = 0;
- }
- return promoIndex;
- }
- // This just tells the widget to stop rotating through items
- function promoStop()
- {
- rotate = 0;
- }
Add Comment
Please, Sign In to add comment