March 28, 2024, 06:23:04 am
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome to Revolution X, where Coding meets Graphics.
 
  Home Help Search Arcade Affiliates Staff List Calendar Members Login Register  

User Widget

Pages: [1]   Go Down
  Print  
Author Topic: User Widget  (Read 1134 times)
0 Members and 1 Guest are viewing this topic.
Agent Moose
Administrator
Adminitrator
Offline Offline

Gender: Male
Posts: 1,470



View Profile WWW
Badges: (View All)
Tenth year Anniversary Nineth year Anniversary Search
« on: August 28, 2009, 09:40:38 pm »

Footers:
Code:
<script type="text/javascript">
var yes = "Welcome {user}.";
var no = "Please <a href='" + smf_scripturl + "?action=login'>Login</a> or <a href='" + smf_scripturl + "?action=join'>Register</a>";

var name = document.getElementsByTagName("span");
//Created by Agent Moose (revolutionx.smfforfree3.com)
for(v=0;v<name.length;v++){
if(name[v].innerHTML.match(/Hello <b>(.*)<\/b>/i)){
var username = RegExp.$1;
if(yes.match(/{user}/i)) yes = yes.replace(/{user}/i,username);
};};
var O_o = document.getElementsByTagName("td");
for(o_O=0;o_O<O_o.length;o_O++){
if(O_o[o_O].className == "catbg" && O_o[o_O].height == "32" && username){
O_o[o_O].innerHTML = "<span style='float: right;'>" + yes + "</span>" + O_o[o_O].innerHTML;
}else if(O_o[o_O].className == "catbg" && O_o[o_O].height == "32" && !username){
O_o[o_O].innerHTML = "<span style='float: right;'>" + no + "</span>" + O_o[o_O].innerHTML;
};};
</script>

Original Request: http://revolutionx.smfforfree3.com/index.php/topic,1010.0.html

This code will add either "Welcome {user}" or "Please Login or Register" to the top where it shows your board name. If you have a banner for your forum, this code will not look very well on your forum.

Edit as you wish Smiley  If you put {user} in the var yes = ""; part, it will show the users' username Smiley

Enjoy Smiley
Report Spam   Logged


Share on Facebook Share on Twitter

Andrew
Exclusive
Exclusive
Offline Offline

Gender: Male
Posts: 539



View Profile WWW
Badges: (View All)
Combination Topic Starter Poll Voter
« Reply #1 on: August 28, 2009, 10:40:51 pm »

Lmao what's with all the 'O_o' s in there? Makes the code look kinda.. silly Cheesy

Gonna go add this one now! Great code Agent!!  Afro
Report Spam   Logged

Exilis
Optimistic & Creative
Global Moderator
Global Moderator
Offline Offline

Posts: 929


View Profile
Badges: (View All)
Tenth year Anniversary Linux User Combination
« Reply #2 on: August 29, 2009, 09:03:33 am »

Ah yes I love the variable names.
Report Spam   Logged

Global Mod, (sort of) at your service.

http://twitter.com/timothyaveni

KrylonKrystals
Starter
Starter
Offline Offline

Gender: Male
Posts: 22


View Profile
Badges: (View All)
« Reply #3 on: August 29, 2009, 09:47:41 am »

Thanks again moose! Smiley
Report Spam   Logged

Nick
Member
Member
Offline Offline

Gender: Male
Posts: 48


View Profile
Badges: (View All)
« Reply #4 on: August 29, 2009, 11:56:36 am »

Awesome code Smiley
Report Spam   Logged
Agent Moose
Administrator
Adminitrator
Offline Offline

Gender: Male
Posts: 1,470



View Profile WWW
Badges: (View All)
Tenth year Anniversary Nineth year Anniversary Search
« Reply #5 on: August 29, 2009, 06:33:10 pm »

Glad all of yall like Smiley
Report Spam   Logged


KrylonKrystals
Starter
Starter
Offline Offline

Gender: Male
Posts: 22


View Profile
Badges: (View All)
« Reply #6 on: August 30, 2009, 09:14:59 pm »

Hey moose I've got a question.. Is it possible to make the code wrapped in <span class= "smalltext"> html? Also, is there a way maybe I can possible move the thing out of catbg? I see you have it in the code, I tried didn't succeed well in doing that maybe you can take a look at my forum for a better spot?

http://gamerscoreachievements.smfforfree3.com (not advertising)

- Thanks again
KrylonKrystals
Report Spam   Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy