SMF For Free Support Forum
Signup For Free Forum
September 10, 2010, 10:41:59 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome to SMF For Free. The best free SMF Host
 
   Home   Help Search Arcade Gallery Login Register  

Pages: 1 ... 4 5 6 [7] 8
  Print  
Author Topic: [Code] Stylesheet Swapper  (Read 9600 times)
0 Members and 1 Guest are viewing this topic.
simply sibyl
Global Moderator
*
Offline Offline

Posts: 13751



View Profile WWW
« Reply #90 on: March 28, 2009, 10:47:20 am »

Is it possible that when you click on the style at the bottom it also changes the Forum images? Like the new/no new posts?


No it's not
Logged

Andrew
Helpers
*
Offline Offline

Posts: 1796


Andrew at your service


View Profile WWW
« Reply #91 on: April 04, 2009, 10:56:33 am »

I currently have this code in my header:
Code:
<!-- Stylesheet Swapper For Portal Block  -->
<link rel="stylesheet" type="text/css" href="http://www.smfforfree4.com/styles/pic/potco.css?fin11" title="potco">

<link rel="alternate stylesheet" type="text/css" href="http://www.smfforfree4.com/styles/pic/pheonix.css?fin11" title="pheonix"
<link rel="alternate stylesheet" type="text/css" href="http://www.smfforfree4.com/styles/pic/xbox360.css?fin11" title="xbox360">


<!-- Script for Stylesheet Swapper DO NOT EDIT  -->
<script type='text/javascript'>
function changeStyle(title) {
var lnks = document.getElementsByTagName('link');
for (var i = lnks.length - 1; i >= 0; i--) {
if (lnks[i].getAttribute('rel').indexOf('style')> -1 && lnks[i].getAttribute('title')) {
lnks[i].disabled = true;
if (lnks[i].getAttribute('title') == title) lnks[i].disabled = false;
}}}


function switchit() {
if (readCookie('style')) { title=readCookie('style'); changeStyle(title); var radios = document.getElementById ('styleswitcher');
if (radios) {
 var inputs = radios.getElementsByTagName ('input');
 if (inputs) {
   for (var i = 0; i < inputs.length; ++i) {
     if (inputs[i].type == 'radio' && inputs[i].name == 'style')
       inputs[i].checked = inputs[i].value == (title)
   }
 }
} } }


// function topchangeStyle(title) {
// var lnks = document.getElementsByTagName('link');
// for (var i = lnks.length - 1; i >= 0; i--) {
// if (lnks[i].getAttribute('rel').indexOf('style')> -1 && lnks[i].getAttribute('title')) {
// lnks[i].disabled = true;
// if (lnks[i].getAttribute('title') == title) lnks[i].disabled = false;
// }}}




function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
</script>

And this in my footer:

Code:
<body onload="switchit()">

<div class="tborder" style="position: relative; top: -16px;">
 <table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
  <tr>
    <td class="titlebg" colspan="2">Choose Style</td>
  </tr>
  <tr>   
    <td class="windowbg" width="28" valign="middle" align="center">
    <img src="http://images.smfboards.com/Themes2/default/images/bbc/img.gif">
    </td>
    <td class="windowbg2" height="20">
     <table align="center" cellpadding="0" cellspacing="0" border="0" style=" margin-right:  10px; position: relative; top: -5px;" width="95%">
      <tr>
       <td align=left valign=bottom>
        <div id="styleform">
         <form style action="#" id="styleswitcher" class="styleswitcher"><small>
  <input type="radio" name="style" value="potco" onclick='changeStyle(this.value); parent.frames["top"].changeStyle(this.value)'>Pirates (default)
  <input type="radio" name="style" value="pheonix" onclick='changeStyle(this.value); parent.frames["top"].changeStyle(this.value)'>Phoenix
  <input type="radio" name="style" value="xbox360" onclick='changeStyle(this.value); parent.frames["top"].changeStyle(this.value)'>xbox360

           </fieldset>
          </form>
         </div>
        </td>
       </tr>
      </table>
   </td>
  </tr>
 </table>
