1699 lines
76 KiB
HTML
1699 lines
76 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="ru" xmlns="http://www.w3.org/1999/html" xmlns="http://www.w3.org/1999/html">
|
|
<head>
|
|
<!-- Required meta tags -->
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
<title>Dial Module: Debug</title>
|
|
|
|
<!-- Bootstrap CSS -->
|
|
<link rel="stylesheet" href="/assets/vendor/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
|
|
|
|
<link rel="stylesheet" href="/assets/css/main.min.css">
|
|
<link href="/assets/css/main.css" rel="stylesheet" type="text/css">
|
|
<link href="/assets/css/floating-labels.css" rel="stylesheet" type="text/css">
|
|
|
|
<style>
|
|
pre {color: #6c757d!important;}
|
|
</style>
|
|
|
|
<meta name="theme-color" content="#252627">
|
|
<meta itemprop="name" content="Crypto Payment Service">
|
|
<meta itemprop="description" content="BitDeals Crypto Payment Service">
|
|
<meta name="twitter:card" content="summary_large_image">
|
|
<meta name="twitter:title" content="Crypto Payment Service">
|
|
<meta name="twitter:description" content="BitDeals Crypto Payment Service">
|
|
</head>
|
|
|
|
<body class="dark-theme">
|
|
<div id="wrapper" class="container" style="text-align: left; justify-content: normal">
|
|
<div class="shadow-sm p-3 bg-dark rounded">
|
|
<h2>Deal Module</h2>
|
|
<br>
|
|
<ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
|
|
<li class="nav-item">
|
|
<a class="nav-link active" data-toggle="pill" role="tab" href="#tab-account" aria-controls="tab-account" aria-selected="true">Account</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="text-sm-center nav-link" role="tab" href="#tab-deal" aria-controls="tab-deal" aria-selected="false">Deal</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="text-sm-center nav-link" data-toggle="pill" role="tab" href="#tab-signature" aria-controls="tab-deal" aria-selected="false">Signature</a>
|
|
</li>
|
|
<li class="nav-item dropdown">
|
|
<a class="nav-link dropdown-toggle" href="#" id="btnSettings" data-toggle="dropdown" role="tab" aria-haspopup="true" aria-expanded="false">Other</a>
|
|
<div class="dropdown-menu" aria-labelledby="other">
|
|
<a class="dropdown-item" data-toggle="tab" href="#tab-config">Settings</a>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
|
|
<div class="tab-content">
|
|
<div id="tab-account" class="tab-pane active">
|
|
<nav class="navbar navbar-expand-lg navbar-dark text-muted bg-dark">
|
|
<a class="navbar-brand" href="#">Action</a>
|
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarAccount" aria-controls="navbarAccount" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarAccount">
|
|
<ul class="nav nav-tabs mr-auto">
|
|
<li class="nav-item">
|
|
<a class="nav-link active" href="#tab-account-help">Help <span class="sr-only">(current)</span></a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="#tab-account-status">Status</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" data-toggle="tab" href="#tab-account-new">New</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="#tab-account-add">Add</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="#tab-account-update">Update</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="#tab-account-delete">Delete</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="#tab-account-get">Get</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="#tab-account-list">List</a>
|
|
</li>
|
|
</ul>
|
|
<span class="navbar-text">
|
|
Account registration
|
|
</span>
|
|
</div>
|
|
</nav>
|
|
<!-- Tab panes -->
|
|
<div class="tab-content text-muted">
|
|
<div id="tab-account-help" class="tab-pane active">
|
|
<div id="action-help" class="mt-3">
|
|
<small class="form-text text-muted">Wait response...</small>
|
|
</div>
|
|
</div>
|
|
<div id="tab-account-status" class="tab-pane fade">
|
|
<div class="mt-3">
|
|
<form onsubmit="actionStatus()">
|
|
<div class="form-group row">
|
|
<label for="statusModuleAddress" class="col-sm-2 col-form-label">Module address</label>
|
|
<div class="col-sm-10">
|
|
<input type="text" readonly class="form-control-plaintext text-muted" id="statusModuleAddress" value="mjTbMV3cbjtGxYMKV2uKZpZt5v7LRp8TBJ">
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<label for="statusUserAddress" class="col-sm-2 col-form-label">User address</label>
|
|
<div class="col-sm-10">
|
|
<input type="text" class="form-control" id="statusUserAddress" placeholder="User bitcoin address">
|
|
</div>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Execute</button>
|
|
</form>
|
|
<hr>
|
|
<div id="action-status">
|
|
<small class="form-text text-muted">Press "Execute" button...</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="tab-account-new" class="tab-pane fade">
|
|
<div class="mt-3">
|
|
<form onsubmit="actionNew()">
|
|
<div class="form-row">
|
|
<div class="form-group col-md-6">
|
|
<label for="newAddress">Bitcoin address</label>
|
|
<input type="text" class="form-control" id="newAddress" placeholder="Bitcoin address" required>
|
|
</div>
|
|
<div class="form-group col-md-6">
|
|
<label for="newBitmessage">Bitmessage address</label>
|
|
<input type="text" class="form-control" id="newBitmessage" placeholder="Bitmessage address">
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="newKey">Bitcoin public key</label>
|
|
<input type="text" class="form-control" id="newKey" placeholder="Bitcoin public key">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="newPGP">PGP public key</label>
|
|
<textarea class="form-control" id="newPGP" rows="5" placeholder="PGP public key"></textarea>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="newURL">URL List</label>
|
|
<textarea class="form-control" id="newURL" rows="5" placeholder="URL List"></textarea>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Execute</button>
|
|
</form>
|
|
<hr>
|
|
<div id="action-new">
|
|
<small class="form-text text-muted">Press "Execute" button...</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="tab-account-add" class="tab-pane fade">
|
|
<div class="mt-3">
|
|
<form onsubmit="actionAdd()">
|
|
<div class="form-row">
|
|
<div class="form-group col-md-6">
|
|
<label for="addAddress">User Bitcoin address</label>
|
|
<input type="text" class="form-control" id="addAddress" aria-describedby="addAddressHelp" placeholder="Enter Bitcoin address" required>
|
|
<small id="addAddressHelp" class="form-text text-muted">Please enter the address of the account for whom you want to add data.</small>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="addKey">Bitcoin public key</label>
|
|
<input type="text" class="form-control" id="addKey" placeholder="Bitcoin public key">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="addPGP">PGP public key</label>
|
|
<textarea class="form-control" id="addPGP" rows="5" placeholder="PGP public key"></textarea>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Execute</button>
|
|
</form>
|
|
<hr>
|
|
<div id="action-add">
|
|
<small class="form-text text-muted">Press "Execute" button...</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="tab-account-update" class="tab-pane fade">
|
|
<div class="mt-3">
|
|
<form onsubmit="actionUpdate()">
|
|
<div class="form-row">
|
|
<div class="form-group col-md-6">
|
|
<label for="updateAddress">User Bitcoin address</label>
|
|
<input type="text" class="form-control" id="updateAddress" aria-describedby="updateAddressHelp" placeholder="Enter Bitcoin address" required>
|
|
<small id="updateAddressHelp" class="form-text text-muted">Please enter the address of the account whose data you want to update.</small>
|
|
</div>
|
|
<div class="form-group col-md-6">
|
|
<label for="updateDate">Now</label>
|
|
<input type="text" class="form-control" id="updateDate" aria-describedby="updateDateHelp" placeholder="Now">
|
|
<small id="updateDateHelp" class="form-text text-muted">Format: YYYY-MM-DD [HH24:MM:SS]</small>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="updatePGP">PGP public key</label>
|
|
<textarea class="form-control" id="updatePGP" rows="5" placeholder="PGP public key"></textarea>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="updateURL">URL List</label>
|
|
<textarea class="form-control" id="updateURL" rows="5" aria-describedby="updateURLHelp" placeholder="URL List"></textarea>
|
|
<small id="updateURLHelp" class="form-text text-muted">Add(+) or delete(-) URL; format: http[s]://<tstring>.</small>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="updateSign">Signature</label>
|
|
<textarea class="form-control" id="updateSign" rows="5" aria-describedby="updateSignHelp" placeholder="Signature" required></textarea>
|
|
<small id="updateSignHelp" class="form-text text-muted">Bitcoin signature for message text (use private key).</small>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Execute</button>
|
|
</form>
|
|
<hr>
|
|
<div id="action-update">
|
|
<small class="form-text text-muted">Press "Execute" button...</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="tab-account-delete" class="tab-pane fade">
|
|
<div class="mt-3">
|
|
<form onsubmit="actionDelete()">
|
|
<div class="form-row">
|
|
<div class="form-group col-md-6">
|
|
<label for="deleteAddress">User Bitcoin address</label>
|
|
<input type="text" class="form-control" id="deleteAddress" aria-describedby="deleteAddressHelp" placeholder="Enter Bitcoin address" required>
|
|
<small id="deleteAddressHelp" class="form-text text-muted">Please enter the address of the account whose data you want to delete.</small>
|
|
</div>
|
|
<div class="form-group col-md-6">
|
|
<label for="deleteDate">Now</label>
|
|
<input type="text" class="form-control" id="deleteDate" aria-describedby="deleteDateHelp" placeholder="Now">
|
|
<small id="deleteDateHelp" class="form-text text-muted">Format: YYYY-MM-DD [HH24:MM:SS]</small>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="deleteFlags">Flags</label>
|
|
<textarea class="form-control" id="deleteFlags" rows="3" aria-describedby="deleteFlaHelp" placeholder="Flags"></textarea>
|
|
<small id="deleteFlagsHelp" class="form-text text-muted">Values: -account</small>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="deleteSign">Signature</label>
|
|
<textarea class="form-control" id="deleteSign" rows="5" aria-describedby="deleteSignHelp" placeholder="Signature" required></textarea>
|
|
<small id="deleteSignHelp" class="form-text text-muted">Bitcoin signature for message text (use private key).</small>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Execute</button>
|
|
</form>
|
|
<hr>
|
|
<div id="action-delete">
|
|
<small class="form-text text-muted">Press "Execute" button...</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="tab-account-get" class="tab-pane fade">
|
|
<div class="mt-3">
|
|
<form onsubmit="actionAccountGet()">
|
|
<div class="form-group row">
|
|
<label for="account-get-ModuleAddress" class="col-sm-2 col-form-label">Module address</label>
|
|
<div class="col-sm-10">
|
|
<input type="text" class="form-control" id="account-get-ModuleAddress" required>
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<label for="account-get-UserAddress" class="col-sm-2 col-form-label">User address</label>
|
|
<div class="col-sm-10">
|
|
<input type="text" class="form-control" id="account-get-UserAddress" placeholder="User bitcoin address" required>
|
|
</div>
|
|
</div>
|
|
<button id="btnAccountGet" type="submit" class="btn btn-primary">Execute</button>
|
|
</form>
|
|
<hr>
|
|
<div id="action-account-get">
|
|
<small class="form-text text-muted">Press "Execute" button...</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="tab-account-list" class="tab-pane fade">
|
|
<div class="mt-3">
|
|
<form onsubmit="actionAccountList()">
|
|
<div class="form-group row">
|
|
<label for="account-list-ModuleAddress" class="col-sm-2 col-form-label">Module address</label>
|
|
<div class="col-sm-10">
|
|
<input type="text" class="form-control" id="account-list-ModuleAddress" required>
|
|
</div>
|
|
</div>
|
|
<button id="btnAccountList" type="submit" class="btn btn-primary">Execute</button>
|
|
</form>
|
|
<hr>
|
|
<div id="action-account-list" class="table-responsive">
|
|
<small class="form-text text-muted">Press "Execute" button...</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="tab-deal" class="tab-pane fade">
|
|
<nav class="navbar navbar-expand-lg navbar-dark text-muted bg-dark">
|
|
<a class="navbar-brand" href="#">Format</a>
|
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarDeal" aria-controls="navbarDeal" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarDeal">
|
|
<ul class="nav nav-tabs mr-auto">
|
|
<li class="nav-item">
|
|
<a class="nav-link active" href="#tab-deal-form">Form</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" data-toggle="tab" href="#tab-deal-json">JSON</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" data-toggle="tab" href="#tab-deal-yaml">YAML</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link ml-2" data-toggle="tab" href="#tab-deal-status">Status</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link ml-2" data-toggle="tab" href="#tab-deal-get">Get</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" data-toggle="tab" href="#tab-deal-list">List</a>
|
|
</li>
|
|
</ul>
|
|
<span class="navbar-text">
|
|
Deal
|
|
</span>
|
|
</div>
|
|
</nav>
|
|
<!-- Tab panes -->
|
|
<div class="tab-content">
|
|
<div id="tab-deal-form" class="tab-pane active">
|
|
<form onsubmit="executeDealForm()">
|
|
<div class="card text-muted bg-dark mb-3">
|
|
<div class="card-header">
|
|
Deal
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="form-row">
|
|
<div class="form-group col-md-6">
|
|
<label for="formOrder" class="col-form-label">Order:</label>
|
|
<select id="formOrder" class="form-control" onchange="OnChangeOrder()">
|
|
<option selected>Create</option>
|
|
<option>Pay</option>
|
|
<option>Complete</option>
|
|
<option>Cancel</option>
|
|
<option>Feedback</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group col-md-6">
|
|
<label for="formType" class="col-form-label">Type:</label>
|
|
<select id="formType" class="form-control" onchange="OnChangeType()">
|
|
<option selected>Prepayment</option>
|
|
<option>Postpayment</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="form-row">
|
|
<div class="form-group col-md-6">
|
|
<label for="formAt" class="col-form-label">At:</label>
|
|
<input type="text" class="form-control" id="formAt" placeholder="http://host:port" required>
|
|
</div>
|
|
<div class="form-group col-md-6">
|
|
<label for="formDate" class="col-form-label">Date:</label>
|
|
<div class="input-group mb-3">
|
|
<input type="text" class="form-control" id="formDate" placeholder="YYYY-MM-DD HH24:MM:SS UTC" required>
|
|
<div class="input-group-append">
|
|
<button class="btn btn-outline-secondary" type="button" id="button-update-form-date" onclick="updateFormDate()">Обновить</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card text-muted bg-dark mb-3">
|
|
<div class="card-header">
|
|
Seller
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="form-row">
|
|
<div class="form-group col-5">
|
|
<label for="formSellerAddress" class="col-form-label">Address:</label>
|
|
<input type="text" class="form-control" id="formSellerAddress" placeholder="Bitcoin address" required>
|
|
</div>
|
|
<div class="form-group col-2">
|
|
<label for="formSellerRating" class="col-form-label">Rating:</label>
|
|
<input type="text" class="form-control" id="formSellerRating" placeholder="count, percent%" disabled>
|
|
</div>
|
|
<div class="form-group col">
|
|
<label for="formSellerSignature" class="col-form-label">Signature:</label>
|
|
<input type="text" class="form-control" id="formSellerSignature" placeholder="Signature for order: Cancel" disabled>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card text-muted bg-dark mb-3">
|
|
<div class="card-header">
|
|
Customer
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="form-row">
|
|
<div class="form-group col-5">
|
|
<label for="formCustomerAddress" class="col-form-label">Address:</label>
|
|
<input type="text" class="form-control" id="formCustomerAddress" placeholder="Bitcoin address" required>
|
|
</div>
|
|
<div class="form-group col-2">
|
|
<label for="formCustomerRating" class="col-form-label">Rating:</label>
|
|
<input type="text" class="form-control" id="formCustomerRating" placeholder="count, percent%" disabled>
|
|
</div>
|
|
<div class="form-group col">
|
|
<label for="formCustomerSignature" class="col-form-label">Signature:</label>
|
|
<input type="text" class="form-control" id="formCustomerSignature" placeholder="Signature for order: Feedback" disabled>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card text-muted bg-dark mb-3">
|
|
<div class="card-header">
|
|
Payment
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="form-row">
|
|
<div class="form-group col-5">
|
|
<label for="formPaymentAddress" class="col-form-label">Address:</label>
|
|
<input type="text" class="form-control" id="formPaymentAddress" placeholder="Bitcoin address" disabled>
|
|
</div>
|
|
<div class="form-group col">
|
|
<label for="formPaymentUntil" class="col-form-label">Until:</label>
|
|
<input type="text" class="form-control" id="formPaymentUntil" placeholder="YYYY-MM-DD HH24:MM:SS UTC" disabled>
|
|
</div>
|
|
<div class="form-group col">
|
|
<label for="formPaymentSum" class="col-form-label">Sum:</label>
|
|
<input type="text" class="form-control" id="formPaymentSum" placeholder="0.00000000" required>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card text-muted bg-dark mb-3">
|
|
<div class="card-header">
|
|
Feedback
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="form-row">
|
|
<div class="form-group col">
|
|
<label for="formFeedbackLeaveBefore" class="col-form-label">Leave-Before:</label>
|
|
<input type="text" class="form-control" id="formFeedbackLeaveBefore" placeholder="YYYY-MM-DD HH24:MM:SS UTC" disabled>
|
|
</div>
|
|
<div class="form-group col">
|
|
<label for="formFeedbackStatus" class="col-form-label">Status:</label>
|
|
<select id="formFeedbackStatus" class="form-control" disabled>
|
|
<option>Negative</option>
|
|
<option selected>Neutral</option>
|
|
<option>Positive</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="formFeedbackComments" class="col-form-label">Comments:</label>
|
|
<input type="text" class="form-control" id="formFeedbackComments" placeholder="Sample text" disabled>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<hr>
|
|
<button id="btnDealForm" type="submit" class="btn btn-primary">Execute</button>
|
|
</form>
|
|
<hr>
|
|
<div id="deal-form">
|
|
<small class="form-text text-muted">Press "Execute" button...</small>
|
|
</div>
|
|
</div>
|
|
<div id="tab-deal-json" class="tab-pane fade">
|
|
<form onsubmit="executeDealJSON()">
|
|
<div class="form-group">
|
|
<label for="dealJSON">Input:</label>
|
|
<textarea class="form-control" id="dealJSON" rows="20" placeholder="JSON" required></textarea>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Execute</button>
|
|
</form>
|
|
<hr>
|
|
<div id="deal-json" class="mt-3">
|
|
<small id="btnDealJSON" class="form-text text-muted">Press "Execute" button...</small>
|
|
</div>
|
|
</div>
|
|
<div id="tab-deal-yaml" class="tab-pane fade">
|
|
<form onsubmit="executeDealYAML()">
|
|
<div class="form-group">
|
|
<label for="dealYAML">Input:</label>
|
|
<textarea class="form-control" id="dealYAML" rows="20" placeholder="YAML" required></textarea>
|
|
</div>
|
|
<button id="btnDealYAML" type="submit" class="btn btn-primary">Execute</button>
|
|
</form>
|
|
<hr>
|
|
<div id="deal-yaml" class="mt-3">
|
|
<small class="form-text text-muted">Press "Execute" button...</small>
|
|
</div>
|
|
</div>
|
|
<div id="tab-deal-status" class="tab-pane fade">
|
|
<div class="mt-3">
|
|
<form onsubmit="actionDealStatus()">
|
|
<div class="form-group row">
|
|
<label for="deal-status-ModuleAddress" class="col-sm-2 col-form-label">Module address</label>
|
|
<div class="col-sm-10">
|
|
<input type="text" readonly class="form-control-plaintext text-muted" id="deal-status-ModuleAddress">
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<label for="deal-status-Address" class="col-sm-2 col-form-label">Payment</label>
|
|
<div class="col-sm-10">
|
|
<input type="text" class="form-control" id="deal-status-Address" placeholder="Deal payment address" required>
|
|
</div>
|
|
</div>
|
|
<button id="btnDealStatus" type="submit" class="btn btn-primary">Execute</button>
|
|
</form>
|
|
<hr>
|
|
<div id="action-deal-status">
|
|
<small class="form-text text-muted">Press "Execute" button...</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="tab-deal-get" class="tab-pane fade">
|
|
<div class="mt-3">
|
|
<form onsubmit="actionDealGet()">
|
|
<div class="form-group row">
|
|
<label for="deal-get-ModuleAddress" class="col-sm-2 col-form-label">Module address</label>
|
|
<div class="col-sm-10">
|
|
<input type="text" class="form-control" id="deal-get-ModuleAddress" required>
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<label for="deal-get-Payment" class="col-sm-2 col-form-label">Payment</label>
|
|
<div class="col-sm-10">
|
|
<input type="text" class="form-control" id="deal-get-Payment" placeholder="Deal payment address" required>
|
|
</div>
|
|
</div>
|
|
<button id="btnDealGet" type="submit" class="btn btn-primary">Execute</button>
|
|
</form>
|
|
<hr>
|
|
<div id="action-deal-get" class="table-responsive">
|
|
<small class="form-text text-muted">Press "Execute" button...</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="tab-deal-list" class="tab-pane fade">
|
|
<div class="mt-3">
|
|
<form onsubmit="actionDealList()">
|
|
<div class="form-group row">
|
|
<label for="deal-list-ModuleAddress" class="col-sm-2 col-form-label">Module address</label>
|
|
<div class="col-sm-10">
|
|
<input type="text" class="form-control" id="deal-list-ModuleAddress">
|
|
</div>
|
|
</div>
|
|
<button id="btnDealList" type="submit" class="btn btn-primary">Execute</button>
|
|
</form>
|
|
<hr>
|
|
<div id="action-deal-list" class="table-responsive">
|
|
<small class="form-text text-muted">Press "Execute" button...</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="tab-signature" class="tab-pane fade">
|
|
<form onsubmit="checkSignature()">
|
|
<div class="form-group">
|
|
<label for="pgp-clear-text">Input:</label>
|
|
<textarea class="form-control" id="pgp-clear-text" rows="20" placeholder="PGP ClearText" required></textarea>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary">Check</button>
|
|
</form>
|
|
<hr>
|
|
<div id="signature-json" class="mt-3">
|
|
<small id="btnCheckSignature" class="form-text text-muted">Press "Check" button...</small>
|
|
</div>
|
|
</div>
|
|
<div id="tab-config" class="tab-pane fade">
|
|
<h3>Settings</h3>
|
|
<div class="mt-3">
|
|
<form>
|
|
<div class="form-row">
|
|
<div class="form-group col-md-4">
|
|
<label for="apiURL">API</label>
|
|
<input type="text" class="form-control" id="apiURL" aria-describedby="apiURLHelp" placeholder="Default: /api/v1" value="/api/v1" required>
|
|
<small id="apiURLHelp" class="form-text text-muted">Deal Module API URL.</small>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="serverURL">Server</label>
|
|
<input type="text" class="form-control" id="serverURL" aria-describedby="serverURLHelp" placeholder="Default: http://localhost:4977">
|
|
<small id="serverURLHelp" class="form-text text-muted">BPS server URL.</small>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="userAddress">User Bitcoin address</label>
|
|
<input type="text" class="form-control" id="userAddress">
|
|
<small id="userAddressHelp" class="form-text text-muted">User Bitcoin address.</small>
|
|
</div>
|
|
</div>
|
|
<div class="custom-control custom-switch">
|
|
<input type="checkbox" checked class="custom-control-input" id="pgp">
|
|
<label class="custom-control-label" for="pgp">PGP</label>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="footer">
|
|
<hr>
|
|
<p class="text-center small" >BitDeals Payment Service</p>
|
|
</div>
|
|
|
|
<!-- Optional JavaScript -->
|
|
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
|
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
|
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
|
<script>
|
|
const spinner = `<div id="spinner" class="text-center">
|
|
<div class="spinner-border" role="status">
|
|
<span class="sr-only">Loading...</span>
|
|
</div>
|
|
</div>
|
|
`;
|
|
|
|
async function CheckResponse(json, status) {
|
|
let error;
|
|
let message;
|
|
let location;
|
|
|
|
if (json.hasOwnProperty('error')) {
|
|
error = json['error'];
|
|
if (typeof error === 'object') {
|
|
message = error["message"];
|
|
} else {
|
|
message = json["error_description"];
|
|
}
|
|
}
|
|
|
|
if (status === 400) {
|
|
return undefined;
|
|
} else if (status === 401) {
|
|
//location = '/welcome/';
|
|
return undefined;
|
|
} else if (status === 403) {
|
|
// Refresh token
|
|
} else if (status === 404) {
|
|
//location = `/error/404/?error=not_found&error_description=${encodeURIComponent(message)}`;
|
|
} else if (status === 500) {
|
|
location = `/error/500/?error=server_error&error_description=${encodeURIComponent(message)}`;
|
|
} else if (status === 504) {
|
|
return undefined;
|
|
} else {
|
|
location = `/error/?code=${status}&error=invalid_request&error_description=${encodeURIComponent(message)}`;
|
|
}
|
|
|
|
return location;
|
|
}
|
|
|
|
/**
|
|
* @return {json}
|
|
*/
|
|
async function AsyncFetch (path, method = "GET", body = null, headers = {}) {
|
|
|
|
// await response of fetch call
|
|
let response = await fetch(path, {
|
|
method: method,
|
|
headers: headers,
|
|
body: body,
|
|
mode: 'cors',
|
|
cache: 'no-store'
|
|
});
|
|
|
|
const json = await response.json();
|
|
|
|
if (response.ok)
|
|
return json;
|
|
|
|
console.log(method + ' ' + path);
|
|
console.log(json);
|
|
|
|
const location = await CheckResponse(json, response.status);
|
|
|
|
if (empty(location))
|
|
return json;
|
|
|
|
document.location.replace(location);
|
|
}
|
|
|
|
function empty(e) {
|
|
switch (e) {
|
|
case "":
|
|
case 0:
|
|
case false:
|
|
case null:
|
|
case undefined:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function getFormattedDate(date) {
|
|
const year = date.getUTCFullYear();
|
|
|
|
let month = (1 + date.getUTCMonth()).toString();
|
|
month = month.length > 1 ? month : '0' + month;
|
|
|
|
let day = date.getUTCDate().toString();
|
|
day = day.length > 1 ? day : '0' + day;
|
|
|
|
return year + '-' + month + '-' + day;
|
|
}
|
|
|
|
function getFormattedDateTime(date) {
|
|
const year = date.getUTCFullYear();
|
|
|
|
let month = (1 + date.getUTCMonth()).toString();
|
|
month = month.length > 1 ? month : '0' + month;
|
|
|
|
let day = date.getUTCDate().toString();
|
|
day = day.length > 1 ? day : '0' + day;
|
|
|
|
let hours = date.getUTCHours().toString();
|
|
hours = hours.length > 1 ? hours : '0' + hours;
|
|
|
|
let minutes = date.getUTCMinutes().toString();
|
|
minutes = minutes.length > 1 ? minutes : '0' + minutes;
|
|
|
|
let seconds = date.getUTCSeconds().toString();
|
|
seconds = seconds.length > 1 ? seconds : '0' + seconds;
|
|
|
|
return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
|
|
}
|
|
|
|
/**
|
|
* @return {string}
|
|
*/
|
|
function JsonToHTML(json) {
|
|
return '<html lang="ru"><body><pre><code>' + JSON.stringify(json, undefined, 4) + '</code></pre></body></html>';
|
|
}
|
|
|
|
/**
|
|
* @return {string}
|
|
*/
|
|
function JsonToTableOne(json) {
|
|
let i, txt;
|
|
|
|
txt = '<table class="table table-sm table-striped">';
|
|
txt += '<thead>';
|
|
txt += '<tr>';
|
|
txt += '<th scope="col">key</th>';
|
|
txt += `<th scope="col">value</th>`;
|
|
txt += '</tr>';
|
|
txt += '</thead>';
|
|
|
|
txt += '<tbody>';
|
|
for (i in json) {
|
|
const value = json[i];
|
|
txt += '<tr>';
|
|
txt += `<th scope="row">${i}</th>`;
|
|
if (typeof value === 'object') {
|
|
txt += `<td scope="row">${JSON.stringify(value, ['name'])}</td>`;
|
|
} else {
|
|
txt += `<td scope="row">${value}</td>`;
|
|
}
|
|
txt += '</tr>';
|
|
}
|
|
|
|
txt += '</tbody>';
|
|
txt += '</table>';
|
|
|
|
return txt;
|
|
}
|
|
|
|
/**
|
|
* @return {string}
|
|
*/
|
|
function JsonToTable(json) {
|
|
let obj, x, i, txt, index;
|
|
|
|
txt = '<table class="table table-sm table-hover table-striped">';
|
|
txt += '<thead>';
|
|
txt += '<tr>';
|
|
|
|
txt += '<th scope="col">#</th>';
|
|
|
|
obj = json[0];
|
|
for (i in obj)
|
|
txt += `<th scope="col">${i}</th>`;
|
|
|
|
txt += '</tr>';
|
|
txt += '</thead>';
|
|
|
|
txt += '<tbody>';
|
|
|
|
index = 0;
|
|
for (x in json) {
|
|
txt += '<tr>';
|
|
|
|
txt += `<th scope="row">${++index}</th>`;
|
|
|
|
obj = json[x];
|
|
|
|
for (i in obj) {
|
|
txt += `<td scope="row">${obj[i]}</td>`;
|
|
}
|
|
|
|
txt += '</tr>';
|
|
}
|
|
|
|
txt += '</tbody>';
|
|
txt += '</table>';
|
|
|
|
return txt;
|
|
}
|
|
|
|
/**
|
|
* @return {string}
|
|
*/
|
|
function JsonToPayload(json) {
|
|
const payload = json['payload'];
|
|
return window.atob(payload);
|
|
}
|
|
|
|
/**
|
|
* @return {string}
|
|
*/
|
|
function PayloadToHTML(payload) {
|
|
return '<html lang="ru"><body><pre><code>' + payload + '</code></pre></body></html>';
|
|
}
|
|
|
|
$('.nav-pills a[href="#tab-deal"]').click(function(){
|
|
actionDeal();
|
|
updateFormDate();
|
|
$(this).tab('show');
|
|
});
|
|
|
|
$('.nav-tabs a[href="#tab-deal-form"]').click(function(){
|
|
$(this).tab('show');
|
|
});
|
|
|
|
// Select tabs Help
|
|
$('.nav-tabs a[href="#tab-account-help"]').click(function(){
|
|
actionHelp();
|
|
$(this).tab('show');
|
|
});
|
|
|
|
// Select tabs status
|
|
$('.nav-tabs a[href="#tab-account-status"]').click(function(){
|
|
const address = $("input[id='userAddress']").val();
|
|
let objectAddress = $("input[id='statusUserAddress']");
|
|
if (empty(objectAddress.val()))
|
|
objectAddress.val(address);
|
|
$(this).tab('show');
|
|
});
|
|
|
|
// Select tabs status
|
|
$('.nav-tabs a[href="#tab-account-add"]').click(function(){
|
|
const address = $("input[id='userAddress']").val();
|
|
let objectAddress = $("input[id='addAddress']");
|
|
if (empty(objectAddress.val()))
|
|
objectAddress.val(address);
|
|
$(this).tab('show');
|
|
});
|
|
|
|
// Select tabs status
|
|
$('.nav-tabs a[href="#tab-account-update"]').click(function(){
|
|
const address = $("input[id='userAddress']").val();
|
|
let objectAddress = $("input[id='updateAddress']");
|
|
if (empty(objectAddress.val()))
|
|
objectAddress.val(address);
|
|
$("input[id='updateDate']").val(getFormattedDate(new Date()));
|
|
$(this).tab('show');
|
|
});
|
|
|
|
// Select tabs status
|
|
$('.nav-tabs a[href="#tab-account-delete"]').click(function(){
|
|
const address = $("input[id='userAddress']").val();
|
|
let objectAddress = $("input[id='deleteAddress']");
|
|
if (empty(objectAddress.val()))
|
|
objectAddress.val(address);
|
|
$("input[id='deleteDate']").val(getFormattedDate(new Date()));
|
|
$("textarea[id='deleteFlags']").val('-account');
|
|
$(this).tab('show');
|
|
});
|
|
|
|
// Select tabs status
|
|
$('.nav-tabs a[href="#tab-account-get"]').click(function(){
|
|
const moduleAddress = $("input[id='statusModuleAddress']").val();
|
|
$("input[id='account-get-ModuleAddress']").val(moduleAddress);
|
|
$(this).tab('show');
|
|
});
|
|
|
|
// Select tabs status
|
|
$('.nav-tabs a[href="#tab-account-list"]').click(function(){
|
|
const moduleAddress = $("input[id='statusModuleAddress']").val();
|
|
$("input[id='account-list-ModuleAddress']").val(moduleAddress);
|
|
$(this).tab('show');
|
|
});
|
|
|
|
// Select tabs status
|
|
$('.nav-tabs a[href="#tab-deal-status"]').click(function(){
|
|
$(this).tab('show');
|
|
});
|
|
|
|
// Select tabs status
|
|
$('.nav-tabs a[href="#tab-deal-get"]').click(function(){
|
|
$(this).tab('show');
|
|
});
|
|
|
|
// Select tabs status
|
|
$('.nav-tabs a[href="#tab-deal-list"]').click(function(){
|
|
$(this).tab('show');
|
|
});
|
|
|
|
function actionHelp() {
|
|
const api = $("input[id='apiURL']").val();
|
|
const server = $("input[id='serverURL']").val();
|
|
|
|
let settings = "";
|
|
if (!empty(server))
|
|
settings = '?server=' + server;
|
|
|
|
const request = $("#action-help");
|
|
request.html(spinner);
|
|
|
|
AsyncFetch(api + '/help' + settings)
|
|
.then(json => request.html(JsonToPayload(json)))
|
|
.catch(reason => request.html(reason.message));
|
|
}
|
|
|
|
function actionStatus() {
|
|
const address = $("input[id='statusUserAddress']").val();
|
|
|
|
const api = $("input[id='apiURL']").val();
|
|
const server = $("input[id='serverURL']").val();
|
|
|
|
let settings = "";
|
|
if (!empty(server))
|
|
settings = '?server=' + server;
|
|
if (!empty(address)) {
|
|
settings += empty(settings) ? '?' : '&';
|
|
settings += 'address=' + address;
|
|
}
|
|
|
|
const request = $("#action-status");
|
|
request.html(spinner);
|
|
|
|
AsyncFetch(api + '/account/status' + settings)
|
|
.then(json => request.html(JsonToPayload(json)))
|
|
.catch(reason => request.html(reason.message));
|
|
}
|
|
|
|
function actionNew() {
|
|
const address = $("input[id='newAddress']").val();
|
|
const bitmessage = $("input[id='newBitmessage']").val();
|
|
const key = $("input[id='newKey']").val();
|
|
const pgp = $("textarea[id='newPGP']").val();
|
|
const url = $("textarea[id='newURL']").val();
|
|
|
|
$("input[id='userAddress']").val(address);
|
|
|
|
let formData = new FormData();
|
|
formData.append('address', address);
|
|
|
|
if (!empty(bitmessage) ) {
|
|
formData.append('bitmessage', bitmessage);
|
|
}
|
|
|
|
if (!empty(key) ) {
|
|
formData.append('key', key);
|
|
}
|
|
|
|
if (!empty(pgp) ) {
|
|
formData.append('pgp', pgp);
|
|
}
|
|
|
|
if (!empty(url) ) {
|
|
formData.append('url', url);
|
|
}
|
|
|
|
const api = $("input[id='apiURL']").val();
|
|
const server = $("input[id='serverURL']").val();
|
|
|
|
let settings = "";
|
|
if (!empty(server))
|
|
settings = '?server=' + server;
|
|
if ($('input[id="pgp"]').prop("checked") === false) {
|
|
settings += empty(settings) ? '?' : '&';
|
|
settings += 'pgp=off'
|
|
}
|
|
|
|
const request = $("#action-new");
|
|
request.html(spinner);
|
|
|
|
AsyncFetch(api + '/account/new' + settings, 'POST', formData, {'Content-Type': 'multipart/form-data'})
|
|
.then(json => request.html(JsonToPayload(json)))
|
|
.catch(reason => request.html(reason.message));
|
|
}
|
|
|
|
function actionAdd() {
|
|
const address = $("input[id='addAddress']").val();
|
|
const key = $("input[id='addKey']").val();
|
|
const pgp = $("textarea[id='addPGP']").val();
|
|
|
|
let formData = new FormData();
|
|
|
|
if (!empty(key) ) {
|
|
formData.append('key', key);
|
|
}
|
|
|
|
if (!empty(pgp) ) {
|
|
formData.append('pgp', pgp);
|
|
}
|
|
|
|
const api = $("input[id='apiURL']").val();
|
|
const server = $("input[id='serverURL']").val();
|
|
|
|
let settings = '?address=' + address;
|
|
if (!empty(server))
|
|
settings += '&server=' + server;
|
|
|
|
if ($('input[id="pgp"]').prop("checked") === false) {
|
|
settings += '&pgp=off'
|
|
}
|
|
|
|
const request = $("#action-add");
|
|
request.html(spinner);
|
|
|
|
AsyncFetch(api + '/account/add' + settings, 'POST', formData, {'Content-Type': 'multipart/form-data'})
|
|
.then(json => request.html(JsonToPayload(json)))
|
|
.catch(reason => request.html(reason.message));
|
|
}
|
|
|
|
function actionUpdate() {
|
|
const address = $("input[id='updateAddress']").val();
|
|
const date = $("input[id='updateDate']").val();
|
|
const bitmessage = $("input[id='updateBitmessage']").val();
|
|
const pgp = $("textarea[id='updatePGP']").val();
|
|
const url = $("textarea[id='updateURL']").val();
|
|
const sign = $("textarea[id='updateSign']").val();
|
|
|
|
let formData = new FormData();
|
|
|
|
formData.append('date', date);
|
|
|
|
if (!empty(bitmessage) ) {
|
|
formData.append('bitmessage', bitmessage);
|
|
}
|
|
|
|
if (!empty(pgp) ) {
|
|
formData.append('pgp', pgp);
|
|
}
|
|
|
|
if (!empty(url) ) {
|
|
formData.append('url', url);
|
|
}
|
|
|
|
formData.append('sign', sign);
|
|
|
|
const api = $("input[id='apiURL']").val();
|
|
const server = $("input[id='serverURL']").val();
|
|
|
|
let settings = '?address=' + address;
|
|
if (!empty(server))
|
|
settings += '&server=' + server;
|
|
|
|
if ($('input[id="pgp"]').prop("checked") === false) {
|
|
settings += '&pgp=off'
|
|
}
|
|
|
|
const request = $("#action-update");
|
|
request.html(spinner);
|
|
|
|
AsyncFetch(api + '/account/update' + settings, 'POST', formData, {'Content-Type': 'multipart/form-data'})
|
|
.then(json => request.html(JsonToPayload(json)))
|
|
.catch(reason => request.html(reason.message));
|
|
}
|
|
|
|
function actionDelete() {
|
|
const address = $("input[id='deleteAddress']").val();
|
|
const date = $("input[id='deleteDate']").val();
|
|
const flags = $("textarea[id='deleteFlags']").val();
|
|
const sign = $("textarea[id='deleteSign']").val();
|
|
|
|
let formData = new FormData();
|
|
|
|
formData.append('date', date);
|
|
formData.append('flags', flags);
|
|
formData.append('sign', sign);
|
|
|
|
const api = $("input[id='apiURL']").val();
|
|
const server = $("input[id='serverURL']").val();
|
|
|
|
let settings = '?address=' + address;
|
|
if (!empty(server))
|
|
settings += '&server=' + server;
|
|
|
|
if ($('input[id="pgp"]').prop("checked") === false) {
|
|
settings += '&pgp=off'
|
|
}
|
|
|
|
const request = $("#action-delete");
|
|
request.html(spinner);
|
|
|
|
AsyncFetch(api + '/account/delete' + settings, 'POST', formData, {'Content-Type': 'multipart/form-data'})
|
|
.then(json => request.html(JsonToPayload(json)))
|
|
.catch(reason => request.html(reason.message));
|
|
}
|
|
|
|
function updateFormDate() {
|
|
let formDate = $("input[id='formDate']");
|
|
let formPaymentUntil = $("input[id='formPaymentUntil']");
|
|
let formFeedbackLeaveBefore = $("input[id='formFeedbackLeaveBefore']");
|
|
|
|
formDate.val(getFormattedDateTime(new Date()) + ' UTC');
|
|
formPaymentUntil.val(getFormattedDateTime(new Date(Date.now() + 3600000)) + ' UTC');
|
|
formFeedbackLeaveBefore.val(getFormattedDateTime(new Date(Date.now() + 24 * 3600000)) + ' UTC');
|
|
}
|
|
|
|
function actionDeal() {
|
|
let parser = document.createElement('a');
|
|
parser.href = window.location;
|
|
|
|
let formAt = $("input[id='formAt']");
|
|
formAt.val(parser.protocol + '//' + parser.host);
|
|
|
|
const moduleAddress = $("input[id='statusModuleAddress']").val();
|
|
$("input[id='deal-status-ModuleAddress']").val(moduleAddress);
|
|
$("input[id='deal-get-ModuleAddress']").val(moduleAddress);
|
|
$("input[id='deal-list-ModuleAddress']").val(moduleAddress);
|
|
}
|
|
|
|
function OnChangeOrder() {
|
|
const formOrder = $("select[id='formOrder']").val();
|
|
|
|
let formSellerRating = $("input[id='formSellerRating']");
|
|
let formSellerSignature = $("input[id='formSellerSignature']");
|
|
let formCustomerRating = $("input[id='formCustomerRating']");
|
|
let formCustomerSignature = $("input[id='formCustomerSignature']");
|
|
let formPaymentAddress = $("input[id='formPaymentAddress']");
|
|
let formPaymentUntil = $("input[id='formPaymentUntil']");
|
|
let formFeedbackLeaveBefore = $("input[id='formFeedbackLeaveBefore']");
|
|
let formFeedbackStatus = $("select[id='formFeedbackStatus']");
|
|
let formFeedbackComments = $("input[id='formFeedbackComments']");
|
|
|
|
if (formOrder === 'Create') {
|
|
formSellerRating.prop('disabled', true);
|
|
formSellerSignature.prop('disabled', true);
|
|
formCustomerRating.prop('disabled', true);
|
|
formCustomerSignature.prop('disabled', true);
|
|
formPaymentAddress.prop('disabled', true);
|
|
formPaymentUntil.prop('disabled', true);
|
|
formFeedbackLeaveBefore.prop('disabled', true);
|
|
formFeedbackStatus.prop('disabled', true);
|
|
formFeedbackComments.prop('disabled', true);
|
|
} else if (formOrder === 'Pay') {
|
|
formSellerRating.prop('disabled', false);
|
|
formSellerSignature.prop('disabled', true);
|
|
formCustomerRating.prop('disabled', false);
|
|
formCustomerSignature.prop('disabled', true);
|
|
formPaymentAddress.prop('disabled', false);
|
|
formPaymentUntil.prop('disabled', false);
|
|
formFeedbackLeaveBefore.prop('disabled', true);
|
|
formFeedbackStatus.prop('disabled', true);
|
|
formFeedbackComments.prop('disabled', true);
|
|
} else if (formOrder === 'Complete') {
|
|
formSellerRating.prop('disabled', false);
|
|
formSellerSignature.prop('disabled', true);
|
|
formCustomerRating.prop('disabled', false);
|
|
formCustomerSignature.prop('disabled', true);
|
|
formPaymentAddress.prop('disabled', false);
|
|
formPaymentUntil.prop('disabled', false);
|
|
formFeedbackLeaveBefore.prop('disabled', false);
|
|
formFeedbackStatus.prop('disabled', false);
|
|
formFeedbackComments.prop('disabled', false);
|
|
} else if (formOrder === 'Cancel') {
|
|
formSellerRating.prop('disabled', false);
|
|
formSellerSignature.prop('disabled', false);
|
|
formCustomerRating.prop('disabled', false);
|
|
formCustomerSignature.prop('disabled', true);
|
|
formPaymentAddress.prop('disabled', false);
|
|
formPaymentUntil.prop('disabled', false);
|
|
formFeedbackLeaveBefore.prop('disabled', false);
|
|
formFeedbackStatus.prop('disabled', false);
|
|
formFeedbackComments.prop('disabled', false);
|
|
} else if (formOrder === 'Feedback') {
|
|
formSellerRating.prop('disabled', false);
|
|
formSellerSignature.prop('disabled', true);
|
|
formCustomerRating.prop('disabled', false);
|
|
formCustomerSignature.prop('disabled', false);
|
|
formPaymentAddress.prop('disabled', false);
|
|
formPaymentUntil.prop('disabled', false);
|
|
formFeedbackLeaveBefore.prop('disabled', false);
|
|
formFeedbackStatus.prop('disabled', false);
|
|
formFeedbackComments.prop('disabled', false);
|
|
}
|
|
|
|
console.log(formOrder);
|
|
}
|
|
|
|
function OnChangeType() {
|
|
const formType = $("select[id='formType']").val();
|
|
|
|
console.log(formType);
|
|
}
|
|
|
|
function executeDealForm() {
|
|
const formOrder = $("select[id='formOrder']");
|
|
const formType = $("select[id='formType']");
|
|
const formAt = $("input[id='formAt']");
|
|
const formDate = $("input[id='formDate']");
|
|
const formSellerAddress = $("input[id='formSellerAddress']");
|
|
const formSellerRating = $("input[id='formSellerRating']");
|
|
const formSellerSignature = $("input[id='formSellerSignature']");
|
|
const formCustomerAddress = $("input[id='formCustomerAddress']");
|
|
const formCustomerRating = $("input[id='formCustomerRating']");
|
|
const formCustomerSignature = $("input[id='formCustomerSignature']");
|
|
const formPaymentAddress = $("input[id='formPaymentAddress']");
|
|
const formPaymentUntil = $("input[id='formPaymentUntil']");
|
|
const formPaymentSum = $("input[id='formPaymentSum']");
|
|
const formFeedbackLeaveBefore = $("input[id='formFeedbackLeaveBefore']");
|
|
const formFeedbackStatus = $("select[id='formFeedbackStatus']");
|
|
const formFeedbackComments = $("input[id='formFeedbackComments']");
|
|
|
|
let formData = new FormData();
|
|
|
|
formData.append('type', formType.val());
|
|
formData.append('at', formAt.val());
|
|
formData.append('date', formDate.val());
|
|
|
|
formData.append('seller_address', formSellerAddress.val());
|
|
|
|
if (!formSellerRating.attr('disabled')) {
|
|
formData.append('seller_rating', formSellerRating.val());
|
|
}
|
|
|
|
if (!formSellerSignature.attr('disabled')) {
|
|
formData.append('seller_signature', formSellerSignature.val());
|
|
}
|
|
|
|
formData.append('customer_address', formCustomerAddress.val());
|
|
|
|
if (!formCustomerRating.attr('disabled')) {
|
|
formData.append('customer_rating', formCustomerRating.val());
|
|
}
|
|
|
|
if (!formCustomerSignature.attr('disabled')) {
|
|
formData.append('customer_signature', formCustomerSignature.val());
|
|
}
|
|
|
|
if (!formPaymentAddress.attr('disabled')) {
|
|
formData.append('payment_address', formPaymentAddress.val());
|
|
}
|
|
|
|
if (!formPaymentUntil.attr('disabled')) {
|
|
formData.append('payment_until', formPaymentUntil.val());
|
|
}
|
|
|
|
formData.append('payment_sum', formPaymentSum.val());
|
|
|
|
if (!formFeedbackLeaveBefore.attr('disabled')) {
|
|
formData.append('feedback_leave_before', formFeedbackLeaveBefore.val());
|
|
}
|
|
|
|
if (!formFeedbackStatus.attr('disabled')) {
|
|
formData.append('feedback_status', formFeedbackStatus.val());
|
|
}
|
|
|
|
if (!formFeedbackComments.attr('disabled')) {
|
|
formData.append('feedback_comments', formFeedbackComments.val());
|
|
}
|
|
|
|
const api = $("input[id='apiURL']").val();
|
|
const server = $("input[id='serverURL']").val();
|
|
|
|
let settings = "";
|
|
if (!empty(server))
|
|
settings = '?server=' + server;
|
|
|
|
if ($('input[id="pgp"]').prop("checked") === false) {
|
|
settings += empty(settings) ? '?' : '&';
|
|
settings += 'pgp=off'
|
|
}
|
|
|
|
const request = $("#deal-form");
|
|
request.html(spinner);
|
|
|
|
let execute = $("button[id='btnDealForm']");
|
|
execute.prop('disabled', true);
|
|
|
|
AsyncFetch(api + '/deal/' + formOrder.val().toLowerCase() + settings, 'POST', formData, {'Content-Type': 'multipart/form-data'})
|
|
.then(function(json) {
|
|
let html;
|
|
let payload;
|
|
let result = true;
|
|
|
|
if (json.hasOwnProperty('error')) {
|
|
let error = json['error'];
|
|
html = '<html lang="ru"><body><pre>' + error['message'] + '</pre></body></html>';
|
|
} else {
|
|
result = json['result']['success'];
|
|
payload = window.atob(json['payload']);
|
|
html = '<html lang="ru"><body><pre><code>' + payload + '</code></pre></body></html>';
|
|
}
|
|
|
|
if (result)
|
|
request.html(html);
|
|
else
|
|
request.html(payload);
|
|
|
|
execute.prop('disabled', false);
|
|
})
|
|
.catch((e) => {
|
|
request.html(e.message);
|
|
execute.prop('disabled', false);
|
|
});
|
|
}
|
|
|
|
function executeDealJSON() {
|
|
const dealJSON = $("textarea[id='dealJSON']");
|
|
|
|
const api = $("input[id='apiURL']").val();
|
|
const server = $("input[id='serverURL']").val();
|
|
|
|
let settings = "";
|
|
if (!empty(server))
|
|
settings = '?server=' + server;
|
|
|
|
if ($('input[id="pgp"]').prop("checked") === false) {
|
|
settings += empty(settings) ? '?' : '&';
|
|
settings += 'pgp=off'
|
|
}
|
|
|
|
const request = $("#deal-json");
|
|
request.html(spinner);
|
|
|
|
let execute = $("button[id='btnDealJSON']");
|
|
execute.prop('disabled', true);
|
|
|
|
AsyncFetch(api + '/deal' + settings, 'POST', dealJSON.val(), {'Content-Type': 'application/json'})
|
|
.then(function(json) {
|
|
let html;
|
|
let payload;
|
|
let result = true;
|
|
|
|
if (json.hasOwnProperty('error')) {
|
|
let error = json['error'];
|
|
html = '<html lang="ru"><body><pre>' + error['message'] + '</pre></body></html>';
|
|
} else {
|
|
result = json['result']['success'];
|
|
payload = window.atob(json['payload']);
|
|
html = '<html lang="ru"><body><pre><code>' + payload + '</code></pre></body></html>';
|
|
}
|
|
|
|
if (result)
|
|
request.html(html);
|
|
else
|
|
request.html(payload);
|
|
|
|
execute.prop('disabled', false);
|
|
})
|
|
.catch((e) => {
|
|
request.html(e.message);
|
|
execute.prop('disabled', false);
|
|
});
|
|
}
|
|
|
|
function executeDealYAML() {
|
|
const dealYAML = $("textarea[id='dealYAML']");
|
|
|
|
const api = $("input[id='apiURL']").val();
|
|
const server = $("input[id='serverURL']").val();
|
|
|
|
let settings = "";
|
|
if (!empty(server))
|
|
settings = '?server=' + server;
|
|
|
|
if ($('input[id="pgp"]').prop("checked") === false) {
|
|
settings += empty(settings) ? '?' : '&';
|
|
settings += 'pgp=off'
|
|
}
|
|
|
|
const request = $("#deal-yaml");
|
|
request.html(spinner);
|
|
|
|
let execute = $("button[id='btnDealYAML']");
|
|
execute.prop('disabled', true);
|
|
|
|
AsyncFetch(api + '/deal' + settings, 'POST', dealYAML.val(), {'Content-Type': 'text/plain'})
|
|
.then(function(json) {
|
|
let html;
|
|
let payload;
|
|
let result = true;
|
|
|
|
if (json.hasOwnProperty('error')) {
|
|
let error = json['error'];
|
|
html = '<html lang="ru"><body><pre>' + error['message'] + '</pre></body></html>';
|
|
} else {
|
|
result = json['result']['success'];
|
|
payload = window.atob(json['payload']);
|
|
html = '<html lang="ru"><body><pre><code>' + payload + '</code></pre></body></html>';
|
|
}
|
|
|
|
if (result)
|
|
request.html(html);
|
|
else
|
|
request.html(payload);
|
|
|
|
execute.prop('disabled', false);
|
|
})
|
|
.catch((e) => {
|
|
request.html(e.message);
|
|
execute.prop('disabled', false);
|
|
});
|
|
}
|
|
|
|
function checkSignature() {
|
|
const cleartext = $("textarea[id='pgp-clear-text']").val();
|
|
const api = $("input[id='apiURL']").val();
|
|
|
|
let json = {
|
|
message: cleartext
|
|
};
|
|
|
|
const request = $("#signature-json");
|
|
request.html(spinner);
|
|
|
|
let execute = $("button[id='btnCheckSignature']");
|
|
execute.prop('disabled', true);
|
|
|
|
AsyncFetch(api + '/signature', 'POST', JSON.stringify(json), {'Content-Type': 'application/json'})
|
|
.then(function(json) {
|
|
let html;
|
|
|
|
if (json.hasOwnProperty('error')) {
|
|
let error = json['error'];
|
|
html = '<html lang="ru"><body><pre>' + error['message'] + '</pre></body></html>';
|
|
} else {
|
|
const verified = json['verified'];
|
|
if (verified) {
|
|
html = '<html lang="ru"><body><pre>' + json['message'] + '</pre></body></html>';
|
|
} else {
|
|
html = JsonToHTML(json);
|
|
}
|
|
}
|
|
|
|
request.html(html);
|
|
|
|
execute.prop('disabled', false);
|
|
})
|
|
.catch((e) => {
|
|
request.html(e.message);
|
|
execute.prop('disabled', false);
|
|
});
|
|
}
|
|
|
|
function actionAccountGet() {
|
|
const api = $("input[id='apiURL']").val();
|
|
const server = $("input[id='serverURL']").val();
|
|
|
|
const moduleAddress = $("input[id='account-get-ModuleAddress']").val();
|
|
let accountAddress = $("input[id='account-get-UserAddress']").val();
|
|
|
|
let params = `?module=${moduleAddress}&bitcoin=${accountAddress}`;
|
|
|
|
const request = $("#action-account-get");
|
|
request.html(spinner);
|
|
|
|
let execute = $("button[id='btnAccountGet']");
|
|
execute.prop('disabled', true);
|
|
|
|
AsyncFetch(`${server}${api}/account/get${params}`)
|
|
.then(function(json) {
|
|
let html;
|
|
|
|
if (json.hasOwnProperty('error')) {
|
|
let error = json['error'];
|
|
html = '<html lang="ru"><body><pre>' + error['message'] + '</pre></body></html>';
|
|
} else {
|
|
const verified = json['verified'];
|
|
if (verified) {
|
|
html = '<html lang="ru"><body><pre>' + json['message'] + '</pre></body></html>';
|
|
} else {
|
|
html = JsonToTableOne(json);
|
|
}
|
|
}
|
|
|
|
request.html(html);
|
|
|
|
execute.prop('disabled', false);
|
|
})
|
|
.catch((e) => {
|
|
request.html(e.message);
|
|
execute.prop('disabled', false);
|
|
});
|
|
}
|
|
|
|
function actionAccountList() {
|
|
const api = $("input[id='apiURL']").val();
|
|
const server = $("input[id='serverURL']").val();
|
|
|
|
const moduleAddress = $("input[id='account-list-ModuleAddress']").val();
|
|
|
|
let params = `?module=${moduleAddress}`;
|
|
|
|
const request = $("#action-account-list");
|
|
request.html(spinner);
|
|
|
|
let execute = $("button[id='btnAccountList']");
|
|
execute.prop('disabled', true);
|
|
|
|
AsyncFetch(`${server}${api}/account/list${params}`)
|
|
.then(function(json) {
|
|
let html;
|
|
|
|
if (json.hasOwnProperty('error')) {
|
|
let error = json['error'];
|
|
html = '<html lang="ru"><body><pre>' + error['message'] + '</pre></body></html>';
|
|
} else {
|
|
const verified = json['verified'];
|
|
if (verified) {
|
|
html = '<html lang="ru"><body><pre>' + json['message'] + '</pre></body></html>';
|
|
} else {
|
|
html = JsonToTable(json);
|
|
}
|
|
}
|
|
|
|
request.html(html);
|
|
|
|
execute.prop('disabled', false);
|
|
})
|
|
.catch((e) => {
|
|
request.html(e.message);
|
|
execute.prop('disabled', false);
|
|
});
|
|
}
|
|
|
|
function actionDealStatus() {
|
|
const api = $("input[id='apiURL']").val();
|
|
const server = $("input[id='serverURL']").val();
|
|
|
|
const address = $("input[id='deal-status-Address']").val();
|
|
|
|
let settings = `?address=${address}`;
|
|
if (!empty(server))
|
|
settings += `&server=${server}`;
|
|
|
|
const request = $("#action-deal-status");
|
|
request.html(spinner);
|
|
|
|
AsyncFetch(`${api}/deal/status${settings}`)
|
|
.then(json => request.html(PayloadToHTML(JsonToPayload(json))))
|
|
.catch(reason => request.html(reason.message));
|
|
}
|
|
|
|
function actionDealFeedback() {
|
|
const api = $("input[id='apiURL']").val();
|
|
const server = $("input[id='serverURL']").val();
|
|
|
|
const address = $("input[id='deal-feedback-Address']").val();
|
|
|
|
let settings = `?address=${address}`;
|
|
if (!empty(server))
|
|
settings += `&server=${server}`;
|
|
|
|
const request = $("#action-deal-feedback");
|
|
request.html(spinner);
|
|
|
|
AsyncFetch(`${api}/deal/feedback${settings}`)
|
|
.then(json => request.html(PayloadToHTML(JsonToPayload(json))))
|
|
.catch(reason => request.html(reason.message));
|
|
}
|
|
|
|
function actionDealCancel() {
|
|
const api = $("input[id='apiURL']").val();
|
|
const server = $("input[id='serverURL']").val();
|
|
|
|
const address = $("input[id='deal-cancel-Address']").val();
|
|
|
|
let settings = `?address=${address}`;
|
|
if (!empty(server))
|
|
settings += `&server=${server}`;
|
|
|
|
const request = $("#action-deal-cancel");
|
|
request.html(spinner);
|
|
|
|
AsyncFetch(`${api}/deal/cancel${settings}`)
|
|
.then(json => request.html(PayloadToHTML(JsonToPayload(json))))
|
|
.catch(reason => request.html(reason.message));
|
|
}
|
|
|
|
function actionDealGet() {
|
|
const api = $("input[id='apiURL']").val();
|
|
const server = $("input[id='serverURL']").val();
|
|
|
|
const moduleAddress = $("input[id='deal-get-ModuleAddress']").val();
|
|
let accountAddress = $("input[id='deal-get-Payment']").val();
|
|
|
|
let params = `?module=${moduleAddress}&payment=${accountAddress}`;
|
|
|
|
const request = $("#action-deal-get");
|
|
request.html(spinner);
|
|
|
|
let execute = $("button[id='btnDealGet']");
|
|
execute.prop('disabled', true);
|
|
|
|
AsyncFetch(`${server}${api}/deal/get${params}`)
|
|
.then(function(json) {
|
|
let html;
|
|
|
|
if (json.hasOwnProperty('error')) {
|
|
let error = json['error'];
|
|
html = '<html lang="ru"><body><pre>' + error['message'] + '</pre></body></html>';
|
|
} else {
|
|
const verified = json['verified'];
|
|
if (verified) {
|
|
html = '<html lang="ru"><body><pre>' + json['message'] + '</pre></body></html>';
|
|
} else {
|
|
html = JsonToTableOne(json);
|
|
}
|
|
}
|
|
|
|
request.html(html);
|
|
|
|
execute.prop('disabled', false);
|
|
})
|
|
.catch((e) => {
|
|
request.html(e.message);
|
|
execute.prop('disabled', false);
|
|
});
|
|
}
|
|
|
|
function actionDealList() {
|
|
const api = $("input[id='apiURL']").val();
|
|
const server = $("input[id='serverURL']").val();
|
|
|
|
const moduleAddress = $("input[id='deal-list-ModuleAddress']").val();
|
|
|
|
let params = `module=${moduleAddress}`;
|
|
|
|
const request = $("#action-deal-list");
|
|
request.html(spinner);
|
|
|
|
let execute = $("button[id='btnDealList']");
|
|
execute.prop('disabled', true);
|
|
|
|
AsyncFetch(`${server}${api}/deal/list?${params}`)
|
|
.then(function(json) {
|
|
let html;
|
|
|
|
if (json.hasOwnProperty('error')) {
|
|
let error = json['error'];
|
|
html = '<html lang="ru"><body><pre>' + error['message'] + '</pre></body></html>';
|
|
} else {
|
|
const verified = json['verified'];
|
|
if (verified) {
|
|
html = '<html lang="ru"><body><pre>' + json['message'] + '</pre></body></html>';
|
|
} else {
|
|
html = JsonToTable(json);
|
|
}
|
|
}
|
|
|
|
request.html(html);
|
|
|
|
execute.prop('disabled', false);
|
|
})
|
|
.catch((e) => {
|
|
request.html(e.message);
|
|
execute.prop('disabled', false);
|
|
});
|
|
}
|
|
|
|
// Example starter JavaScript for disabling form submissions if there are invalid fields
|
|
(function() {
|
|
'use strict';
|
|
window.addEventListener('load', function() {
|
|
// Fetch all the forms we want to apply custom Bootstrap validation styles to
|
|
let forms = document.getElementsByTagName('form');
|
|
// Loop over them and prevent submission
|
|
let validation = Array.prototype.filter.call(forms, function(form) {
|
|
form.addEventListener('submit', function(event) {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
if (form.checkValidity() === false) {
|
|
form.classList.add('was-validated');
|
|
}
|
|
}, false);
|
|
});
|
|
}, false);
|
|
})();
|
|
|
|
$(document).ready(function() {
|
|
actionHelp();
|
|
actionDeal();
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|