| Conditions | 6 |
| Total Lines | 31 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | /** |
||
| 35 | /** |
||
| 36 | * fetch userdata |
||
| 37 | */ |
||
| 38 | fetch(callback: Function | null) { |
||
| 39 | const ini = this; |
||
| 40 | return $.ajax({ |
||
| 41 | url: "/user", |
||
| 42 | method: "POST", |
||
| 43 | silent: true, |
||
| 44 | indicator: false, |
||
| 45 | data: { |
||
| 46 | check: true, |
||
| 47 | user: true, |
||
| 48 | }, |
||
| 49 | success: function (res: Object) { |
||
| 50 | if (typeof res != "object") { |
||
| 51 | return; |
||
| 52 | } |
||
| 53 | if (res) { |
||
| 54 | if (res.hasOwnProperty("id")) { |
||
| 55 | (<any>res).user_id = (<any>res).id; |
||
| 56 | (<any>res)._ = new Date(); |
||
| 57 | } |
||
| 58 | if (res.hasOwnProperty("username")) { |
||
| 59 | if (typeof callback == "function") { |
||
| 60 | callback(res); |
||
| 61 | } |
||
| 62 | } |
||
| 63 | } |
||
| 64 | storage().set(ini.key, JSON.stringify(res)); |
||
| 65 | console.log("user::fetch", ini.all()); |
||
| 66 | }, |
||
| 81 |