</div>

For some reason when you select the 3rd one it changed it to the default style (like here at support)
Logged

simply sibyl
Global Moderator
*
Offline Offline

Posts: 13751



View Profile WWW
« Reply #92 on: April 04, 2009, 11:20:59 am »

Andrew set the style on your forum to potco with the style picker.. looking at your source code you have it set to the default style.

Also you left this part out of your header - it will make the section the radios are in look better:
Code:
<style type="text/css">
fieldset { border: none !important; }
#styleform form { display:inline; margin-bottom: 0;}
</style>
Logged

Andrew
Helpers
*
Offline Offline

Posts: 1796


Andrew at your service


View Profile WWW
« Reply #93 on: April 04, 2009, 11:55:41 am »

Changed the style picker to potco, and inserted the code in headers

That about half-way fixed the problem, now when I click the xbox360, it changed to the SMF default.
Logged

simply sibyl
Global Moderator
*
Offline Offline

Posts: 13751



View Profile WWW
« Reply #94 on: April 04, 2009, 12:11:45 pm »

the code all looks correct..   but,  the styles you are using also have header and footer codes for them.   They need to be used in order for the styles to display correctly.   The xbox one has a header code that has images in it..  I cannot remember how the pirate ones setup at the moment but i know there is code for that too.   You are going to have to do a bunch of editing in the header/footer and the css for the styles you chose to work together.    That and check all the id's to be sure this isnt a duplicate someplace.   This code works superbly but its going to take you some work to use those particular styles together in it.   It would take me a good amount of time to figure out a way to make them work Andrew and I dont have that kind of time.
« Last Edit: April 04, 2009, 12:13:42 pm by simply sibyl » Logged

Andrew
Helpers
*
Offline Offline

Posts: 1796


Andrew at your service


View Profile WWW
« Reply #95 on: April 04, 2009, 12:21:47 pm »

Ah I forgot the xbox360 had a header.
Perhaps I could just try to use ones that dont require a header/footer?
Logged

Mary
SMF For Free Sr. Member
*
Offline Offline

Posts: 434



View Profile WWW
« Reply #96 on: April 16, 2009, 10:32:43 am »

Forum Url: http://pogojustpogo.smfforfree3.com


Sibyl, help, help, help.   I had/have the Stylesheet swapper and it worked great until I changed stylesheets for Easter, and now that I have changed back, it is not swapping like it should.  I have it set to Helios Blue.  Here is what I have in my headers and footers.  What have I done wrong?   Undecided   Thanks for any help you can give me, you know I always come to you and know you will straighten me out.  lol

Header
Code:
<!-- Helios Stylesheet Color Swapper -->
<style type="text/css">
fieldset { border: none !important; }
</style>
<table cellpadding="0" cellspacing="0" align="center">
<tr>
<td  align=right>
<form action="#" id="styleswitcher" class="styleswitcher">
<input name="style" style="cursor: pointer;  border: solid 1px #808080; background-color: #005000; color: #005000; font-size: 6px;" type="submit" value="green" onclick='changeStyle(this.value); parent.frames["top"].changeStyle(this.value)'>
<input name="style" style="cursor: pointer;  border: solid 1px #808080; background-color: #600000; color: #600000; font-size: 6px;" type="submit" value="red" onclick='changeStyle(this.value); parent.frames["top"].changeStyle(this.value)'>
<input name="style" style="cursor: pointer;  border: solid 1px #808080; background-color: #455861; color: #455861; font-size: 6px;" type="submit" value="blue" onclick='changeStyle(this.value); parent.frames["top"].changeStyle(this.value)'>
<input name="style" style="cursor: pointer;  border: solid 1px #808080; background-color: #937C43; color: #937C43; font-size: 6px;" type="submit" value="gold" onclick='changeStyle(this.value); parent.frames["top"].changeStyle(this.value)'>
<input name="style" style="cursor: pointer;  border: solid 1px #808080; background-color: #A55521; color: #A55521; font-size: 6px;" type="submit" value="orange" onclick='changeStyle(this.value); parent.frames["top"].changeStyle(this.value)'>
<input name="style" style="cursor: pointer;  border: solid 1px #808080; background-color: #750075; color: #750075; font-size: 6px;" type="submit" value="purple" onclick='changeStyle(this.value); parent.frames["top"].changeStyle(this.value)'>
</fieldset>
</form>
</td>
</tr>
 <tr>
   <td  class=header height="54px" width="1000px" align=center>
  </td>
 </tr>
