3232 * console, go to Your Name | Setup | Security Controls | Remote Site Settings
3333 */
3434
35+ /*jslint browser: true*/
36+ /*global alert, Blob, $, jQuery*/
37+
3538var forcetk = window . forcetk ;
3639
3740if ( forcetk === undefined ) {
@@ -52,6 +55,7 @@ if (forcetk.Client === undefined) {
5255 * @constructor
5356 */
5457 forcetk . Client = function ( clientId , loginUrl , proxyUrl , communityInd ) {
58+ 'use strict' ;
5559 this . clientId = clientId ;
5660 this . loginUrl = loginUrl || 'https://login.salesforce.com/' ;
5761 if ( typeof proxyUrl === 'undefined' || proxyUrl === null ) {
@@ -90,6 +94,7 @@ if (forcetk.Client === undefined) {
9094 * @param refreshToken an OAuth refresh token
9195 */
9296 forcetk . Client . prototype . setRefreshToken = function ( refreshToken ) {
97+ 'use strict' ;
9398 this . refreshToken = refreshToken ;
9499 }
95100
@@ -99,6 +104,7 @@ if (forcetk.Client === undefined) {
99104 * @param error function to call on failure
100105 */
101106 forcetk . Client . prototype . refreshAccessToken = function ( callback , error ) {
107+ 'use strict' ;
102108 var that = this ;
103109 var url = this . loginUrl + '/services/oauth2/token' ;
104110 return $ . ajax ( {
@@ -127,6 +133,7 @@ if (forcetk.Client === undefined) {
127133 * use the value from the OAuth token.
128134 */
129135 forcetk . Client . prototype . setSessionToken = function ( sessionId , apiVersion , instanceUrl ) {
136+ 'use strict' ;
130137 this . sessionId = sessionId ;
131138 this . apiVersion = ( typeof apiVersion === 'undefined' || apiVersion === null )
132139 ? 'v29.0' : apiVersion ;
@@ -162,6 +169,7 @@ if (forcetk.Client === undefined) {
162169 * @param [payload=null] payload for POST/PATCH etc
163170 */
164171 forcetk . Client . prototype . ajax = function ( path , callback , error , method , payload , retry ) {
172+ 'use strict' ;
165173 var that = this ;
166174 var url = ( this . visualforce ? '' : this . instanceUrl ) + '/services/data' + path ;
167175
@@ -210,6 +218,7 @@ if (forcetk.Client === undefined) {
210218 * @param retry true if we've already tried refresh token flow once
211219 */
212220 forcetk . Client . prototype . getChatterFile = function ( path , mimeType , callback , error , retry ) {
221+ 'use strict' ;
213222 var that = this ;
214223 var url = ( this . visualforce ? '' : this . instanceUrl ) + path ;
215224
@@ -280,6 +289,7 @@ if (forcetk.Client === undefined) {
280289 * @param retry true if we've already tried refresh token flow once
281290 */
282291 forcetk . Client . prototype . blob = function ( path , fields , filename , payloadField , payload , callback , error , retry ) {
292+ 'use strict' ;
283293 var that = this ;
284294 var url = ( this . visualforce ? '' : this . instanceUrl ) + '/services/data' + path ;
285295 var boundary = randomString ( ) ;
@@ -352,6 +362,7 @@ if (forcetk.Client === undefined) {
352362 forcetk . Client . prototype . createBlob = function ( objtype , fields , filename ,
353363 payloadField , payload , callback ,
354364 error , retry ) {
365+ 'use strict' ;
355366 return this . blob ( '/' + this . apiVersion + '/sobjects/' + objtype + '/' ,
356367 fields , filename , payloadField , payload , callback , error ) ;
357368 }
@@ -373,6 +384,7 @@ if (forcetk.Client === undefined) {
373384 forcetk . Client . prototype . updateBlob = function ( objtype , id , fields , filename ,
374385 payloadField , payload , callback ,
375386 error , retry ) {
387+ 'use strict' ;
376388 return this . blob ( '/' + this . apiVersion + '/sobjects/' + objtype + '/' + id +
377389 '?_HttpMethod=PATCH' , fields , filename , payloadField , payload , callback , error ) ;
378390 }
@@ -388,6 +400,7 @@ if (forcetk.Client === undefined) {
388400 * @param [retry] specifies whether to retry on error
389401 */
390402 forcetk . Client . prototype . apexrest = function ( path , callback , error , method , payload , paramMap , retry ) {
403+ 'use strict' ;
391404 var that = this ;
392405 var url = this . instanceUrl + '/services/apexrest' + path ;
393406
@@ -438,6 +451,7 @@ if (forcetk.Client === undefined) {
438451 * @param [error=null] function to which jqXHR will be passed in case of error
439452 */
440453 forcetk . Client . prototype . versions = function ( callback , error ) {
454+ 'use strict' ;
441455 return this . ajax ( '/' , callback , error ) ;
442456 }
443457
@@ -448,6 +462,7 @@ if (forcetk.Client === undefined) {
448462 * @param [error=null] function to which jqXHR will be passed in case of error
449463 */
450464 forcetk . Client . prototype . resources = function ( callback , error ) {
465+ 'use strict' ;
451466 return this . ajax ( '/' + this . apiVersion + '/' , callback , error ) ;
452467 }
453468
@@ -458,6 +473,7 @@ if (forcetk.Client === undefined) {
458473 * @param [error=null] function to which jqXHR will be passed in case of error
459474 */
460475 forcetk . Client . prototype . describeGlobal = function ( callback , error ) {
476+ 'use strict' ;
461477 return this . ajax ( '/' + this . apiVersion + '/sobjects/' , callback , error ) ;
462478 }
463479
@@ -468,6 +484,7 @@ if (forcetk.Client === undefined) {
468484 * @param [error=null] function to which jqXHR will be passed in case of error
469485 */
470486 forcetk . Client . prototype . metadata = function ( objtype , callback , error ) {
487+ 'use strict' ;
471488 return this . ajax ( '/' + this . apiVersion + '/sobjects/' + objtype + '/'
472489 , callback , error ) ;
473490 }
@@ -480,6 +497,7 @@ if (forcetk.Client === undefined) {
480497 * @param [error=null] function to which jqXHR will be passed in case of error
481498 */
482499 forcetk . Client . prototype . describe = function ( objtype , callback , error ) {
500+ 'use strict' ;
483501 return this . ajax ( '/' + this . apiVersion + '/sobjects/' + objtype
484502 + '/describe/' , callback , error ) ;
485503 }
@@ -494,6 +512,7 @@ if (forcetk.Client === undefined) {
494512 * @param [error=null] function to which jqXHR will be passed in case of error
495513 */
496514 forcetk . Client . prototype . create = function ( objtype , fields , callback , error ) {
515+ 'use strict' ;
497516 return this . ajax ( '/' + this . apiVersion + '/sobjects/' + objtype + '/'
498517 , callback , error , "POST" , JSON . stringify ( fields ) ) ;
499518 }
@@ -508,6 +527,7 @@ if (forcetk.Client === undefined) {
508527 * @param [error=null] function to which jqXHR will be passed in case of error
509528 */
510529 forcetk . Client . prototype . retrieve = function ( objtype , id , fieldlist , callback , error ) {
530+ 'use strict' ;
511531 if ( arguments . length == 4 ) {
512532 error = callback ;
513533 callback = fieldlist ;
@@ -531,6 +551,7 @@ if (forcetk.Client === undefined) {
531551 * @param [error=null] function to which jqXHR will be passed in case of error
532552 */
533553 forcetk . Client . prototype . upsert = function ( objtype , externalIdField , externalId , fields , callback , error ) {
554+ 'use strict' ;
534555 return this . ajax ( '/' + this . apiVersion + '/sobjects/' + objtype + '/' + externalIdField + '/' + externalId
535556 + '?_HttpMethod=PATCH' , callback , error , "POST" , JSON . stringify ( fields ) ) ;
536557 }
@@ -546,6 +567,7 @@ if (forcetk.Client === undefined) {
546567 * @param [error=null] function to which jqXHR will be passed in case of error
547568 */
548569 forcetk . Client . prototype . update = function ( objtype , id , fields , callback , error ) {
570+ 'use strict' ;
549571 return this . ajax ( '/' + this . apiVersion + '/sobjects/' + objtype + '/' + id
550572 + '?_HttpMethod=PATCH' , callback , error , "POST" , JSON . stringify ( fields ) ) ;
551573 }
@@ -559,6 +581,7 @@ if (forcetk.Client === undefined) {
559581 * @param [error=null] function to which jqXHR will be passed in case of error
560582 */
561583 forcetk . Client . prototype . del = function ( objtype , id , callback , error ) {
584+ 'use strict' ;
562585 return this . ajax ( '/' + this . apiVersion + '/sobjects/' + objtype + '/' + id
563586 , callback , error , "DELETE" ) ;
564587 }
@@ -571,6 +594,7 @@ if (forcetk.Client === undefined) {
571594 * @param [error=null] function to which jqXHR will be passed in case of error
572595 */
573596 forcetk . Client . prototype . query = function ( soql , callback , error ) {
597+ 'use strict' ;
574598 return this . ajax ( '/' + this . apiVersion + '/query?q=' + encodeURIComponent ( soql )
575599 , callback , error ) ;
576600 }
@@ -586,6 +610,7 @@ if (forcetk.Client === undefined) {
586610 * @param [error=null] function to which jqXHR will be passed in case of error
587611 */
588612 forcetk . Client . prototype . queryMore = function ( url , callback , error ) {
613+ 'use strict' ;
589614 //-- ajax call adds on services/data to the url call, so only send the url after
590615 var serviceData = "services/data" ;
591616 var index = url . indexOf ( serviceData ) ;
@@ -607,6 +632,7 @@ if (forcetk.Client === undefined) {
607632 * @param [error=null] function to which jqXHR will be passed in case of error
608633 */
609634 forcetk . Client . prototype . search = function ( sosl , callback , error ) {
635+ 'use strict' ;
610636 return this . ajax ( '/' + this . apiVersion + '/search?q=' + encodeURIComponent ( sosl )
611637 , callback , error ) ;
612638 }
0 commit comments