$.ajax({
xhr: function() {
var xhr = new window.XMLHttpRequest();
xhr.addEventListener("progress", function(evt) {
if (evt.lengthComputable) {
var percentComplete = evt.loaded / evt.total;
//Do something with download progress
}
}, false);
return xhr;
},
type: 'POST',
url: "/",
data: {},
success: function(data){
//Do something on success
}
});
request('https://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png'))
package test;
import java.io.FileWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class MAin {
public static void main(String[] args) {
String key = "7075966f7075966f7075966f577018909e770757075966f2dfd2579655817dfd28d3bfd";
String Vers = "5.103";
String url = "https://api.vk.com/method/photos.search?user_ids=210700286&fields=bdate&lat=55.879960&long=38.227373&count=1"
+ "&access_token=" + key+"&v="+Vers;
try {
URL obj = new URL(url);
HttpURLConnection connection = (HttpURLConnection) obj.openConnection();
connection.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
// System.out.println(response.toString());
try (FileWriter file = new FileWriter("./response-vk.json")) {
file.write(response.toString());
}
}catch(Exception e){}
}
}
const loadScript = (url) => (
new Promise((resolve, reject) => {
const script = document.createElement('script');
script.src = url;
script.onload = () => resolve(script);
script.onerror = () => reject(new Error(`Ошибка загрузки скрипта ${src}`));
document.head.append(script);
})
);
loadScript('../node_modules/jquery/dist/jquery.min.js')
.then(() => {
// Теперь когда jQuery подключен, можно подключить сам Bootstrap.js и svg-pan-zoom
// Можно паралельно грузить, так как они не зависят друг от друга
return Promise.all([
loadScript('../node_modules/bootstrap/dist/js/bootstrap.min.js'),
loadScript('../node_modules/svg-pan-zoom/dist/svg-pan-zoom.min.js')
]);
})
.then(() => {
console.log('Все скрипты загружены');
svgPanZoom('#wsr_map', {
zoomEnabled: true,
controlIconsEnabled: true,
fit: true,
center: true
});
})
const GROUP_ID = 123456789;
const mentionPattern = new RegExp(
String.raw`^(?:\[club${GROUP_ID}\|[^\]]+\])(?:[\s.,\'\"!?\-+]+|$)`,
'i'
);
vk.updates.on('message', (context, next) => {
if (context.isChat && !mentionPattern.test(context.text)) {
return;
}
if (context.text) {
context.text = context.text.replace(mentionPattern, '');
}
return next();
});
Limits the number of updates to be retrieved. Values between 1—100 are accepted. Defaults to 100.
let icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAnUlEQVR42u3bMQ7AIAgAQP//afuE1hSw1CNhccFcIoPimHOOk3MAAADgLrNiVx0AAAC8A8hqSFF1AFQBZB+B1ToAAADYC5DVBKPWAVQBZB8BAAAA9AI4vgkCeLgxAAAAAAAAAAAAAAAAAAAAAAAAAAAAuBQF4GEEAAAA3QBMiJwKsBoAAADoDVA1LA3gawBRAQAAgB4Afo4CAPDfvABS2dwbcpzXlAAAAABJRU5ErkJggg==';
const iconBuffer = Buffer.from(icon.replace('data:image/png;base64,', ''), 'base64');
context.sendPhoto(iconBuffer, {message: `test`});