The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

What should I add to this code assignments change the caption of the photo.

View previous topic View next topic Go down

Solved What should I add to this code assignments change the caption of the photo.

Post by smurfavr on July 10th 2014, 12:35 am

What should I add to this code assignments change the caption of the photo.



Code:
$(function() {
    var replace1 = 'Трябва да си регистриран за да виждаш линковете..';
    var replace2 = 'Вие нямате права за сваляне !';
    var replace3 = '$1Свален $2 пъти.';
 
    var post = $('.postbody div');
    var atbox = $('.attachbox');
    var reg1 = /\[You must be.*?to see this [A-Z]+.\]/ig;
    var reg2 = /You don't have permission to download attachments./ig;
    var reg3 = /(\(\d+ [A-Z]+\)) Downloaded (\d+) times/ig;
   
    for (i=0;i<post.length;i++)if(reg1.test(post[i].innerHTML))post[i].innerHTML=post[i].innerHTML.replace(reg1,replace1);
    for (i=0;i<atbox.length;i++)if(reg2.test(atbox[i].innerHTML) || reg3.test(atbox[i].innerHTML))atbox[i].innerHTML=atbox[i].innerHTML.replace(reg2,replace2).replace(reg3,replace3);
});

smurfavr
Active Poster

Male Posts : 1384
Reputation : 9
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: What should I add to this code assignments change the caption of the photo.

Post by Ange Tuteur on July 10th 2014, 1:14 am

Hello smurfavr,

I simplified the code for you, replace your script by :
Code:
$(function() {
 replaceText('.postbody div', /\[You must be.*?to see this [A-Z]+.\]/ig, 'Трябва да си регистриран за да виждаш линковете..');
 replaceText('.attachbox', /You don't have permission to download attachments./ig, 'Вие нямате права за сваляне !');
 replaceText('.attachbox', /(\(\d+ [A-Z]+\)) Downloaded (\d+) times/ig, '$1 Свален $2 пъти.');
 replaceText('.attachbox', /Attachments/g, 'Attachments text');
 
 function replaceText(element, reg, rep){var el=$('.post '+element);for(i=0;i<el.length;i++)if(reg.test(el[i].innerHTML))el[i].innerHTML=el[i].innerHTML.replace(reg,rep)}
});

In the script you'll see :
Code:
replaceText('.attachbox', /Attachments/g, 'Attachments text');

Replace Attachments text by the texts you want to display.


Explanation :

To replace texts simply write replaceText();, between the parenthesis you'll fill out the following information in order :
Element : The element the texts are inside
Reg : The regular expression to search for the texts
Rep : The replacement for the searched texts

When done your result should be :
Code:
replaceText('.attachbox', /Attachments/g, 'Attachments text');

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2684
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: What should I add to this code assignments change the caption of the photo.

Post by smurfavr on July 10th 2014, 1:25 am

Thank you Ange Tuteur.Everything works.

smurfavr
Active Poster

Male Posts : 1384
Reputation : 9
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: What should I add to this code assignments change the caption of the photo.

Post by Ange Tuteur on July 10th 2014, 1:28 am

You're welcome :rose:

Topic archived

Have a good day ! ^^

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2684
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum