The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Add more links to this script

2 posters

Go down

Solved Add more links to this script

Post by Mati September 4th 2015, 6:48 pm

Is it possible to add more links to this script...

Code:
jQuery(function() {
if (document.location.href.indexOf('/f9-graphics-design') > -1 ) {
jQuery('.page-title').after('<div class="rules"><strong><span style="font-size: 18px;"><i class="fa fa-exclamation-triangle"></i> Forum rules</span></strong>
<br>
Hello and welcome to the community.</div>');
}
});


Last edited by Mati on September 5th 2015, 4:02 pm; edited 1 time in total
Mati
Mati
Hyperactive

Posts : 2020
Reputation : 330
Language : HTML, CSS & JavaScript
Location : Forum Services

https://forumservice.forumotion.com/

Back to top Go down

Solved Re: Add more links to this script

Post by Ange Tuteur September 4th 2015, 8:03 pm

Hi @Mati,

You mean for the condition, correct ? If so you can use regular expressions like this :
Code:
jQuery(function() {
  if (/\/f(?:1|2|9)-/.test(window.location.href)) {
    jQuery('.page-title').after('<div class="rules"><strong><span style="font-size: 18px;"><i class="fa fa-exclamation-triangle"></i> Forum rules</span></strong><br>Hello and welcome to the community.</div>');
  }
});

The forum ids are where you see "1|2|9" separate each individual forum id by a bar. ( | )
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Add more links to this script

Post by Mati September 4th 2015, 8:51 pm

Hi @Ange Tuteur

I'm not sure if I explained good but here is what I want to do

In the Forum Directory "Promote Your Forum" category I have 10 forums

And I want to add this code for each of them without adding the links

Code:
jQuery(function() {
if (document.location.href.indexOf('/f10-computers-internet') > -1 ) {
jQuery('.page-title').after('<div class="rules"><strong><span style="font-size: 18px;"><i class="fa fa-exclamation-triangle"></i> Forum rules</span></strong>
<br>
 Welcome to Forum Directory! We want to thank you for wanting to submit your forum into our Forum Directory. \n We want to provide you with the best service possible, \n so if you have any suggestions, \n we will be glad to hear them.
<br>
<br>
<strong><span style="font-size: 18px;"><i class="fa fa-exclamation-circle"></i> Guidelines:</span></strong><br>
Before posting a new topic for our Forum Directory, \n we ask that you read through these few guidelines we have.
<br>
You are required to have minimum of 2 posts.
<br>
You may bump your topic every 12 hours.
<br>
We ask that you use the template when you open a new topic.
</div>');
}
});

Forum link -> http://forumdirectory.forumotion.net/
Mati
Mati
Hyperactive

Posts : 2020
Reputation : 330
Language : HTML, CSS & JavaScript
Location : Forum Services

https://forumservice.forumotion.com/

Back to top Go down

Solved Re: Add more links to this script

Post by Ange Tuteur September 4th 2015, 9:29 pm

Are you going to be using the same message for each section, or will they be different. Let me know Smile
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Add more links to this script

Post by Mati September 4th 2015, 10:06 pm

The same message for each section. Very Happy
Mati
Mati
Hyperactive

Posts : 2020
Reputation : 330
Language : HTML, CSS & JavaScript
Location : Forum Services

https://forumservice.forumotion.com/

Back to top Go down

Solved Re: Add more links to this script

Post by Ange Tuteur September 4th 2015, 10:13 pm

Oh, in that case, you should be able to use the solution in this message. Just replace the after() content with whatever you want in those sections, and of course change the forum IDs to the ones you want it in. Smile
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Add more links to this script

Post by Mati September 5th 2015, 3:39 pm

I got that @Ange Tuteur and how about this code?

Code:
$(function() {
    if (location.pathname == '/post' && location.search == '?f=10&mode=newtopic') {
      $('#text_editor_textarea').val('[b]Field 1[/b]:\n[b]Field 2[/b]: Don\'t fill this field in\n[b]Field 3[/b]:');
    }
});
Mati
Mati
Hyperactive

Posts : 2020
Reputation : 330
Language : HTML, CSS & JavaScript
Location : Forum Services

https://forumservice.forumotion.com/

Back to top Go down

Solved Re: Add more links to this script

Post by Ange Tuteur September 5th 2015, 3:48 pm

We should be able to do the same thing, except we'll only check for a match in location.search. ^^
Code:
$(function() {
  if (/f=(?:10|11|12)&mode=newtopic/.test(window.location.search)) {
    $('#text_editor_textarea').val('[b]Field 1[/b]:\n[b]Field 2[/b]: Don\'t fill this field in\n[b]Field 3[/b]:');
  }
});

10|11|12 is the same as the last script; the ids of the forums. Smile
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Add more links to this script

Post by Mati September 5th 2015, 4:02 pm

Thanks a lot mate this can be locked now. Smile
Mati
Mati
Hyperactive

Posts : 2020
Reputation : 330
Language : HTML, CSS & JavaScript
Location : Forum Services

https://forumservice.forumotion.com/

Back to top Go down

Solved Re: Add more links to this script

Post by Ange Tuteur September 5th 2015, 4:16 pm

You're welcome ^^

Topic archived

Have a good weekend. Very Happy
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Back to top

- Similar topics

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