Created
February 16, 2017 20:51
-
-
Save neomadara/00440823e16c97f427ea45ae021c85e3 to your computer and use it in GitHub Desktop.
vendimia chat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
en index | |
<?if($_REQUEST["mod"]!=""){include("mods/".$prefijo."".$_REQUEST["mod"].".txt");}else{ include("mods/".$prefijo."".$index.".txt");}?> | |
en sg config | |
$index='qNsGn33iC1t6LCL7NRg2'; | |
modulo | |
<? | |
if($_SESSION['idusuario']!=17){ | |
?> | |
<section class="content-header"> | |
<h1>Tablero de Información</h1> | |
<ol class="breadcrumb"> | |
<li><a href="index.php"><i class="fa fa-home"></i> Home</a></li> | |
<li class="active">Tablero de Información</li> | |
</ol> | |
</section> | |
<section class="content"> | |
<div class="row"> | |
<div class="col-md-6"> | |
<div class="box <?=$boxcaja?> direct-chat direct-chat-success"> | |
<div class="box-footer" style="display: block;"> | |
<div class="input-group"> | |
<input type="text" id="mensaje" placeholder="mensaje ..." class="form-control"> | |
<input type="hidden" id="ultimoid" value=0> | |
<span class="input-group-btn"> | |
<button type="button" class="btn <?=$btnform?> " onclick="enviamensaje();"> Enviar </button> | |
</span> | |
</div> | |
</div><!-- /.box-footer--> | |
<div class="box-body" style="display: block;"> | |
<div class="direct-chat-messages" style="height:500px"> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</section> | |
<script> | |
$(document).ready(function() { | |
buscarmensajes(); | |
setInterval(buscarmensajes,60000); | |
}); | |
$('#mensaje').bind('keypress', function(e) { | |
var code = e.keyCode || e.which; | |
if(code == 13) { //Enter keycode | |
enviamensaje(); | |
} | |
}); | |
function enviamensaje(){ | |
var mensaje=$("#mensaje").val(); | |
if(mensaje!=""){ | |
var text=""; | |
$.get("sg_operacion.php", {operacion:'enviamensaje',mensaje:''+mensaje+'',retornar:'no'} ,function(data){ | |
if(data!='no'){ | |
$("#ultimoid").val(data.id); | |
text+='<div class="direct-chat-msg right">'; | |
text+='<div class="direct-chat-info clearfix">'; | |
text+='<span class="direct-chat-name pull-right">'+data.nombre+'</span>'; | |
text+='<span class="direct-chat-timestamp pull-left">'+data.fecha+'</span>'; | |
text+='</div>'; | |
text+='<img class="direct-chat-img" src="img/'+data.imagen+'" alt="message user image">'; | |
text+='<div class="direct-chat-text">'; | |
text+=data.mensaje; | |
text+='</div>'; | |
text+='</div>'; | |
$(".direct-chat-messages").prepend(text); | |
} | |
},'json'); | |
} | |
} | |
function buscarmensajes(){ | |
var ultimoid=$("#ultimoid").val(); | |
var miid="<?=$_SESSION['idusuario'];?>"; | |
if(mensaje!=""){ | |
var text=""; | |
$.get("sg_operacion.php", {operacion:'buscamensaje',ultimoid:''+ultimoid+'',retornar:'no'} ,function(data){ | |
if(data!="no"){ | |
$.each( data , function(x, val ) { | |
$("#ultimoid").val(val.id); | |
text='<div class="direct-chat-msg '; | |
if(miid==val.user){text+='right ';} | |
text+='">'; | |
text+='<div class="direct-chat-info clearfix">'; | |
text+='<span class="direct-chat-name pull-right">'+val.nombre+'</span>'; | |
text+='<span class="direct-chat-timestamp pull-left">'+val.fecha+'</span>'; | |
text+='</div>'; | |
text+='<img class="direct-chat-img" src="img/'+val.imagen+'" alt="message user image">'; | |
text+='<div class="direct-chat-text">'; | |
text+=val.mensaje; | |
text+='</div>'; | |
text+='</div>'; $(".direct-chat-messages").prepend(text); | |
}); | |
} | |
},'json'); | |
} | |
} | |
</script> | |
<?}?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment