123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
-
- //Declare variables
- var path = "Server";
- var fs = require('fs');
- var files = fs.readdirSync(path);
- var filenames = [files.length];
- //console.log("*******"+filenames);
- //Remove space from strings
- for(var i=0; i<files.length; i++)
- if(/\s/.test(files[i]))
- filenames[i] = files[i].replace(/\s/g, '');
- else
- filenames[i] = files[i];
-
- //Extract json files to local folder
- for(var i=0; i<files.length; i++) {
-
- //Print filenames
- // console.log(files[i] + " = "+filenames[i]);
-
- fs.copyFile(path+'/'+files[i], 'data/'+filenames[i], (err) => {
- if (err) throw err;
- });
-
- };
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- /*
- var xmlhttp = new XMLHttpRequest();
- var url = "http://136.145.231.34/";
-
- xmlhttp.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- var myArr = JSON.parse(this.responseText);
- myFunction(myArr);
- }
- };
- xmlhttp.open("GET", url, true);
- xmlhttp.send();
-
- function myFunction(arr) {
- var out = "";
- var i;
- for(i = 0; i < arr.length; i++) {
- out += '<a href="' + arr[i].url + '">' +
- arr[i].display + '</a><br>';
- }
- document.getElementById("id01").innerHTML = out;
- }
-
-
- src="http://code.jquery.com/jquery-1.11.0.min.js";
-
- (function() {
- var URL = "/Json/";
- $.getJSON( URL, {
- format: "json"
- })
- .done(function( data ) {
- $.each( data.items, function( i, item ) {
-
- //copyfile.js
- const fs = require('fs');
-
- // destination will be created or overwritten by default.
- fs.copyFile('#.json', '/JsonFiles/#.json', (err) => {
- if (err) throw err;
- console.log('File was copied to destination');
- });
-
- if ( i === 3 ) {
- return false;
- }
- });
- });
- })();
-
-
- */
-
- /*
- $.ajax({
- url: 'http://136.145.231.34',
- data: data,
- success: null,
- dataType: "json"
- });
-
-
-
-
- $.get( "ajax/test.html", function( data ) {
- $( ".result" ).html( data );
- alert( "Load was performed." );
- });
-
-
- // Assign handlers immediately after making the request,
- // and remember the jqxhr object for this request
- var jqxhr = $.get( "AROMATIZACIÓN.json", function() {
- alert( "success" );
- })
- .done(function() {
- alert( "second success" );
- })
- .fail(function() {
- alert( "error" );
- })
- .always(function() {
- alert( "finished" );
- });
-
- // Perform other work here ...
-
- // Set another completion function for the request above
- jqxhr.always(function() {
- alert( "second finished" );
- });
-
-
-
- ftp://ubuntu:BE#u3bFh@136.145.231.34/
-
- host: '136.145.231.34',
- username: 'ubuntu',
- password: 'BE#u3bFh'
- jquery get json
- */
|