import { Utils } from "../providers/utils" ; import { Config } from "../providers/config" ; export class ServerModel { address : string ; name : string ; online : 'online' | 'offline' | 'connected' = 'offline' ; constructor ( address , name ) { this . address = address ; this . name = name ; } equals ( server ) { if ( ! server ) { return false ; } return this . address == server . address ; } public static serversFromJSON ( jsonString ) { let result = [ ] ; if ( jsonString . indexOf ( Config . WEBSITE_NAME ) == - 1 ) { return result ; } let hostname = Utils . getUrlParameterValue ( jsonString , 'h' ) ; let addresses = Utils . getUrlParameterValue ( jsonString , 'a' ) . split ( '-' ) ; addresses . forEach ( address => { result . push ( new ServerModel ( address , hostname ) ) ; } ) ; return result ; } }