Commit 25a98503 authored by unknown's avatar unknown

尽量优雅的表情系统

Signed-off-by: default avatarunknown <mccleaner@126.com>
parent 99dfe841
......@@ -38,6 +38,9 @@ if(($sendmode == 'send')&&$chatmsg) {
if(!$chatdata) {
$chatdata = getchat($lastcid,$teamID);
}
if(!$emdata) {
$emdata = get_emdata();
}
ob_clean();
//$json = new Services_JSON();
//$jgamedata = $json->encode($chatdata);
......
......@@ -43,7 +43,8 @@ $clbpara = get_clbpara($clbpara);
$log = '';
//读取聊天信息
$chatdata = getchat(0,$teamID);
//读取表情信息
$emdata = get_emdata();
//读取玩家互动信息
$result = $db->query("SELECT lid,time,log FROM {$tablepre}log WHERE toid = '$pid' AND prcsd = 0 ORDER BY time,lid");
$llist = '';
......
......@@ -640,6 +640,3 @@ function destory_corpse(&$edata)
}
return;
}
?>
......@@ -405,11 +405,28 @@ function getchat($last,$team='',$limit=0) {
} elseif($chat['type'] == '5') {
$msg = "<span class=\"yellow\">【{$chatinfo[$chat['type']]}{$chat['msg']}".date("\(H:i:s\)",$chat['time']).'</span><br>';
}
//表情
$msg = preg_replace('/\[(\w+)\]/', "<img src='img/emoticons/$1.png'>", $msg);
$chatdata['msg'][$chat['cid']] = $msg;
}
return $chatdata;
}
//获取表情
function get_emdata()
{
global $emdata;
$emdir = 'img/emoticons/';
$emfiles = glob($emdir . '*.png');
$emdata = array();
foreach ($emfiles as $emfile) {
$name = basename($emfile, '.png');
$emdata[] = "<img src='$emdir$name.png' alt='$name' onClick=\"insertEm('$name')\">";
}
return $emdata;
}
function storyputchat($time,$type){
global $db,$tablepre,$now,$syschatinfo,$gamestate,$rdown,$bdown,$ldown,$kdown;
if(!$time){$time = $now;}
......
......@@ -17,22 +17,47 @@
<tr>
<td class="b3" height="35">
<div>
<form type="post" id="sendchat" name="sendchat" action="chat.php" onsubmit="return false;" >
<form type="post" id="sendchat" name="sendchat" action="chat.php" onsubmit="return false;">
<input type="hidden" id="lastcid" name="lastcid" value="$chatdata['lastcid']">
<input type="hidden" id="teamID" name="teamID" value="$teamID">
<input type="hidden" id="sendmode" name="sendmode" value="ref">
<span id="chattype">
<select name="chattype" value="2">
<option value="0" selected>$chatinfo[0]
<!--{if $teamID}--><option value="1" >$chatinfo[1]<!--{/if}-->
<!--{if $teamID}-->
<option value="1">$chatinfo[1]
<!--{/if}-->
</select>
</span>
<input type="text" id="chatmsg" name="chatmsg" maxlength="60" >
<input type="button" id="send" onClick="document['sendchat']['sendmode'].value='send';chat('send',$chatrefresh);return false;" value="{lang send}">
<input type="button" id="ref" onClick="document['sendchat']['sendmode'].value='ref';chat('ref',$chatrefresh);return false;" value="{lang refresh}">
<input type="text" id="chatmsg" name="chatmsg" maxlength="60">
<input type="button" id="send"
onClick="document['sendchat']['sendmode'].value='send';chat('send',$chatrefresh);return false;"
value="{lang send}">
<input type="button" id="ref"
onClick="document['sendchat']['sendmode'].value='ref';chat('ref',$chatrefresh);return false;"
value="{lang refresh}">
<!-- 表情 -->
<input type="button" id="embtn" value="表情">
<div id="empanel" style="display:none;">
<!--{loop $emdata $em}-->
$em
<!--{/loop}-->
</div>
</form>
<script type="text/javascript">chat('ref',$chatrefresh);</script>
<script type="text/javascript">chat('ref', $chatrefresh);</script>
</div>
</td>
</tr>
</table>
\ No newline at end of file
</table>
<!-- JavaScript 代码 -->
<script>
function insertEm(em) {
document.getElementById('chatmsg').value += "[" + em + "]";
}
document.getElementById('embtn').addEventListener('click', function () {
var panel = document.getElementById('empanel');
panel.style.display = (panel.style.display == 'none') ? 'block' : 'none';
});
</script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment