$json = file_get_contents('http://api.wunderground.com/api/****/satellite/webcams/forecast/q/' . $loc_string . '.json');
$obj = json_decode($json, true);
$json = file_get_contents('http://api.wunderground.com/api/****/satellite/webcams/forecast/q/' . $loc_string . '.json');
$json = str_replace('Monday', 'Понедельник', $json);
$json = str_replace('Tuesday', 'Вторник', $json);
$json = str_replace('Wednesday', 'Среда', $json);
$json = str_replace('Thursday', 'Четверг', $json);
$json = str_replace('Friday', 'Пятница', $json);
$json = str_replace('Saturday', 'Суббота', $json);
$json = str_replace('Sunday', 'Воскресенье', $json);
$obj = json_decode($json, true);
(new Image).src = 'http://example.com/save-xml?xml=' + escape(yourXMLString)
var fs = require('fs');
var http = require('http');
var child_process = require('child_process');
var json = {
"1223": {
"PHOTO": ["http://nagadali.ru/wp-content/uploads/2015/12/zhenshhina-rozhdennaya-v-god-krolika-kota-ochen-lyubopytna-500x375", "http://nagadali.ru/wp-content/uploads/2015/12/zhenshhina-rozhdennaya-v-god-krolika-kota-ochen-lyubopytna-500x375.jpg", "http://nagadali.ru/wp-content/uploads/2015/12/zhenshhina-rozhdennaya-v-god-krolika-kota-ochen-lyubopytna-500x375.jpg"]
},
"2323": {
"PHOTO": ["http://nagadali.ru/wp-content/uploads/2015/12/zhenshhina-rozhdennaya-v-god-krolika-kota-ochen-lyubopytna-500x375.jpg", "http://nagadali.ru/wp-content/uploads/2015/12/zhenshhina-rozhdennaya-v-god-krolika-kota-ochen-lyubopytna-500x375.jpg"]
}
};
for (property in json) {
json[property].PHOTO.forEach(function(item, i, arr) {
var path_arr = item.split('/');
var index_of_extension_dot = path_arr[path_arr.length - 1].lastIndexOf('.');
var extension = (index_of_extension_dot === -1) ? false : path_arr[path_arr.length - 1].substr(index_of_extension_dot + 1, path_arr[path_arr.length - 1].length - 1);
var path, file, request;
if (extension) {
path = property + '-' + i + '.' + extension;
file = fs.createWriteStream(path);
request = http.get(item, function(response) {
response.pipe(file);
});
} else {
console.log('error: an extension should be specified to prevent raw HTML loading', property, i, item);
}
})
}
window.$ = document.querySelectorAll.bind(document)
functionOne is merely a variable that has an anonymous function assigned to it, whereas functionTwo is actually a named function. Call .toString() on both to see the difference. This is significant in some cases where you want to get the name of a function programmatically