Repository: incubator-freemarker-online-tester Updated Branches: refs/heads/master 007c4e131 -> 01a23c575
(Flattened assets/ directory structure) Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker-online-tester/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker-online-tester/commit/36d5a234 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker-online-tester/tree/36d5a234 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker-online-tester/diff/36d5a234 Branch: refs/heads/master Commit: 36d5a2341c429fcb41708067edceceb3b05bee82 Parents: 007c4e1 Author: ddekany <ddek...@apache.org> Authored: Fri Mar 23 22:42:43 2018 +0100 Committer: ddekany <ddek...@apache.org> Committed: Fri Mar 23 22:42:43 2018 +0100 ---------------------------------------------------------------------- src/main/resources/assets/css/main.css | 140 --------------------- src/main/resources/assets/js/script.js | 110 ---------------- src/main/resources/assets/main.css | 140 +++++++++++++++++++++ src/main/resources/assets/script.js | 110 ++++++++++++++++ src/main/resources/view/freemarker-online.ftl | 4 +- 5 files changed, 252 insertions(+), 252 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-freemarker-online-tester/blob/36d5a234/src/main/resources/assets/css/main.css ---------------------------------------------------------------------- diff --git a/src/main/resources/assets/css/main.css b/src/main/resources/assets/css/main.css deleted file mode 100644 index ba1fc9b..0000000 --- a/src/main/resources/assets/css/main.css +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -.clear { - clear: both; -} - -#layout { - position: relative; - padding: 0; -} - -.header { - margin: 0; - padding: 1em 0; - border-bottom: 1px solid #eee; - text-align: center; - color: #444; -} - -.content { - margin: 0 auto; - padding: 1em 0; - width: 920px; -} - -.footer { - margin: 0; - padding: 1em 2em 0; - border-top: 1px solid #eee; - text-align: center; - color: #444; -} - -.errorMessage { - font-size: small; - color: red; - display: none; -} - -.header h1 { - margin: 0.2em 0; - font-size: 1.75em; - font-weight: normal; -} - -#result { - background-color: #FFF; - color: #000 -} - -#result.error { - background-color: #FFF0F0; - color: #A00; -} - -.faint { - color: #bbb -} - -textarea.source-code { - font-family: monospace !important; - /* We set a few more things to decrease the chance of jQuery Autosize plugin issues: */ - font-size: 1em !important; - resize: none !important; - line-height: 1em !important; -} - -.hiddenByDefault { - display: none; -} - -#dataModelExamples { - background: #eee; - padding: 4px; - margin: 0; -} - -#dataModelExamples .description { - font-style: italic; - margin-bottom: 1em; -} - -#dataModelExamples pre { - font-family: monospace; - font-size: 1em; - padding: 0; - margin: 0; -} - -#templateAndModelForm input, -#templateAndModelForm textarea, -#templateAndModelForm button { - margin-bottom: 1em; -} - -#templateAndModelForm label { - margin-top: 1em; - margin-bottom: 0.25em; -} - -.formPanel { - -} - -.formBottomButtonsContainer { - margin-top: 1.5em; -} - -.resultContainer { - margin-top: 1em; -} - -.horizontalBox { - display: inline-block; - padding-right: 1em; -} - -.forkMeOnGithub { - position: absolute; - top: 0; - right: 0; - border: 0; -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker-online-tester/blob/36d5a234/src/main/resources/assets/js/script.js ---------------------------------------------------------------------- diff --git a/src/main/resources/assets/js/script.js b/src/main/resources/assets/js/script.js deleted file mode 100644 index 9afba14..0000000 --- a/src/main/resources/assets/js/script.js +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -// IMPORTANT! If you modify this file, increase the number after "?v=" in the FreeMarker template! - -$(document).ready(function() { - $("#eval-btn").click(function() { - execute(); - }); - $('#templateAndModelForm textarea, #templateAndModelForm select').keydown(function (e) { - if ((e.keyCode == 10 || e.keyCode == 13) && e.ctrlKey) { - execute(); - } - }); - $.blockUI.defaults.fadeIn = 1000; - $.blockUI.defaults.fadeOut = 0; -}); - -var hasPendingExecuteAjaxCall = false; - -function execute() { - if (hasPendingExecuteAjaxCall || !checkFormSendable()) { - return; - } - - var request = { - "template": $("#template").val(), - "dataModel": $("#dataModel").val(), - "outputFormat": $("#outputFormat").val(), - "locale": $("#locale").val(), - "timeZone": $("#timeZone").val(), - "tagSyntax": $("#tagSyntax").val(), - "interpolationSyntax": $("#interpolationSyntax").val(), - } - - $.ajax({ - method: "POST", - url: "/api/execute", - data: JSON.stringify(request), - headers: { "Content-Type":"application/json" }, - beforeSend: function (jqXHR, options) { - hasPendingExecuteAjaxCall = true; - $.blockUI({ message: null }); - $("#error").hide(); - return true; - } - }) - .done(function (data) { - if (data.problems && data.problems.length != 0) { - showResult(data.problems[0].message, true); - } else { - showResult(data.result, false); - } - }) - .fail(function (data) { - if (data.responseJSON) { - if (typeof data.responseJSON.errorCode != 'undefined') { - showResult(data.responseJSON.errorCode + ": " + data.responseJSON.errorDescription, true); - } else { - showResult("The service has responded with error:\n" - + "HTTP " + data.status - + (data.responseJSON.message ? ":\n" + data.responseJSON.message : " (No more details available)"), - true); - } - } else { - showResult("The service was unavailable or had returned an invalid response.", true); - } - }) - .always(function (data) { - hasPendingExecuteAjaxCall = false; - $.unblockUI(); - }); -} - -function checkFormSendable() { - if($.trim($("#template").val()) === "" ) { - showResult("Template was empty; nothing to do.", true); - return false; - } - return true; -} - -function showResult(result, isError) { - if (isError) { - $("#result").addClass("error"); - } else { - $("#result").removeClass("error"); - } - $("#result").val(result); - $(".resultContainer").show(); - autosize.update($("#result")); -} - -//IMPORTANT! If you modify this file, increase the number after "?v=" in the FreeMarker template! http://git-wip-us.apache.org/repos/asf/incubator-freemarker-online-tester/blob/36d5a234/src/main/resources/assets/main.css ---------------------------------------------------------------------- diff --git a/src/main/resources/assets/main.css b/src/main/resources/assets/main.css new file mode 100644 index 0000000..ba1fc9b --- /dev/null +++ b/src/main/resources/assets/main.css @@ -0,0 +1,140 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +.clear { + clear: both; +} + +#layout { + position: relative; + padding: 0; +} + +.header { + margin: 0; + padding: 1em 0; + border-bottom: 1px solid #eee; + text-align: center; + color: #444; +} + +.content { + margin: 0 auto; + padding: 1em 0; + width: 920px; +} + +.footer { + margin: 0; + padding: 1em 2em 0; + border-top: 1px solid #eee; + text-align: center; + color: #444; +} + +.errorMessage { + font-size: small; + color: red; + display: none; +} + +.header h1 { + margin: 0.2em 0; + font-size: 1.75em; + font-weight: normal; +} + +#result { + background-color: #FFF; + color: #000 +} + +#result.error { + background-color: #FFF0F0; + color: #A00; +} + +.faint { + color: #bbb +} + +textarea.source-code { + font-family: monospace !important; + /* We set a few more things to decrease the chance of jQuery Autosize plugin issues: */ + font-size: 1em !important; + resize: none !important; + line-height: 1em !important; +} + +.hiddenByDefault { + display: none; +} + +#dataModelExamples { + background: #eee; + padding: 4px; + margin: 0; +} + +#dataModelExamples .description { + font-style: italic; + margin-bottom: 1em; +} + +#dataModelExamples pre { + font-family: monospace; + font-size: 1em; + padding: 0; + margin: 0; +} + +#templateAndModelForm input, +#templateAndModelForm textarea, +#templateAndModelForm button { + margin-bottom: 1em; +} + +#templateAndModelForm label { + margin-top: 1em; + margin-bottom: 0.25em; +} + +.formPanel { + +} + +.formBottomButtonsContainer { + margin-top: 1.5em; +} + +.resultContainer { + margin-top: 1em; +} + +.horizontalBox { + display: inline-block; + padding-right: 1em; +} + +.forkMeOnGithub { + position: absolute; + top: 0; + right: 0; + border: 0; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker-online-tester/blob/36d5a234/src/main/resources/assets/script.js ---------------------------------------------------------------------- diff --git a/src/main/resources/assets/script.js b/src/main/resources/assets/script.js new file mode 100644 index 0000000..9afba14 --- /dev/null +++ b/src/main/resources/assets/script.js @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +// IMPORTANT! If you modify this file, increase the number after "?v=" in the FreeMarker template! + +$(document).ready(function() { + $("#eval-btn").click(function() { + execute(); + }); + $('#templateAndModelForm textarea, #templateAndModelForm select').keydown(function (e) { + if ((e.keyCode == 10 || e.keyCode == 13) && e.ctrlKey) { + execute(); + } + }); + $.blockUI.defaults.fadeIn = 1000; + $.blockUI.defaults.fadeOut = 0; +}); + +var hasPendingExecuteAjaxCall = false; + +function execute() { + if (hasPendingExecuteAjaxCall || !checkFormSendable()) { + return; + } + + var request = { + "template": $("#template").val(), + "dataModel": $("#dataModel").val(), + "outputFormat": $("#outputFormat").val(), + "locale": $("#locale").val(), + "timeZone": $("#timeZone").val(), + "tagSyntax": $("#tagSyntax").val(), + "interpolationSyntax": $("#interpolationSyntax").val(), + } + + $.ajax({ + method: "POST", + url: "/api/execute", + data: JSON.stringify(request), + headers: { "Content-Type":"application/json" }, + beforeSend: function (jqXHR, options) { + hasPendingExecuteAjaxCall = true; + $.blockUI({ message: null }); + $("#error").hide(); + return true; + } + }) + .done(function (data) { + if (data.problems && data.problems.length != 0) { + showResult(data.problems[0].message, true); + } else { + showResult(data.result, false); + } + }) + .fail(function (data) { + if (data.responseJSON) { + if (typeof data.responseJSON.errorCode != 'undefined') { + showResult(data.responseJSON.errorCode + ": " + data.responseJSON.errorDescription, true); + } else { + showResult("The service has responded with error:\n" + + "HTTP " + data.status + + (data.responseJSON.message ? ":\n" + data.responseJSON.message : " (No more details available)"), + true); + } + } else { + showResult("The service was unavailable or had returned an invalid response.", true); + } + }) + .always(function (data) { + hasPendingExecuteAjaxCall = false; + $.unblockUI(); + }); +} + +function checkFormSendable() { + if($.trim($("#template").val()) === "" ) { + showResult("Template was empty; nothing to do.", true); + return false; + } + return true; +} + +function showResult(result, isError) { + if (isError) { + $("#result").addClass("error"); + } else { + $("#result").removeClass("error"); + } + $("#result").val(result); + $(".resultContainer").show(); + autosize.update($("#result")); +} + +//IMPORTANT! If you modify this file, increase the number after "?v=" in the FreeMarker template! http://git-wip-us.apache.org/repos/asf/incubator-freemarker-online-tester/blob/36d5a234/src/main/resources/view/freemarker-online.ftl ---------------------------------------------------------------------- diff --git a/src/main/resources/view/freemarker-online.ftl b/src/main/resources/view/freemarker-online.ftl index 7b13c68..f4c68b0 100644 --- a/src/main/resources/view/freemarker-online.ftl +++ b/src/main/resources/view/freemarker-online.ftl @@ -28,13 +28,13 @@ <html> <head> <meta charset="utf-8"> - <link rel="stylesheet" href="assets/css/main.css"> + <link rel="stylesheet" href="assets/main.css"> <link rel="stylesheet" href="https://unpkg.com/purecss@1.0.0/build/pure-min.css"> <script src="https://code.jquery.com/jquery-1.11.2.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.blockUI/2.70/jquery.blockUI.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/autosize.js/3.0.8/autosize.min.js"></script> - <script src="assets/js/script.js?v=4"></script><!-- Always increase v if the script.js is changed! --> + <script src="assets/script.js?v=4"></script><!-- Always increase v if the script.js is changed! --> <script> $(function() { // Auto-focus on first form input: