locatine 0.01546 → 0.01659

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a4b678e1915017d1898771afe9cd2b737051b62
4
- data.tar.gz: 8adbe3846eecb369e49483a1aa2e08b291dddf6c
3
+ metadata.gz: 9be6c3fbe4cec2f39899f6874683c8653b12d756
4
+ data.tar.gz: 1c00862aa6032251a4f7a14f4a80a02e68d1be3e
5
5
  SHA512:
6
- metadata.gz: f79005a1036bbe968439219a2b3c90ec183b95d4ae7990cebdee2aa9065186a93dcb96c592dd5dd894a1b1f633eb20d9e5ee604206c8c6ef88296eb2a936a531
7
- data.tar.gz: 53b87536a961b56ec9b82a2762812dfd151b7454b716eb108137f97fa8d71e751fca8c564c6da414c0f8d68c5784a69d0c2d4853e9a477d2b248a7b9f5497560
6
+ metadata.gz: bc1289f818358b5a05789676cff4384f24ca3494cfafbbed95a64e04cf0a172b841490f267f93d7ba6db8e9ea72e4081c96d4b1bda184d6da02ce067d55b46fd
7
+ data.tar.gz: 12d72cb6cb38cac62e74c9c7ee38eaec0586cf93ab1997e70e8d0cf4608fe95aa05baf53a32c694f0d367aafd3925a1fc43a9635d3df24b87dd19bfc3c4d615f
@@ -9,50 +9,60 @@ async function get_value(name) {
9
9
  return x[name];
10
10
  };
11
11
 
12
- document.addEventListener("locatine_send", async function(e) {
13
- await set_value(e.detail.varname, e.detail.varvalue);
14
- });
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
+ };
19
+ locatine_create_element(document.body, "div", options, "");
20
+ const magic_cover = document.getElementById('locatine_magic_div');
21
+ magic_cover.onclick = function(e) {locatine_magic_click(e)};
22
+ }
23
+
24
+ async function setStyle(style, magicDiv){
25
+ if (style === "set_true") {
26
+ await set_value('magic_div', true);
27
+ magicDiv.setAttribute("locatinestyle", "true");
28
+ };
29
+ if (style === "set_false") {
30
+ await set_value('magic_div', false);
31
+ magicDiv.setAttribute("locatinestyle", "false");
32
+ };
33
+ let status = await get_value('magic_div');
34
+ magicDiv.setAttribute("locatinestyle", status);
35
+ }
36
+
37
+ async function setTitleHint(magicDiv){
38
+ if (magicDiv.getAttribute("locatinetitle") != "ok") {
39
+ await set_value('locatine_title', magicDiv.getAttribute("locatinetitle"));
40
+ await set_value('locatine_hint', magicDiv.getAttribute("locatinehint"));
41
+ magicDiv.setAttribute("locatinetitle", "ok");
42
+ }
43
+ }
44
+
45
+ async function setConfirm(magicDiv) {
46
+ if (magicDiv.getAttribute("locatineconfirmed") === "ok") {
47
+ magicDiv.removeAttribute("tag");
48
+ magicDiv.removeAttribute("index");
49
+ await set_value("locatine_confirm", false);
50
+ }
51
+
52
+ const confirmed = await get_value('locatine_confirm');
53
+ magicDiv.setAttribute("locatineconfirmed", confirmed);
54
+ }
15
55
 
16
56
  async function refreshData(){
57
+ const magicDiv = document.getElementById("locatine_magic_div");
17
58
  if (!document.getElementById("locatine_magic_div")){
18
- const options = {
19
- "locatineclass": "locatine_smthing",
20
- "id":"locatine_magic_div",
21
- "locatinestyle": await get_value('magic_div') || "false",
22
- "locatinetitle": "ok",
23
- "locatinehint": "ok"
24
- };
25
- locatine_create_element(document.body, "div", options, "");
59
+ creatingDiv();
26
60
  } else {
27
- const magicDiv = document.getElementById("locatine_magic_div");
28
- if (magicDiv.getAttribute("locatinestyle") === "set_true") {
29
- await set_value('magic_div', true);
30
- magicDiv.setAttribute("locatinestyle", "true");
31
- };
32
- if (magicDiv.getAttribute("locatinestyle") === "set_false") {
33
- await set_value('magic_div', false);
34
- magicDiv.setAttribute("locatinestyle", "false");
35
- };
36
- if (magicDiv.getAttribute("locatinetitle") != "ok") {
37
- await set_value('locatine_title', magicDiv.getAttribute("locatinetitle"));
38
- await set_value('locatine_hint', magicDiv.getAttribute("locatinehint"));
39
- magicDiv.setAttribute("locatinetitle", "ok");
40
- }
41
- let status = await get_value('magic_div');
42
- if (magicDiv.getAttribute("locatinestyle") != "set_true"){
43
- magicDiv.setAttribute("locatinestyle", status);
44
- }
45
- magicDiv.setAttribute("locatinecollection", await get_value("locatine_collection"))
46
- if (magicDiv.getAttribute("locatineconfirmed") === "ok") {
47
- magicDiv.removeAttribute("tag");
48
- magicDiv.removeAttribute("index");
49
- await set_value("locatine_confirm", false);
50
- }
51
- const confirmed = await get_value('locatine_confirm');
52
- magicDiv.setAttribute("locatineconfirmed", confirmed);
61
+ setStyle(magicDiv.getAttribute("locatinestyle"), magicDiv);
62
+ setTitleHint(magicDiv);
63
+ magicDiv.setAttribute("locatinecollection", await get_value("locatine_collection"));
64
+ setConfirm(magicDiv);
53
65
  };
54
- const magic_cover = document.getElementById('locatine_magic_div');
55
- magic_cover.onclick = function(e) {locatine_magic_click(e)};
56
66
  };
57
67
 
58
68
  async function getSelected(value){
@@ -78,8 +88,8 @@ async function locatine_magic_click(e) {
78
88
  const array = Array.prototype.slice.call( document.getElementsByTagName(tagName) );
79
89
  const index = array.indexOf(value);
80
90
  await set_value("locatine_confirm", "selected");
81
- document.getElementById("locatine_magic_div").setAttribute("TAG", tagName);
82
- document.getElementById("locatine_magic_div").setAttribute("INDEX", index);
91
+ document.getElementById("locatine_magic_div").setAttribute("tag", tagName);
92
+ document.getElementById("locatine_magic_div").setAttribute("index", index);
83
93
  };
84
94
 
85
95
  function locatine_create_element(dom, tag, attrs, inner) {
@@ -92,8 +102,6 @@ function locatine_create_element(dom, tag, attrs, inner) {
92
102
  return element;
93
103
  };
94
104
 
95
- //set_value('magic_div','off');
96
-
97
105
  setInterval(async function(){
98
106
  if (document.getElementById("locatine_magic_div")) {
99
107
  if (document.getElementById("locatine_magic_div").getAttribute("locatinestyle") != "blocked") {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "Locatine app",
3
- "version": "0.01546",
3
+ "version": "0.01659",
4
4
  "description": "Messaging from browser to main app",
5
5
  "devtools_page": "devtools.html",
6
6
  "permissions": ["activeTab", "storage", "contextMenus", "tabs"],
@@ -85,7 +85,7 @@ module Locatine
85
85
  attributes = element.attributes
86
86
  array = []
87
87
  attributes.each_pair do |name, value|
88
- next if name.to_s == 'locatineclass'
88
+ next if name.to_s == 'locatineclass' # Should never happen
89
89
 
90
90
  value.split(/['" ]/).reject(&:empty?).uniq.each do |part|
91
91
  array.push('name' => name.to_s, 'type' => 'attribute',
@@ -82,17 +82,25 @@ module Locatine
82
82
  return nil, {}
83
83
  end
84
84
 
85
+ def user_selection(els, attrs, vars, name, scope)
86
+ case get_from_app('locatineconfirmed')
87
+ when 'selected'
88
+ els, attrs = what_was_selected(els, attrs, vars, name, scope)
89
+ when 'declined'
90
+ els, attrs = decline(els, name, scope)
91
+ end
92
+ return els, attrs
93
+ end
94
+
85
95
  def listening(els, attrs, vars, name, scope)
86
96
  until get_from_app('locatineconfirmed') == 'true'
87
97
  sleep(0.1)
88
- case get_from_app('locatineconfirmed')
89
- when 'selected'
90
- els, attrs = what_was_selected(els, attrs, vars, name, scope)
91
- when 'declined'
92
- els, attrs = decline(els, name, scope)
93
- end
98
+ els, attrs = user_selection(els, attrs, vars, name, scope)
94
99
  end
95
- return els, attrs
100
+ return els, attrs if els
101
+
102
+ decline(els, name, scope)
103
+ listening(els, attrs, vars, name, scope)
96
104
  end
97
105
 
98
106
  ##
@@ -1,6 +1,6 @@
1
1
  module Locatine
2
2
  # constants here...
3
- VERSION = '0.01546'.freeze
3
+ VERSION = '0.01659'.freeze
4
4
  NAME = 'locatine'.freeze
5
5
  HOME = if File.readable?("#{Dir.pwd}/lib/#{Locatine::NAME}")
6
6
  "#{Dir.pwd}/lib/#{Locatine::NAME}"
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.01546'
4
+ version: '0.01659'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergei Seleznev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-23 00:00:00.000000000 Z
11
+ date: 2019-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler