-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathstatic.js
More file actions
109 lines (102 loc) · 4.06 KB
/
Copy pathstatic.js
File metadata and controls
109 lines (102 loc) · 4.06 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
const sessions = require('../data/sessions');
const fUtil = require('../fileUtil');
const stuff = require('./info');
function toAttrString(table) {
return typeof (table) == 'object' ? Object.keys(table).filter(key => table[key] !== null).map(key =>
`${encodeURIComponent(key)}=${encodeURIComponent(table[key])}`).join('&') : table.replace(/"/g, "\\\"");
}
function toParamString(table) {
return Object.keys(table).map(key =>
`<param name="${key}" value="${toAttrString(table[key])}">`
).join(' ');
}
function toObjectString(attrs, params) {
return `<object id="obj" ${Object.keys(attrs).map(key =>
`${key}="${attrs[key].replace(/"/g, "\\\"")}"`
).join(' ')}>${toParamString(params)}</object>`;
}
module.exports = function (req, res, url) {
if (req.method != 'GET') return;
const query = url.query;
var attrs, params, title;
switch (url.pathname) {
case '/cc': {
title = 'Character Creator';
attrs = {
data: process.env.SWF_URL + '/cc.swf', // data: 'cc_.swf',
type: 'application/x-shockwave-flash', id: 'char_creator', width: '100%', height: '100%',
};
params = {
flashvars: {
'apiserver': '/', 'storePath': process.env.STORE_URL + '/<store>',
'clientThemePath': process.env.CLIENT_URL + '/<client_theme>', 'original_asset_id': query['id'] || null,
'themeId': 'business', 'ut': 60, 'bs': 'default', 'appCode': 'go', 'page': '', 'siteId': 'go',
'm_mode': 'school', 'isLogin': 'Y', 'isEmbed': 1, 'ctc': 'go', 'tlang': 'en_US',
},
allowScriptAccess: 'always',
movie: process.env.SWF_URL + '/cc.swf', // 'http://localhost/cc.swf'
};
break;
}
case '/cc_browser': {
title = 'Character Creator Browser';
attrs = {
data: process.env.SWF_URL + '/cc_browser.swf', // data: 'cc_browser_.swf',
type: 'application/x-shockwave-flash', id: 'char_creator', width: '100%', height: '100%',
};
params = {
flashvars: {
'apiserver': '/', 'storePath': process.env.STORE_URL + '/<store>',
'clientThemePath': process.env.CLIENT_URL + '/<client_theme>', 'original_asset_id': query['id'] || null,
'themeId': 'business', 'ut': 60, 'bs': 'default', 'appCode': 'go', 'page': '', 'siteId': 'go',
'm_mode': 'school', 'isLogin': 'Y', 'isEmbed': 1, 'ctc': 'go', 'tlang': 'en_US',
},
allowScriptAccess: 'always',
movie: process.env.SWF_URL + '/cc_browser.swf', // 'http://localhost/cc_browser.swf'
};
break;
}
case '/go_full': {
let presave = query.movieId && query.movieId.startsWith('m') ? query.movieId :
`m-${fUtil[query.noAutosave ? 'getNextFileId' : 'fillNextFileId']('movie-', '.xml')}`;
title = 'Video Editor';
attrs = {
data: process.env.SWF_URL + '/go_full.swf',
type: 'application/x-shockwave-flash', width: '100%', height: '100%',
};
params = {
flashvars: {
'apiserver': '/', 'storePath': process.env.STORE_URL + '/<store>', 'isEmbed': 1, 'ctc': 'go',
'ut': 60, 'bs': 'default', 'appCode': 'go', 'page': '', 'siteId': 'go', 'lid': 13, 'isLogin': 'Y', 'retut': 1,
'clientThemePath': process.env.CLIENT_URL + '/<client_theme>', 'themeId': 'business', 'tlang': 'en_US',
'presaveId': presave, 'goteam_draft_only': 1, 'isWide': 1, 'nextUrl': '/pages/html/list.html',
},
allowScriptAccess: 'always',
};
sessions.set({ movieId: presave }, req);
break;
}
case '/player': {
title = 'Video Player';
attrs = {
data: process.env.SWF_URL + '/player.swf',
type: 'application/x-shockwave-flash', width: '100%', height: '100%',
};
params = {
flashvars: {
'apiserver': '/', 'storePath': process.env.STORE_URL + '/<store>', 'ut': 60,
'autostart': 1, 'isWide': 1, 'clientThemePath': process.env.CLIENT_URL + '/<client_theme>',
},
allowScriptAccess: 'always',
};
break;
}
default:
return;
}
res.setHeader('Content-Type', 'text/html; charset=UTF-8');
Object.assign(params.flashvars, query);
res.end(`<script>document.title='${title}',flashvars=${JSON.stringify(params.flashvars)}</script><body style="margin:0px">${toObjectString(attrs, params)
}</body>${stuff.pages[url.pathname] || ''}`);
return true;
}