timeeditapi
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -17,2 +17,14 @@ 'use strict'; | ||
static getAllTypes(url){ | ||
const t = new TimeEditCrawler(url); | ||
return new Promise(function(resolve, reject) { | ||
t.getHtml(t.getTypeUrl()) | ||
.then(html => resolve( | ||
dataParser.getTypes(html))) | ||
.catch(e => reject(e)); | ||
}); | ||
} | ||
/** | ||
@@ -19,0 +31,0 @@ * [check if x exsits] |
@@ -11,3 +11,3 @@ 'use strict'; | ||
this.scheduleUrl = 'ri.json?h=f&sid=3&p=0.m%2C12.n&objects=&ox=0&types=0&fe=0&h2=f'; | ||
this.typeUrlExtension = 'ri1Q7.html'; | ||
this.searchText = 'search_text='; | ||
@@ -33,2 +33,6 @@ this.objectsText = 'objects='; | ||
getTypeUrl(){ | ||
return this.originUrl+this.typeUrlExtension; | ||
} | ||
buildDataURL(id){ | ||
@@ -35,0 +39,0 @@ let urlArray = this._splitString(this.searchURL, this.searchText); |
@@ -20,2 +20,13 @@ 'use strict'; | ||
getTypes(html){ | ||
let $ = this._loadHtml(html); | ||
let types = $('#fancytypeselector option').map((i, elem) => { | ||
return { | ||
name: $(elem).text(), | ||
value: $(elem).val() | ||
}; | ||
}).get(); | ||
return types; | ||
} | ||
/** | ||
@@ -22,0 +33,0 @@ * [sorts schedule infromation] |
{ | ||
"name": "timeeditapi", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "api to easy get schedule information from timeedit", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
#### Example | ||
#### Examples | ||
get all the types available | ||
```javascript | ||
const timeEdidApiLnu = new TimeEdidApi( | ||
const TimeEdidApi = require('timeeditApi'); | ||
TimeEdidApi.getAllTypes( | ||
'https://se.timeedit.net/web/lnu/db1/schema1/' | ||
).then((result) => { | ||
console.log(JSON.stringify(result, null ,2)); | ||
}).catch((er) => { | ||
console.log(er); | ||
}); | ||
``` | ||
Get schedule | ||
```javascript | ||
const timeEdidApi = new TimeEdidApi( | ||
'https://se.timeedit.net/web/lnu/db1/schema1/', | ||
@@ -13,3 +28,3 @@ 4 | ||
// todays schedule | ||
timeEdidApiLnu.getTodaysSchedule('ny105') | ||
timeEdidApi.getTodaysSchedule('ny105') | ||
.then((roomSchedule) => { | ||
@@ -22,3 +37,3 @@ console.log(JSON.stringify(roomSchedule, null ,2)); | ||
// full schedule | ||
timeEdidApiLnu.getSchedule('ny105') | ||
timeEdidApi.getSchedule('ny105') | ||
.then((schedule) => { | ||
@@ -31,3 +46,3 @@ console.log(JSON.stringify(schedule, null ,2)); | ||
// search and se if exists | ||
timeEdidApiLnu.search('ny105') | ||
timeEdidApi.search('ny105') | ||
.then((result) => { | ||
@@ -34,0 +49,0 @@ console.log(JSON.stringify(result, null ,2)); |
9654
227
52