mirror of
https://github.com/cheveguerra/botLeiferAurik-Mod_2.0.git
synced 2026-04-19 12:19:19 +00:00
feat: Imagenes
This commit is contained in:
@@ -65,7 +65,7 @@
|
||||
<div>
|
||||
<select id="tipoMensaje">
|
||||
<option>Mensaje</option>
|
||||
<!-- <option>Imagen</option> -->
|
||||
<option>Imagen</option>
|
||||
<option>Botones</option>
|
||||
</select>
|
||||
</div>
|
||||
@@ -120,26 +120,28 @@
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<!-- <div id="postImg">
|
||||
<div id="postImg">
|
||||
<table>
|
||||
<form action="/send-image" method="POST" id="imgForm" enctype="multipart/form-data">
|
||||
<tr>
|
||||
<td>Número:</td>
|
||||
<td><input type="text" id="number" value="5215554192439"></td>
|
||||
<td><input type="text" id="imgnumber" value="5215554192439" style="width:160px;"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Imagen:</td>
|
||||
<td><input type="text" id="image" value="test1"></td>
|
||||
<td><input type="file" id="imgimage" name="imgimage" style="width:160px;" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Texto:</td>
|
||||
<td><input type="text" id="caption" placeholder="El texto aquí"></td>
|
||||
<td><input type="text" id="imgcaption" placeholder="El texto aquí" style="width:160px;"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td align="center"><input type="button" id="btnImg" value="Enviar Mensaje"></td>
|
||||
</tr>
|
||||
</form>
|
||||
</table>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <input type="button" id="chkConn" value="QR"> -->
|
||||
@@ -148,6 +150,14 @@
|
||||
<ul class="logs"></ul>
|
||||
</div>
|
||||
<div id="div_wa_msg" style="display: none;"></div>
|
||||
|
||||
|
||||
<!-- <form action="/send-image" method="POST" enctype="multipart/form-data">
|
||||
<input type="text" name="number" value="5215554192439"><br>
|
||||
<input type="text" name="caption" placeholder="El texto de la imagen"><br>
|
||||
<input type="file" name="image" />
|
||||
<button type="submit">Upload</button>
|
||||
</form> -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" crossorigin="anonymous"></script>
|
||||
<script src="/socket.io/socket.io.js" crossorigin="anonymous"></script>
|
||||
<script>
|
||||
@@ -175,13 +185,16 @@
|
||||
$("#div_wa_msg").fadeOut("slow")
|
||||
}, 1500);
|
||||
})
|
||||
socket.on('imgOk', function (msg) {
|
||||
alert("¡Imagen mandada con exito!")
|
||||
})
|
||||
socket.on('message', function (msg) {
|
||||
$('.logs').prepend($('<li>').text(msg));
|
||||
console.log("|" + msg + "|");
|
||||
console.log("MENSAJES = " + $(".logs li").length)
|
||||
if($(".logs li").length >= 15){ $('.logs li').last().remove(); }
|
||||
if (msg == 'Conectando...' && IOSTATUS == "wa_ready") { $('#divQRPage').hide(); $('#postman').show(); waReady = false, $("#btnMessage").attr("disabled", true); $("#btnBtn").attr("disabled", true); }
|
||||
if (msg == 'Whatsapp esta listo!') { $("#btnMessage").attr("disabled", false); $("#btnBtn").attr("disabled", false); }
|
||||
// if (msg == 'Whatsapp esta listo!') { $("#btnMessage").attr("disabled", false); $("#btnBtn").attr("disabled", false); }
|
||||
})
|
||||
socket.on('qr', function (src) {
|
||||
var extra = Date.now();
|
||||
@@ -196,8 +209,10 @@
|
||||
startImer()
|
||||
})
|
||||
socket.on('ready', function (data) {
|
||||
$("#divQRPage").hide()
|
||||
$("#divQRPage").hide();
|
||||
$('#postman').show();
|
||||
$("#btnMessage").attr("disabled", false);
|
||||
$("#btnBtn").attr("disabled", false);
|
||||
clearInterval(IntervaloABorrar);
|
||||
})
|
||||
socket.on('authenticated', function (data) {
|
||||
@@ -302,6 +317,31 @@
|
||||
}
|
||||
else{alert("Es necesario llenar por lo menos el número, mensaje y boton1.")}
|
||||
})
|
||||
|
||||
$("#btnImg").click(function () {
|
||||
var fd = new FormData();
|
||||
console.log("IMAGEN=" + $('#imgimage')[0]?.files[0])
|
||||
var files = $('#imgimage')[0].files[0];
|
||||
fd.append('image', files);
|
||||
fd.append('number', $("#imgnumber").val())
|
||||
fd.append('caption', $("#imgcaption").val())
|
||||
$.ajax({
|
||||
url: 'http://localhost:3005/send-image/',
|
||||
type: 'POST',
|
||||
data: fd,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function (response) {
|
||||
if (response != 0) {
|
||||
// alert('file uploaded');
|
||||
}
|
||||
else {
|
||||
alert('file not uploaded');
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
$("#tipoMensaje").change(function () {
|
||||
let sel = $("select option:selected").val()
|
||||
console.log(sel)
|
||||
|
||||
Reference in New Issue
Block a user