So I've managed to modify a script used to automatically replace text within a specific element based on a simpler dictionary script someone else wrote. But i'm starting to see a build up of redundant code I think could be simplified further, but unsure how.
What I have currently implemented:
var dictionary= {
" jquery ":" #jQuery ",
" jQuery ":" #jQuery ",
" JQuery ":" #jQuery ",
" jQuery1 ":" #jQuery ",
" jQuery2 ":" #jQuery ",
" jQuery3 ":" #jQuery ",
};
jQuery(document).ready(function() {
setTimeout(function() {
$("#status").each( function(){
for( var ptrn in dictionary){
$(this).text( $(this).text().replace(new RegExp(ptrn ,"g"), dictionary[ptrn] ) );
}
});
}, 500);
});
What I would like is to simplify combining 3 words its to detect, without multiples of "#jQuery", something like the following or similar. "jQuery1" would be something it is suppose to detect opposed to "jQuery5":
" jQuery1 "," jQuery2 "," jQuery3 ":" #jQuery ",
This modified jQuery script is based off of this: https://stackoverflow.com/a/9908925/2038928