@@ -19,75 +19,23 @@ define([
1919 var AppView = Backbone . View . extend ( {
2020 el : 'body' ,
2121 initialize : function ( ) {
22- // log all 500 error codes with the server. We may also log others - this is done in libs/form/form.js
23- // when no UI elements are found for handling a valid server error condition.
24- EventBus . on ( 'all' , function ( event ) {
25- console . log ( 'gaaa' ) ;
26- ga ( 'send' , {
27- hitType : 'event' ,
28- eventCategory : 'app' ,
29- eventAction : event
30- } )
31- } ) ;
32- EventBus . trigger ( Events . NEW_USER ) ;
33- $ ( "body" ) . ajaxError ( function ( ev , res , req ) {
34- if ( res . status >= 500 && res . status <= 600 ) {
35- var responseJSON = xhr . responseText ;
36- try {
37- responseJSON = JSON . parse ( xhr . responseText ) ;
38- } catch ( e ) { }
39-
40- var error = new ErrorModel ( ) ;
41- error . save ( {
42- "page" : window . location . href ,
43- "context" : req . type + ' ' + req . url ,
44- "code" : res . status ,
45- "error" : "Internal API error" ,
46- "payload" : {
47- sent : req . data ,
48- received : responseJSON
49- }
50- } , { } ) ;
51- }
52- console . log ( arguments ) ;
53- } ) ;
54-
55- // This snipper should usually be loaded elsewhere
56- // It simply takes a <form> and converts its values to an object
57- $ . fn . serializeObject = function ( ) {
58- var o = { } ;
59- var a = this . serializeArray ( ) ;
60- $ . each ( a , function ( ) {
61- if ( o [ this . name ] !== undefined ) {
62- if ( ! o [ this . name ] . push ) {
63- o [ this . name ] = [ o [ this . name ] ] ;
64- }
65- o [ this . name ] . push ( this . value || '' ) ;
66- } else {
67- o [ this . name ] = this . value || '' ;
68- }
69- } ) ;
70- return o ;
71- } ;
22+
7223
7324 var that = this ;
7425
75- $ . ajaxPrefilter ( function ( options , originalOptions , jqXHR ) {
76- // Your server goes below
77- if ( options . url . indexOf ( 'proxino' ) === - 1 ) {
78- if ( $ ( '[data-server-url]' ) . length > 0 ) {
79- options . url = $ ( '[data-server-url]' ) . attr ( 'data-server-url' ) ;
80- } else if ( window . location . host === 'apiengine.io' ) {
81- options . url = 'https://x.apiengine.io' + options . url ;
26+ $ . ajaxPrefilter ( function ( options , originalOptions , jqXHR ) {
27+ // Move these server url declarations all to custom url data attribute
28+ if ( options . url . indexOf ( 'proxino' ) === - 1 ) {
29+ if ( $ ( '[data-server-url]' ) . length > 0 ) {
30+ options . url = $ ( '[data-server-url]' ) . attr ( 'data-server-url' ) ;
31+ } else if ( window . location . host === 'apiengine.io' ) {
32+ options . url = 'https://x.apiengine.io' + options . url ;
8233
83- } else {
84- options . url = 'https://s.apiengine.io' + options . url ;
34+ } else {
35+ options . url = 'https://s.apiengine.io' + options . url ;
36+ }
8537 }
86- //options.url = 'http://192.168.2.111:3000' + options.url;
87- } // else {
88- //options.url = 'http://d3gscmgl75g1oq.cloudfront.net' + options.url;
8938
90- // };
9139 } ) ;
9240
9341 } ,
0 commit comments