1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- "use strict";
- define( [ "rsvp" ] , function( rsvp ) {
-
-
- function getPathInformation( ) {
- var result = {}
- result[ "applicationPath" ] = undefined;
- result[ "instanceID" ] = undefined;
- var app = window.location.pathname;
- var pathSplit = app.split( '/' );
- if ( pathSplit[ 0 ] == "" ) {
- pathSplit.shift( );
- }
- if ( pathSplit[ pathSplit.length - 1 ] == "" ) {
- pathSplit.pop( );
- }
- if ( ( pathSplit.length > 0 ) && ( pathSplit[ pathSplit.length - 1 ].length == 16 ) ) {
- result[ "instanceID" ] = pathSplit.pop( );
- }
- if ( pathSplit.length > 0 ) {
- result[ "applicationPath" ] = "/" + pathSplit.join("/") + "/";
- }
- else {
- result[ "applicationPath" ] = "/";
- }
- return result;
- };
-
- var exports = {
-
-
- getSaveStates: function( ) {
- var pathInformation = getPathInformation( );
- var promise = new require( 'rsvp' ).Promise( function( resolve, reject ) {
- if ( pathInformation[ "instanceID" ] ) {
- var requestURL = pathInformation[ "applicationPath" ] + pathInformation[ "instanceID" ] + "/saves";
- $.getJSON( requestURL ).done( function( data ) {
- resolve( data );
- } ).fail( function( jqxhr, textStatus, error) {
- reject( { "error": error } );
- } );
- }
- else {
- reject( { "error": "getSaveStates could not identify current instance to get save states from" } );
- }
- } );
- return promise;
- },
- application: {
-
-
- getSaveStates: function( ) {
- var pathInformation = getPathInformation( );
- var promise = new require( 'rsvp' ).Promise( function( resolve, reject ) {
- var requestURL = pathInformation[ "applicationPath" ] + "saves";
- $.getJSON( requestURL ).done( function( data ) {
- resolve( data );
- } ).fail( function( jqxhr, textStatus, error) {
- reject( { "error": error } );
- } );
- } );
- return promise;
- }
- }
- };
- return exports;
- } );
|