let actionCalculate = '-', inputCalculator = '50-5';
inputCalculator.split(actionCalculate).reduce((firstNumber, secondNumber) => {
let resultNumber;
switch (actionCalculate) {
case '+':
resultNumber = Number(firstNumber) + Number(secondNumber);
break;
case '-':
resultNumber = Number(firstNumber) - Number(secondNumber);
break;
case '*':
resultNumber = Number(firstNumber) * Number(secondNumber);
break;
case '/':
resultNumber = Number(firstNumber) / Number(secondNumber);
break;
};
return resultNumber;
});
async function getCurrencies() {
let response = await fetch("https://api.github.com/repos/javascript-tutorial/en.javascript.info/commits");
if (!(await response.json())) response = await fetch("https://raw.githubusercontent.com/webdataorg/webdata-api/master/package.json");
const result = await response.json();
}
const criptoValute = ['BTC'];
[{id: 'BHD', current: 0.37699, title: '0,377 бахрейнского динара'},
{id: 'BTC', current: 0.000052198327, title: '0,00 BTC'},
{id: 'XAG', current: 0.0520102, title: '0,05 XAG'},
{id: 'XAU', current: 0.00060038, title: '0,00 XAU'}].filter(x => !criptoValute.includes(x.id));
$('.comment-form').submit(function(e) {
e.preventDefault();
data = $(this).serializeArray()
var _postid = $(this).attr('data-id');
var _comment = $(this).find('.form-control').val();
var _nodeid = $(this).attr('data-nodeid');
var _parentid = $(this).attr('data-reply-id')
$.ajax({
type: "POST",
url: "{% url 'comment_post' %}",
data: {'post_id': _postid, 'content': _comment, 'parent_id': _parentid || '', 'csrfmiddlewaretoken': '{{ csrf_token }}'},
success: function(response) {
$('.form-comment-'+_postid).val('');
const options = {
year: 'numeric',
month: 'short',
day: 'numeric',
hour12: true,
hour: 'numeric',
minute: '2-digit'
};
let currentdate = new Date().toLocaleString('en-US', options)
var _html =
`<li>
{{ request.user }} <small class="text-muted">${currentdate}</small><br>
${_comment}<br>
<a class="text-decoration-none" data-bs-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">Ответить</a> <br>
<div class="collapse comment-form" id="collapseExample${_nodeid}">
<form class="comment-form" id="comment-form-{{ node.id }}" data-id="{{ post.id }}" data-reply-id="{{ node.id }}">
<textarea class="form-control" rows="2" cols="40" placeholder="Комментарий" id="comment-text{{ post.id }}" name="comment_content"></textarea>
<button class="btn btn-dark btn-sm mt-1" type="submit">Ответить</button>
</form>
</div>
</li>
${_postid}
`
$(".comment-node-post"+_postid).prepend(_html);
}
});
})
bot.on(['photo'], (ctx) => {
if (ctx.message.photo.length > 1) return;
if (ctx.message.media_group_id) {
const photo = ctx.message.photo[0]
let link = await ctx.telegram.getFileLink(photo.file_id)
const url = link.href
// need send photos to user
ctx.telegram.sendMediaGroup(user_tg_id,[
{
type: 'photo',
media: // url for first photo
},
{
type: 'photo',
media: // url for second photo
},
])
} else {
// works well
const photo = ctx.message.photo[0]
let link = await ctx.telegram.getFileLink(photo.file_id)
const url = link.href
return ctx.telegram.sendPhoto(user_tg_id, {url})
}
})
require
, это невозможно, в сайте вы должны подключать свои скрипты так <script src="путь до хоста где скрипт"></script>
<script>
var bitrixexists = false;
var button = 0;
function myThankyhou() {
window.location.replace("http://localhost/binokl/thankyou");
}
function checkbitrix(){
buttons = document.getElementsByClassName("b24-form-btn");
console.log("buttons.length " + Number(buttons.length));
if (Number(buttons.length) === Number(4)) {
button = buttons[0];
button.addEventListener("click", myThankyou);
clearInterval(id);
alert("i got it");
} else
{console.log("bitrix not found"); }
}
let id = setInterval(checkbitrix, 10000);
</script>
function myFunction() {
let greeting,
time = new Date().getHours();
if (time >= 6 && time <= 12) {
greeting = "Good morning";
} else if (time > 12 && time <= 18) {
greeting = "Good day";
} else if (time >= 0 && time < 6) {
greeting = "Good night";
} else {
greeting = "Good evening";
};
document.getElementById("random_txt").innerHTML = greeting;
};