From 8a61280320c28896f6b6d15fcfeffd3566f4d9f0 Mon Sep 17 00:00:00 2001 From: Matchu Date: Mon, 27 Jul 2015 13:33:15 -0400 Subject: [PATCH] whoops; Neopia uses ImpressUser, so make sure it can access it --- app/assets/javascripts/modeling.js.jsx | 114 +++++++++++++------------ 1 file changed, 58 insertions(+), 56 deletions(-) diff --git a/app/assets/javascripts/modeling.js.jsx b/app/assets/javascripts/modeling.js.jsx index 2a0d3546..89a4d93e 100644 --- a/app/assets/javascripts/modeling.js.jsx +++ b/app/assets/javascripts/modeling.js.jsx @@ -1,61 +1,6 @@ /** @jsx React.DOM */ -var Neopia = { - User: { - get: function(id) { - return $.ajax({ - dataType: "json", - url: Neopia.API_URL + "/users/" + id, - useCSRFProtection: false - }).then(function(response) { - return response.users[0]; - }); - } - }, - Customization: { - request: function(petId, type) { - var data = {}; - if (ImpressUser.id) { - data.impress_user = ImpressUser.id; - } - return $.ajax({ - dataType: "json", - type: type, - url: Neopia.API_URL + "/pets/" + petId + "/customization", - useCSRFProtection: false, - data: data - }); - }, - get: function(petId) { - return this.request(petId, "GET"); - }, - post: function(petId) { - return this.request(petId, "POST"); - } - }, - Status: { - get: function() { - return $.ajax({ - dataType: "json", - url: Neopia.API_URL + "/status", - useCSRFProtection: false - }); - } - }, - init: function() { - var hostEl = $('meta[name=neopia-host]'); - if (!hostEl.length) { - throw "missing neopia-host meta tag"; - } - var host = hostEl.attr('content'); - if (!host) { - throw "neopia-host meta tag exists, but is empty"; - } - Neopia.API_URL = "http://" + host + "/api/1"; - } -}; - -(function($, I18n) { +var Neopia = (function($, I18n) { // Console-polyfill. MIT license. // https://github.com/paulmillr/console-polyfill // Make it safe to do console.log() always. @@ -73,6 +18,61 @@ var Neopia = { return con; })(window.console || {}); + var Neopia = { + User: { + get: function(id) { + return $.ajax({ + dataType: "json", + url: Neopia.API_URL + "/users/" + id, + useCSRFProtection: false + }).then(function(response) { + return response.users[0]; + }); + } + }, + Customization: { + request: function(petId, type) { + var data = {}; + if (ImpressUser.id) { + data.impress_user = ImpressUser.id; + } + return $.ajax({ + dataType: "json", + type: type, + url: Neopia.API_URL + "/pets/" + petId + "/customization", + useCSRFProtection: false, + data: data + }); + }, + get: function(petId) { + return this.request(petId, "GET"); + }, + post: function(petId) { + return this.request(petId, "POST"); + } + }, + Status: { + get: function() { + return $.ajax({ + dataType: "json", + url: Neopia.API_URL + "/status", + useCSRFProtection: false + }); + } + }, + init: function() { + var hostEl = $('meta[name=neopia-host]'); + if (!hostEl.length) { + throw "missing neopia-host meta tag"; + } + var host = hostEl.attr('content'); + if (!host) { + throw "neopia-host meta tag exists, but is empty"; + } + Neopia.API_URL = "http://" + host + "/api/1"; + } + }; + var ImpressUser = (function() { var userSignedIn = ($('meta[name=user-signed-in]').attr('content') === 'true'); if (userSignedIn) { @@ -384,4 +384,6 @@ var Neopia = { }); Modeling.init($); + + return Neopia; })(jQuery, ModelingI18n);