;(function(){
var player = new Audio()
var buttons = document.querySelectorAll('.pin')
buttons.forEach(btn => btn.addEventListener('click', play))
function play(evt) {
let sound = evt.target.textContent
player.src = `https://translate.google.ps/translate_tts?tk=505935%7C631501&ie=UTF-8&tl=zh&total=1&idx=0&textlen=8&client=tw-ob&q=${sound}`
player.play();
}
})();
<ul id="q1" class="cards"></ul>
const vkGetData = {
getUser: function() {
return $.ajax({ url:'https://api.vk.com/method/users.get',
data:{"uid": 1},
dataType: 'jsonp'})
.then((data)=> {return data.response;})
.then((data)=>{return `Имя: ${data[0].first_name} Фамилия: ${data[0].last_name}`;});
}
};
vkGetData.getUser().done((arr)=> {$('#q1').text(arr);});
var res = [{
Channel: 3,
file_name: "1111",
id: 1,
time_start: "1111",
time_end: "1111",
}, {
Channel: 2,
file_name: "2222",
id: 2,
time_start: "2222",
time_end: "2222",
}, {
Channel: 2,
file_name: "3333",
id: 3,
time_start: "3333",
time_end: "3333",
}];
var groupedData = _.groupBy(res, function(d){return d. Channel});
console.log(groupedData);
arr = Array.from({ length: 10 }, (v, k) => k);
function timeout(val){
return new Promise((resolve, reject)=>{
setTimeout(()=>{
console.log(val);
resolve();
}, 1000 * Math.random());
});
}
(async () => {
for (const val of arr) {
await timeout(val);
}
console.log('Расчет окончен');
})();
<canvas id="myCanvas" width="560" height="560" style="border:2px solid #d3d3d3;"></canvas>
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
for(i=0;i<8;i++){
for(j=0;j<8;j++){
ctx.moveTo(0,70*j);
ctx.lineTo(560,70*j);
ctx.stroke();
ctx.moveTo(70*i,0);
ctx.lineTo(70*i,560);
ctx.stroke();
var left = 0;
for(var a=0;a<8;a++) {
for(var b=0; b<8;b+=2) {
startX = b * 70;
if(a%2==0) startX = (b+1) * 70;
ctx.fillRect(startX + left,(a*70) ,70,70);
}}
}}
var mylist = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'];
var newArray = mylist.map(()=>{
return mylist.splice(0,2);
});
console.log(newArray);
function nextElement() {
document.getElementById('test').appendChild(genButtons(newArray[myIndex++%newArray.length]));
};
var mylist = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'];
var myIndex = 0;
var newArray = mylist.map(()=>{
return mylist.splice(0,2);
});
function genButtons(a) {
for (var x = 0; x < a.length; x++) {
var btn = document.createElement('input')
btn.id = 'b' + x;
btn.value = a[x];
btn.type = 'button';
btn.onclick = function() { // Note this is a function
nextElement();
};
document.getElementById('test').appendChild(btn);
}
}
genButtons(newArray[myIndex]);
function nextElement() {
myIndex ++;
genButtons(newArray[myIndex]);
};
var classDeptch = 1; // так как var item в этой переменной находится <li data-depth="1" >4</li> оно равно одному
$( "li" ).each(function() {
var item = $( this );
if(classDeptch >0){
var siblingItemDepht = classDeptch--;
var parent=item.siblings().data( "data-depth", siblingItemDepht )[0];
console.log(parent);
}
});
font-family: "Helvetica Neue", "Calibri Light", Roboto, sans-serif;
<video width="400" controls>
<source src="mov_bbb.mp4" id="video_here">
Your browser does not support HTML5 video.
</video>
<input type="file" name="file[]" class="file_multi_video" accept="video/*">
$(document).on("change", ".file_multi_video", function(evt) {
var $source = $('#video_here');
$source[0].src = URL.createObjectURL(this.files[0]);
$source.parent()[0].load();
});
<ul id="q1" class="cards"></ul>
function GoodsView (obj) {
return `<li class="cards_item">
<div class="card">
<div class="card_image">
<img src="${obj.thumb_photo}" />
</div>
<div class="card_content">
<h2 class="card_heading">${obj.title}</h2>
<p> Цена : ${obj.price.text} <br>
${obj.description}</p>
<a href="#" class="card_button">Button</a>
</div>
</div>
</li>`
}
const vkGetData = {
goods: function() {
return $.ajax({
url:'https://api.vk.com/method/market.get?owner_id=-81454608&access_token=???????&v=5.59',
dataType: 'jsonp'})
.then((data)=> {
console.log(data)
return data.response.items;
})
.then((data)=>{
let listGoods = '';
data.forEach((item) => {
listGoods += GoodsView(item);
})
return listGoods;
});
}
};
vkGetData.goods().done((arr)=> {
$('#q1').append(arr)
});
$(document).ready(function() {
$('.spoiler_links').click(function() {
$(this).parent().children('div.spoiler_body').toggle('normal');
return false;
});
var x = document.getElementsByClassName('spoiler_links'),
xx = document.getElementsByClassName('destination'),
sp = document.getElementsByClassName('spoiler_body');
$(x).each(function( index ) {
if (this) {sp[index].setAttribute('style', 'display:none;');}
$(this).attr('id', index);
$('#' + index).prependTo(xx[index]);
});
});
const GeoUrl = 'https://ipinfo.io/json';
function httpGet(url) {
return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onload = function() {
if (this.status == 200) {
resolve(this.response);
} else {
var error = new Error(this.statusText);
error.code = this.status;
reject(error);
}
};
xhr.onerror = function() {
reject(new Error("Network Error"));
};
xhr.send();
});
}
httpGet(GeoUrl)
.then(response => {
let data = JSON.parse(response);
return data;
})
.then(data => httpGet("http://api.openweathermap.org/data/2.5/weather?q="+ data.city+"&units=metric&APPID=061f24cf3cde2f60644a8240302983f2"))
.then(data => {
console.log(data);
return
})