FM Design
Would you like to react to this message? Create an account in a few clicks or log in to continue.

IMPORTANT

FM Design is in read-only mode, please click here for more information.

Latest topics
» Forumactif Edge - Releases
by Ange Tuteur Tue 03 Sep 2019, 11:49

» GIFActif - Giphy Button for the Editor
by Ange Tuteur Wed 08 May 2019, 17:21

» Forum Closure
by Ange Tuteur Mon 01 Jan 2018, 01:28

» Chit Chat Thread
by Valoish Sun 31 Dec 2017, 19:15

» Font/Text background color.
by Valoish Sun 31 Dec 2017, 19:11

» Forumactif Messenger - Instant Message Application for Forumotion
by Wolfuryo Sun 31 Dec 2017, 18:24

» [GAME] Count to One Million!
by brandon_g Fri 29 Dec 2017, 18:58

» Post Cards
by manikbiradar Wed 20 Dec 2017, 07:50

» [GAME] Countdown from 200,000
by Valoish Wed 13 Dec 2017, 23:22

» GeekPolice Tech Support Forums - GeekPolice.net
by Dr Jay Mon 11 Dec 2017, 19:12

» Asking about some plugin for Forumotion
by Dr Jay Mon 11 Dec 2017, 19:10

» [GAME] What are you thinking right now?
by Van-Helsing Sat 09 Dec 2017, 14:51

» Widget : Similar topics
by ranbac Wed 06 Dec 2017, 18:11

» Change the Background of the Forum and put an image and how to make prefixs?
by Clement Wed 06 Dec 2017, 15:19

» Hello from Western Australia
by SarkZKalie Wed 06 Dec 2017, 05:34

Recent Tutorials
Top posting users this month

Who is online?
In total there are 55 users online :: 0 Registered, 0 Hidden and 55 Guests :: 1 Bot

None

[ View the whole list ]


Most users ever online was 515 on Tue 14 Sep 2021, 15:24

[SOLVED] Script addition for rank and posts

View previous topic View next topic Go down

Luffy
Luffy

Gender : Male
Age : 30
Posts : 291
Points : 4256
Reputation : 64
Language : Greek, English
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
https://www.inforumgr.com/ https://www.facebook.com/inforumgr https://twitter.com/inforumgr

PostLuffy Fri 10 Jun 2016, 17:54

Hello,

We recently have been working on implementing a new feature where each member, based on their "Crew" rank and their post will have an additional image shown on their profile in the posts.
The script we have so far is this one:
Code:
$(function() {
  var a = $('.user-info'), // all post stats
      i = 0, // user-info index
      j = a.length, // user-info length
      rank,
      posts; // posts will be redefined in the loop
 
  for (; i < j; i++) {
    posts = $(a[i]).text().replace(/\n/g, '').replace(/.*?Posts.*?: (\d+).*/, '$1');
    rank = $(a[i]).html().replace(/\n/g, '').replace(/.*?Crew.*?:\s(.*?)<br>.*/, '$1');
 
    // αρχικά πάντα μπαίνει ο μεγαλύτερος αριθμός και όσο κατεβαίνεις να μικραίνει ο αριθμός.
 
    if (rank == 'Strawhats' && posts > 37) {
      $(a[i]).prepend('<div><img src="http://i65.tinypic.com/6f77dh.jpg" alt="zoro"></div>');
    }
 
    else if (rank == 'Strawhats' && posts > 1) {
      $(a[i]).prepend('<div><img src="http://i68.tinypic.com/jzjzas.jpg" alt="zoro"></div>');
    }
 
  }
});
The forum version is PunBB and the forum link is this one: http://onepiecegr.forumgreek.com/forum
schiggysboard
schiggysboard

Gender : Male
Posts : 79
Points : 3933
Reputation : 20
Language : German, English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : phpBB3
http://www.schiggysboard.com/

Postschiggysboard Fri 10 Jun 2016, 17:59

Sounds interesting. Possible to convert to phpbb3 @Luffy @Ange Tuteur?
Ange Tuteur
Ange Tuteur
Administrator
Gender : Male
Posts : 4741
Points : 12252
Reputation : 2376
Location : Pennsylvania
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
https://sethclydesdale.github.io/ https://twitter.com/sethc1995

PostAnge Tuteur Mon 13 Jun 2016, 10:27

@Luffy thanks for all the information. Rose I think I found the problem, there was a closing span tag in front of the crew rank text. See if this works for you guys :
Code:
$(function() {
  var a = $('.user-info'), // all post stats
      i = 0, // user-info index
      j = a.length, // user-info length
      rank,
      posts; // posts will be redefined in the loop
 
  for (; i < j; i++) {
    posts = $(a[i]).text().replace(/\n/g, '').replace(/.*?Posts.*?: (\d+).*/, '$1');
    rank = $(a[i]).html().replace(/\n/g, '').replace(/.*?Crew.*?:\s.*?<\/span>(.*?)<br>.*/, '$1');

    // αρχικά πάντα μπαίνει ο μεγαλύτερος αριθμός και όσο κατεβαίνεις να μικραίνει ο αριθμός.
 
    if (rank == 'Strawhats' && posts > 37) {
      $(a[i]).prepend('<div><img src="http://i65.tinypic.com/6f77dh.jpg" alt="zoro"></div>');
    }
 
    else if (rank == 'Strawhats' && posts > 1) {
      $(a[i]).prepend('<div><img src="http://i68.tinypic.com/jzjzas.jpg" alt="zoro"></div>');
    }
 
  }
});
Luffy
Luffy

Gender : Male
Age : 30
Posts : 291
Points : 4256
Reputation : 64
Language : Greek, English
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
https://www.inforumgr.com/ https://www.facebook.com/inforumgr https://twitter.com/inforumgr

PostLuffy Mon 13 Jun 2016, 19:19

@Ange Tuteur the member said that this didn't actually work, and that he has an avatar displaying to the fa_toolbar and it removes that avatar and the points that he has on a widget.. Sad
Ange Tuteur
Ange Tuteur
Administrator
Gender : Male
Posts : 4741
Points : 12252
Reputation : 2376
Location : Pennsylvania
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
https://sethclydesdale.github.io/ https://twitter.com/sethc1995

PostAnge Tuteur Tue 14 Jun 2016, 10:34

Did he edit the script at all ? Because I'm seeing this error and I don't see it in the script I posted above :
[SOLVED] Script addition for rank and posts Untitl10

It should be
Code:
posts == 1
not
Code:
posts = 1
. One equal sign is used to assign a value to something, such as a variable. Two equal signs are used to compare two objects, and three equal signs are used for type checking. So in short, let him know that if he wants to check if posts is equal to something use two equal signs. ( I know it's confusing for non-programmers Razz ) This is a good list of the comparison operators in JS in case he want's to see the other operators he can use for comparisons :
http://www.w3schools.com/js/js_comparisons.asp
Luffy
Luffy

Gender : Male
Age : 30
Posts : 291
Points : 4256
Reputation : 64
Language : Greek, English
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
https://www.inforumgr.com/ https://www.facebook.com/inforumgr https://twitter.com/inforumgr

PostLuffy Sat 18 Jun 2016, 06:15

Thank you @Ange Tuteur this is now solved! Smile
Ange Tuteur
Ange Tuteur
Administrator
Gender : Male
Posts : 4741
Points : 12252
Reputation : 2376
Location : Pennsylvania
Language : EN, JA, FR
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
https://sethclydesdale.github.io/ https://twitter.com/sethc1995

PostAnge Tuteur Mon 20 Jun 2016, 09:35

No problem ! Salute

Have a good one. Smile
Sponsored content

PostSponsored content

View previous topic View next topic Back to top

Create an account or log in to leave a reply

You need to be a member in order to leave a reply.

Create an account

Join our community by creating a new account. It's easy!


Create a new account

Log in

Already have an account? No problem, log in here.


Log in

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