Skip to content

Commit

Permalink
V0.1.6 Fixed blank recognizion before value, UI
Browse files Browse the repository at this point in the history
  • Loading branch information
christianTF committed Oct 25, 2018
1 parent 64d358c commit 4ce8f52
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
2 changes: 1 addition & 1 deletion plugin.cfg
Expand Up @@ -10,7 +10,7 @@ EMAIL=christiantf@gmx.at
[PLUGIN]
# The version of your plugin - important if you would like to write an
# upgrade script.
VERSION=0.1.5
VERSION=0.1.6

# Short name and prefered subfolder of your Plugin (do not use blanks - they
# will be filtered - and use lowercase only)! Used for script names in
Expand Down
4 changes: 2 additions & 2 deletions release.cfg
Expand Up @@ -5,10 +5,10 @@
# the donwload link here

# Version of the new release
VERSION=0.1.5
VERSION=0.1.6

# Download URL of the ZIP Archive
ARCHIVEURL=https://github.com/christianTF/LoxBerry-Plugin-CommandRecognition/archive/0.1.5.zip
ARCHIVEURL=https://github.com/christianTF/LoxBerry-Plugin-CommandRecognition/archive/0.1.6.zip

# URL for further information about this release
INFOURL=https://github.com/christianTF/LoxBerry-Plugin-CommandRecognition/releases
38 changes: 35 additions & 3 deletions templates/comrec.html
Expand Up @@ -26,8 +26,8 @@
<h2>Source</h2>
<div data-role="navbar">
<ul>
<li><a href="#" onclick="$('#divurl').show();$('#divstring').hide();" class="ui-btn-active">Webpage</a></li>
<li><a href="#" onclick="$('#divurl').hide();$('#divstring').show();">Input field</a></li>
<li><a id="nav_web" href="#" onclick="$('#divurl').show();$('#divstring').hide();restoreWindow();storeWindow('nav', 'nav_web');" class="ui-btn-active">Webpage</a></li>
<li><a id="nav_string" href="#" onclick="$('#divurl').hide();$('#divstring').show();restoreWindow();storeWindow('nav', 'nav_string');">Input field</a></li>
</ul>
</div>

Expand Down Expand Up @@ -65,6 +65,9 @@ <h2>Input text</h2>
$(function()
{
console.log("Loaded.");
var nav = sessionStorage.getItem("comrec_nav");
if(nav !== null) { $('#'+nav).trigger("click"); }
restoreWindow();
});

$('#recognition').on('input', function() {
Expand All @@ -76,12 +79,14 @@ <h2>Input text</h2>

$('#syntaxstatus').html('<span class="ok">OK</span>');
var recstr = $('#recognition').val();
storeWindow("recognition", recstr);
var regex = parse_recstring( recstr );
// var regexval = parse_valuestring( $('#recognition').val() );
var regexval;
var conversion=0;
if (recstr.indexOf('\\v') != -1) {
regexval = '^(-)?\\d+[.,]?\\d*';
// regexval = '^(-)?\\d+[.,]?\\d*';
regexval = '^(\\s)*(-)?\\d+[.,]?\\d*';
}
else if (recstr.indexOf('\\1') != -1) {
regexval = '[\x00-\xFF]';
Expand Down Expand Up @@ -156,6 +161,7 @@ <h2>Input text</h2>
str = str.replace('\\n', "\n");
rawhtml = str;
$('#visiblehtml').html(htmlEncode(rawhtml));
storeWindow ("inputstring", str)
update_result();

});
Expand Down Expand Up @@ -252,6 +258,7 @@ <h2>Input text</h2>
$('#sslwarning').html("");
$('#visiblehtml').html('<span class="OK">Please wait...</span>');
var url = $('#fetchurl').val().trim();
storeWindow("fetchurl", url);
if (! url.startsWith("http://") && ! url.startsWith("https://")) {
url = 'http://' + url;
}
Expand Down Expand Up @@ -319,4 +326,29 @@ <h2>Input text</h2>
return re;
}

function storeWindow (name, val)
{
sessionStorage.setItem("comrec_"+name, val);
}

function restoreWindow()
{

var fetchurl = sessionStorage.getItem("comrec_fetchurl");
var recognition = sessionStorage.getItem("comrec_recognition");
var inputstring = sessionStorage.getItem("comrec_inputstring");

console.log(fetchurl, recognition, inputstring);

if(fetchurl !== null) $("#fetchurl").val(fetchurl);

if(inputstring !== null && $("#divstring").is(':visible')) { $("#inputstring").val(inputstring); $("#inputstring").trigger("input"); }
if(recognition !== null) { $("#recognition").val(recognition); $("#recognition").trigger("input"); }

console.log("Inputs restored");

}



</script>

0 comments on commit 4ce8f52

Please sign in to comment.