|
1 | 1 | window.cls || (window.cls = {}); |
2 | 2 |
|
3 | | -cls.OpenSingleResource = function(view,manager, url, data) |
| 3 | +cls.OpenSingleResource = function(view, manager, url, data) |
4 | 4 | { |
5 | | - this._view = view; |
6 | | - this._manager = manager; |
7 | | - this._url = url; |
8 | | - this._data = data; |
9 | | - |
10 | | - if (!this._tagman) |
11 | | - { |
12 | | - this._init_prototype(); |
13 | | - } |
14 | | - this._show_resource(); |
| 5 | + this._view = view; |
| 6 | + this._manager = manager; |
| 7 | + this._url = url; |
| 8 | + this._data = data; |
| 9 | + |
| 10 | + if (!this._tagman) |
| 11 | + { |
| 12 | + this._init_prototype(); |
| 13 | + } |
| 14 | + this._show_resource(); |
15 | 15 | }; |
16 | 16 |
|
17 | 17 | cls.OpenSingleResource.prototype = new function() |
18 | 18 | { |
19 | | - const |
20 | | - TRANSPORT_STRING = 1, |
21 | | - TRANSPORT_DATA_URI = 3, |
22 | | - DECODE_TRUE = 1, |
23 | | - SIZE_LIMIT = 1e7, |
24 | | - TRANSPORT_OFF = 4; |
| 19 | + const |
| 20 | + TRANSPORT_STRING = 1, |
| 21 | + TRANSPORT_DATA_URI = 3, |
| 22 | + DECODE_TRUE = 1, |
| 23 | + SIZE_LIMIT = 1e7, |
| 24 | + TRANSPORT_OFF = 4; |
25 | 25 |
|
26 | | - this._show_resource = function() |
27 | | - { |
28 | | - if (!this._manager.get_resource_for_url(this._url)) |
29 | | - //if (!this._view.show_resource_for_url(this._url, this._data)) |
30 | | - { |
31 | | - if (this._service.requestGetResourceID) |
32 | | - { |
33 | | - var tag = this._tagman.set_callback(this, this._on_resolve_url); |
34 | | - this._service.requestGetResourceID(tag, [this._url]); |
35 | | - } |
36 | | - else |
37 | | - { |
38 | | - this._fallback(); |
39 | | - } |
40 | | - } |
41 | | - }; |
| 26 | + this._show_resource = function() |
| 27 | + { |
| 28 | + if (!this._manager.get_resource_for_url(this._url)) |
| 29 | + { |
| 30 | + if (this._service.requestGetResourceID) |
| 31 | + { |
| 32 | + var tag = this._tagman.set_callback(this, this._on_resolve_url); |
| 33 | + this._service.requestGetResourceID(tag, [this._url]); |
| 34 | + } |
| 35 | + else |
| 36 | + { |
| 37 | + this._fallback(); |
| 38 | + } |
| 39 | + } |
| 40 | + }; |
42 | 41 |
|
43 | | - this._on_resolve_url = function(status, message) |
44 | | - { |
45 | | - if (status) |
46 | | - { |
47 | | - if (this._service.requestCreateRequest) |
48 | | - { |
49 | | - var debugContext = window.window_manager_data.get_debug_context(); |
50 | | - var tag = this._tagman.set_callback(this, this._on_resolve_url_request); |
51 | | - this._service.requestCreateRequest(tag, [debugContext, this._url, 'GET']); |
52 | | - } |
53 | | - else |
54 | | - { |
55 | | - this._fallback(); |
56 | | - } |
57 | | - } |
58 | | - else |
59 | | - { |
60 | | - const RESOURCE_ID = 0; |
61 | | - this._rid = message[RESOURCE_ID]; |
| 42 | + this._requestResource = function(id) |
| 43 | + { |
| 44 | + const RESOURCE_ID = 0; |
| 45 | + this._rid = message[RESOURCE_ID]; |
62 | 46 | // if (!this._view.show_resource_for_id(this._rid)) |
63 | | - { |
64 | | - var tag = this._tagman.set_callback(this, this._on_mime_type); |
65 | | - this._service.requestGetResource(tag, [this._rid, [TRANSPORT_OFF]]); |
66 | | - } |
67 | | - } |
68 | | - }; |
| 47 | + { |
| 48 | + var tag = this._tagman.set_callback(this, this._on_mime_type); |
| 49 | + this._service.requestGetResource(tag, [this._rid, [TRANSPORT_OFF]]); |
| 50 | + } |
| 51 | + } |
69 | 52 |
|
70 | | - this._on_resolve_url_request = function(status, message) |
71 | | - { |
72 | | - if (status) |
73 | | - { |
74 | | - this._fallback(); |
75 | | - } |
76 | | - else |
77 | | - { |
78 | | - const RESOURCE_ID = 0; |
79 | | - this._rid = message[RESOURCE_ID]; |
| 53 | + this._on_resolve_url = function(status, message) |
| 54 | + { |
| 55 | + if (status) |
| 56 | + { |
| 57 | + if (this._service.requestCreateRequest) |
| 58 | + { |
| 59 | + var debugContext = window.window_manager_data.get_debug_context(); |
| 60 | + var tag = this._tagman.set_callback(this, this._on_resolve_url_request); |
| 61 | + this._service.requestCreateRequest(tag, [debugContext, this._url, 'GET']); |
| 62 | + } |
| 63 | + else |
| 64 | + { |
| 65 | + this._fallback(); |
| 66 | + } |
| 67 | + } |
| 68 | + else |
| 69 | + { |
| 70 | + const RESOURCE_ID = 0; |
| 71 | + this._rid = message[RESOURCE_ID]; |
80 | 72 | // if (!this._view.show_resource_for_id(this._rid)) |
81 | | - { |
82 | | - var tag = this._tagman.set_callback(this, this._on_mime_type); |
83 | | - this._service.requestGetResource(tag, [this._rid, [TRANSPORT_OFF]]); |
84 | | - } |
85 | | - } |
86 | | - }; |
| 73 | + { |
| 74 | + var tag = this._tagman.set_callback(this, this._on_mime_type); |
| 75 | + this._service.requestGetResource(tag, [this._rid, [TRANSPORT_OFF]]); |
| 76 | + } |
| 77 | + } |
| 78 | + }; |
87 | 79 |
|
88 | | - this._on_mime_type = function(status, message) |
89 | | - { |
90 | | - if (status) |
91 | | - { |
92 | | - this._fallback(); |
93 | | - } |
94 | | - else |
95 | | - { |
96 | | - this._res = new cls.Resource(this._rid); |
97 | | - this._res.update("urlfinished", new this._ResourceData(message)); |
98 | | - var resptype = this._utils.mime_to_content_mode(this._res.mime); |
99 | | - var tag = this._tagman.set_callback(this, this._on_resource); |
100 | | - var msg = |
101 | | - [ |
102 | | - this._rid, |
103 | | - [ |
104 | | - resptype == "datauri" ? TRANSPORT_DATA_URI : TRANSPORT_STRING, |
105 | | - DECODE_TRUE, |
106 | | - SIZE_LIMIT |
107 | | - ] |
108 | | - ]; |
109 | | - this._service.requestGetResource(tag, msg); |
110 | | - } |
111 | | - }; |
112 | | -.001 |
| 80 | + this._on_resolve_url_request = function(status, message) |
| 81 | + { |
| 82 | + if (status) |
| 83 | + { |
| 84 | + this._fallback(); |
| 85 | + } |
| 86 | + else |
| 87 | + { |
| 88 | + const RESOURCE_ID = 0; |
| 89 | + this._rid = message[RESOURCE_ID]; |
| 90 | +// if (!this._view.show_resource_for_id(this._rid)) |
| 91 | + { |
| 92 | + var tag = this._tagman.set_callback(this, this._on_mime_type); |
| 93 | + this._service.requestGetResource(tag, [this._rid, [TRANSPORT_OFF]]); |
| 94 | + } |
| 95 | + } |
| 96 | + }; |
| 97 | + |
| 98 | + this._on_mime_type = function(status, message) |
| 99 | + { |
| 100 | + if (status) |
| 101 | + { |
| 102 | + this._fallback(); |
| 103 | + } |
| 104 | + else |
| 105 | + { |
| 106 | + this._res = new cls.Resource(this._rid); |
| 107 | + this._res.update("urlfinished", new this._ResourceData(message)); |
| 108 | + var resptype = this._utils.mime_to_content_mode(this._res.mime); |
| 109 | + var tag = this._tagman.set_callback(this, this._on_resource); |
| 110 | + var msg = |
| 111 | + [ |
| 112 | + this._rid, |
| 113 | + [ |
| 114 | + resptype == "datauri" ? TRANSPORT_DATA_URI : TRANSPORT_STRING, |
| 115 | + DECODE_TRUE, |
| 116 | + SIZE_LIMIT |
| 117 | + ] |
| 118 | + ]; |
| 119 | + this._service.requestGetResource(tag, msg); |
| 120 | + } |
| 121 | + }; |
113 | 122 |
|
114 | | - this._on_resource = function(status, message) |
115 | | - { |
116 | | - if (status) |
117 | | - { |
118 | | - this._fallback(); |
119 | | - } |
120 | | - else |
121 | | - { |
122 | | - //this._res.update("urlfinished", new this._ResourceData(message)); |
123 | | - this._res.update("responsefinished", message ); |
124 | | - this._view.open_resource_tab(this._res, this._data); |
125 | | - window.UI.instance.show_view( this._view.id ); |
126 | | - } |
127 | | - }; |
| 123 | + this._on_resource = function(status, message) |
| 124 | + { |
| 125 | + if (status) |
| 126 | + { |
| 127 | + this._fallback(); |
| 128 | + } |
| 129 | + else |
| 130 | + { |
| 131 | + //this._res.update("urlfinished", new this._ResourceData(message)); |
| 132 | + this._res.update("responsefinished", message ); |
| 133 | + this._view.open_resource_tab(this._res, this._data); |
| 134 | + window.UI.instance.show_view( this._view.id ); |
| 135 | + } |
| 136 | + }; |
128 | 137 |
|
129 | | - this._fallback = function() |
130 | | - { |
131 | | - window.open(this._url); |
132 | | - }; |
| 138 | + this._fallback = function() |
| 139 | + { |
| 140 | + window.open(this._url); |
| 141 | + }; |
133 | 142 |
|
134 | | - this._init_prototype = function() |
135 | | - { |
136 | | - this._tagman = window.tagManager; |
137 | | - this._service = window.services['resource-manager']; |
138 | | - this._ResourceData = cls.ResourceManager["1.0"].ResourceData; |
139 | | - this._utils = cls.ResourceUtil; |
140 | | - }.bind(this); |
| 143 | + this._init_prototype = function() |
| 144 | + { |
| 145 | + this._tagman = window.tagManager; |
| 146 | + this._service = window.services['resource-manager']; |
| 147 | + this._ResourceData = cls.ResourceManager["1.0"].ResourceData; |
| 148 | + this._utils = cls.ResourceUtil; |
| 149 | + }.bind(this); |
141 | 150 |
|
142 | 151 | }; |
0 commit comments