3 var services = app.ns("services");
6 function parse_version( v ) {
7 return v.match(/^(\d+)\.(\d+)\.(\d+)/).slice(1,4).map( function(d) { return parseInt(d || 0, 10); } );
10 services.Cluster = ux.Class.extend({
15 this.base_uri = this.config.base_uri;
17 setVersion: function( v ) {
19 this._version_parts = parse_version( v );
21 versionAtLeast: function( v ) {
22 var testVersion = parse_version( v );
23 for( var i = 0; i < 3; i++ ) {
24 if( testVersion[i] !== this._version_parts[i] ) {
25 return testVersion[i] < this._version_parts[i];
30 request: function( params ) {
31 return $.ajax( $.extend({
32 url: this.base_uri + params.path,
34 error: function(xhr, type, message) {
35 if("console" in window) {
36 console.log({ "XHR Error": type, "message": message });
41 "get": function(path, success) { return this.request( { type: "GET", path: path, success: success } ); },
42 "post": function(path, data, success) { return this.request( { type: "POST", path: path, data: data, success: success } ); },
43 "put": function(path, data, success) { return this.request( { type: "PUT", path: path, data: data, success: success } ); },
44 "delete": function(path, data, success) { return this.request( { type: "DELETE", path: path, data: data, success: success } ); }
47 })( this.jQuery, this.app );