Post by ialex on Oct 25, 2007 22:49:48 GMT -8
Well, admittedly not much originality in this code, I simply re-wrote my old mood icon code, but with less features!
This code will allow each user to individually select a mood in their profile. This mood will then be displayed in their mini profile. There are no images incorporated in this code, there mood will be displayed in text.
Modify Profile Preview
Mini Profile Preview
Global Footer.
Cross-Browser.
<script type="text/javascript">
<!--
/*Personal Moods - By iAlex - Open Source*/
var iMoodList=[
"Happy",
"Wink",
"Grin",
"Cheesy",
"Angry",
"Sad",
"Shocked",
"Cool",
"Confused",
"Sarcastic",
"Silly",
"Embarrassed",
"Silent",
"Unsure",
"Kiss",
"Crying" //No comma on last line
];
if(document.modifyForm){
var iMoodTable=document.modifyForm.personaltext.parentNode.parentNode.parentNode.parentNode.parentNode;
var iMoodDiv=document.createElement('div');
iMoodDiv.innerHTML='<table cellpadding="2" cellspacing="2" border="0"><tr><td width="154" valign="top"><font size="-1">Mood:</font></td><td width="245"><font size="-1" id="iMoodFont"></font></td><td width="245"><font size="-2">If you wish to display a mood, select it here.</font></td></tr></table>';
iMoodTable.parentNode.insertBefore(iMoodDiv, iMoodTable);
var iMoodFont=document.getElementById('iMoodFont');
var iMoodSelect=document.createElement('select');
var iMoodText=document.modifyForm.personaltext;
iMoodSelect.options[0]=new Option('Mood');
for(i=0;i<iMoodList.length;i++){
iMoodSelect.options[iMoodSelect.length]=new Option(iMoodList);
}
if(iMoodText.value.match(/\[Mo0:(\d+)\]/)){
iMoodSelect.selectedIndex=RegExp.$1;
iMoodText.value=iMoodText.value.replace(/\[Mo0:(\d+)\]/g, '');
}
iMoodFont.appendChild(iMoodSelect);
if(document.addEventListener){
document.modifyForm.addEventListener('submit', function(){
iMoodText.value=iMoodText.value+'[Mo0:'+iMoodSelect.selectedIndex+']';
}, false);
}
else{
document.modifyForm.attachEvent('onsubmit', function(){
iMoodText.value=iMoodText.value+'[Mo0:'+iMoodSelect.selectedIndex+']';
});
}
}
if(location.href.match(/action=(display|viewprofile|(user)?recent|calendarview|search2|pmview)/) || location.href.match(/index.cgi$/) && document.title.match(/Preview/) && document.postForm){
var iTd=document.getElementsByTagName('td');
for(i=0;i<iTd.length;i++){
if(iTd.item(i).width=="20%" && iTd.item(i).className.match(/windowbg(2)?/) && iTd.item(i).vAlign=="top" && iTd.item(i).innerHTML.match(/member is/) && iTd.item(i).innerHTML.match(/\[Mo0:(\d+)\]/)){
if(RegExp.$1>0){
var iMoodDisplay=document.createElement('div');
iMoodDisplay.innerHTML='Mood: '+iMoodList[RegExp.$1-1];
iTd.item(i).appendChild(iMoodDisplay);
}
iTd.item(i).innerHTML=iTd.item(i).innerHTML.replace(/\[Mo0:(\d+)\]/g, '');
}
}
}
//-->
</script>
You can modify the moods through the variables at the top. Just change the words to whatever you want.
You may add as many moods as you want, just make sure there is no comma on the last line.
This code will allow each user to individually select a mood in their profile. This mood will then be displayed in their mini profile. There are no images incorporated in this code, there mood will be displayed in text.
Modify Profile Preview
Mini Profile Preview
Global Footer.
Cross-Browser.
<script type="text/javascript">
<!--
/*Personal Moods - By iAlex - Open Source*/
var iMoodList=[
"Happy",
"Wink",
"Grin",
"Cheesy",
"Angry",
"Sad",
"Shocked",
"Cool",
"Confused",
"Sarcastic",
"Silly",
"Embarrassed",
"Silent",
"Unsure",
"Kiss",
"Crying" //No comma on last line
];
if(document.modifyForm){
var iMoodTable=document.modifyForm.personaltext.parentNode.parentNode.parentNode.parentNode.parentNode;
var iMoodDiv=document.createElement('div');
iMoodDiv.innerHTML='<table cellpadding="2" cellspacing="2" border="0"><tr><td width="154" valign="top"><font size="-1">Mood:</font></td><td width="245"><font size="-1" id="iMoodFont"></font></td><td width="245"><font size="-2">If you wish to display a mood, select it here.</font></td></tr></table>';
iMoodTable.parentNode.insertBefore(iMoodDiv, iMoodTable);
var iMoodFont=document.getElementById('iMoodFont');
var iMoodSelect=document.createElement('select');
var iMoodText=document.modifyForm.personaltext;
iMoodSelect.options[0]=new Option('Mood');
for(i=0;i<iMoodList.length;i++){
iMoodSelect.options[iMoodSelect.length]=new Option(iMoodList);
}
if(iMoodText.value.match(/\[Mo0:(\d+)\]/)){
iMoodSelect.selectedIndex=RegExp.$1;
iMoodText.value=iMoodText.value.replace(/\[Mo0:(\d+)\]/g, '');
}
iMoodFont.appendChild(iMoodSelect);
if(document.addEventListener){
document.modifyForm.addEventListener('submit', function(){
iMoodText.value=iMoodText.value+'[Mo0:'+iMoodSelect.selectedIndex+']';
}, false);
}
else{
document.modifyForm.attachEvent('onsubmit', function(){
iMoodText.value=iMoodText.value+'[Mo0:'+iMoodSelect.selectedIndex+']';
});
}
}
if(location.href.match(/action=(display|viewprofile|(user)?recent|calendarview|search2|pmview)/) || location.href.match(/index.cgi$/) && document.title.match(/Preview/) && document.postForm){
var iTd=document.getElementsByTagName('td');
for(i=0;i<iTd.length;i++){
if(iTd.item(i).width=="20%" && iTd.item(i).className.match(/windowbg(2)?/) && iTd.item(i).vAlign=="top" && iTd.item(i).innerHTML.match(/member is/) && iTd.item(i).innerHTML.match(/\[Mo0:(\d+)\]/)){
if(RegExp.$1>0){
var iMoodDisplay=document.createElement('div');
iMoodDisplay.innerHTML='Mood: '+iMoodList[RegExp.$1-1];
iTd.item(i).appendChild(iMoodDisplay);
}
iTd.item(i).innerHTML=iTd.item(i).innerHTML.replace(/\[Mo0:(\d+)\]/g, '');
}
}
}
//-->
</script>
You can modify the moods through the variables at the top. Just change the words to whatever you want.
You may add as many moods as you want, just make sure there is no comma on the last line.