Skip to content

Commit

Permalink
#972 - add remove_char() helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
kensoh committed Jun 4, 2021
1 parent 8640240 commit 0945279
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/tagui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ chrome_command="google-chrome"

if [ -z "$1" ]
then
echo "tagui v6.40: use following options and this syntax to run - ./tagui flow_filename option(s)"
echo "tagui v6.41: use following options and this syntax to run - ./tagui flow_filename option(s)"
echo
echo "tagui live launch TagUI live mode enabled with visual automation for interactive development"
echo "input(s) add your own parameter(s) to be used in your automation flow as variables p1 to p8"
Expand Down
2 changes: 1 addition & 1 deletion src/tagui.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ rem enable windows for loop advanced flow control
setlocal enableextensions enabledelayedexpansion

if "%~1"=="" (
echo tagui v6.40: use following options and this syntax to run - tagui flow_filename option^(s^)
echo tagui v6.41: use following options and this syntax to run - tagui flow_filename option^(s^)
echo.
echo tagui live launch TagUI live mode enabled with visual automation for interactive development
echo input^(s^) add your own parameter^(s^) to be used in your automation flow as variables p1 to p8
Expand Down
3 changes: 0 additions & 3 deletions src/tagui_global.csv

This file was deleted.

16 changes: 14 additions & 2 deletions src/tagui_header.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,22 @@ function get_text(source_text, left_marker, right_marker, optional_count) {
var left_position = source_text.indexOf(left_marker); if (left_position == -1) return '';
var right_position = source_text.indexOf(right_marker, left_position+1); if (right_position == -1) return '';
if (optional_count > 1) {var occurrence_count = 2; while(occurrence_count <= optional_count) {occurrence_count++;
left_position = source_text.indexOf(left_marker, right_position+1); if (left_position == -1) return '';
right_position = source_text.indexOf(right_marker, left_position+1); if (right_position == -1) return '';}}
left_position = source_text.indexOf(left_marker, right_position+1); if (left_position == -1) return '';
right_position = source_text.indexOf(right_marker, left_position+1); if (right_position == -1) return '';}}
return source_text.slice(left_position + left_marker.length, right_position).trim();}

// remove all occurrences of given characters from a given string
function remove_char(source_text, characters) {
if (!source_text) return ''; else if (!characters) return source_text;
characters = characters.replace(/\\n/g,'\n').replace(/\\r/g,'\r').replace(/\\t/g,'\t');
characters = characters.replace(/\\f/g,'\f').replace(/\\v/g,'\v').replace(/\\\\/g,'\\');
for (char_counter = 0; char_counter < characters.length; char_counter++) {
if (characters[char_counter] != '\\')
source_text = source_text.replace(new RegExp(characters[char_counter],'g'),'');
else
source_text = source_text.replace(/\\/g,'');}
return source_text;}

// for initialising integration with sikuli visual automation
function sikuli_handshake() { // techo('[connecting to sikuli process]');
var ds; if (flow_path.indexOf('/') !== -1) ds = '/'; else ds = '\\'; clear_sikuli_text();
Expand Down
21 changes: 17 additions & 4 deletions src/test/positive_test.signature
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,22 @@ function get_text(source_text, left_marker, right_marker, optional_count) {
var left_position = source_text.indexOf(left_marker); if (left_position == -1) return '';
var right_position = source_text.indexOf(right_marker, left_position+1); if (right_position == -1) return '';
if (optional_count > 1) {var occurrence_count = 2; while(occurrence_count <= optional_count) {occurrence_count++;
left_position = source_text.indexOf(left_marker, right_position+1); if (left_position == -1) return '';
right_position = source_text.indexOf(right_marker, left_position+1); if (right_position == -1) return '';}}
left_position = source_text.indexOf(left_marker, right_position+1); if (left_position == -1) return '';
right_position = source_text.indexOf(right_marker, left_position+1); if (right_position == -1) return '';}}
return source_text.slice(left_position + left_marker.length, right_position).trim();}

// remove all occurrences of given characters from a given string
function remove_char(source_text, characters) {
if (!source_text) return ''; else if (!characters) return source_text;
characters = characters.replace(/\\n/g,'\n').replace(/\\r/g,'\r').replace(/\\t/g,'\t');
characters = characters.replace(/\\f/g,'\f').replace(/\\v/g,'\v').replace(/\\\\/g,'\\');
for (char_counter = 0; char_counter < characters.length; char_counter++) {
if (characters[char_counter] != '\\')
source_text = source_text.replace(new RegExp(characters[char_counter],'g'),'');
else
source_text = source_text.replace(/\\/g,'');}
return source_text;}

// for initialising integration with sikuli visual automation
function sikuli_handshake() { // techo('[connecting to sikuli process]');
var ds; if (flow_path.indexOf('/') !== -1) ds = '/'; else ds = '\\'; clear_sikuli_text();
Expand Down Expand Up @@ -853,7 +865,7 @@ if (inside_py_block !== 0) return 'py'; if (inside_r_block !== 0) return 'r';
if (inside_run_block !== 0) return 'run'; if (inside_vision_block !== 0) return 'vision';
if (inside_js_block !== 0) return 'js'; if (inside_dom_block !== 0) return 'dom';

if (lc_raw_intent.substr(0,7) == 'http://' || lc_raw_intent.substr(0,8) == 'https://') return 'url';
if (lc_raw_intent.substr(0,7) == 'http://' || lc_raw_intent.substr(0,8) == 'https://' || lc_raw_intent.substr(0,4) == 'www.') return 'url';

// first set of conditions check for valid keywords with their parameters
if ((lc_raw_intent.substr(0,4) == 'tap ') || (lc_raw_intent.substr(0,6) == 'click ')) return 'tap';
Expand Down Expand Up @@ -1031,7 +1043,8 @@ if (!fs.exists('tagui_py/tagui_py.in')) return "this.echo('ERROR - cannot initia
if (!fs.exists('tagui_py/tagui_py.out')) return "this.echo('ERROR - cannot initialise tagui_py.out')";
return "py_result = ''; if (!py_step('"+input_intent+"')) this.echo('ERROR - cannot execute Python command(s)'); else {py_result = fetch_py_text(); clear_py_text(); try {py_json = JSON.parse(py_result);} catch(e) {py_json = JSON.parse('null');}}";}

function url_intent(raw_intent) {raw_intent = eval("'" + escape_bs(raw_intent) + "'"); // support dynamic variables
function url_intent(raw_intent) {if (raw_intent.toLowerCase().substr(0,4) == 'www.') raw_intent = 'https://' + raw_intent;
raw_intent = eval("'" + escape_bs(raw_intent) + "'"); // support dynamic variables
if (chrome_id == 0) return "this.echo('ERROR - step only supported in live mode using Chrome browser')";
else return "this.evaluate(function() {window.location.href = \"" + raw_intent + "\"})";}

Expand Down

0 comments on commit 0945279

Please sign in to comment.