Domanda

I would like to make a small gadget to use at work and show me the time of check in, from the morning.

I am trying to open a network file using http protocol and read from it the line which is referring to my check in. This is located on our intranet and can be accessed like this:

filename = 'http://www.intranet.loc/docs/dru/Acces/' + ystr + '-' + mstr + '-' + dstr + '.mvm';

Every employer has a unique code for check in. The structure of the check In file is like this:

12:475663:1306285:072819:11:1:1:0:
12:512362:1306285:072837:11:1:1:0:
12:392058:1306285:072927:11:1:1:0:
12:516990:1306285:072947:11:1:1:0:
12:288789:1306285:073018:11:1:1:0:
12:510353:1306285:073032:11:1:1:0:
12:453338:1306285:073033:11:1:1:0:
12:510364:1306285:073153:11:1:1:0:
12:510640:1306285:073156:11:1:1:0:

In this example, 12 is the gate number, which I don't need, the second is my ID, the third is the current date, and what I need is the fourth (the hour).

Edit: I am using this function to return the content of the mvm file with no luck:

function readfile(fileToRead) {

var allText = [];
var allTextLines = [];
var Lines = [];
var Cells = [];

var txtFile = new XMLHttpRequest();
txtFile.open("GET",fileToRead, true);
allText = txtFile.responseText;
allTextLines = allText.split(/r\r\n|\n/);

return allTextLines;

}

È stato utile?

Soluzione

Do you really need a RegEx? Would it be possible to split the line by ":"?

$.get('http://www.intranet.loc/docs/dru/Acces/' + ystr + '-' + mstr + '-' + dstr + '.mvm', function(data) {
    var lines = data.split("\n"),
        values;

    for (var i in lines) {
        values = lines[i].split(':');
    }
});

With this you would have everything you need.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top