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) { ...@@ -38,6 +38,9 @@ if(($sendmode == 'send')&&$chatmsg) {
if(!$chatdata) { if(!$chatdata) {
$chatdata = getchat($lastcid,$teamID); $chatdata = getchat($lastcid,$teamID);
} }
if(!$emdata) {
$emdata = get_emdata();
}
ob_clean(); ob_clean();
//$json = new Services_JSON(); //$json = new Services_JSON();
//$jgamedata = $json->encode($chatdata); //$jgamedata = $json->encode($chatdata);
......
...@@ -43,7 +43,8 @@ $clbpara = get_clbpara($clbpara); ...@@ -43,7 +43,8 @@ $clbpara = get_clbpara($clbpara);
$log = ''; $log = '';
//读取聊天信息 //读取聊天信息
$chatdata = getchat(0,$teamID); $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"); $result = $db->query("SELECT lid,time,log FROM {$tablepre}log WHERE toid = '$pid' AND prcsd = 0 ORDER BY time,lid");
$llist = ''; $llist = '';
......
...@@ -640,6 +640,3 @@ function destory_corpse(&$edata) ...@@ -640,6 +640,3 @@ function destory_corpse(&$edata)
} }
return; return;
} }
?>
...@@ -405,11 +405,28 @@ function getchat($last,$team='',$limit=0) { ...@@ -405,11 +405,28 @@ function getchat($last,$team='',$limit=0) {
} elseif($chat['type'] == '5') { } elseif($chat['type'] == '5') {
$msg = "<span class=\"yellow\">【{$chatinfo[$chat['type']]}{$chat['msg']}".date("\(H:i:s\)",$chat['time']).'</span><br>'; $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; $chatdata['msg'][$chat['cid']] = $msg;
} }
return $chatdata; 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){ function storyputchat($time,$type){
global $db,$tablepre,$now,$syschatinfo,$gamestate,$rdown,$bdown,$ldown,$kdown; global $db,$tablepre,$now,$syschatinfo,$gamestate,$rdown,$bdown,$ldown,$kdown;
if(!$time){$time = $now;} if(!$time){$time = $now;}
......
...@@ -17,22 +17,47 @@ ...@@ -17,22 +17,47 @@
<tr> <tr>
<td class="b3" height="35"> <td class="b3" height="35">
<div> <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="lastcid" name="lastcid" value="$chatdata['lastcid']">
<input type="hidden" id="teamID" name="teamID" value="$teamID"> <input type="hidden" id="teamID" name="teamID" value="$teamID">
<input type="hidden" id="sendmode" name="sendmode" value="ref"> <input type="hidden" id="sendmode" name="sendmode" value="ref">
<span id="chattype"> <span id="chattype">
<select name="chattype" value="2"> <select name="chattype" value="2">
<option value="0" selected>$chatinfo[0] <option value="0" selected>$chatinfo[0]
<!--{if $teamID}--><option value="1" >$chatinfo[1]<!--{/if}--> <!--{if $teamID}-->
<option value="1">$chatinfo[1]
<!--{/if}-->
</select> </select>
</span> </span>
<input type="text" id="chatmsg" name="chatmsg" maxlength="60" > <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="send"
<input type="button" id="ref" onClick="document['sendchat']['sendmode'].value='ref';chat('ref',$chatrefresh);return false;" value="{lang refresh}"> 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> </form>
<script type="text/javascript">chat('ref',$chatrefresh);</script> <script type="text/javascript">chat('ref', $chatrefresh);</script>
</div> </div>
</td> </td>
</tr> </tr>
</table> </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