-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
tranformSize.js
43 lines (39 loc) · 1001 Bytes
/
tranformSize.js
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
import * as utils from '../../src/utils.js';
/**
* get sizes for rtb
* @param {Array|Object} requestSizes
* @return {Object}
*/
export function transformSizes(requestSizes) {
let sizes = [];
let sizeObj = {};
if (
utils.isArray(requestSizes) &&
requestSizes.length === 2 &&
!utils.isArray(requestSizes[0])
) {
sizeObj.width = parseInt(requestSizes[0], 10);
sizeObj.height = parseInt(requestSizes[1], 10);
sizes.push(sizeObj);
} else if (typeof requestSizes === 'object') {
for (let i = 0; i < requestSizes.length; i++) {
let size = requestSizes[i];
sizeObj = {};
sizeObj.width = parseInt(size[0], 10);
sizeObj.height = parseInt(size[1], 10);
sizes.push(sizeObj);
}
}
return sizes;
}
export const normalAdSize = [
{ w: 300, h: 250 },
{ w: 300, h: 600 },
{ w: 728, h: 90 },
{ w: 970, h: 250 },
{ w: 320, h: 50 },
{ w: 160, h: 600 },
{ w: 320, h: 180 },
{ w: 320, h: 100 },
{ w: 336, h: 280 },
];