View previous topic :: View next topic |
Author |
Message |
Benjy
Joined: 25 Jan 2002 Posts: 108 Location: Paris, France
|
Posted: Thu May 23, 2002 6:56 pm Post subject: B2 Pseudo Smilies Hack v1.3 |
|
|
After giving the exclusivity of this one to The B2 template and hack archives, here it is:
Hack: b2 Pseudo Smilies
====
Author: Benjy
[email protected]
www.newcomics.fr.st
====
Release: 1.3 (05/23/2002)
====
Description: Allows you to include smilies in your post by choosing them in a popup window.
*No* BB Code, only mouse power.
====
History:
1.3 (05/20/2002): script completely redone
smilies list popups
1.2 (05/14/2002): corrected the paths
1.1 (04/11/2002): xml compliancy (thx to dodo)
1.0 (04/08/2002): initial release
====
Instructions for an upgrade:
I know some people are gonna hate me for this, but this release of the b2 pseudo smilies hack will require you to remove all previously made modifications (ONLY if you installed previous release), that is:
(1/2) <B2_root>\b2-include\b2quicktags.js - remove Quote: | function smilie(path2smilie) {
smilie2insert='<img alt="" src="' + path2smilie + '" />';
if ((parseInt(navigator.appVersion) >= 4) && (navigator.appName == "Microsoft Internet Explorer"))
theSelection = document.selection.createRange().text; // Get text selection
if (theSelection) {
// Add tags around selection
document.selection.createRange().text = theSelection + smilie2insert + ' ';
document.post.content.focus();
theSelection = '';
return;
}
document.post.content.value += ' ' + smilie2insert + ' ';
document.post.content.focus();
} |
(2/2) <B2_root>\b2-include\b2edit.form.php - replace Quote: | <!--SMILIES HACK BEGIN-->
<table cellspacing="0" cellpadding="0" border="0" width="100%"><tr>
<td valign="top" width="90%"><textarea rows="9" cols="40" style="width:100%" name="content" tabindex="4" wrap="virtual"><?php echo $content ?></textarea></td>
<td valign="top">
<?php
$dir2open="b2-img/smilies"; //dir 2 preview smilies
$dir2include="b2/b2-img/smilies"; //dir 2 include smilies
$nbrcol=4; //columns for the smilies
$handle=opendir($dir2open);
echo "<table>\n";
echo "<tr>\n";
$i=0;
while ($file = readdir($handle)) {
if ($file != "." and $file !=".." and eregi("\.gif$",$file)) {
if ($i==$nbrcol) {
echo "</tr><tr>\n";
$i=0;
}
echo "<td><img src=\"$dir2open/$file\" onClick=\"smilie('$siteurl/$dir2include/$file')\" style=\"cursor:hand\"></td>\n";
$i++;
}
}
echo "</tr>\n";
echo "</table>\n";
closedir($handle);
?>
</td>
</tr></table>
<!--SMILIES HACK END--> | with Quote: | <textarea rows="9" cols="40" style="width:100%" name="content" tabindex="4" wrap="virtual"><?php echo $content ?></textarea> |
Now drop to the fresh install part
====
Instructions for a fresh install:
(1/3) <B2_root>\b2smilies.php - create Quote: | <?php
/* b2 Smilies - original hack by Benjy - [email protected] - www.newcomics.fr.st */
$standalone="1";
include_once("./b2header.php");
if ($user_level == 0) //Checks to see if user has logged in
die ("Cheatin' uh ?");
?><html>
<head>
<title>b2 > insert smilies/images</title>
<link rel="stylesheet" href="<?php echo $b2inc; ?>/b2.css" type="text/css">
<style type="text/css">
<!--
body {
background-image: url('<?php
if ($is_gecko || $is_macIE) {
?>b2-img/bgbookmarklet1.gif<?php
} else {
?>b2-img/bgbookmarklet3.gif<?php
}
?>');
background-repeat: no-repeat;
margin: 30px;
}
<?php
if (!$is_NS4) {
?>
textarea,input,select {
background-color: white;
/*<?php if ($is_gecko || $is_macIE) { ?>
background-image: url('b2-img/bgbookmarklet.png');
<?php } elseif ($is_winIE) { ?>
background-color: #cccccc;
filter: alpha(opacity:80);
<?php } ?>
*/ border-width: 1px;
border-color: #cccccc;
border-style: solid;
padding: 2px;
margin: 1px;
}
<?php if (!$is_gecko) { ?>
.checkbox {
border-width: 0px;
border-color: transparent;
border-style: solid;
padding: 0px;
margin: 0px;
}
.uploadform {
background-color: white;
<?php if ($is_winIE) { ?>
filter: alpha(opacity:100);
<?php } ?>
border-width: 1px;
border-color: #333333;
border-style: solid;
padding: 2px;
margin: 1px;
width: 265px;
height: 24px;
}
<?php } ?>
<?php
}
?>
-->
</style>
</head>
<body>
<table align="center" width="100%" height="100%" cellpadding="15" cellspacing="0" border="1" style="border-width: 1px; border-color: #cccccc;">
<tbody>
<tr>
<td valign="top" style="background-color: transparent; <?php if ($is_gecko || $is_macIE) { ?>background-image: url('b2-img/bgbookmarklet.png');<?php } elseif ($is_winIE) { ?>background-color: #cccccc; filter: alpha(opacity:60);<?php } ?>;">
<?php
$dir2open="b2-img/smilies"; //dir 2 preview smilies
$dir2include="b2/b2-img/smilies"; //dir 2 include smilies
$nbrcol=4; //columns for the smilies
$handle=opendir($dir2open);
echo "<table>\n";
echo "<tr>\n";
$i=0;
while ($file = readdir($handle)) {
if ($file != "." and $file !=".." and eregi("\.gif$",$file)) {
if ($i==$nbrcol) {
echo "</tr><tr>\n";
$i=0;
}
echo "<td><img src=\"$dir2open/$file\" onClick=\"javascript:opener.smilie('$siteurl/$dir2include/$file')\" style=\"cursor:hand\"></td>\n";
$i++;
}
}
echo "</tr>\n";
echo "</table>\n";
closedir($handle);
?>
</td>
</tr>
</tbody>
</table>
</body>
</html> |
(2/3) <B2_root>\b2-include\b2quicktags.php - add below Quote: | <td>
<input type="button" class="quicktags" accesskey="p" name="addbbcode14" value="image" title="insert an image" style="width: 40px" onClick="bbstyle(this.form,14)" />
</td> | this code Quote: | <td>
<input type="button" class="quicktags" accesskey="s" value="smilies" onclick="javascript:window.open('/','b2smilies','width=200,height=300,location=0,menubar=0,resizable=1,scrollbars=yes,status=1,toolbar=0');" style="width: 60px" />
</td> |
(3/3) <B2_root>\b2-include\b2quicktags.js - add in the end Quote: | function smilie(thesmilie) {
smilie2insert='<img alt="" src="' + thesmilie + '" />';
document.post.content.value += smilie2insert + " ";
document.post.content.focus();
} |
Then, don't forget to setup *your* $dir2open, $dir2include, $nbrcol variables in b2smilies.php, and, if needed, correct the width and height of the popup window in b2quicktags.php.
====
Enjoy,
Benjy.
Note: I began a new thread because it's a looooong post |
|
Back to top |
|
 |
adamwalker
Joined: 07 Apr 2002 Posts: 125 Location: England
|
Posted: Thu May 23, 2002 9:01 pm Post subject: lo |
|
|
we had the exclusive. yay!!!! wooooo. hehehe. chears benjy, i feel so proud!! _________________ Shameless Plug - For all your B2 template and hack needs visit www.adamwalker.34sp.com |
|
Back to top |
|
 |
zootsuit
Joined: 17 May 2002 Posts: 14
|
Posted: Thu May 23, 2002 9:06 pm Post subject: |
|
|
lol!
contain yerself adam!
benjy.. been having problems installing the smilie hack since the version before this. I've even tried the "already altered" files. think I'm missing something... or is it my OS X IE 5 isn't cooperating.. |
|
Back to top |
|
 |
Benjy
Joined: 25 Jan 2002 Posts: 108 Location: Paris, France
|
Posted: Thu May 23, 2002 9:49 pm Post subject: |
|
|
What is the problem? |
|
Back to top |
|
 |
zootsuit
Joined: 17 May 2002 Posts: 14
|
Posted: Thu May 23, 2002 11:44 pm Post subject: |
|
|
well.. in the previous version.. clicking on a smilie did not produce any image url in the text field as I understood it to do (actually.. produced absolutely nuthin' in the text field). this new version.. well.. I'm still trying to install it. I'll try it tomorrow and letcha know how it goes.
oops shoulda added a little bit more info on it.
made sure $dir2open and $dir2include were correct, as well as b2header path. Used both the posted version and the files available at Adam's. And, uh, yea.. made sure to upload to the proper directory |
|
Back to top |
|
 |
tricky
Joined: 22 May 2002 Posts: 7
|
Posted: Fri May 24, 2002 2:53 am Post subject: Hey There |
|
|
Hey, I'm trying to use your hack, cause it seems great...
I added the b2smiles.php, I added the code to the two other files, and as far as I can tell all should be working (and I changed the stuff in the b2smiles.php, too. For whatever reason, my edit post page is exactly the same, even though I added all the code and such.
Any idea what is wrong? One other thing is I'm using IE 5 for Mac, would this make a difference? I don't see why it couldn't work on Mac...I just can't see the buttion on the edit page.
Thanks,
Liz |
|
Back to top |
|
 |
Benjy
Joined: 25 Jan 2002 Posts: 108 Location: Paris, France
|
Posted: Fri May 24, 2002 9:37 am Post subject: |
|
|
Are you sure you inserted the code for b2quicktags.php between Quote: | <td>
<input type="button" class="quicktags" accesskey="p" name="addbbcode14" value="image" title="insert an image" style="width: 40px" onClick="bbstyle(this.form,14)" />
</td> | and Quote: | <td>
<input type="button" class="quicktags" accesskey="w" name="addbbcode16" value="link" title="insert a link" style="text-decoration: underline; width: 40px" onClick="bbstyle(this.form,16)" />
</td> | ?
It's a standard code, fully HTML compliant, and shouldn't cause any problem, on any platform or browser. After that the smilies button will appear between the image and the link buttons.
Here's an animated gif:
And btw it ain't b2smiles.php, but b2smilies.php.
Benjy. |
|
Back to top |
|
 |
zootsuit
Joined: 17 May 2002 Posts: 14
|
Posted: Fri May 24, 2002 3:38 pm Post subject: |
|
|
Benjy!!!
I'm not seeing ANY of those style tags!! (I didn't even know they existed!) That's gotta be the prob.. oh boy! I think I can fix this now.. thanks for the screenshot!
Here's what mine's looking like:
|
|
Back to top |
|
 |
Benjy
Joined: 25 Jan 2002 Posts: 108 Location: Paris, France
|
Posted: Fri May 24, 2002 3:53 pm Post subject: Only for MacOS people! |
|
|
Oh my! It's because quicktags are disabled on MacOS
So you can try adding this (or similar): Quote: | <a href="#" onclick="javascript:window.open('/','b2smilies','width=200,height=300,location=0,menubar=0,resizable=1,scrollbars=yes,status=1,toolbar=0');">Smilies</a> | under this Quote: | <?php if ($use_quicktags) include($b2inc."/b2quicktags.php"); ?> | in b2.edit.form.php.
Tell me if then the add-a-smilie code works...
Oh! and you can remove the mods from b2quicktags.php
Benjy. |
|
Back to top |
|
 |
zootsuit
Joined: 17 May 2002 Posts: 14
|
Posted: Fri May 24, 2002 4:17 pm Post subject: |
|
|
getting closer.. smilies popup link works.. shows the smilies.. but unfortunately, the js to insert the smilie image urls isn't cooperating now.. "object doesn't support this property or method" |
|
Back to top |
|
 |
Benjy
Joined: 25 Jan 2002 Posts: 108 Location: Paris, France
|
Posted: Fri May 24, 2002 6:43 pm Post subject: |
|
|
And replacing, in b2quicktags.js, this Quote: | function smilie(thesmilie) {
smilie2insert='<img alt="" src="' + thesmilie + '" />';
document.post.content.value += smilie2insert + " ";
document.post.content.focus();
} | with this? Quote: | function smilie(thesmilie) {
smilie2insert='<img alt="" src="' + thesmilie + '" />';
document.forms['post'].content.value += smilie2insert + " ";
document.forms['post'].content.focus();
} |
|
|
Back to top |
|
 |
zootsuit
Joined: 17 May 2002 Posts: 14
|
Posted: Fri May 24, 2002 7:02 pm Post subject: |
|
|
didn't work.. this is getting perplexing |
|
Back to top |
|
 |
Benjy
Joined: 25 Jan 2002 Posts: 108 Location: Paris, France
|
Posted: Fri May 24, 2002 9:52 pm Post subject: |
|
|
Yes. It seems to me that MacOS doesn't understand the opener javascript function
The last shot would be, in b2smilies.php, to replace Quote: | echo "<td><img src=\"$dir2open/$file\" onClick=\"javascript:opener.smilie('$siteurl/$dir2include/$file')\" style=\"cursor:hand\"></td>\n"; | with Quote: | echo "<td><img src=\"$dir2open/$file\" onClick=\"javascript:smilie('$siteurl/$dir2include/$file')\" style=\"cursor:hand\"></td>\n"; | and to write in the same file, just beforethis code Quote: | <script language="javascript" type="text/javascript">
<!--
function smilie(thesmilie) {
smilie2insert='<img alt="" src="' + thesmilie + '" />';
opener.document.forms['post'].content.value += smilie2insert + " ";
opener.document.forms['post'].content.focus();
}
//-->
</script> |
And btw I'm curious... do smilies work on this board? and from the popup window ('view more emoticons')? or perhaps is it the onClick action... seems odd to me
Has Michel an idea?
Benjy. |
|
Back to top |
|
 |
tricky
Joined: 22 May 2002 Posts: 7
|
Posted: Fri May 24, 2002 10:16 pm Post subject: Yay! |
|
|
Woohoo!! It works! Yay!
(btw, yes, the pop up window for the board's smilies works)
Thanks,
Liz |
|
Back to top |
|
 |
zootsuit
Joined: 17 May 2002 Posts: 14
|
Posted: Fri May 24, 2002 11:09 pm Post subject: |
|
|
YES!!!!!
It works!
Maybe should throw a separate version up on adam's for mac users? |
|
Back to top |
|
 |
|