locatine 0.02542 → 0.02878
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +269 -296
- data/bin/locatine-daemon.rb +4 -2
- data/lib/locatine.rb +14 -2
- data/lib/locatine/daemon.rb +48 -56
- data/lib/locatine/daemon_helpers/methods.rb +85 -0
- data/lib/locatine/element.rb +32 -0
- data/lib/locatine/error.rb +14 -0
- data/lib/locatine/logger.rb +69 -0
- data/lib/locatine/results.rb +128 -0
- data/lib/locatine/results_helpers/common.rb +68 -0
- data/lib/locatine/results_helpers/find_by_magic.rb +121 -0
- data/lib/locatine/results_helpers/guess.rb +76 -0
- data/lib/locatine/results_helpers/info_generator.rb +79 -0
- data/lib/locatine/{for_search → results_helpers}/xpath_generator.rb +18 -11
- data/lib/locatine/scripts/element.js +40 -0
- data/lib/locatine/scripts/page.js +54 -0
- data/lib/locatine/scripts/parent.js +6 -0
- data/lib/locatine/session.rb +107 -0
- data/lib/locatine/version.rb +4 -2
- metadata +40 -49
- data/lib/locatine/app/background.js +0 -8
- data/lib/locatine/app/content.css +0 -43
- data/lib/locatine/app/content.js +0 -149
- data/lib/locatine/app/devtools.html +0 -1
- data/lib/locatine/app/devtools.js +0 -3
- data/lib/locatine/app/manifest.json +0 -20
- data/lib/locatine/app/popup.css +0 -47
- data/lib/locatine/app/popup.html +0 -19
- data/lib/locatine/app/popup.js +0 -65
- data/lib/locatine/daemon_helpers.rb +0 -52
- data/lib/locatine/for_search.rb +0 -6
- data/lib/locatine/for_search/data_generate.rb +0 -67
- data/lib/locatine/for_search/data_logic.rb +0 -98
- data/lib/locatine/for_search/defaults.rb +0 -40
- data/lib/locatine/for_search/dialog_logic.rb +0 -107
- data/lib/locatine/for_search/element_selection.rb +0 -80
- data/lib/locatine/for_search/file_work.rb +0 -67
- data/lib/locatine/for_search/find_by_guess.rb +0 -67
- data/lib/locatine/for_search/find_by_locator.rb +0 -59
- data/lib/locatine/for_search/find_by_magic.rb +0 -65
- data/lib/locatine/for_search/find_logic.rb +0 -79
- data/lib/locatine/for_search/helpers.rb +0 -106
- data/lib/locatine/for_search/highlight.rb +0 -41
- data/lib/locatine/for_search/listening.rb +0 -48
- data/lib/locatine/for_search/merge.rb +0 -40
- data/lib/locatine/for_search/name_helper.rb +0 -51
- data/lib/locatine/for_search/page_work.rb +0 -126
- data/lib/locatine/for_search/public.rb +0 -179
- data/lib/locatine/for_search/saying.rb +0 -196
- data/lib/locatine/large_scripts/css.js +0 -21
- data/lib/locatine/large_scripts/dimensions.js +0 -17
- data/lib/locatine/large_scripts/element.js +0 -30
- data/lib/locatine/large_scripts/page.js +0 -60
- data/lib/locatine/scope.rb +0 -88
- data/lib/locatine/search.rb +0 -67
@@ -0,0 +1,54 @@
|
|
1
|
+
function walk(target) {
|
2
|
+
let node;
|
3
|
+
|
4
|
+
const index = everything.indexOf(target);
|
5
|
+
let element = [];
|
6
|
+
let att_array = [];
|
7
|
+
let item = {children: [],
|
8
|
+
data: [],
|
9
|
+
index: index};
|
10
|
+
|
11
|
+
// Taking text
|
12
|
+
let text = "";
|
13
|
+
if (target.childNodes){
|
14
|
+
for (let i = 0; i < target.childNodes.length; ++i){
|
15
|
+
if (target.childNodes[i].nodeType === 3){
|
16
|
+
text += target.childNodes[i].textContent;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
} else {
|
20
|
+
text = target.textContent
|
21
|
+
}
|
22
|
+
const text_array = text.split(/[\s\'\\]/).filter(word => word !== "");
|
23
|
+
for (let i = 0; i < text_array.length; ++i){
|
24
|
+
element.push({value: text_array[i], type: "text", name: "text"});
|
25
|
+
}
|
26
|
+
|
27
|
+
//Taking tag
|
28
|
+
element.push({value: target.tagName.toLowerCase(), type: "tag", name: "tag"});
|
29
|
+
|
30
|
+
//Taking attributes
|
31
|
+
let atts = target.attributes;
|
32
|
+
if (atts) {
|
33
|
+
for (let k = 0, n = atts.length; k < n; k++){
|
34
|
+
att = atts[k];
|
35
|
+
att_array = att.nodeValue.split(/[\s\'\\]/).filter(word => word !== "");
|
36
|
+
for (let i = 0; i < att_array.length; ++i){
|
37
|
+
element.push({value: att_array[i], type: "attribute", name: att.nodeName});
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
// Handle child elements (not magic ones)
|
43
|
+
for (node = target.firstChild; node; node = node.nextSibling) {
|
44
|
+
if (node.nodeType === 1) { // 1 == Element
|
45
|
+
item.children.push(walk(node))
|
46
|
+
}
|
47
|
+
}
|
48
|
+
item.data = element;
|
49
|
+
return item;
|
50
|
+
}
|
51
|
+
const everything = Array.prototype.slice.call( document.getElementsByTagName("*") );
|
52
|
+
let result = walk(document.body);
|
53
|
+
// We need to incapsulate since chromedriver cannot return a giant object
|
54
|
+
return JSON.stringify({"result": [result]});
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Locatine
|
4
|
+
#
|
5
|
+
# Locatine session operator finds and returns
|
6
|
+
class Session
|
7
|
+
include Locatine::Logger
|
8
|
+
attr_accessor :json, :depth, :trusted, :untrusted, :tolerance, :stability,
|
9
|
+
:elements, :timeout
|
10
|
+
|
11
|
+
def defaults
|
12
|
+
{ json: "#{Dir.pwd}/locatine_files/default.json", depth: 3, trusted: [],
|
13
|
+
untrusted: [], tolerance: 50, stability: 10, timeout: 25 }
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(selenium, session)
|
17
|
+
@selenium = selenium
|
18
|
+
@parsed_selenium = URI.parse @selenium
|
19
|
+
@session = session
|
20
|
+
@elements = []
|
21
|
+
@threads = []
|
22
|
+
# defaults
|
23
|
+
configure defaults
|
24
|
+
end
|
25
|
+
|
26
|
+
def configure(params)
|
27
|
+
params.to_h.each_pair do |var, value|
|
28
|
+
instance_variable_set("@#{var}", value)
|
29
|
+
read if var.to_s == 'json'
|
30
|
+
end
|
31
|
+
params
|
32
|
+
end
|
33
|
+
|
34
|
+
def read
|
35
|
+
dir = File.dirname(@json)
|
36
|
+
FileUtils.mkdir_p(dir) unless File.directory?(dir)
|
37
|
+
unless File.exist?(@json)
|
38
|
+
File.open(@json, 'w') do |f|
|
39
|
+
f.write('{"elements" : {}}')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
@elements = JSON.parse(File.read(@json))['elements']
|
43
|
+
end
|
44
|
+
|
45
|
+
def write
|
46
|
+
File.open(@json, 'w') do |f|
|
47
|
+
f.write(JSON.pretty_generate('elements' => @elements))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def find(params, parent = nil)
|
52
|
+
find_routine(params, parent)
|
53
|
+
rescue RuntimeError => e
|
54
|
+
raise e.message unless e.message == 'stale element reference'
|
55
|
+
|
56
|
+
warn_unstable_page
|
57
|
+
find(params, parent)
|
58
|
+
end
|
59
|
+
|
60
|
+
def find_routine(params, parent)
|
61
|
+
results = Results.new
|
62
|
+
results.configure(self, params, parent)
|
63
|
+
answer = results.find
|
64
|
+
if !answer.empty? && answer.first.class != Locatine::Error
|
65
|
+
@elements[results.name] = results.info
|
66
|
+
write
|
67
|
+
end
|
68
|
+
answer
|
69
|
+
end
|
70
|
+
|
71
|
+
def execute_script(script, *args)
|
72
|
+
args.map! { |item| item.class == Locatine::Element ? item.answer : item }
|
73
|
+
response = api_request('/execute/sync', 'Post',
|
74
|
+
{ script: script, args: args }.to_json).body
|
75
|
+
value = JSON.parse(response, max_nesting: false)['value']
|
76
|
+
error_present = (value.class == Hash) && value['error']
|
77
|
+
raise_script_error(script, args, value) if error_present
|
78
|
+
|
79
|
+
value
|
80
|
+
end
|
81
|
+
|
82
|
+
def page
|
83
|
+
# We need duplicated JSON parse since standart
|
84
|
+
# chromedriver giving an error here if the page is too large
|
85
|
+
page = execute_script(File.read("#{HOME}/scripts/page.js"))
|
86
|
+
JSON.parse(page, max_nesting: false)['result']
|
87
|
+
end
|
88
|
+
|
89
|
+
def call_uri(path)
|
90
|
+
URI::HTTP.build(
|
91
|
+
host: @parsed_selenium.host,
|
92
|
+
port: @parsed_selenium.port,
|
93
|
+
path: "/wd/hub/session/#{@session}#{path}"
|
94
|
+
)
|
95
|
+
end
|
96
|
+
|
97
|
+
def api_request(path, method, body)
|
98
|
+
uri = call_uri(path)
|
99
|
+
req = Net::HTTP.const_get(method)
|
100
|
+
.new(uri,
|
101
|
+
"Content-Type": 'application/json; charset=utf-8',
|
102
|
+
"Cache-Control": 'no-cache')
|
103
|
+
req.body = body
|
104
|
+
Net::HTTP.new(uri.hostname, uri.port).start { |http| http.request(req) }
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
data/lib/locatine/version.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Locatine
|
2
4
|
# constants here...
|
3
|
-
VERSION = '0.
|
4
|
-
NAME = 'locatine'
|
5
|
+
VERSION = '0.02878'
|
6
|
+
NAME = 'locatine'
|
5
7
|
HOME = if File.readable?("#{Dir.pwd}/lib/#{Locatine::NAME}")
|
6
8
|
"#{Dir.pwd}/lib/#{Locatine::NAME}"
|
7
9
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: locatine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.02878'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergei Seleznev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: pry
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: simplecov
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
@@ -73,7 +73,7 @@ dependencies:
|
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '6.16'
|
76
|
-
type: :
|
76
|
+
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
@@ -90,7 +90,7 @@ dependencies:
|
|
90
90
|
- - ">="
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: 4.0.1
|
93
|
-
type: :
|
93
|
+
type: :development
|
94
94
|
prerelease: false
|
95
95
|
version_requirements: !ruby/object:Gem::Requirement
|
96
96
|
requirements:
|
@@ -104,16 +104,30 @@ dependencies:
|
|
104
104
|
name: sinatra
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
|
-
- - "
|
107
|
+
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 2.0
|
109
|
+
version: '2.0'
|
110
110
|
type: :runtime
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- - "
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '2.0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: colorize
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0.8'
|
124
|
+
type: :runtime
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
115
129
|
- !ruby/object:Gem::Version
|
116
|
-
version:
|
130
|
+
version: '0.8'
|
117
131
|
description: The main goal to write locators never
|
118
132
|
email: s_seleznev_qa@hotmail.com
|
119
133
|
executables:
|
@@ -124,43 +138,21 @@ files:
|
|
124
138
|
- README.md
|
125
139
|
- bin/locatine-daemon.rb
|
126
140
|
- lib/locatine.rb
|
127
|
-
- lib/locatine/app/background.js
|
128
|
-
- lib/locatine/app/content.css
|
129
|
-
- lib/locatine/app/content.js
|
130
|
-
- lib/locatine/app/devtools.html
|
131
|
-
- lib/locatine/app/devtools.js
|
132
|
-
- lib/locatine/app/manifest.json
|
133
|
-
- lib/locatine/app/popup.css
|
134
|
-
- lib/locatine/app/popup.html
|
135
|
-
- lib/locatine/app/popup.js
|
136
141
|
- lib/locatine/daemon.rb
|
137
|
-
- lib/locatine/daemon_helpers.rb
|
138
|
-
- lib/locatine/
|
139
|
-
- lib/locatine/
|
140
|
-
- lib/locatine/
|
141
|
-
- lib/locatine/
|
142
|
-
- lib/locatine/
|
143
|
-
- lib/locatine/
|
144
|
-
- lib/locatine/
|
145
|
-
- lib/locatine/
|
146
|
-
- lib/locatine/
|
147
|
-
- lib/locatine/
|
148
|
-
- lib/locatine/
|
149
|
-
- lib/locatine/
|
150
|
-
- lib/locatine/
|
151
|
-
- lib/locatine/for_search/listening.rb
|
152
|
-
- lib/locatine/for_search/merge.rb
|
153
|
-
- lib/locatine/for_search/name_helper.rb
|
154
|
-
- lib/locatine/for_search/page_work.rb
|
155
|
-
- lib/locatine/for_search/public.rb
|
156
|
-
- lib/locatine/for_search/saying.rb
|
157
|
-
- lib/locatine/for_search/xpath_generator.rb
|
158
|
-
- lib/locatine/large_scripts/css.js
|
159
|
-
- lib/locatine/large_scripts/dimensions.js
|
160
|
-
- lib/locatine/large_scripts/element.js
|
161
|
-
- lib/locatine/large_scripts/page.js
|
162
|
-
- lib/locatine/scope.rb
|
163
|
-
- lib/locatine/search.rb
|
142
|
+
- lib/locatine/daemon_helpers/methods.rb
|
143
|
+
- lib/locatine/element.rb
|
144
|
+
- lib/locatine/error.rb
|
145
|
+
- lib/locatine/logger.rb
|
146
|
+
- lib/locatine/results.rb
|
147
|
+
- lib/locatine/results_helpers/common.rb
|
148
|
+
- lib/locatine/results_helpers/find_by_magic.rb
|
149
|
+
- lib/locatine/results_helpers/guess.rb
|
150
|
+
- lib/locatine/results_helpers/info_generator.rb
|
151
|
+
- lib/locatine/results_helpers/xpath_generator.rb
|
152
|
+
- lib/locatine/scripts/element.js
|
153
|
+
- lib/locatine/scripts/page.js
|
154
|
+
- lib/locatine/scripts/parent.js
|
155
|
+
- lib/locatine/session.rb
|
164
156
|
- lib/locatine/version.rb
|
165
157
|
homepage: https://github.com/sseleznevqa/locatine
|
166
158
|
licenses:
|
@@ -181,8 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
173
|
- !ruby/object:Gem::Version
|
182
174
|
version: '0'
|
183
175
|
requirements: []
|
184
|
-
|
185
|
-
rubygems_version: 2.5.2.3
|
176
|
+
rubygems_version: 3.0.3
|
186
177
|
signing_key:
|
187
178
|
specification_version: 4
|
188
179
|
summary: Element locating tool based on watir
|
@@ -1,43 +0,0 @@
|
|
1
|
-
@keyframes locatine_found {
|
2
|
-
0% {border: 4px dashed #6495ED;}
|
3
|
-
20% {border: 4px dashed #FF7F50;}
|
4
|
-
40% {border: 4px dashed #8FBC8F;}
|
5
|
-
60% {border: 4px dashed #FFA500;}
|
6
|
-
80% {border: 4px dashed #DDA0DD;}
|
7
|
-
100% {border: 4px dashed #6495ED;}
|
8
|
-
}
|
9
|
-
|
10
|
-
div[locatinestyle=true] {
|
11
|
-
position:fixed;
|
12
|
-
padding:0;
|
13
|
-
margin:0;
|
14
|
-
top:0;
|
15
|
-
left:0;
|
16
|
-
opacity: 0;
|
17
|
-
background-color:rgba(0, 0, 0, 0.5);
|
18
|
-
height: 100%;
|
19
|
-
width: 100%;
|
20
|
-
display: block;
|
21
|
-
z-index: 2147483646;
|
22
|
-
color: #FF99AA;
|
23
|
-
font-size: 45px;
|
24
|
-
text-align: center;
|
25
|
-
cursor: default;
|
26
|
-
}
|
27
|
-
|
28
|
-
div[locatinestyle=false] {
|
29
|
-
height: 0%;
|
30
|
-
width: 0%;
|
31
|
-
}
|
32
|
-
|
33
|
-
div[locatinestyle=blocked] {
|
34
|
-
height: 0%;
|
35
|
-
width: 0%;
|
36
|
-
}
|
37
|
-
|
38
|
-
[locatineclass=foundbylocatine]
|
39
|
-
{animation: locatine_found 6s infinite;
|
40
|
-
-webkit-appearance: none;
|
41
|
-
-moz-appearance: none;
|
42
|
-
appearance: none;
|
43
|
-
}
|
data/lib/locatine/app/content.js
DELETED
@@ -1,149 +0,0 @@
|
|
1
|
-
async function set_value(name, value){
|
2
|
-
let temp = {};
|
3
|
-
temp[name] = value;
|
4
|
-
await chrome.storage.sync.set(temp, function() {});
|
5
|
-
};
|
6
|
-
|
7
|
-
async function get_value(name) {
|
8
|
-
let x = await new Promise((resolve, reject) => chrome.storage.sync.get([name], resolve));
|
9
|
-
return x[name];
|
10
|
-
};
|
11
|
-
|
12
|
-
async function creatingDiv(){
|
13
|
-
const options = {
|
14
|
-
"id":"locatine_magic_div",
|
15
|
-
"locatinestyle": await get_value('magic_div') || "false",
|
16
|
-
"locatinetitle": "ok",
|
17
|
-
"locatinehint": "ok",
|
18
|
-
"locatine_name": ""
|
19
|
-
};
|
20
|
-
locatine_create_element(document.body, "div", options, "");
|
21
|
-
const magic_cover = document.getElementById('locatine_magic_div');
|
22
|
-
magic_cover.onclick = function(e) {locatine_magic_click(e)};
|
23
|
-
await set_value('locatine_confirm', 'new')
|
24
|
-
document.body.onkeypress = async function(e) {
|
25
|
-
if (e.which == 13) {
|
26
|
-
await set_value('locatine_confirm', true)
|
27
|
-
}
|
28
|
-
}
|
29
|
-
}
|
30
|
-
|
31
|
-
async function setStyle(style, magicDiv){
|
32
|
-
if (style === "set_true") {
|
33
|
-
await set_value('magic_div', true);
|
34
|
-
magicDiv.setAttribute("locatinestyle", "true");
|
35
|
-
};
|
36
|
-
if (style === "set_false") {
|
37
|
-
await set_value('magic_div', false);
|
38
|
-
magicDiv.setAttribute("locatinestyle", "false");
|
39
|
-
};
|
40
|
-
let status = await get_value('magic_div');
|
41
|
-
magicDiv.setAttribute("locatinestyle", status);
|
42
|
-
}
|
43
|
-
|
44
|
-
async function setTitleHint(magicDiv){
|
45
|
-
if (magicDiv.getAttribute("locatinetitle") != "ok") {
|
46
|
-
await set_value('locatine_title', magicDiv.getAttribute("locatinetitle"));
|
47
|
-
await set_value('locatine_hint', magicDiv.getAttribute("locatinehint"));
|
48
|
-
magicDiv.setAttribute("locatinetitle", "ok");
|
49
|
-
let op = 1;
|
50
|
-
magicDiv.innerHTML = await get_value("locatine_title");
|
51
|
-
let timer = setInterval(function () {
|
52
|
-
if ((magicDiv.style.opacity == 1) && (op < 0.97)) {
|
53
|
-
clearInterval(timer);// If other process changed opacity.
|
54
|
-
};
|
55
|
-
if (op <= 0.2) {
|
56
|
-
clearInterval(timer);
|
57
|
-
magicDiv.style.opacity = 0;
|
58
|
-
magicDiv.innerHTML = "";
|
59
|
-
}
|
60
|
-
magicDiv.style.opacity = op;
|
61
|
-
magicDiv.style.filter = 'alpha(opacity=' + op * 100 + ")";
|
62
|
-
op -= op * 0.03;
|
63
|
-
}, 50);
|
64
|
-
}
|
65
|
-
}
|
66
|
-
|
67
|
-
async function setConfirm(magicDiv) {
|
68
|
-
if (magicDiv.getAttribute("locatineconfirmed") === "ok") {
|
69
|
-
magicDiv.removeAttribute("tag");
|
70
|
-
magicDiv.removeAttribute("index");
|
71
|
-
await set_value("locatine_confirm", false);
|
72
|
-
}
|
73
|
-
|
74
|
-
const confirmed = await get_value('locatine_confirm');
|
75
|
-
magicDiv.setAttribute("locatineconfirmed", confirmed);
|
76
|
-
}
|
77
|
-
|
78
|
-
async function setName(magicDiv) {
|
79
|
-
const selectionName = magicDiv.getAttribute("locatine_name");
|
80
|
-
const nameMark = magicDiv.getAttribute("locatine_name_mark");
|
81
|
-
if (nameMark != "true") {
|
82
|
-
magicDiv.setAttribute("locatine_name", await get_value("locatineName"));
|
83
|
-
}
|
84
|
-
if ((selectionName != "") && (nameMark == "true")){
|
85
|
-
await set_value("locatineName", selectionName);
|
86
|
-
magicDiv.setAttribute("locatine_name_mark", "");
|
87
|
-
}
|
88
|
-
}
|
89
|
-
|
90
|
-
async function refreshData(){
|
91
|
-
const magicDiv = document.getElementById("locatine_magic_div");
|
92
|
-
if (!document.getElementById("locatine_magic_div")){
|
93
|
-
creatingDiv();
|
94
|
-
set_value("locatineName", "");
|
95
|
-
} else {
|
96
|
-
setStyle(magicDiv.getAttribute("locatinestyle"), magicDiv);
|
97
|
-
setTitleHint(magicDiv);
|
98
|
-
setName(magicDiv);
|
99
|
-
magicDiv.setAttribute("locatinecollection", await get_value("locatine_collection"));
|
100
|
-
setConfirm(magicDiv);
|
101
|
-
};
|
102
|
-
};
|
103
|
-
|
104
|
-
async function getSelected(value){
|
105
|
-
if (value) {
|
106
|
-
const magic_div = document.getElementById("locatine_magic_div");
|
107
|
-
const tagName = value.tagName;
|
108
|
-
const array = Array.prototype.slice.call( document.getElementsByTagName(tagName) );
|
109
|
-
const index = array.indexOf(value);
|
110
|
-
if ((document.locatine_selected != value) && (String(tagName) != "")) {
|
111
|
-
document.locatine_selected = value;
|
112
|
-
await set_value("locatine_confirm", "selected");
|
113
|
-
magic_div.setAttribute("tag", tagName);
|
114
|
-
magic_div.setAttribute("index", index);
|
115
|
-
}
|
116
|
-
}
|
117
|
-
};
|
118
|
-
|
119
|
-
async function locatine_magic_click(e) {
|
120
|
-
document.getElementById("locatine_magic_div").setAttribute("locatinestyle", "blocked");
|
121
|
-
const value = document.elementFromPoint(e.clientX, e.clientY);
|
122
|
-
document.getElementById("locatine_magic_div").setAttribute("locatinestyle", "true");
|
123
|
-
const tagName = value.tagName;
|
124
|
-
const array = Array.prototype.slice.call( document.getElementsByTagName(tagName) );
|
125
|
-
const index = array.indexOf(value);
|
126
|
-
await set_value("locatine_confirm", "selected");
|
127
|
-
document.getElementById("locatine_magic_div").setAttribute("tag", tagName);
|
128
|
-
document.getElementById("locatine_magic_div").setAttribute("index", index);
|
129
|
-
};
|
130
|
-
|
131
|
-
function locatine_create_element(dom, tag, attrs, inner) {
|
132
|
-
const element = document.createElement(tag);
|
133
|
-
dom.appendChild(element);
|
134
|
-
for (var key in attrs) {
|
135
|
-
element.setAttribute(key, attrs[key])
|
136
|
-
};
|
137
|
-
element.innerHTML = inner;
|
138
|
-
return element;
|
139
|
-
};
|
140
|
-
|
141
|
-
setInterval(async function(){
|
142
|
-
if (document.getElementById("locatine_magic_div")) {
|
143
|
-
if (document.getElementById("locatine_magic_div").getAttribute("locatinestyle") != "blocked") {
|
144
|
-
await refreshData()
|
145
|
-
}
|
146
|
-
} else {
|
147
|
-
await refreshData()
|
148
|
-
}
|
149
|
-
}, 100);
|