()
| 25 | } |
| 26 | |
| 27 | function init() { |
| 28 | isSurge = () => { |
| 29 | return undefined === this.$httpClient ? false : true |
| 30 | } |
| 31 | isQuanX = () => { |
| 32 | return undefined === this.$task ? false : true |
| 33 | } |
| 34 | getdata = (key) => { |
| 35 | if (isSurge()) return $persistentStore.read(key) |
| 36 | if (isQuanX()) return $prefs.valueForKey(key) |
| 37 | } |
| 38 | setdata = (key, val) => { |
| 39 | if (isSurge()) return $persistentStore.write(key, val) |
| 40 | if (isQuanX()) return $prefs.setValueForKey(key, val) |
| 41 | } |
| 42 | msg = (title, subtitle, body) => { |
| 43 | if (isSurge()) $notification.post(title, subtitle, body) |
| 44 | if (isQuanX()) $notify(title, subtitle, body) |
| 45 | } |
| 46 | log = (message) => console.log(message) |
| 47 | get = (url, cb) => { |
| 48 | if (isSurge()) { |
| 49 | $httpClient.get(url, cb) |
| 50 | } |
| 51 | if (isQuanX()) { |
| 52 | url.method = 'GET' |
| 53 | $task.fetch(url).then((resp) => cb(null, {}, resp.body)) |
| 54 | } |
| 55 | } |
| 56 | post = (url, cb) => { |
| 57 | if (isSurge()) { |
| 58 | $httpClient.post(url, cb) |
| 59 | } |
| 60 | if (isQuanX()) { |
| 61 | url.method = 'POST' |
| 62 | $task.fetch(url).then((resp) => cb(null, {}, resp.body)) |
| 63 | } |
| 64 | } |
| 65 | done = (value = {}) => { |
| 66 | $done(value) |
| 67 | } |
| 68 | return { isSurge, isQuanX, msg, log, getdata, setdata, get, post, done } |
| 69 | } |
| 70 | chavy.done() |
no test coverage detected