Welcome Guest [Log In] [Register]
This board has been archived and is no longer accepting new questions. If you have a support question for your ZetaBoard, please visit us at the new support board. Registration is free and easy.


Visit the NEW ZetaBoards Support forum!

Username:   Password:
Add Reply
Add Colors; allows you to add more colors
Topic Started: Feb 6 2008, 07:57 PM (5,055 Views)
Interrobang
Member Avatar
Yeah, I went there.
[ * ]
Edit: not to derail your thread, I just made a new topic.
Edited by Interrobang, Feb 10 2008, 06:36 PM.
Offline Profile Quote Post Goto Top
 
lanie
Member Avatar
Member
[ * ]
beta
Feb 9 2008, 09:50 PM
actually, you can use either. of course, if you use #111111, it will show up as #111111 in the dropdown - as well as in the UBBC that's placed in the textarea.

here's a different version that lets you have a different text than the value.

Code:
 
<script type="text/javascript"> <!--
var colors = [["Displayed in Dropdown", "Displayed in UBBC"], ["Ditto", "Ditto 2"]];
if(document.posting && document.posting.fcolor) $("select[@name=fcolor]").each(function() {
for(var j = 0, f = this.options.length; j < colors.length; j++) this.options[f + j] = new Option(colors[j][0], colors[j][1]);
for(var i = 1; i < this.options.length; i ++) this.options[i].style.color = this.options[i].value;
});
// --> </script>


so, if i had it like this: ["Red", "#123456"];
the dropdown list would say Red, but the tag would be [ color=#123456 ] - get it?
Thanks very much, I appreciate your help
Offline Profile Quote Post Goto Top
 
g0dfather
Member
[ *  * ]
Thank you!
Offline Profile Quote Post Goto Top
 
Thunder
Member Avatar
Thunder
[ *  *  * ]
Preview, please?
Offline Profile Quote Post Goto Top
 
Ambrosia
Member
[ *  * ]
There are 3 scenario's with this code.

1 it worked
2 colors showed up in the drop down list and on the post made.
3 shows the color in preview, but output is default theme colour AND all the colours in the drop down menu are grey (supposed to display the colour it is)



<script type="text/javascript">
<!--
var colors = [["Deeppink2", "ee1289"], ["Slateblue", "7a67ee"], ["Royalblue", "3333ff"], ["Turquoise2", "00e5ee"], ["Seagreen2", "4eee94"], ["Red3", "cd0000"], ["Magenta3", "cd00cd"], ["Papaya", "ffff7e"], ["Plum2", "eaadea"], ["Violetred", "db2645"]];
if(document.posting && document.posting.fcolor) $("select[@name=fcolor]").each(function() {
for(var j = 0, f = this.options.length; j < colors.length; j++) this.options[f + j] = new Option(colors[j][0], colors[j][1]);
for(var i = 1; i < this.options.length; i ++) this.options.style.color = this.options.value;
});
// --> </script>

I added more colours then everything 'broke', now even if I remove the full code it won't revert my default colours in the drop down menu!
Offline Profile Quote Post Goto Top
 
Arrogant
Member Avatar
Vote Choco and Nicola!
[ *  *  * ]
Code:
 
<script type="text/javascript"> <!--
var x = [["Deeppink2", "#ee1289"], ["Slateblue", "#7a67ee"], ["Royalblue", "#3333ff"], ["Turquoise2", "#00e5ee"], ["Seagreen2", "#4eee94"], ["Red3", "#cd0000"], ["Magenta3", "#cd00cd"], ["Papaya", "#ffff7e"], ["Plum2", "#eaadea"], ["Violetred", "#db2645"]];
if(document.posting && document.posting.fcolor) (function() { var z = document.posting.fcolor;
for(var i = 0, j = z.options.length; i < x.length; i ++) z.options[i + j] = new Option(x[i][0], x[i][1]);
for(var i = 1; i < z.options.length; i ++) z.options[i].style.color = z.options[i].value; })();
// --> </script>


Breaking mah codeh. :(
Edited by Arrogant, May 19 2008, 07:34 PM.
Offline Profile Quote Post Goto Top
 
Ambrosia
Member
[ *  * ]
Lol sorry man I don't know what happend either.
The code I posted broke both of my testboards.

I believe (as stated in the jQuery version) ZB is limited to 5 additional colours.
And there might be a bug somewhere in the code, because even after reverting it to 1-5 colours it didn't work anymore.
I checked all the settings 3 times no result.
One thing that was really neat was the first 2 times I added a colour, in the drop down menu it displayed the proper colour instead of my theme's default.
Offline Profile Quote Post Goto Top
 
Arrogant
Member Avatar
Vote Choco and Nicola!
[ *  *  * ]
that's what..
Code:
 
for(var i = 1; i < z.options.length; i ++) z.options[i].style.color = z.options[i].value;
... does :o

anyway, it should work now, and i've had it working on my test board - so more than 5 additional colors should work. o.O


OH! by the way - it broke because..
1. You didn't have a # before the hex codes in the colors array.. #FFFFFF, for example.
2. Not sure if it was when you posted it or not, but two of the array indexing []'s are missing because of how the board parses then - they're the italic ubbc ones.
Edited by Arrogant, May 19 2008, 07:43 PM.
Offline Profile Quote Post Goto Top
 
Ambrosia
Member
[ *  * ]
Hell yeah!
Works like a charm, I love the preview of x colour in the drop down menu.
It display all the colours and more than 5.
Good stuff and thanks for replying and fixing it so fast.
Now i'mma have to switch back to your code :P
Offline Profile Quote Post Goto Top
 
BlubbernuggetX
Member Avatar
Lord of the Blubbernuggets
[ *  * ]
Thanks, great code.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · User Created Codes · Next Topic »
Add Reply