locatine 0.02539 → 0.02542

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: 63c1d452b58e6881483141749a4cd5fc572a1a34
4
- data.tar.gz: 5436ddbbd222888ab16ef121750e871be2d0b330
3
+ metadata.gz: df3f8d995c895faf833681632462dcd884e73bce
4
+ data.tar.gz: 8885ecd8b1513df7cac86761a22e02acdb692f03
5
5
  SHA512:
6
- metadata.gz: 875b40b1ebc3294dc60868c4f029a3eb2c37b984509002c30fadecad20d7e26f0df207eab8ed3466cc7021777d9a89baa6a0a6c4ba7dc655bea1109b573031cb
7
- data.tar.gz: 9c36756f4c0388acf60d1009ed79ebed732b2401daa387930a3f61c8c97b745f2c1bc0bdeeced30e300543d88b09459c7bdf0f7320ef4630dbd47e83c9b58550
6
+ metadata.gz: 0234243bf852972ac60752c0be0232a2c427ce0f40f21fefaaa2cf8e7a32403e2c33f8761fcaa28712ffd8bd0960b1d2c46f5f3846e45c56e51edf5b5dc2831e
7
+ data.tar.gz: ec7071e6b671a03d6cf2fe034b510f914af84e403248ddcd6a3d230a9c8cf9ba4f2c291ffe9722a5a58436d3208754b5898d1a9dc94d00f9016772fcf2a6b117
data/README.md CHANGED
@@ -16,7 +16,7 @@ That's it.
16
16
 
17
17
  ## Stage of development:
18
18
 
19
- Version of Locatine is **0.02539** only. It means so far this is an alfa. You can use it in a real project if you are a risky person.
19
+ Version of Locatine is **0.02542** only. It means so far this is an alfa. You can use it in a real project if you are a risky person.
20
20
 
21
21
  ## Installation
22
22
 
@@ -1,6 +1,5 @@
1
1
  chrome.browserAction.onClicked.addListener(
2
2
  function(tab) {
3
- console.log("WAS here");
4
3
  chrome.windows.create( {'url': 'popup.html',
5
4
  'type': 'popup',
6
5
  'width': 640,
@@ -20,6 +20,7 @@ async function creatingDiv(){
20
20
  locatine_create_element(document.body, "div", options, "");
21
21
  const magic_cover = document.getElementById('locatine_magic_div');
22
22
  magic_cover.onclick = function(e) {locatine_magic_click(e)};
23
+ await set_value('locatine_confirm', 'new')
23
24
  document.body.onkeypress = async function(e) {
24
25
  if (e.which == 13) {
25
26
  await set_value('locatine_confirm', true)
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "Locatine app",
3
- "version": "0.02539",
3
+ "version": "0.02542",
4
4
  "description": "Messaging from browser to main app",
5
5
  "devtools_page": "devtools.html",
6
6
  "permissions": ["activeTab", "storage", "contextMenus", "tabs"],
@@ -20,8 +20,10 @@ async function correct_buttons() {
20
20
  } else {
21
21
  document.getElementById("mode").setAttribute("value", "You are in single selection mode")
22
22
  };
23
- document.getElementById("mainTitle").innerText = await get_value("locatine_title");
24
- document.getElementById("hint").innerText = await get_value("locatine_hint");
23
+ if (await get_value("locatine_title")) {
24
+ document.getElementById("mainTitle").innerText = await get_value("locatine_title");
25
+ document.getElementById("hint").innerText = await get_value("locatine_hint");
26
+ }
25
27
  if ((document.getElementById("nameHandler").value != await get_value("locatineName")) && (!document.hasFocus())){
26
28
  document.getElementById("nameHandler").value = (await get_value("locatineName") || "");
27
29
  }
@@ -53,18 +53,40 @@ module Locatine
53
53
  return els, attrs
54
54
  end
55
55
 
56
+ # get_from_app('locatineconfirmed') 'selected' or 'declined' or 'true'
57
+ # or 'abort' or 'new' or anything else (ok or false)
56
58
  def listening(els, attrs, vars, name, scope)
57
- until %w[true abort].include?(get_from_app('locatineconfirmed'))
58
- sleep(0.1)
59
- els, attrs = user_selection(els, attrs, vars, name, scope)
59
+ sleep(0.1)
60
+ result = hearing
61
+ els, attrs = understanding(els, attrs, vars, name, scope, result)
62
+ if (!result[:done] || !els) && !result[:abort]
63
+ return listening(els, attrs, vars, name, scope)
60
64
  end
61
- result = get_from_app('locatineconfirmed')
62
- return els, attrs if els && result != 'abort'
63
65
 
64
- els, attrs = decline(els, name, scope)
65
- return els, attrs if result == 'abort'
66
+ return els, attrs
67
+ end
68
+
69
+ def understanding(els, attrs, vars, name, scope, result)
70
+ if result[:selected]
71
+ els, attrs = user_selection(els, attrs, vars, name, scope)
72
+ else
73
+ start_listening(scope, name) if result[:new]
74
+ els, attrs = decline(els, name, scope) if result[:declined]
75
+ end
76
+ return els, attrs
77
+ end
66
78
 
67
- listening(els, attrs, vars, name, scope)
79
+ def hearing
80
+ answer = {}
81
+ result = get_from_app('locatineconfirmed')
82
+ answer[:selected] = ((result == 'selected') || (result == 'true'))
83
+ answer[:new] = result == 'new'
84
+ answer[:done] = result == 'true'
85
+ answer[:abort] = result == 'abort'
86
+ answer[:declined] = ((result == 'new') ||
87
+ (result == 'declined') ||
88
+ (result == 'abort'))
89
+ answer
68
90
  end
69
91
 
70
92
  ##
@@ -25,7 +25,6 @@ module Locatine
25
25
  suggested = most_common_of(all).map do |element|
26
26
  engine.elements(tag_name: element['tag'])[element['index'].to_i]
27
27
  end
28
- send_no_guess(name, scope) if suggested.length > 1
29
28
  suggested
30
29
  end
31
30
 
@@ -18,13 +18,12 @@ module Locatine
18
18
 
19
19
  def take_html
20
20
  engine.locate
21
- engine.html
21
+ engine.html.gsub(/<div.*id="locatine_magic_div".*>/, '')
22
22
  end
23
23
 
24
24
  def time
25
25
  t = Time.now
26
- "#{t.year}.#{t.month}.#{t.day} #{t.hour.to_s.rjust(2, '0')}:"\
27
- "#{t.min.to_s.rjust(2, '0')}:#{t.sec.to_s.rjust(2, '0')}"
26
+ t.strftime('%F %T')
28
27
  end
29
28
 
30
29
  def fix_iframe
@@ -23,6 +23,7 @@ module Locatine
23
23
  def start_listening(scope, name)
24
24
  send_to_app('locatinestyle', 'blocked', @browser) if @iframe
25
25
  send_to_app('locatinestyle', 'set_true')
26
+ send_to_app('locatineconfirmed', 'ok')
26
27
  send_selecting(name, scope)
27
28
  sleep 0.5
28
29
  end
@@ -1,6 +1,5 @@
1
1
 
2
2
  function one_element(target){
3
- console.log("TARGET ==", target);
4
3
 
5
4
  let element = {};
6
5
  let attribute = {};
@@ -1,6 +1,6 @@
1
1
  module Locatine
2
2
  # constants here...
3
- VERSION = '0.02539'.freeze
3
+ VERSION = '0.02542'.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.02539'
4
+ version: '0.02542'
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-09-20 00:00:00.000000000 Z
11
+ date: 2019-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler