Mercurial > MadButterfly
annotate nodejs/examples/mce/epg.js @ 1340:10d5f06f7566
Fix issue of shouting error when removing a node.
- It shout a Python traceback message when removing a node that is
referenced by a svg:use node.
- when the node been removed, the node would be duplicated. The
duplication was used to replace the svg:use one.
- The ID of inserted duplication is the same as duplicated node,
and modified to a new and unique ID.
- Original design of domview_monitor can not handle it.
- It is resolved by changing domview_monitor._id2node from single
mapping to multiple mapping one.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Sun, 06 Feb 2011 23:12:48 +0800 |
parents | 3d438daea48c |
children | 9f3f20c4a4fb |
rev | line source |
---|---|
932
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
2 // vim: sw=4:ts=8:sts=4 |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
3 var http = require('http'); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
4 var URL = require('url'); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
5 var sys = require("sys"); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
6 var fs = require("fs"); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
7 var os = require("child_process"); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
8 function EPG() |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
9 { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
10 var epgsrv = http.createClient(8080, '211.23.50.144'); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
11 var cmd = '{"Protocol":"EPG-CSP","Command":"SearchRequest","ProgramCat":"MainCat"}'; |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
12 var headers={ |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
13 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
14 'Host':'211.23.50.144:8080', |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
15 'User-Agent':'MadButterfly', |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
16 'Content-Type':'application/x-www-form-urlencoded' |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
17 }; |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
18 headers['Content-Length'] = cmd.length; |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
19 var request = epgsrv.request('POST', '/IPTV_EPG/EPGService.do?timestamp='+new Date().getTime(),headers); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
20 var self = this; |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
21 sys.puts("aaaa"); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
22 var js = ''; |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
23 request.write(cmd); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
24 request.end(); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
25 request.on('response', function(res) { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
26 sys.puts("connected"); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
27 res.on('data',function (data) { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
28 js = js + data; |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
29 }); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
30 res.on('end', function () { |
1122 | 31 try { |
32 res = JSON.parse(js); | |
33 } catch(e) { | |
34 sys.puts(e); | |
35 sys.puts(js); | |
36 } | |
932
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
37 sys.puts("parsed"); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
38 self.onLoad(res); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
39 |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
40 }); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
41 }); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
42 } |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
43 |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
44 |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
45 /** |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
46 * Check if the file has been cached. Create a symbolic to link if it is cached already. |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
47 * |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
48 */ |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
49 function isCached(cachepath,file,obj) { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
50 var fields = cachepath.split('.'); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
51 try { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
52 var ext = fields.pop(); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
53 var pngfile = cachepath; |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
54 sys.puts("ext="+ext); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
55 if (ext != 'png') { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
56 fields.push('png'); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
57 pngfile = fields.join('.'); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
58 } |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
59 var st = fs.statSync(pngfile); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
60 try { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
61 fs.unlinkSync(file); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
62 } catch(e) { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
63 } |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
64 fs.linkSync(pngfile, file); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
65 obj.pend = obj.pend - 1; |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
66 if (obj.pend == 0) { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
67 obj.onInitDone(); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
68 } |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
69 return 1; |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
70 } catch(e) { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
71 sys.puts(e); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
72 } |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
73 return 0; |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
74 } |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
75 |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
76 /** |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
77 * Implement the mkdir -p to create the directory |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
78 */ |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
79 function CreateDirectory(cachepath) |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
80 { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
81 var fields = cachepath.split('/'); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
82 var p=''; |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
83 for(i=0;i<fields.length-1;i++) { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
84 p = p + fields[i]+'/'; |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
85 try { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
86 fs.mkdirSync(p,0777); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
87 } catch(e) { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
88 } |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
89 } |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
90 } |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
91 /* |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
92 * We will check the cache directory. If the file is available, we will create a symbolic link only. Otherwise, |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
93 * we will fetch it before create the symbolic link. |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
94 */ |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
95 function httpGetFile(url,file,obj) |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
96 { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
97 sys.puts("fetch "+ file); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
98 var u = URL.parse(url); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
99 var cachepath = 'cache/'+u.pathname; |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
100 if (isCached(cachepath,file,obj)) return; |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
101 CreateDirectory(cachepath); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
102 |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
103 // Fetch file from the server and convert it tyo PNG if it is not PNG format. |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
104 var f = fs.openSync(cachepath,'w'); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
105 sys.puts("f="+f); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
106 var headers={ |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
107 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
108 'Host':'211.23.50.144:8080', |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
109 'User-Agent':'MadButterfly', |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
110 'Content-Type':'application/x-www-form-urlencoded' |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
111 }; |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
112 sys.puts("host="+u.host+' '+u.port+' '+u.pathname); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
113 for(k in u) { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
114 sys.puts(k+"--->"+u[k]); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
115 } |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
116 var c = http.createClient(8080,'211.23.50.144'); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
117 var req = c.request('GET',u.pathname,headers); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
118 req.end(); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
119 req.on('response', function(res) { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
120 res.on('data',function(data) { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
121 fs.writeSync(f,data,0,data.length); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
122 }); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
123 res.on('end',function() { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
124 fs.close(f); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
125 var fields = cachepath.split('.'); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
126 var ext = fields.pop(); |
1122 | 127 if (ext != "png" && ext != 'jpg') { |
932
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
128 fields.push("png"); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
129 newf = fields.join("."); |
1035
18329b6f77a4
Generate the PNG fropm the JPG file. We need to add the JPG/GIF graphics format
wycc
parents:
932
diff
changeset
|
130 sys.puts("cachepath="+cachepath+" newf="+newf); |
18329b6f77a4
Generate the PNG fropm the JPG file. We need to add the JPG/GIF graphics format
wycc
parents:
932
diff
changeset
|
131 os.spawn("convert",[cachepath,newf]); |
932
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
132 } else { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
133 newf = cachepath; |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
134 } |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
135 try { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
136 fs.unlinkSync(file); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
137 } catch(e) { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
138 } |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
139 sys.puts("end of "+cachepath+" to "+file); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
140 fs.symlinkSync(newf, file); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
141 obj.pend = obj.pend - 1; |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
142 if (obj.pend == 0) { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
143 obj.onInitDone(); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
144 } |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
145 |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
146 }); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
147 |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
148 }); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
149 } |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
150 |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
151 EPG.prototype.onLoad = function(res) { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
152 cats = res['ProgramCat']; |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
153 this.pend = cats.length; |
1065 | 154 this.maincat = cats; |
932
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
155 for (i in cats) { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
156 c = cats[i]; |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
157 httpGetFile(c['ProgramPIC'],'cat'+i+'.png',this); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
158 } |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
159 } |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
160 |
1065 | 161 EPG.prototype.getList=function(item,func) { |
162 var epgsrv = http.createClient(8080, '211.23.50.144'); | |
163 var cmd = '{"Protocol":"EPG-CSP","Command":"SearchRequest","ProgramSub":"'+item.Category+'"}'; | |
164 var headers={ | |
165 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', | |
166 'Host':'211.23.50.144:8080', | |
167 'User-Agent':'MadButterfly', | |
168 'Content-Type':'application/x-www-form-urlencoded' | |
169 }; | |
170 headers['Content-Length'] = cmd.length; | |
171 var request = epgsrv.request('POST', '/IPTV_EPG/EPGService.do?timestamp='+new Date().getTime(),headers); | |
172 var self = this; | |
173 sys.puts("aaaa"); | |
174 var js = ''; | |
175 request.write(cmd); | |
176 request.end(); | |
177 request.on('response', function(res) { | |
178 sys.puts("connected"); | |
179 res.on('data',function (data) { | |
180 js = js + data; | |
181 }); | |
182 res.on('end', function () { | |
183 res = JSON.parse(js); | |
184 sys.puts("parsed"); | |
185 func(); | |
932
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
186 |
1065 | 187 }); |
188 }); | |
189 } | |
932
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
190 EPG.prototype.onInitDone=function() { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
191 if (this.loadCallback) |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
192 this.loadCallback(); |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
193 } |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
194 |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
195 EPG.prototype.registerInitDone=function(cb) { |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
196 this.loadCallback = cb; |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
197 } |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
198 |
bd9b0142fc7e
Update the sample application. We can use the ./test5 to test it now. It will download the image from the VOD server and render it in the screen.
wycc
parents:
diff
changeset
|
199 exports.EPG = EPG; |