From 138157a4444c37722584729767253aa8e875651f Mon Sep 17 00:00:00 2001 From: cbrender-deploy1 <128198801+cbrender-deploy1@users.noreply.github.com> Date: Sat, 18 Mar 2023 11:02:13 +0800 Subject: [PATCH 1/7] Update handwriting.js Add serviceEndpointURLs --- handwriting.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/handwriting.js b/handwriting.js index 9e63752..66bc5fd 100644 --- a/handwriting.js +++ b/handwriting.js @@ -20,6 +20,13 @@ options = this.options; callback = this.callback; } else if (!options) options = {}; + var serviceEndpointURLs = { + "default": "https://www.google.com.tw/inputtools/request?ime=handwriting&app=mobilesearch&cs=1&oe=UTF-8", + "google_tw": "https://www.google.com.tw/inputtools/request?ime=handwriting", + "google_jp": "https://www.google.co.jp/inputtools/request?ime=handwriting", + "google": "https://www.google.com/inputtools/request?ime=handwriting", + "inputtools": "https://inputtools.google.com/request?ime=handwriting" + } var data = JSON.stringify({ "options": "enable_pre_space", "requests": [{ @@ -61,7 +68,7 @@ } }); - xhr.open("POST", "https://www.google.com.tw/inputtools/request?ime=handwriting&app=mobilesearch&cs=1&oe=UTF-8"); + xhr.open("POST", serviceEndpointURLs[options.serviceEndpoint] || serviceEndpointURLs["default"]); xhr.setRequestHeader("content-type", "application/json"); xhr.send(data); }; From c83ce952b353e279bc48528aa7a01ab6925da8db Mon Sep 17 00:00:00 2001 From: cbrender-deploy1 <128198801+cbrender-deploy1@users.noreply.github.com> Date: Sat, 18 Mar 2023 11:05:18 +0800 Subject: [PATCH 2/7] Update handwriting.canvas.js Add serviceEndpointURLs --- handwriting.canvas.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/handwriting.canvas.js b/handwriting.canvas.js index 4890d3d..992a515 100644 --- a/handwriting.canvas.js +++ b/handwriting.canvas.js @@ -199,6 +199,13 @@ options = this.options; callback = this.callback; } else if (!options) options = {}; + var serviceEndpointURLs = { + "default": "https://www.google.com.tw/inputtools/request?ime=handwriting&app=mobilesearch&cs=1&oe=UTF-8", + "google_tw": "https://www.google.com.tw/inputtools/request?ime=handwriting", + "google_jp": "https://www.google.co.jp/inputtools/request?ime=handwriting", + "google": "https://www.google.com/inputtools/request?ime=handwriting", + "inputtools": "https://inputtools.google.com/request?ime=handwriting" + } var data = JSON.stringify({ "options": "enable_pre_space", "requests": [{ @@ -240,7 +247,7 @@ } }); - xhr.open("POST", "https://www.google.com.tw/inputtools/request?ime=handwriting&app=mobilesearch&cs=1&oe=UTF-8"); + xhr.open("POST", serviceEndpointURLs[options.serviceEndpoint] || serviceEndpointURLs["default"]); xhr.setRequestHeader("content-type", "application/json"); xhr.send(data); }; From 090d8d92f35485970d85e21a259015424c7f1dd8 Mon Sep 17 00:00:00 2001 From: cbrender-deploy1 <128198801+cbrender-deploy1@users.noreply.github.com> Date: Sat, 18 Mar 2023 11:18:38 +0800 Subject: [PATCH 3/7] Update README.md Add serviceEndpointURL documentation --- README.md | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a09afa5..c03b436 100644 --- a/README.md +++ b/README.md @@ -52,11 +52,12 @@ options argument is an optional object of following fields: ```javascript var options = { - width : 800, //int, width of the writing area, default: undefined - height : 800, //int, height of the writing area, default: undefined - language : "zh_TW", //string, language of input trace, default: "zh_TW" - numOfWords : 1, //int, number of words of input trace, default: undefined - numOfReturn : 5, //int, number of maximum returned results, default: undefined + width : 800, //int, width of the writing area, default: undefined + height : 800, //int, height of the writing area, default: undefined + language : "zh_TW", //string, language of input trace, default: "zh_TW" + serviceEndpoint: "google_tw", //string, service endpoint URL used, default: "default" + numOfWords : 1, //int, number of words of input trace, default: undefined + numOfReturn : 5, //int, number of maximum returned results, default: undefined }; ``` @@ -177,6 +178,17 @@ Note that, even included handwriting.canvas.js now, the previous way of calling so that you can take advantage of the **handwriting.canvas** object, while not changing previous code. +--- +