</table>


 
<!-- The Stylesheet Links -->

<link rel="stylesheet" type="text/css" href="http://www.smfforfree.com/styles/PogoJustPogo/heliosblue.css?fin11" title="blue">
<link rel="alternate stylesheet" type="text/css" href="http://www.smfforfree3.com/styles/PogoJustPogo/heliosred.css?fin11" title="red">
<link rel="alternate stylesheet" type="text/css" href="http://www.smfforfree3.com/styles/PogoJustPogo/heliosgreen.css?fin11" title="green">
<link rel="alternate stylesheet" type="text/css" href="http://www.smfforfree3.com/styles/PogoJustPogo/heliospurple.css?fin11" title="purple">
<link rel="alternate stylesheet" type="text/css" href="http://www.smfforfree3.com/styles/PogoJustPogo/heliosgold.css?fin11" title="gold">
<link rel="alternate stylesheet" type="text/css" href="http://www.smfforfree3.com/styles/PogoJustPogo/heliosorange.css?fin11" title="orange">

<!-- Script for Stylesheet Swapper DO NOT EDIT  -->
<script type='text/javascript'>
function changeStyle(title) {
var lnks = document.getElementsByTagName('link');
for (var i = lnks.length - 1; i >= 0; i--) {
if (lnks[i].getAttribute('rel').indexOf('style')> -1 && lnks[i].getAttribute('title')) {
lnks[i].disabled = true;
if (lnks[i].getAttribute('title') == title) lnks[i].disabled = false;
}}}

function switchit() {
if (readCookie('style')) { title=readCookie('style'); changeStyle(title); var radios = document.getElementById ('styleswitcher');
if (radios) {
 var inputs = radios.getElementsByTagName ('input');
 if (inputs) {
   for (var i = 0; i < inputs.length; ++i) {
     if (inputs[i].type == 'radio' && inputs[i].name == 'style')
       inputs[i].checked = inputs[i].value == (title)
   }
 }
} } }


// function topchangeStyle(title) {
// var lnks = document.getElementsByTagName('link');
// for (var i = lnks.length - 1; i >= 0; i--) {
// if (lnks[i].getAttribute('rel').indexOf('style')> -1 && lnks[i].getAttribute('title')) {
// lnks[i].disabled = true;
// if (lnks[i].getAttribute('title') == title) lnks[i].disabled = false;
// }}}

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
</script>

Footer - At least I think this is the part of my Footer that goes with this, if not tell me which part does.  I get so confused.  lol
Code:
<body onload="switchit()">
<table align=center>
<td class=footer height="54px" width="1000px" align=center>
</td>
</table>
Logged

Vist us at www.pogojustpogo.smfforfree3.com
Best and Friendliest Pogo FanSite There Is!!
simply sibyl
Global Moderator
*
Offline Offline

Posts: 13751



View Profile WWW
« Reply #97 on: April 21, 2009, 07:59:46 pm »

Granny1 hiya..   sorry it took me so long to get back to you;  I was away on a vacation and got back home yesterday afternoon.     Here is the link for the style swapper for the helious styles...  look thru and compare to how you did it and see if that helps you.   Let me know if you still have problems with it and I'll see what I can do for you.
http://www.smfsupport.com/support/smf_for_free_codes/helios_stylesheet_color_swapper-t10959.0.html;msg49345#msg49345
Logged

Bolens
SMF For Free Member
*
Offline Offline

Posts: 23


View Profile WWW
« Reply #98 on: May 04, 2010, 04:26:46 pm »

Forum Url: http://www.pokemonhackpalace.tk/index.php
Whenever I click mu style, it doesn't change. It just clicks the button, and nothing happens. Any help would be most appreciated?
Logged

simply sibyl
Global Moderator
*
Offline Offline

Posts: 13751



View Profile WWW
« Reply #99 on: May 04, 2010, 04:54:28 pm »

Forum Url: http://www.pokemonhackpalace.tk/index.php
Whenever I click mu style, it doesn't change. It just clicks the button, and nothing happens. Any help would be most appreciated?

The only thing I see in your header for this code is the script.
Go back through the directions, step by step and do everything it says to do.
Logged

Bolens
SMF For Free Member
*
Offline Offline

Posts: 23


View Profile WWW
« Reply #100 on: May 04, 2010, 06:05:12 pm »

Forum Url: http://www.pokemonhackpalace.tk/index.php
Mine has the buttons on the side, but they don't do anything. Any help?
Logged

simply sibyl
Global Moderator
*
Offline Offline

Posts: 13751



View Profile WWW
« Reply #101 on: May 04, 2010, 08:00:05 pm »

Forum Url: http://www.pokemonhackpalace.tk/index.php
Mine has the buttons on the side, but they don't do anything. Any help?

This code will not work in an EzPortal Block .. it was created when we had only the Legacy Portal.  It will work in that one but you cannot use both Portal Systems at the same time.

If you decide to try it either on the bottom of the forum or use Legacy instead of EzPortal there are some problems with the code in your Header:

The urls for the stylesheets in your Header are incorrect.   
The urls have to be the smfforfree urls as that is where the  stylesheets reside, not on .tk 
The directions explain how to do the urls.

You have this in your header twice  (at the top and near the bottom)

Code:
<style type="text/css">
fieldset { border: none !important; }
#styleform form { display:inline; margin-bottom: 0;}
</style>
Logged

Bolens
SMF For Free Member
*
Offline Offline

Posts: 23


View Profile WWW
« Reply #102 on: May 05, 2010, 03:01:09 pm »

Forum Url: http://www.pokemonhackpalace.tk/index.php?action=style;sa=admin
I changed everthing you siad, but it still won't work, any help would be most appreciated?
Logged

simply sibyl
Global Moderator
*
Offline Offline

Posts: 13751



View Profile WWW
« Reply #103 on: May 05, 2010, 03:06:46 pm »

Stylesheet links are incorrect.

Use this:

Code:
<link rel="stylesheet" type="text/css" href="http://www.smfforfree.com/styles/pokehackpalace/hackoriginal.css?fi11" title="PokeHack Original Theme">
<link rel="alternate stylesheet" type="text/css" href="http://www.smfforfree.com/styles/pokehackpalace/neverpjedutheme.css?fi11" title="Never PJed U Theme">

Make sure you get the entire code.. you also had a missing > at the end of the second one

hackoriginal style has to be set as the forum default in Manage styles
« Last Edit: May 05, 2010, 03:09:42 pm by simply sibyl » Logged

Bolens
SMF For Free Member
*
Offline Offline

Posts: 23


View Profile WWW
« Reply #104 on: May 05, 2010, 03:09:28 pm »

Alright, I did this to, but it still doesn't work. This is getting to be very hard, what is wrong with it?  Angry
Logged



Pages: 1 ... 4 5 6 [7] 8
  Print  
 
Jump to:  



Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC
Hostgator Hosting
Page created in 0.786 seconds with 20 queries. (Pretty URLs adds 0.207s, 2q)