*/
function vc_search_word(param, replace) {
/* phase 2. search partial word in the webpage */
- /* second, compare with links in html documents */
+ /* First, compare with links in html documents */
if (vc_flag_log == true) {
vc_rec_result.style.background = 'rgba(0, 100, 200, 1)';
}
return el;
}
- /* first, compare with whole text of elements in html documents */
+ /* Second, compare with whole text of elements in html documents */
var result = [];
for (var i = 0; i < resultTokenArr.length; i++) {
var obj = vc_selector([resultTokenArr[i]]);
* @param text text string from voice-control-webview.cpp.
*/
function vc_is_included_number(text) {
- var numbers = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'];
+ var numbers = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten',
+ 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty',
+ 'twenty one', 'twenty two', 'twenty three', 'twenty four', 'twenty five', 'twenty six', 'twenty seven', 'twenty eight', 'twenty nine', 'thirty',
+ 'thirty one', 'thirty two', 'thirty three', 'thirty four', 'thirty five', 'thirty six', 'thirty seven', 'thirty eight', 'thirty nine', 'forty',
+ 'forty one', 'forty two', 'forty three', 'forty four', 'forty five', 'forty six', 'forty seven', 'forty eight', 'forty nine', 'fifty',
+ 'fifty one', 'fifty two', 'fifty three', 'fifty four', 'fifty five', 'fifty six', 'fifty seven', 'fifty eight', 'fifty nine', 'sixty',
+ 'sixty one', 'sixty two', 'sixty three', 'sixty four', 'sixty five', 'sixty six', 'sixty seven', 'sixty eight', 'sixty nine', 'seventy',
+ 'seventy one', 'seventy two', 'seventy three', 'seventy four', 'seventy five', 'seventy six', 'seventy seven', 'seventy eight', 'seventy nine', 'eighty',
+ 'eighty one', 'eighty two', 'eighty three', 'eighty four', 'eighty five', 'eighty six', 'eighty seven', 'eighty eight', 'eighty nine', 'ninety',
+ 'ninety one', 'ninety two', 'ninety three', 'ninety four', 'ninety five', 'ninety six', 'ninety seven', 'ninety eight', 'ninety nine', 'hundred'];
var convert = text.toLowerCase();
var result;
result.param = result.param.substr(words[0].length + 1).trim();
}
+ var idx_sep;
+ if (isNaN(result.cmd) == true) {
+ if (0 < (idx_sep = result.param.includes('st ')) && !isNaN(result.param.substr(0, idx_sep))) {
+ if (idx_sep == result.param.length - 1) {
+ result.cmd = parseFloat(result.param.substr(0, idx_sep));
+ result.param = '';
+ } else {
+ result.cmd = parseFloat(result.param.substr(0, idx_sep));
+ result.param = result.param.substr(idx_sep + 3, result.param.length);
+ }
+ } else if (0 < (idx_sep = result.param.includes('nd ')) && !isNaN(result.param.substr(0, idx_sep))) {
+ if (idx_sep == result.param.length - 1) {
+ result.cmd = parseFloat(result.param.substr(0, idx_sep));
+ result.param = '';
+ } else {
+ result.cmd = parseFloat(result.param.substr(0, idx_sep));
+ result.param = result.param.substr(idx_sep + 3, result.param.length);
+ }
+ } else if (0 < (idx_sep = result.param.includes('th ')) && !isNaN(result.param.substr(0, idx_sep))) {
+ if (idx_sep == result.param.length - 1) {
+ result.cmd = parseFloat(result.param.substr(0, idx_sep));
+ result.param = '';
+ } else {
+ result.cmd = parseFloat(result.param.substr(0, idx_sep));
+ result.param = result.param.substr(idx_sep + 3, result.param.length);
+ }
+ }
+ }
+
return result
}
function vc_check_web_control(text) {
text = text.toLowerCase();
var convert = text.replace(/ /g, '');
- var googleSearch = 'google search';
- var youtubeSearch = 'youtube search';
+ var googleSearch = 'search google';
+ var googleSearch2 = ['search', 'on google'];
+ var youtubeSearch = 'search youtube';
+ var youtubeSearch2 = ['search', 'on youtube'];
if (text.startsWith(googleSearch) == true) {
- location.href = 'https://www.google.co.kr/search?q=' + (text.substr(googleSearch.length)).trim();
+ location.href = 'https://www.google.com/search?q=' + (text.substr(googleSearch.length)).trim();
+ } else if (text.startsWith(googleSearch2[0]) && text.endsWith(googleSearch2[1])) {
+ var query = text.substr(googleSearch2[0].length, text.length - googleSearch2[0].length - googleSearch2[1].length);
+ location.href = 'https://www.google.com/search?q=' + query.trim();
} else if (text.startsWith(youtubeSearch) == true) {
location.href = 'https://www.youtube.com/results?search_query=' + (text.substr(youtubeSearch.length)).trim();
- } else if (convert == 'refresh') {
+ } else if (text.startsWith(youtubeSearch2[0]) && text.endsWith(youtubeSearch2[1])) {
+ var query = text.substr(youtubeSearch2[0].length, text.length - youtubeSearch2[0].length - youtubeSearch2[1].length);
+ location.href = 'https://www.youtube.com/results?search_query=' + query.trim();
+ } else if (convert == 'refresh' || convert == 'reload') {
location.reload();
} else if (convert == 'google') {
- location.href = 'https://www.google.co.kr/';
+ location.href = 'https://www.google.com/';
} else if (convert == 'facebook') {
location.href = 'https://www.facebook.com/';
} else if (convert == 'amazon') {