#00AF33
14306
0
1
Sept 8, 2023 8:54:17 GMT -8
Jordan
What is truth?
11,838
October 2003
jab2
|
Post by Jordan on Nov 24, 2012 12:05:58 GMT -8
You can chain all you want, but it depends on what you are calling. It's something you'll just figure out over time. Not sure why that wasn't working for you, I'd have to see exactly what you had. In my collapsible category code, you can see I chain quite a bit when I create a div that contains two other divs. $('<div></div>') .addClass('cc-data') .append($('<div></div>') .addClass('cc-bg-color') .attr('title', title.css('background-color'))) .append($('<div></div>') .addClass('cc-bg-image') .attr('title', title.css('background-image'))) .appendTo(_board);
|
|
inherit
153968
0
Nov 19, 2012 15:03:05 GMT -8
Thesealion
New Phone Who Dis?
4,124
April 2010
joemaggio
|
Post by Thesealion on Nov 24, 2012 14:37:16 GMT -8
In my last two posts i pretty much posted what I had...
|
|
#00AF33
14306
0
1
Sept 8, 2023 8:54:17 GMT -8
Jordan
What is truth?
11,838
October 2003
jab2
|
Post by Jordan on Nov 24, 2012 15:34:01 GMT -8
So it's just not getting passed that last if statement? Have you added the correct staff id's to your regular expresssion variable?
var staff_ids = /^test$/i;
Is test the username of your staff account on your test forum?
|
|
inherit
153968
0
Nov 19, 2012 15:03:05 GMT -8
Thesealion
New Phone Who Dis?
4,124
April 2010
joemaggio
|
Post by Thesealion on Nov 24, 2012 17:05:29 GMT -8
test is the username of one of them...admin is the other...although i think it would be easier for the code if we used their user numbers which are 1 & 2 cause then couldn't i use one of the built in variable systems to input the staff?
|
|
#00AF33
14306
0
1
Sept 8, 2023 8:54:17 GMT -8
Jordan
What is truth?
11,838
October 2003
jab2
|
Post by Jordan on Nov 24, 2012 18:26:44 GMT -8
test is the username of one of them...admin is the other...although i think it would be easier for the code if we used their user numbers which are 1 & 2 cause then couldn't i use one of the built in variable systems to input the staff? You need to debug through the code to see what is happening. If you don't know how to use the developer console, just do a few alerts. You need to do an alert(staff_id) and see if it matches what is in your staff_ids regular expression because it's possible I made a mistake as I did not test the code I gave you. And yes, you could use the staff ID instead. I don't know off the top of my head if you can use the variable system, but that's a good thought. You should try it.
|
|
inherit
153968
0
Nov 19, 2012 15:03:05 GMT -8
Thesealion
New Phone Who Dis?
4,124
April 2010
joemaggio
|
Post by Thesealion on Nov 25, 2012 10:07:13 GMT -8
Ok so here is where i am at now. I used the auto variable for the pluggin thing where you can add users by searching for them. I have added two users one with the user-id 1 and the other 2. When you alert the variable it gives you "1,2"
$(document).ready(function() { var staff_ids = 1; $('.edited_by').each(function() { var staff_id = $(this).find('a').attr('href').replace(/\/user\//i,''); if(staff_id == staff_ids) { $(this).hide(); } }); });
That is my code. What I need to be able to do is replace "staff_ids" with the built in variable that equals 1,2 and then have the if statement "if(staff_id == staff_ids) {" check to see if staff_ids is part of 1,2....and I am lost as to how to do this properly EDIT: Guess what? I got it...i just have no idea what i did I found this line in a code my brother has that does something similar. He got this part from someone who helped him so eh doesn't know what it does either Mind explaining how the highlighted line works? $(document).ready(function() { $('.edited_by').each(function() { var staff_id = $(this).find('a').attr('href').replace(/\/user\//i,''); if( $.inArray( staff_id.toString(), proboards.plugin.get('hidden_staff_edits').settings.test ) > -1 ) { $(this).hide(); } }); });
|
|
#00AF33
14306
0
1
Sept 8, 2023 8:54:17 GMT -8
Jordan
What is truth?
11,838
October 2003
jab2
|
Post by Jordan on Nov 25, 2012 11:53:22 GMT -8
Ok so here is where i am at now. I used the auto variable for the pluggin thing where you can add users by searching for them. I have added two users one with the user-id 1 and the other 2. When you alert the variable it gives you "1,2" $(document).ready(function() { var staff_ids = 1; $('.edited_by').each(function() { var staff_id = $(this).find('a').attr('href').replace(/\/user\//i,''); if(staff_id == staff_ids) { $(this).hide(); } }); }); That is my code. What I need to be able to do is replace "staff_ids" with the built in variable that equals 1,2 and then have the if statement "if(staff_id == staff_ids) {" check to see if staff_ids is part of 1,2....and I am lost as to how to do this properly The == operator won't work in this situation because it will only compare two values. If the alert was giving you "1,2" it looks like it is a string and although that is one value, it will try and match a single id with that entire string which wont work (i.e. if your staff id was 2: "2" == "1,2" would fail). (It also might be an array, I'm not sure which browser you are using and the syntax it gives for an array.) So assuming the value above was a string, you'd want to split it up by using the comma as a delimiter like so: var array = staff_ids.split(",");Now you would have an array that looks like ["1","2"], but you still couldn't use the == operator because it would only compare the address of the reference to the array, not the values in the array. So, you'd have to do a for loop and loop through each value in the array, and then compare each value with the == operator. That's what the line below does that you got from your brother when it calls inArray(). Google is your best friend, and I use it constantly with JQuery. All you need to do is type "jquery inarray" into Google and its documentation will come up. For inArray() it says: "Search for a specified value within an array and return its index (or -1 if not found)".The first parameter staff_id.toString() is the value you want to look for in the second parameter proboards.plugin.get('hidden_staff_edits').settings.test which is the array. You don't have to call .toString() on the staff_id since I believe it is already a string, and even if it wasn't, I believe Javascript would convert it for you automatically. Then we check if the value returned from the inArray() method is greater than -1, because remember, the documentation above said if it returns anything but -1 then it found the value in the array.
|
|
inherit
153968
0
Nov 19, 2012 15:03:05 GMT -8
Thesealion
New Phone Who Dis?
4,124
April 2010
joemaggio
|
Post by Thesealion on Nov 25, 2012 12:29:17 GMT -8
Ok...thanks a million
|
|
#00AF33
14306
0
1
Sept 8, 2023 8:54:17 GMT -8
Jordan
What is truth?
11,838
October 2003
jab2
|
Post by Jordan on Nov 25, 2012 12:34:47 GMT -8
No problem, glad to help.
|
|