-
Notifications
You must be signed in to change notification settings - Fork 6
/
AJAXFunctions.ts
44 lines (35 loc) · 1.62 KB
/
AJAXFunctions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
///<reference path='c:\development\Netsuite\SuiteScriptAPITS.d.ts'/>
/*
Utility Functions
© 2008 - 2012 Brett Knights.
This EULA grants you the following rights:
Installation and Use. You may install and use an unlimited number of copies of the SOFTWARE PRODUCT.
Reproduction and Distribution. You may reproduce and distribute an unlimited number of copies of the SOFTWARE PRODUCT
either in whole or in part; each copy should include all copyright and trademark notices, and shall be accompanied by a copy of this EULA.
Copies of the SOFTWARE PRODUCT may be distributed as a standalone product or included with your own product.
Commercial Use. You may sell for profit and freely distribute scripts and/or compiled scripts that were created with the SOFTWARE PRODUCT.
For permission, contact [email protected]
*/
module KOTNUtil {
export function sendJSResponse(request : nlobjRequest, response : nlobjResponse, respObject : Object){
var startTime = new Date().getTime();
response.setContentType('JAVASCRIPT');
var callbackFcn = request.getParameter("callback") || request.getParameter("jsoncallback");
if(callbackFcn){
response.writeLine( callbackFcn + "(" + JSON.stringify(respObject) + ");");
}else response.writeLine( JSON.stringify(respObject) );
nlapiLogExecution("DEBUG", "sendJSResponse", (new Date().getTime() - startTime) +" ms");
}
export function unique(arr){
var u = [];
noadd :
for(var i = 0; i< arr.length;i++){
for(var k = 0; k< u.length; k++){
if(arr[i] == u[k]) continue noadd;
}
u.push(arr[i]);
}
return u;
}
export function toJSON(target){return JSON.stringify(target);};
}