|
1 | | -(function() |
2 | | -{ |
3 | | - var get_path = function(ele) |
4 | | - { |
5 | | - var path = [], proto = null; |
6 | | - while (ele && (proto = ele.parentNode) && |
7 | | - proto.parentNode.nodeName.toLowerCase() == 'examine-objects') |
8 | | - { |
9 | | - path.push([ |
10 | | - ele.getElementsByTagName('key')[0].textContent, |
11 | | - parseInt(ele.getAttribute('obj-id')), |
12 | | - parseInt(proto.getAttribute('data-proto-index')) |
13 | | - ]); |
14 | | - ele = proto.parentNode.parentNode; |
15 | | - } |
16 | | - return path.reverse(); |
17 | | - }; |
18 | | - |
19 | | - var examine_object_cb = function(target, container, data_model, path) |
20 | | - { |
21 | | - container.render(window.templates.inspected_js_object(data_model, null, path)); |
22 | | - // update the icon |
23 | | - target.style.backgroundPosition = "0px -11px"; |
24 | | - }; |
25 | | - |
26 | | - window.eventHandlers.click['expand-prototype'] = function(event, target) |
27 | | - { |
28 | | - const PATH_PROTO_INDEX = 2; |
29 | | - |
30 | | - var |
31 | | - data_model = window.inspections[target.get_attr('parent-node-chain', 'data-id')], |
32 | | - is_unfolded = target.hasClass('unfolded'), |
33 | | - path = get_path(target), |
34 | | - name = target.getElementsByTagName('key')[0].textContent; |
35 | | - |
36 | | - if (is_unfolded) |
37 | | - data_model.collapse_prototype(path); |
38 | | - else |
39 | | - data_model.expand_prototype(path); |
40 | | - var index = path.pop()[PATH_PROTO_INDEX]; |
41 | | - var templ = window.templates.inspected_js_prototype(data_model, path, index, name); |
42 | | - target.parentNode.re_render(templ); |
43 | | - } |
44 | | - |
45 | | - window.eventHandlers.click['examine-object'] = function examine_objects(event, target) |
46 | | - { |
47 | | - /* |
48 | | - // prototype header |
49 | | - <examine-objects data-id="inspection-id-2"> |
50 | | - <div class="prototype" data-proto-index="0"/> |
51 | | - <div class="prototype" data-proto-index="1"> |
52 | | - <div class="prototype-chain-object"> |
53 | | - <input type="button" handler="expand-prototype" class="folder-key inverted" proto-index="1"/> |
54 | | - Function |
55 | | - </div> |
56 | | - </div> |
57 | | - <div class="prototype" data-proto-index="2"/> |
58 | | - </examine-objects> |
59 | | -
|
60 | | - // object item |
61 | | - <examine-objects rt-id="1" data-id="inspection-id-1" obj-id="1"> |
62 | | - <div class="prototype" data-proto-index="0"> |
63 | | - <item obj-id="112"> |
64 | | - <input type="button" handler="examine-object" class="folder-key"/> |
65 | | - <key>ApplicationCache</key> |
66 | | - <value class="object" >ApplicationCache</value> |
67 | | - </item> |
68 | | - */ |
69 | | - |
70 | | - const PATH_OBJ_ID = 1; |
71 | | - |
72 | | - var |
73 | | - parent = target.parentNode, |
74 | | - data_model = window.inspections[parent.get_attr('parent-node-chain', 'data-id')], |
75 | | - examine_object = parent.getElementsByTagName('examine-objects')[0], |
76 | | - path = get_path(parent); |
77 | | - |
78 | | - if (data_model) |
79 | | - { |
80 | | - if (examine_object) // is unfolded |
81 | | - { |
82 | | - if (!target.disabled) |
83 | | - { |
84 | | - data_model.collapse(path); |
85 | | - parent.removeChild(examine_object); |
86 | | - target.style.removeProperty("background-position"); |
87 | | - } |
88 | | - } |
89 | | - else |
90 | | - { |
91 | | - var cb = examine_object_cb.bind(this, target, parent, data_model, path); |
92 | | - data_model.expand(cb, path); |
93 | | - } |
94 | | - } |
95 | | - }; |
96 | | - |
97 | | - window.eventHandlers.click['get-getter-value'] = function examine_objects(event, target) |
98 | | - { |
99 | | - var obj_id = Number(target.get_attr('parent-node-chain', 'obj-id')); |
100 | | - var data_model = window.inspections[target.get_attr('parent-node-chain', 'data-id')]; |
101 | | - var parent = target.get_ancestor("item"); |
102 | | - var key = parent && parent.querySelector("key"); |
103 | | - var path = data_model && data_model.norm_path(get_path(parent)); |
104 | | - if (obj_id && data_model && key && path) |
105 | | - { |
106 | | - var getter = key.textContent; |
107 | | - var cb = _expand_getter.bind(null, target, obj_id, data_model, getter, path); |
108 | | - var tag = window.tag_manager.set_callback(null, cb, []); |
109 | | - var ex_ctx = window.runtimes.get_execution_context(); |
110 | | - var rt_id = ex_ctx.rt_id; |
111 | | - var thread_id = ex_ctx.thread_id; |
112 | | - var frame_index = ex_ctx.frame_index; |
113 | | - if (data_model.runtime_id != rt_id) |
114 | | - { |
115 | | - rt_id = data_model.runtime_id; |
116 | | - thread_id = 0; |
117 | | - frame_index = 0; |
118 | | - } |
119 | | - var script = "obj[\"" + window.helpers.escape_input(getter) + "\"]"; |
120 | | - var msg = [rt_id, thread_id, frame_index, script, [["obj", obj_id]]]; |
121 | | - window.services["ecmascript-debugger"].requestEval(tag, msg); |
122 | | - } |
123 | | - }; |
124 | | - |
125 | | - window.eventHandlers.click['expand-scope-chain'] = function(event, target) |
126 | | - { |
127 | | - var |
128 | | - parent = target.parentNode, |
129 | | - data_model = window.inspections[target.getAttribute('data-id')], |
130 | | - examine_object = parent.getElementsByTagName('examine-objects')[0]; |
131 | | - |
132 | | - if (examine_object) // is unfolded |
133 | | - { |
134 | | - data_model.collapse_scope_chain(); |
135 | | - parent.re_render(window.templates.inspected_js_scope_chain(data_model)); |
136 | | - } |
137 | | - else |
138 | | - { |
139 | | - data_model.expand_scope_chain(); |
140 | | - parent.re_render(window.templates.inspected_js_scope_chain(data_model)); |
141 | | - } |
142 | | - }; |
143 | | - |
144 | | - var _expand_getter = function(target, obj_id, data_model, getter, path, status, message) |
145 | | - { |
146 | | - var PATH_PROTO_INDEX = 2; |
147 | | - var STATUS_OK = 0; |
148 | | - if (status === STATUS_OK && |
149 | | - data_model.set_getter_value(obj_id, getter, message) && |
150 | | - target.parentNode && target.parentNode.parentNode) |
151 | | - { |
152 | | - var index = path.pop()[PATH_PROTO_INDEX]; |
153 | | - var templ = window.templates.inspected_js_prototype(data_model, path, index); |
154 | | - target.parentNode.parentNode.re_render(templ); |
155 | | - } |
156 | | - }; |
157 | | - |
158 | | - var _inspect_object = function(rt_id, obj_id, force_show_view) |
159 | | - { |
160 | | - messages.post('active-inspection-type', {inspection_type: 'object'}); |
161 | | - if (force_show_view) |
162 | | - { |
163 | | - UI.get_instance().show_view(views.inspection.id); |
164 | | - } |
165 | | - messages.post('object-selected', {rt_id: rt_id, obj_id: obj_id}); |
166 | | - }; |
167 | | - |
168 | | - window.eventHandlers.click['inspect-object-link'] = function(event, target) |
169 | | - { |
170 | | - var rt_id = Number(target.get_ancestor_attr('rt-id') || |
171 | | - target.get_ancestor_attr('data-rt-id')); |
172 | | - var obj_id = Number(target.get_ancestor_attr('obj-id') || |
173 | | - target.get_ancestor_attr('data-obj-id')); |
174 | | - if (rt_id && obj_id) |
175 | | - _inspect_object(rt_id, obj_id, true); |
176 | | - }; |
177 | | - |
178 | | - window.eventHandlers.click['inspect-object-inline-link'] = function(event, target) |
179 | | - { |
180 | | - if (event.target.nodeName.toLowerCase() == "key" && |
181 | | - event.target.parentNode.hasAttribute('obj-id')) |
182 | | - { |
183 | | - var obj_id = parseInt(event.target.parentNode.getAttribute('obj-id')); |
184 | | - var model_id = event.target.get_attr('parent-node-chain', 'data-id'); |
185 | | - var model = model_id && window.inspections[model_id]; |
186 | | - var rt_id = model && model.runtime_id; |
187 | | - _inspect_object(rt_id, obj_id); |
188 | | - } |
189 | | - }; |
190 | | - |
191 | | -})(); |
| 1 | +(function() |
| 2 | +{ |
| 3 | + var get_path = function(ele) |
| 4 | + { |
| 5 | + var path = [], proto = null; |
| 6 | + while (ele && (proto = ele.parentNode) && |
| 7 | + proto.parentNode.nodeName.toLowerCase() == 'examine-objects') |
| 8 | + { |
| 9 | + path.push([ |
| 10 | + ele.getElementsByTagName('key')[0].textContent, |
| 11 | + parseInt(ele.getAttribute('obj-id')), |
| 12 | + parseInt(proto.getAttribute('data-proto-index')) |
| 13 | + ]); |
| 14 | + ele = proto.parentNode.parentNode; |
| 15 | + } |
| 16 | + return path.reverse(); |
| 17 | + }; |
| 18 | + |
| 19 | + var examine_object_cb = function(target, container, data_model, path) |
| 20 | + { |
| 21 | + container.render(window.templates.inspected_js_object(data_model, null, path)); |
| 22 | + // update the icon |
| 23 | + target.style.backgroundPosition = "0px -11px"; |
| 24 | + }; |
| 25 | + |
| 26 | + window.eventHandlers.click['expand-prototype'] = function(event, target) |
| 27 | + { |
| 28 | + const PATH_PROTO_INDEX = 2; |
| 29 | + |
| 30 | + var |
| 31 | + data_model = window.inspections[target.get_attr('parent-node-chain', 'data-id')], |
| 32 | + is_unfolded = target.hasClass('unfolded'), |
| 33 | + path = get_path(target), |
| 34 | + name = target.getElementsByTagName('key')[0].textContent; |
| 35 | + |
| 36 | + if (is_unfolded) |
| 37 | + data_model.collapse_prototype(path); |
| 38 | + else |
| 39 | + data_model.expand_prototype(path); |
| 40 | + var index = path.pop()[PATH_PROTO_INDEX]; |
| 41 | + var templ = window.templates.inspected_js_prototype(data_model, path, index, name); |
| 42 | + target.parentNode.re_render(templ); |
| 43 | + } |
| 44 | + |
| 45 | + window.eventHandlers.click['examine-object'] = function examine_objects(event, target) |
| 46 | + { |
| 47 | + /* |
| 48 | + // prototype header |
| 49 | + <examine-objects data-id="inspection-id-2"> |
| 50 | + <div class="prototype" data-proto-index="0"/> |
| 51 | + <div class="prototype" data-proto-index="1"> |
| 52 | + <div class="prototype-chain-object"> |
| 53 | + <input type="button" handler="expand-prototype" class="folder-key inverted" proto-index="1"/> |
| 54 | + Function |
| 55 | + </div> |
| 56 | + </div> |
| 57 | + <div class="prototype" data-proto-index="2"/> |
| 58 | + </examine-objects> |
| 59 | +
|
| 60 | + // object item |
| 61 | + <examine-objects rt-id="1" data-id="inspection-id-1" obj-id="1"> |
| 62 | + <div class="prototype" data-proto-index="0"> |
| 63 | + <item obj-id="112"> |
| 64 | + <input type="button" handler="examine-object" class="folder-key"/> |
| 65 | + <key>ApplicationCache</key> |
| 66 | + <value class="object" >ApplicationCache</value> |
| 67 | + </item> |
| 68 | + */ |
| 69 | + |
| 70 | + const PATH_OBJ_ID = 1; |
| 71 | + |
| 72 | + var |
| 73 | + parent = target.parentNode, |
| 74 | + data_model = window.inspections[parent.get_attr('parent-node-chain', 'data-id')], |
| 75 | + examine_object = parent.getElementsByTagName('examine-objects')[0], |
| 76 | + path = get_path(parent); |
| 77 | + |
| 78 | + if (data_model) |
| 79 | + { |
| 80 | + if (examine_object) // is unfolded |
| 81 | + { |
| 82 | + if (!target.disabled) |
| 83 | + { |
| 84 | + data_model.collapse(path); |
| 85 | + parent.removeChild(examine_object); |
| 86 | + target.style.removeProperty("background-position"); |
| 87 | + } |
| 88 | + } |
| 89 | + else |
| 90 | + { |
| 91 | + var cb = examine_object_cb.bind(this, target, parent, data_model, path); |
| 92 | + data_model.expand(cb, path); |
| 93 | + } |
| 94 | + } |
| 95 | + }; |
| 96 | + |
| 97 | + window.eventHandlers.click['get-getter-value'] = function examine_objects(event, target) |
| 98 | + { |
| 99 | + var obj_id = Number(target.get_attr('parent-node-chain', 'obj-id')); |
| 100 | + var data_model = window.inspections[target.get_attr('parent-node-chain', 'data-id')]; |
| 101 | + var parent = target.get_ancestor("item"); |
| 102 | + var key = parent && parent.querySelector("key"); |
| 103 | + var path = data_model && data_model.norm_path(get_path(parent)); |
| 104 | + if (obj_id && data_model && key && path) |
| 105 | + { |
| 106 | + var getter = key.textContent; |
| 107 | + var cb = _expand_getter.bind(null, target, obj_id, data_model, getter, path); |
| 108 | + var tag = window.tag_manager.set_callback(null, cb, []); |
| 109 | + var ex_ctx = window.runtimes.get_execution_context(); |
| 110 | + var rt_id = ex_ctx.rt_id; |
| 111 | + var thread_id = ex_ctx.thread_id; |
| 112 | + var frame_index = ex_ctx.frame_index; |
| 113 | + if (data_model.runtime_id != rt_id) |
| 114 | + { |
| 115 | + rt_id = data_model.runtime_id; |
| 116 | + thread_id = 0; |
| 117 | + frame_index = 0; |
| 118 | + } |
| 119 | + var script = "obj[\"" + window.helpers.escape_input(getter) + "\"]"; |
| 120 | + var msg = [rt_id, thread_id, frame_index, script, [["obj", obj_id]]]; |
| 121 | + window.services["ecmascript-debugger"].requestEval(tag, msg); |
| 122 | + } |
| 123 | + }; |
| 124 | + |
| 125 | + window.eventHandlers.click['expand-scope-chain'] = function(event, target) |
| 126 | + { |
| 127 | + var |
| 128 | + parent = target.parentNode, |
| 129 | + data_model = window.inspections[target.getAttribute('data-id')], |
| 130 | + examine_object = parent.getElementsByTagName('examine-objects')[0]; |
| 131 | + |
| 132 | + if (examine_object) // is unfolded |
| 133 | + { |
| 134 | + data_model.collapse_scope_chain(); |
| 135 | + parent.re_render(window.templates.inspected_js_scope_chain(data_model)); |
| 136 | + } |
| 137 | + else |
| 138 | + { |
| 139 | + data_model.expand_scope_chain(); |
| 140 | + parent.re_render(window.templates.inspected_js_scope_chain(data_model)); |
| 141 | + } |
| 142 | + }; |
| 143 | + |
| 144 | + var _expand_getter = function(target, obj_id, data_model, getter, path, status, message) |
| 145 | + { |
| 146 | + var PATH_PROTO_INDEX = 2; |
| 147 | + var STATUS_OK = 0; |
| 148 | + if (status === STATUS_OK && |
| 149 | + data_model.set_getter_value(obj_id, getter, message) && |
| 150 | + target.parentNode && target.parentNode.parentNode) |
| 151 | + { |
| 152 | + var index = path.pop()[PATH_PROTO_INDEX]; |
| 153 | + var templ = window.templates.inspected_js_prototype(data_model, path, index); |
| 154 | + target.parentNode.parentNode.re_render(templ); |
| 155 | + } |
| 156 | + }; |
| 157 | + |
| 158 | + var _inspect_object = function(rt_id, obj_id, force_show_view) |
| 159 | + { |
| 160 | + messages.post('active-inspection-type', {inspection_type: 'object'}); |
| 161 | + if (force_show_view) |
| 162 | + { |
| 163 | + UI.get_instance().show_view(views.inspection.id); |
| 164 | + } |
| 165 | + messages.post('object-selected', {rt_id: rt_id, obj_id: obj_id}); |
| 166 | + }; |
| 167 | + |
| 168 | + window.eventHandlers.click['inspect-object-link'] = function(event, target) |
| 169 | + { |
| 170 | + var rt_id = Number(target.get_ancestor_attr('rt-id') || |
| 171 | + target.get_ancestor_attr('data-rt-id')); |
| 172 | + var obj_id = Number(target.get_ancestor_attr('obj-id') || |
| 173 | + target.get_ancestor_attr('data-obj-id')); |
| 174 | + if (rt_id && obj_id) |
| 175 | + _inspect_object(rt_id, obj_id, true); |
| 176 | + }; |
| 177 | + |
| 178 | + window.eventHandlers.click['inspect-object-inline-link'] = function(event, target) |
| 179 | + { |
| 180 | + if (event.target.nodeName.toLowerCase() == "key" && |
| 181 | + event.target.parentNode.hasAttribute('obj-id')) |
| 182 | + { |
| 183 | + var obj_id = parseInt(event.target.parentNode.getAttribute('obj-id')); |
| 184 | + var model_id = event.target.get_attr('parent-node-chain', 'data-id'); |
| 185 | + var model = model_id && window.inspections[model_id]; |
| 186 | + var rt_id = model && model.runtime_id; |
| 187 | + _inspect_object(rt_id, obj_id); |
| 188 | + } |
| 189 | + }; |
| 190 | + |
| 191 | +})(); |
0 commit comments