Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Тестирование сервиса квитанций</title>
- <link
- rel="stylesheet"
- href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css"
- integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb"
- crossorigin="anonymous"
- >
- <script
- src="http://code.jquery.com/jquery-3.2.1.min.js"
- integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
- crossorigin="anonymous"
- ></script>
- <script
- src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
- integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
- crossorigin="anonymous"
- ></script>
- <link rel="stylesheet" href="http://esironal.github.io/cmtouch/lib/codemirror.css">
- <link rel="stylesheet" href="http://esironal.github.io/cmtouch/addon/hint/show-hint.css">
- <link rel="stylesheet" href="http://esironal.github.io/cmtouch/theme/neonsyntax.css">
- <script src="http://esironal.github.io/cmtouch/lib/codemirror.js"></script>
- <script src="http://esironal.github.io/cmtouch/addon/hint/show-hint.js"></script>
- <script src="http://esironal.github.io/cmtouch/addon/hint/xml-hint.js"></script>
- <script src="http://esironal.github.io/cmtouch/addon/hint/html-hint.js"></script>
- <script src="http://esironal.github.io/cmtouch/mode/xml/xml.js"></script>
- <script src="http://esironal.github.io/cmtouch/mode/javascript/javascript.js"></script>
- <script src="http://esironal.github.io/cmtouch/mode/css/css.js"></script>
- <script src="http://esironal.github.io/cmtouch/mode/htmlmixed/htmlmixed.js"></script>
- <script src="http://esironal.github.io/cmtouch/addon/selection/active-line.js"></script>
- <script src="http://esironal.github.io/cmtouch/addon/edit/matchbrackets.js"></script>
- <style type="text/css">
- #txtArgs {
- /* Offset: 56+48+70+16+24+8+16+38+24 */
- min-height: calc(100vh - 300px);
- }
- .CodeMirror {
- border: 1px solid #ced4da;
- border-radius: .25rem;
- }
- </style>
- </head>
- <body>
- <nav class="navbar navbar-dark bg-dark">
- <a class="navbar-brand" href="#">Тестирование сервиса квитанций</a>
- </nav>
- <div class="container pt-5">
- <form action="" method="post" class="form" id="testForm">
- <div class="form-group">
- <label for="testUrl">Адрес сервиса</label>
- <input
- placeholder="Введите адрес сервиса"
- class="form-control"
- id="testUrl"
- type="text"
- name="url"
- required=""
- value="http://localhost:8733/ReceiptService/DoReceipt"
- >
- </div>
- <div class="form-group">
- <label for="testParam">Параметр запроса</label>
- <input
- placeholder="Введите параметр запроса, который принимает JSON"
- class="form-control"
- id="testParam"
- type="text"
- name="url"
- required=""
- value="receipt"
- >
- </div>
- <div class="form-group">
- <label for="testData">Значение параметра (в JSON)</label>
- <textarea
- placeholder="Введите JSON со входными параметрами"
- class="form-control"
- id="testData"
- type="text"
- name="ARGS"
- ></textarea>
- </div>
- <button type="submit" class="btn btn-primary">Отправить</button>
- </form>
- </div>
- <script type="text/plain" id="jsonPreset">
- {
- "templateId": 0,
- "ReceiptId": "",
- "INN": "",
- "Email": "fake@mail.mail",
- "Phone": "+7 (987) 654-32-10",
- "TotalSum": 0.0,
- "PaidSum": 0.0,
- "Items": [
- {
- "Name": "",
- "Price": 0.0,
- "Quantity": 0.0,
- "Sum": 0.0
- }
- ]
- }
- </script>
- <script type="text/javascript">
- var jsonPresetNode = document.getElementById('jsonPreset');
- var jsonPreset = jsonPresetNode ? jsonPresetNode.innerHTML : '';
- jsonPreset = jsonPreset.replace(/^\s{4}/gm, '').replace(/^\s+|\s+$/g, '');
- var testDataNode = document.getElementById('testData');
- testDataNode.value = jsonPreset;
- var testUrlNode = document.getElementById('testUrl');
- var testParamNode = document.getElementById('testParam');
- cdmArgs = CodeMirror.fromTextArea(testDataNode, {
- lineNumbers: true,
- mode: {
- name: "javascript",
- json: true
- }
- });
- var onSuccess = function() {
- alert("Запрос прошел удачно. "
- + "Чтобы посмотреть подробности, откройте браузерную консоль отладки, вкладка 'Network'.");
- };
- var onError = function(xhr) {
- alert("Запрос не удался. "
- + "Чтобы посмотреть подробности, откройте браузерную консоль отладки, вкладка 'Network'.");
- };
- var testForm = $(document.getElementById('testForm'));
- testForm.submit(function(e) {
- e.preventDefault();
- var json = testDataNode.value.replace(/\s+/g, '');
- var url = testUrlNode.value;
- var param = testParamNode.value;
- var data = {};
- data[param] = json;
- $.ajax({
- type: 'post',
- url: url,
- data: data,
- success: onSuccess,
- error: onError
- });
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement