// JavaScript Document /* Create our object to hold all functions and vars ---------------------------------------------------------*/ var objSite = {}; /* ---------------------------------------------------------*/ objSite.site_url = "http://www.translatedfiction.org.uk/" objSite.admin_url = "http://booktrustadmin.kentlyons.com/"; objSite.reloadPage = function( data/*string*/) { window.location.reload(); } /*-------------------------------------------------------- @description update the login data once a login has been submitted ---------------------------------------------------------*/ objSite.updateLogin = function( data/*string*/) { var data=data; var isLoggedIn ="false"; if(data=="" ||data==null){ isLoggedIn ="true"; } //---------------------------------------------- var holder = document.getElementById("login"); var all_items = document.getElementById("loginError"); holder.removeChild(all_items); //---------------------------------------------- //---------------------------------------------- var new_all_items = document.createElement("div"); new_all_items.setAttribute("id", "loginError"); new_all_items.innerHTML = data; holder.appendChild(new_all_items); if(isLoggedIn=="true"){ objSite.reloadPage(data); } } /*-------------------------------------------------------- @description update the current div once and ajax response has been recieved ---------------------------------------------------------*/ objSite.updateAssignment = function( data/*string*/) { //---------------------------------------------- var holder = document.getElementById(objSite.holderDiv); var all_items= document.getElementById(objSite.div); holder.removeChild(all_items); //---------------------------------------------- //---------------------------------------------- var new_all_items = document.createElement("div"); new_all_items.setAttribute("id", objSite.div); new_all_items.innerHTML = data; holder.appendChild(new_all_items); } /*-------------------------------------------------------- @description append to the current chat div once and ajax response has been recieved ---------------------------------------------------------*/ objSite.appendChat = function( data/*string*/) { if( data == 'ending chat' ) location.reload(true); //check for any alerts if( data.search(/warn::/)==0 ){ //show the warning and carry on objSite.alertUser( "The moderator of this site has felt the need to give you a warning for your behaviour on this chat. Please be careful!" ); } else if( data.search(/ban::/)==0 ){ var failText = "The moderator of this chat has banned you due to your innappropriate use of this chat. To reactivate your account please contact admin@booktrust.org.uk"; objSite.alertUser( failText, true ); } else if( data.search(/commentDelete::/)==0 ){ new_data = data.replace("commentDelete::",""); $("#chatTranscript").empty(); $("#chatTranscript").append(new_data); objSite.resetChatDelete(); } else if( data!='fail'){ //append a new comment $("#chatTranscript").append(data); objSite.resetChatDelete(); } var baseURL = objSite.site_url; window.setTimeout( function() { var newURL = baseURL + "getComments"; $.ajax({ type: "POST", url: newURL, data: 'itemId=' + objSite.itemId + '&typeId=' + objSite.typeId, success: objSite.appendChat }); },1000); } objSite.resetChatDelete = function(){ //Needed to avoid adding multiple js calls onto an item $('.modDisplay').unbind(); $('.modDisplay').hover(function(){ $(this).css('background-color','#f2f2f2'); objSite.deleteTool( $(this).attr('id'), 'Are you sure you want to delete this item?',objSite.itemId); }, function(){ $("#delete").remove(); $("#tooltip").remove(); $(this).css('background-color','#ffffff'); }); } objSite.alertUser = function( text, ban ){ var alertBoxHtml = '
'; alertBoxHtml += text; alertBoxHtml += '
User: '+ username +'
'; toolHtml += ''; toolHtml += ''; toolHtml += 'x'; toolHtml += 'Are you sure you want to '+ type +' this user?
'; confirmHtml += 'YesThe users status has been updated
'; $("#modtools").empty(); $("#modtools").append(confirmHtml); window.setTimeout( function() { $("#modtools").animate({ opacity: 0 }, 400, function(){ $("#modtools").remove() }); },2000); } objSite.deleteTool = function( chatCommentId, confirm, chatId ){ $("#" + chatCommentId).append(''); //create a tooltip $('#delete').hover(function(e){ var x = 297; var y = e.pageY - 377; var toolPosition = 'style="top: '+ y +'px; left: '+ x +'px"'; $("#" + chatCommentId).append('From "+fromName+"
"); } objSite.submitEcard = function( ecardID ){ //get values var input_values = objSite.get_form_values( 'ecard_form' ); var rtnString = "ecardID="+ecardID +"&theMessage=" + escape( tinyMCE.get( 'form_ecardMessage' ).getContent() ) + input_values; var baseURL = objSite.site_url; var newURL = baseURL + "validate_ecard"; objSite.div="ecard_form"; objSite.holderDiv = "ecardHolder"; tinyMCE.execCommand('mceRemoveControl',false,'form_ecardMessage'); $.ajax({ type: "POST", url: newURL, data: rtnString, success: function(data){ objSite.updateAssignment( data ); tinyMCE.execCommand("mceAddControl", true, 'form_ecardMessage'); } }); } objSite.getEventInfo = function( infoItem, event ){ var top = event.pageY - 55; var left = event.pageX + 25; $("#eventInfo").remove( ); switch( infoItem ){ case 'event_name_info': var title = "Give your event a name eg 'Bookstart Rhymetimes'.
"; break; case 'event_location_info': var title = "What is the full address of the venue where your event is taking place? Separate each line with a comma. Eg Booktrust, Book House, 45 East Hill, London
"; break; case 'event_location_name_info': var title = "What is the name of the venue where your event taking place? Eg 'British Library'
"; break; case 'event_postcode_info': var title = "What is the full postcode for your venue? The more accurate you are, the easier it will be to find on the Google Map. Eg SW18 2QZ.
"; break; case 'event_region_info': var title = "Please select the region your event is taking place in. This will help people searching for local events
"; break; case 'event_description_info': var title = "Add any details here to help promote your event. What is happening? Who should attend? What will attendees get out of attending? Also highlight any special details people may need to know.
"; break; case 'event_email_info': var title = "Add the event organiser’s full email address. This is so Booktrust or any attendee can contact you with any queries regarding your event.
"; break; case 'event_cost_info': var title = "Enter the cost of your event in pounds and pence. Eg £2.50. If the event is free, leave it as £0.00. If you are advertising a Bookstart event, it should be free.
"; break; case 'event_date_info': var title = "Enter start date of your event. Enter in the format DD-MM-YYYY.
"; break; case 'event_until_info': var title = "If your event has an end date, enter here. Enter in the format DD-MM-YYYY.
"; break; case 'event_time_info': var title = "Enter the time your event starts using the 24 hour clock. Eg 14:00
"; break; case 'event_recurring_info': var title = "If your event is weekly, monthly or annually, tick this box and then select how often you wish the event to recur.
"; break; case 'event_type_info': var title = "Select which age range this event will appeal to most. You can select more than one if need be.
"; break; } $("#maincontainer").append('