close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

updating a js file

Thread began 10/09/2012 5:25 am by JamieEff | Last modified 10/09/2012 11:09 am by JamieEff | 605 views | 1 replies

JamieEff

updating a js file

Hey Jason

Am using the following js to run a testimonials 'slideshow' on a site and was wondering if there is any way to use PCMS to allow the client to be able to update the textArray area without having to get them to update the whole js file?

$(document).ready( function() {
var textArray = [
'Yesterday is history. Tomorrow is a mystery. Today is a gift. That\'s why we call it present.',
'The best way to get a man to do something is to suggest they are too old for it.',
'To be happy with a man you must understand him a lot and love him a little. To be happy with a woman you must love her a lot and not try to understand her at all.',
'My wife suggested a book for me to read to enhance our relationship. It\'s titled, "Women are from Venus, Men are Wrong."',
'You can tell more about a person by what he says about others than you can by what others say about him.',
'If you wish to live wisely, ignore sayings, including this one.',
'You have the right to remain silent. Anything you say will be misquoted, then used against you.',
'Murphy\'s Fourth Law: If there is a possibility that several things can go wrong, then the one that will cause the greatest damage will be the one to go wrong.',
'I want to die peacefully in my sleep like my grandfather - not screaming and yelling like the passengers in his car.',
'The early bird may get the worm, but the second mouse gets the cheese.',
'Evening news is where they start by saying "Good Evening" and proceed by telling you why it\'s not.',
'Before you criticize someone, walk a mile in their shoes. That way, you\'ll be a mile from them and have their shoes.',
'All generalizations are false, including this one.' /**/
];
$('#text-box').randomText( textArray, 10000); // ( array, interval, ["reload text or html"] )
});
// custom jquery plugin loadText()
$.fn.randomText = function( textArray, interval, randomEle, prevText ) {
var obj = $(this);
if( $('#text-content').length == 0 ){ obj.append('<div id="text-content">'); }
var textCont = $('#text-content');
if( typeof randomEle != 'undefined' ){ if( $('#randomizer').length == 0 ){ obj.append('<a href="javascript:;" id="randomizer"><em>' + randomEle ); } }
textCont.fadeOut( 'slow', function() {
var chosenText = random_array( textArray );
while( chosenText == prevText ) { chosenText = random_array( textArray ); }
textCont.empty().html( chosenText );
textCont.fadeIn( 'slow' );
sendText = chosenText;
});
timeOut = setTimeout( function(){ obj.randomText( textArray, interval, randomEle, sendText ); }, interval );
$("#randomizer").click( function(){
if( !textCont.is(':animated') ) { clearTimeout( timeOut ); obj.randomText( textArray, interval, randomEle, sendText );} // animation check prevents "too much recursion" error in jQuery
});
}
//public function
function random_array( aArray ) {
var rand = Math.floor( Math.random() * aArray.length + aArray.length );
var randArray = aArray[ rand - aArray.length ];
return randArray;
}

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...