diff --git a/README.md b/README.md index a09afa5..fdad9c1 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,18 @@ 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. +--- +

Supported Service Endpoint URLs

+ +| code | URL | +|------------|---------------------------------------------------------------------------------------------| +| 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_kr | https://www.google.co.kr/inputtools/request?ime=handwriting | +| google | https://www.google.com/inputtools/request?ime=handwriting | +| inputtools | https://inputtools.google.com/request?ime=handwriting | + ---

Supported Language

diff --git a/handwriting.canvas.js b/handwriting.canvas.js index 4890d3d..69f13ce 100644 --- a/handwriting.canvas.js +++ b/handwriting.canvas.js @@ -199,6 +199,14 @@ 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_kr": "https://www.google.co.kr/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 +248,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); }; diff --git a/handwriting.js b/handwriting.js index 9e63752..750fac0 100644 --- a/handwriting.js +++ b/handwriting.js @@ -20,6 +20,14 @@ 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_kr": "https://www.google.co.kr/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 +69,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); };