marta 0.37396 → 0.41245
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +42 -19
- data/example_project/p_object/test_page.rb +2 -1
- data/example_project/project_itself/iframe.html +5 -0
- data/{lib/marta/data/test.html → example_project/project_itself/index.html} +1 -1
- data/example_project/spec/p_object/pageobjects/MartaTestPage.json +707 -124
- data/example_project/spec/p_object/pageobjects/TheIframe.json +70 -14
- data/example_project/spec/spec_helper.rb +3 -1
- data/lib/marta/black_magic.rb +59 -13
- data/lib/marta/data/element.html +4 -15
- data/lib/marta/data/element.js +25 -226
- data/lib/marta/data/style.css +2 -2
- data/lib/marta/dialogs.rb +52 -4
- data/lib/marta/element_information.rb +86 -0
- data/lib/marta/injector.rb +2 -2
- data/lib/marta/json_2_class.rb +1 -1
- data/lib/marta/lightning.rb +1 -0
- data/lib/marta/marta_app/content.js +8 -0
- data/lib/marta/marta_app/devtools.html +1 -0
- data/lib/marta/marta_app/devtools.js +5 -0
- data/lib/marta/marta_app/manifest.json +3 -2
- data/lib/marta/options_and_paths.rb +1 -10
- data/lib/marta/page_arithmetic.rb +85 -97
- data/lib/marta/public_methods.rb +5 -4
- data/lib/marta/read_write.rb +50 -1
- data/lib/marta/server.rb +0 -18
- data/lib/marta/simple_element_finder.rb +0 -19
- data/lib/marta/version.rb +1 -1
- data/lib/marta/x_path.rb +154 -139
- metadata +7 -3
@@ -1,24 +1,80 @@
|
|
1
1
|
{
|
2
|
-
"vars": {
|
3
|
-
"path": "",
|
4
|
-
"url": ""
|
5
|
-
},
|
6
2
|
"meths": {
|
7
3
|
"github_link": {
|
8
|
-
"granny": {
|
9
|
-
},
|
10
4
|
"options": {
|
11
|
-
"collection": false
|
12
|
-
"granny": "HTML",
|
13
|
-
"pappy": "BODY",
|
14
|
-
"self": "A"
|
5
|
+
"collection": false
|
15
6
|
},
|
16
|
-
"
|
7
|
+
"positive": {
|
8
|
+
"self": {
|
9
|
+
"tag": [
|
10
|
+
"A"
|
11
|
+
],
|
12
|
+
"text": [
|
13
|
+
"GITHUB link"
|
14
|
+
],
|
15
|
+
"attributes": {
|
16
|
+
"href": [
|
17
|
+
"https://github.com/sseleznevqa/marta"
|
18
|
+
]
|
19
|
+
}
|
20
|
+
},
|
21
|
+
"pappy": {
|
22
|
+
"tag": [
|
23
|
+
"BODY"
|
24
|
+
],
|
25
|
+
"text": [
|
26
|
+
|
27
|
+
],
|
28
|
+
"attributes": {
|
29
|
+
}
|
30
|
+
},
|
31
|
+
"granny": {
|
32
|
+
"tag": [
|
33
|
+
"HTML"
|
34
|
+
],
|
35
|
+
"text": [
|
36
|
+
|
37
|
+
],
|
38
|
+
"attributes": {
|
39
|
+
}
|
40
|
+
}
|
17
41
|
},
|
18
|
-
"
|
19
|
-
"
|
20
|
-
|
42
|
+
"negative": {
|
43
|
+
"self": {
|
44
|
+
"text": [
|
45
|
+
|
46
|
+
],
|
47
|
+
"tag": [
|
48
|
+
|
49
|
+
],
|
50
|
+
"attributes": {
|
51
|
+
}
|
52
|
+
},
|
53
|
+
"pappy": {
|
54
|
+
"text": [
|
55
|
+
|
56
|
+
],
|
57
|
+
"tag": [
|
58
|
+
|
59
|
+
],
|
60
|
+
"attributes": {
|
61
|
+
}
|
62
|
+
},
|
63
|
+
"granny": {
|
64
|
+
"text": [
|
65
|
+
|
66
|
+
],
|
67
|
+
"tag": [
|
68
|
+
|
69
|
+
],
|
70
|
+
"attributes": {
|
71
|
+
}
|
72
|
+
}
|
21
73
|
}
|
22
74
|
}
|
75
|
+
},
|
76
|
+
"vars": {
|
77
|
+
"path": "",
|
78
|
+
"url": ""
|
23
79
|
}
|
24
80
|
}
|
@@ -6,7 +6,9 @@ RSpec.configure do |config|
|
|
6
6
|
config.before do |example|
|
7
7
|
@port = 7000
|
8
8
|
folder = "./spec/p_object/pageobjects"
|
9
|
-
dance_with(folder: folder,
|
9
|
+
dance_with(folder: folder,
|
10
|
+
port: @port,
|
11
|
+
base_url: "file:///#{Dir.pwd}/project_itself")
|
10
12
|
require 'test_page'
|
11
13
|
end
|
12
14
|
end
|
data/lib/marta/black_magic.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'marta/x_path'
|
2
2
|
require 'marta/simple_element_finder'
|
3
3
|
require 'marta/options_and_paths'
|
4
|
+
require 'marta/element_information'
|
5
|
+
require 'marta/page_arithmetic'
|
6
|
+
require 'marta/read_write'
|
4
7
|
|
5
8
|
module Marta
|
6
9
|
|
@@ -26,11 +29,13 @@ module Marta
|
|
26
29
|
# @note It is believed that no user will use it
|
27
30
|
class MagicFinder < BasicFinder
|
28
31
|
|
29
|
-
include OptionsAndPaths
|
32
|
+
include OptionsAndPaths, PageArithmetic, ElementInformation, ReadWrite
|
30
33
|
|
31
|
-
def initialize(meth, tolerancy, requestor)
|
34
|
+
def initialize(meth, tolerancy, name, requestor)
|
32
35
|
@tolerancy = tolerancy
|
33
36
|
@engine = requestor.engine
|
37
|
+
@name = name
|
38
|
+
@requestor = requestor
|
34
39
|
super(meth, requestor)
|
35
40
|
end
|
36
41
|
|
@@ -44,22 +49,63 @@ module Marta
|
|
44
49
|
end
|
45
50
|
end
|
46
51
|
|
52
|
+
# When black magic is finding some collection it is not only returning
|
53
|
+
# it. It is silently generating changes to a json file
|
54
|
+
def return_collection
|
55
|
+
result = prefind_collection
|
56
|
+
to_save = @meth
|
57
|
+
result.each do |item|
|
58
|
+
meth_data = method_structure true
|
59
|
+
meth_data['positive'] = get_attributes item, @requestor
|
60
|
+
to_save = make_collection(to_save, meth_data)
|
61
|
+
end
|
62
|
+
file_name = @requestor.instance_variable_get("@class_name").to_s
|
63
|
+
file_data = @requestor.instance_variable_get("@data")
|
64
|
+
file_data['meths'][@name] = to_save
|
65
|
+
file_write(file_name, file_data)
|
66
|
+
result
|
67
|
+
end
|
68
|
+
|
69
|
+
# When black magic is finding some element it is not only returning
|
70
|
+
# it. It is silently writing actual data about the element to json
|
71
|
+
def return_element
|
72
|
+
result = prefind
|
73
|
+
meth_data = method_structure
|
74
|
+
meth_data['positive'] = get_attributes result, @requestor
|
75
|
+
to_save = forget_unstable(@meth, meth_data)
|
76
|
+
file_name = @requestor.instance_variable_get("@class_name").to_s
|
77
|
+
file_data = @requestor.instance_variable_get("@data")
|
78
|
+
file_data['meths'][@name] = to_save
|
79
|
+
file_write(file_name, file_data)
|
80
|
+
subtype_of prefind
|
81
|
+
end
|
82
|
+
|
47
83
|
# Main method. It finds an element
|
48
84
|
def find
|
49
85
|
if !forced_xpath?
|
50
86
|
element = prefind_with_waiting
|
51
|
-
|
87
|
+
if !element.exists?
|
88
|
+
warn_and_search element
|
89
|
+
if collection?
|
90
|
+
return_collection
|
91
|
+
else
|
92
|
+
return_element
|
93
|
+
end
|
94
|
+
end
|
52
95
|
end
|
53
96
|
super
|
54
97
|
end
|
55
98
|
|
56
99
|
# Marta is producing warning when element was not found normally
|
57
100
|
def warn_and_search(element)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
101
|
+
warn "ATTENTION: Element "\
|
102
|
+
"#{@requestor.instance_variable_get("@class_name")}.#{@name}"\
|
103
|
+
" was not found by locator = #{@xpath}."
|
104
|
+
warn "And Marta uses a black"\
|
105
|
+
" magic to find it. If she finds something"\
|
106
|
+
" Marta redefines it without warning."
|
107
|
+
actual_searching(element)
|
108
|
+
warn "Xpath suggested by Marta = #{@xpath}"
|
63
109
|
end
|
64
110
|
|
65
111
|
# Marta can form special xpath guess for element finding attempt
|
@@ -67,10 +113,10 @@ module Marta
|
|
67
113
|
xpath_factory = XPathFactory.new(@meth, @requestor)
|
68
114
|
xpath_factory.granny = granny
|
69
115
|
xpath_factory.pappy = pappy
|
70
|
-
if xpath_factory.
|
116
|
+
if xpath_factory.array_of_hashes.count <= unknowns
|
71
117
|
raise "Marta did her best. But she found nothing"
|
72
118
|
else
|
73
|
-
xpath_factory.generate_xpaths(unknowns)
|
119
|
+
xpath_factory.generate_xpaths(unknowns, @tolerancy)
|
74
120
|
end
|
75
121
|
end
|
76
122
|
|
@@ -142,7 +188,7 @@ module Marta
|
|
142
188
|
granny, pappy, i = true, true, 1
|
143
189
|
while !result.exists?
|
144
190
|
array_of_xpaths = form_complex_xpath(i, granny, pappy)
|
145
|
-
if
|
191
|
+
if XPathFactory.new(@meth, @requestor).analyze(i, @tolerancy)[0] < i
|
146
192
|
# One more step.
|
147
193
|
# We will try to exclude grandparent element data at first.
|
148
194
|
# Then we will try to exclude parent.
|
@@ -162,8 +208,8 @@ module Marta
|
|
162
208
|
end
|
163
209
|
|
164
210
|
# Marta can find something when data is incorrect (by Black magick)
|
165
|
-
def marta_magic_finder(meth)
|
166
|
-
finder = MagicFinder.new(meth, tolerancy_value, self)
|
211
|
+
def marta_magic_finder(meth, name = "unknown")
|
212
|
+
finder = MagicFinder.new(meth, tolerancy_value, name, self)
|
167
213
|
finder.find
|
168
214
|
end
|
169
215
|
end
|
data/lib/marta/data/element.html
CHANGED
@@ -9,33 +9,22 @@
|
|
9
9
|
</div>
|
10
10
|
<div martaclass=marta_smthing martastyle=hint id=marta_hint>
|
11
11
|
<p martaclass=marta_smthing>You are about to define some element</p>
|
12
|
-
<p martaclass=marta_smthing>CLICK to select element. Do not worry
|
13
|
-
<p martaclass=marta_smthing>
|
14
|
-
<p martaclass=marta_smthing>To edit attribute value just change it and hit ENTER</p>
|
15
|
-
<p martaclass=marta_smthing>It is highly recomended to delete dynamically changing attributes</p>
|
16
|
-
<p martaclass=marta_smthing>IF you are gonna to find iframe! Elements in it are active now</p>
|
12
|
+
<p martaclass=marta_smthing>CLICK to select element. Do not worry js of the page will not work</p>
|
13
|
+
<p martaclass=marta_smthing>IF you are gonna to find iframe!</p>
|
17
14
|
<p martaclass=marta_smthing>You should click at non-action element of iframe.</p>
|
18
15
|
<p martaclass=marta_smthing>Find it like a usual element and focus to it in code with dance_with(your_iframe)</p>
|
16
|
+
<p martaclass=marta_smthing>Yo can also select element in devtools. And click IMPORT FROM DEVTOOLS button</p>
|
19
17
|
</div>
|
20
18
|
</div>
|
21
19
|
<div id=marta_s_content martaclass=marta_smthing martastyle=main_content>
|
22
20
|
<div martastyle=buttons_holder martaclass=marta_smthing>
|
23
21
|
<input type=button martaclass=marta_smthing id=marta_confirm martastyle=confirm_button value=Confirm />
|
24
22
|
<input type=button martaclass=marta_smthing id=marta_set_by_hand martastyle=action_button value="Set by hand" />
|
25
|
-
<input type=button martaclass=marta_smthing id=marta_show_html martastyle=action_button value="
|
23
|
+
<input type=button index="" tag="" martaclass=marta_smthing id=marta_show_html martastyle=action_button value="Import from devtools" />
|
26
24
|
</div>
|
27
25
|
</div>
|
28
26
|
<div id=marta_s_element_type martaclass=marta_smthing martastyle=options_holder>
|
29
27
|
<div martaclass=marta_smthing class=label id=marta_element_label>What we are looking for (one element or group?)</div>
|
30
28
|
<label martaclass=marta_smthing><input type=checkbox id=marta_array martaclass=marta_smthing>Collection</label>
|
31
29
|
</div>
|
32
|
-
<div martaclass=marta_smthing martastyle=html_content>
|
33
|
-
<div martaclass=marta_smthing id=marta_s_html_holder readonly=true>Enable HTML selector by Find in html button. NOTE: It is highly experimental.</div>
|
34
|
-
</div>
|
35
|
-
<div martastyle=table_headers martaclass=marta_smthing>
|
36
|
-
<input type=text martaclass=marta_smthing martastyle=name_field value=attribute_name disabled=disabled;>
|
37
|
-
<input martaclass=marta_smthing martastyle=value_field type=text value=default_value disabled=disabled;>
|
38
|
-
</div>
|
39
|
-
<div id=attr_fields martaclass=marta_smthing martastyle=user_fields>
|
40
|
-
</div>
|
41
30
|
</div>
|
data/lib/marta/data/element.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
document.marta_room = 0;
|
2
1
|
document.marta_result = {};
|
3
2
|
document.marta_confirm_mark = false;
|
4
3
|
document.marta_test_xx = 0;
|
@@ -7,7 +6,7 @@ document.marta_shift = false;
|
|
7
6
|
|
8
7
|
document.getElementById("marta_confirm").onclick = function() {document.marta_end_loop()};
|
9
8
|
document.getElementById("marta_set_by_hand").onclick = function() {document.marta_set_by_hand()};
|
10
|
-
document.getElementById("marta_show_html").onclick = function() {document.marta_show_html()};
|
9
|
+
document.getElementById("marta_show_html").onclick = function(e) {document.marta_show_html(e)};
|
11
10
|
document.getElementById("marta_hide").onclick = function() {document.marta_hide()};
|
12
11
|
document.getElementById("marta_stop").onclick = function() {document.marta_stop()};
|
13
12
|
document.getElementById("marta_array").onclick = function() {document.marta_array_switch()};
|
@@ -36,8 +35,9 @@ document.marta_magic_click = function(e) {
|
|
36
35
|
if (document.marta_test_xx == 0) {var xx = e.clientX} else {var xx = document.marta_test_xx};
|
37
36
|
if (document.marta_test_yy == 0) {var yy = e.clientY} else {var yy = document.marta_test_yy};
|
38
37
|
document.getElementById("marta_magic_div").setAttribute("martastyle", "off");
|
39
|
-
|
40
|
-
document.
|
38
|
+
let is_shift = e.shiftKey||document.marta_shift;
|
39
|
+
document.marta_result = {"element": document.elementFromPoint(xx, yy), "collection": document.getElementById("marta_array").checked, "exclude": is_shift};
|
40
|
+
document.marta_confirm();
|
41
41
|
document.getElementById("marta_magic_div").setAttribute("martastyle", "at_large");
|
42
42
|
};
|
43
43
|
|
@@ -58,243 +58,33 @@ if (!document.getElementById("marta_magic_div")){
|
|
58
58
|
};
|
59
59
|
document.getElementById('marta_magic_div').onclick = function(e) {document.marta_magic_click(e)};
|
60
60
|
|
61
|
-
document.marta_add_field = function(title, what, key, marker) {
|
62
|
-
document.marta_room++;
|
63
|
-
var objTo = document.getElementById("attr_fields");
|
64
|
-
var divtest = document.createElement("div");
|
65
|
-
objTo.appendChild(divtest);
|
66
|
-
divtest.setAttribute("martaclass", "marta_smthing");
|
67
|
-
var headerDiv = document.marta_create_element(divtest, "div", {"martaclass": "marta_smthing", "class": "label", "id": "marta_title"+document.marta_room}, "ATTR");
|
68
|
-
var contentDiv = document.marta_create_element(divtest, "div", {"martaclass": "marta_smthing", "martastyle": "field_line", "class": "content", "id": "marta_staff"+document.marta_room}, "");
|
69
|
-
var nameField = document.marta_create_element(contentDiv, "input", {"martaclass": "marta_smthing", "martastyle": "name_field", "class": "marta_s_name_field", "type": "text", "disabled": "disabled;", "id": "marta_name"+document.marta_room, "value": ""}, "");
|
70
|
-
var valueStyle = "value_field";
|
71
|
-
if (title.indexOf("not_") == 0) {
|
72
|
-
var isNot = document.marta_create_element(contentDiv, "input", {"martaclass": "marta_smthing", "martastyle": "not_field", "class": "marta_s_not_field", "type": "text", "disabled": "disabled;", "value": " IS NOT "}, "");
|
73
|
-
valueStyle = "not_value_field";
|
74
|
-
};
|
75
|
-
var valueField = document.marta_create_element(contentDiv, "input", {"martaclass": "marta_smthing", "martastyle": valueStyle, "type": "text", "id": "marta_default_value"+document.marta_room, "value": ""}, "");
|
76
|
-
var cancelButton = document.marta_create_element(contentDiv, "input", {"martaclass": "marta_smthing", "martaroom": document.marta_room, "martastyle": "cancel_button", "type": "button", "id": "delete_marta_value"+document.marta_room, "value": "Delete"}, "");
|
77
|
-
document.getElementById("marta_title"+document.marta_room ).innerHTML = title;
|
78
|
-
document.getElementById("marta_name"+document.marta_room ).value = what;
|
79
|
-
var field = document.getElementById("marta_default_value"+document.marta_room);
|
80
|
-
field.value = key;
|
81
|
-
var att = document.createAttribute("marta_object_map");
|
82
|
-
att.value = title+";;"+what+";;"+marker;
|
83
|
-
field.setAttributeNode(att);
|
84
|
-
document.getElementById("delete_marta_value"+document.marta_room).onclick = function(e) {document.marta_delete_line(e)};
|
85
|
-
document.getElementById("marta_default_value"+document.marta_room).onchange = function(e) {document.marta_change_field(e)};
|
86
|
-
};
|
87
|
-
|
88
|
-
document.marta_change_field = function(event){
|
89
|
-
var field = event.target;
|
90
|
-
var data = field.getAttribute("marta_object_map").split(";;");
|
91
|
-
if (data[2] == "-1"){
|
92
|
-
if (field.value == ""){
|
93
|
-
delete document.marta_result[data[0]][data[1]];
|
94
|
-
} else {
|
95
|
-
document.marta_result[data[0]][data[1]]=field.value;
|
96
|
-
};
|
97
|
-
}else if (data[2] == "taggy"){
|
98
|
-
if (field.value == ""){
|
99
|
-
document.marta_result["options"][data[1]] = "*";
|
100
|
-
} else {
|
101
|
-
document.marta_result["options"][data[1]]=field.value;
|
102
|
-
};
|
103
|
-
}else {
|
104
|
-
if (field.value == ""){
|
105
|
-
delete document.marta_result[data[0]][data[1]][parseInt(data[2])];
|
106
|
-
} else {
|
107
|
-
document.marta_result[data[0]][data[1]][parseInt(data[2])]=field.value;
|
108
|
-
};
|
109
|
-
};
|
110
|
-
document.marta_confirm();
|
111
|
-
};
|
112
|
-
|
113
61
|
document.marta_clean_up = function(){
|
114
62
|
var toClear = document.body.querySelectorAll("[martaclass=marta_div],[martaclass=marta_script],[martaclass=marta_style]");
|
115
63
|
for (var i = 0; i < toClear.length; i++) {
|
116
64
|
toClear[i].parentNode.removeChild(toClear[i]);
|
117
65
|
};
|
118
|
-
document.marta_room = 0;
|
119
66
|
};
|
120
67
|
|
121
68
|
document.marta_confirm = function(){
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
for (var key in document.marta_result[what]){
|
127
|
-
if (document.marta_result[what][key] instanceof Array){
|
128
|
-
for (var i = 0; i < document.marta_result[what][key].length; i++) {
|
129
|
-
if (document.marta_result[what][key][i] == undefined) {
|
130
|
-
document.marta_result[what][key].splice(i, 1);
|
131
|
-
i--;
|
132
|
-
};
|
133
|
-
};
|
134
|
-
};
|
135
|
-
};
|
136
|
-
};
|
137
|
-
document.marta_confirm_mark = true;
|
138
|
-
document.marta_connect();
|
139
|
-
return document.marta_result;
|
140
|
-
};
|
141
|
-
};
|
142
|
-
|
143
|
-
document.marta_add_data = function() {
|
144
|
-
document.marta_result = document.old_marta_Data;
|
145
|
-
document.marta_confirm_mark = false;
|
146
|
-
document.getElementById("marta_main_title").innerHTML = document.marta_what;
|
147
|
-
if (document.old_marta_Data != {}){
|
148
|
-
try {
|
149
|
-
document.getElementById("marta_array").checked = document.old_marta_Data["options"]["collection"];}
|
150
|
-
catch(e){};
|
151
|
-
for (var what in document.old_marta_Data){
|
152
|
-
if (what != "options"){
|
153
|
-
document.marta_add_field("TAG", what, document.old_marta_Data["options"][what], "taggy");
|
154
|
-
for (var key in document.old_marta_Data[what]){
|
155
|
-
if (/class/.test(key) == true){
|
156
|
-
for (var k = 0, length = document.old_marta_Data[what][key].length; k < length; k++){
|
157
|
-
if ((document.old_marta_Data[what][key][k] != "") && (document.old_marta_Data[what][key][k] != null)){
|
158
|
-
document.marta_add_field(what, key, document.old_marta_Data[what][key][k], k);
|
159
|
-
};
|
160
|
-
};
|
161
|
-
}else
|
162
|
-
{
|
163
|
-
if ((document.old_marta_Data[what][key] != "") && (document.old_marta_Data[what][key] != null)){
|
164
|
-
document.marta_add_field(what, key, document.old_marta_Data[what][key], "-1");
|
165
|
-
};
|
166
|
-
};
|
167
|
-
};
|
168
|
-
};
|
169
|
-
};
|
170
|
-
};
|
69
|
+
document.marta_clean_up();
|
70
|
+
document.marta_confirm_mark = true;
|
71
|
+
document.marta_connect();
|
72
|
+
return document.marta_result;
|
171
73
|
};
|
172
74
|
|
173
|
-
document.marta_show_html = function() {
|
174
|
-
|
175
|
-
|
75
|
+
document.marta_show_html = function(e) {
|
76
|
+
console.log(e.target.getAttribute('tag'));
|
77
|
+
console.log(e.target.getAttribute('index'));
|
78
|
+
document.pretouch(document.getElementsByTagName(e.target.getAttribute('tag')).item(e.target.getAttribute('index')),e.shiftKey);
|
176
79
|
};
|
177
80
|
|
178
81
|
document.marta_touch = function(element, shift) {
|
179
|
-
|
180
|
-
|
181
|
-
for (var i=0, max=everything.length; i < max; i++) {
|
182
|
-
var check = everything[i].outerHTML.replace(/</g,"<").replace(/>/g,">");
|
183
|
-
if (check == control) {
|
184
|
-
document.marta_click_work(everything[i], shift);
|
185
|
-
};
|
186
|
-
};
|
82
|
+
document.marta_result = {"element": element, "collection": document.getElementById("marta_array").checked, "exclude": shift};
|
83
|
+
document.marta_confirm();
|
187
84
|
};
|
188
85
|
|
189
|
-
document.
|
190
|
-
|
191
|
-
el.parentNode.replaceChild(wrapper, el);
|
192
|
-
};
|
193
|
-
|
194
|
-
document.spaninize = function(string) {
|
195
|
-
var dummy = document.createElement( "marta_span" );
|
196
|
-
dummy.innerHTML = string;
|
197
|
-
ignore = dummy.querySelectorAll("[martaclass=marta_div],[martaclass=marta_script],[martaclass=marta_style]");
|
198
|
-
for (var i = 0; i < ignore.length; i++) {
|
199
|
-
ignore[i].parentNode.removeChild(ignore[i]);
|
200
|
-
};
|
201
|
-
dummy.setAttribute("martaclass", "marta_smthng");
|
202
|
-
var counter = {};
|
203
|
-
var everything = dummy.getElementsByTagName("*");
|
204
|
-
for (var i=0, max=everything.length; i < 2*max; i=i+2) {
|
205
|
-
if (counter[everything[i].tagName] == null) {
|
206
|
-
counter[everything[i].tagName] = 0;
|
207
|
-
} else {
|
208
|
-
counter[everything[i].tagName] = counter[everything[i].tagName] + 1;
|
209
|
-
};
|
210
|
-
var wrapper = document.createElement( "marta_span" );
|
211
|
-
wrapper.setAttribute("martaclass","marta_smthing");
|
212
|
-
document.wrap(everything[i], wrapper);
|
213
|
-
};
|
214
|
-
var theParent = document.getElementById("marta_s_html_holder");
|
215
|
-
theParent.onclick = function(e) {document.pretouch(e)};
|
216
|
-
return dummy.innerHTML.replace(/<(?!.?marta_span)([^>]*)>/g,"<$1>").replace(/marta_span/g,"span");
|
217
|
-
};
|
218
|
-
|
219
|
-
document.pretouch = function(e) {
|
220
|
-
if (e.target !== e.currentTarget) {
|
221
|
-
var clickedItem = e.target;
|
222
|
-
document.marta_touch(clickedItem, e.shiftKey);
|
223
|
-
};
|
224
|
-
};
|
225
|
-
|
226
|
-
document.marta_click_work = function(target, shift) {
|
227
|
-
var marta_smthing = target.getAttribute("martaclass")=="marta_smthing";
|
228
|
-
if(!marta_smthing){
|
229
|
-
if (shift) {
|
230
|
-
var self = "not_self";
|
231
|
-
var pappy = "not_pappy";
|
232
|
-
var granny = "not_granny";
|
233
|
-
} else {
|
234
|
-
var self = "self";
|
235
|
-
var pappy = "pappy";
|
236
|
-
var granny = "granny";
|
237
|
-
};
|
238
|
-
document.getElementById("attr_fields").innerHTML="";
|
239
|
-
document.marta_room = 0;
|
240
|
-
document.marta_result = {};
|
241
|
-
document.marta_result["options"] = {};
|
242
|
-
document.marta_after_click(target, self);
|
243
|
-
if (!!target.parentElement){
|
244
|
-
document.marta_after_click(target.parentElement, pappy);
|
245
|
-
};
|
246
|
-
if (!!target.parentElement.parentElement){
|
247
|
-
document.marta_after_click(target.parentElement.parentElement, granny);
|
248
|
-
};
|
249
|
-
document.marta_confirm();
|
250
|
-
};
|
251
|
-
};
|
252
|
-
|
253
|
-
document.marta_after_click = function(el, what) {
|
254
|
-
document.marta_result[what] = {};
|
255
|
-
document.marta_result["options"][what] = el.tagName;
|
256
|
-
document.marta_add_field("TAG", what, document.marta_result["options"][what], "taggy");
|
257
|
-
for (var att, i = 0, atts = el.attributes, n = atts.length; i < n; i++){
|
258
|
-
att = atts[i];
|
259
|
-
if(/^[a-zA-Z0-9- _!@#$%^*();:,.?/]*$/.test(att.nodeValue) == true && att.nodeName != "martaclass"){
|
260
|
-
if (/class/.test(att.nodeName) == true){
|
261
|
-
var values=att.nodeValue.split(" ");
|
262
|
-
document.marta_result[what][att.nodeName]=[];
|
263
|
-
for (var val, j = 0, vals = values, l = vals.length; j < l; j++){
|
264
|
-
val = vals[j];
|
265
|
-
document.marta_result[what][att.nodeName][j]=val;
|
266
|
-
};
|
267
|
-
} else {
|
268
|
-
document.marta_result[what][att.nodeName]=att.nodeValue;
|
269
|
-
};
|
270
|
-
};
|
271
|
-
};
|
272
|
-
if ((what == "self")||(what == "not_self")){
|
273
|
-
try{
|
274
|
-
document.marta_result[what]["retrieved_by_marta_text"]=el.firstChild.nodeValue;
|
275
|
-
}catch(e){};
|
276
|
-
};
|
277
|
-
for (var key in document.marta_result[what]){
|
278
|
-
if (/class/.test(key) == true){
|
279
|
-
for (var k = 0, length = document.marta_result[what][key].length; k < length; k++){
|
280
|
-
document.marta_add_field(what, key, document.marta_result[what][key][k], k);
|
281
|
-
};
|
282
|
-
}else
|
283
|
-
{
|
284
|
-
document.marta_add_field(what, key, document.marta_result[what][key], "-1");
|
285
|
-
};
|
286
|
-
};
|
287
|
-
};
|
288
|
-
|
289
|
-
document.marta_delete_line = function(theEvent) {
|
290
|
-
var line = theEvent.target.getAttribute("martaroom");
|
291
|
-
var title = document.getElementById("marta_title"+line);
|
292
|
-
var staff = document.getElementById("marta_staff"+line);
|
293
|
-
var field = document.getElementById("marta_default_value"+line);
|
294
|
-
field.value = "";
|
295
|
-
document.marta_change_field(field);
|
296
|
-
staff.parentNode.removeChild(staff);
|
297
|
-
title.parentNode.removeChild(title);
|
86
|
+
document.pretouch = function(element, shift) {
|
87
|
+
document.marta_touch(element, shift);
|
298
88
|
};
|
299
89
|
|
300
90
|
document.marta_set_by_hand = function(){
|
@@ -323,6 +113,15 @@ document.marta_hide = function() {
|
|
323
113
|
};
|
324
114
|
};
|
325
115
|
|
116
|
+
document.marta_add_data = function() {
|
117
|
+
document.marta_result = document.old_marta_Data;
|
118
|
+
document.marta_confirm_mark = false;
|
119
|
+
document.getElementById("marta_main_title").innerHTML = document.marta_what;
|
120
|
+
try {
|
121
|
+
document.getElementById("marta_array").checked = document.old_marta_Data["options"]["collection"];}
|
122
|
+
catch(e){};
|
123
|
+
};
|
124
|
+
|
326
125
|
document.marta_connect = function() {
|
327
126
|
var event = new CustomEvent('marta_send', {'detail':{ 'port': document.martaPort, 'mark': document.marta_confirm_mark }});
|
328
127
|
this.dispatchEvent(event);
|