| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Layer.js Test</title>
- <style>
- body {
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
- text-align: center;
- padding: 50px;
- background: #f0f2f5;
- }
- h1 { margin-bottom: 30px; }
- .btn-group {
- display: flex;
- flex-wrap: wrap;
- justify-content: center;
- gap: 15px;
- }
- button {
- padding: 10px 20px;
- font-size: 16px;
- cursor: pointer;
- border: none;
- border-radius: 5px;
- background: #fff;
- box-shadow: 0 2px 5px rgba(0,0,0,0.1);
- transition: transform 0.1s;
- }
- button:active {
- transform: scale(0.98);
- }
- #result {
- margin-top: 30px;
- font-size: 18px;
- color: #555;
- height: 30px;
- }
- </style>
- </head>
- <body>
- <h1>Layer.js Test</h1>
- <div class="btn-group">
- <button onclick="testBasic()">Basic Message</button>
- <button onclick="testSuccess()">Success Icon</button>
- <button onclick="testError()">Error Icon</button>
- <button onclick="testWarning()">Warning Icon</button>
- <button onclick="testConfirm()">Confirm Dialog</button>
- <button onclick="testChaining()">Chain Promises</button>
- </div>
- <div id="result"></div>
- <script src="layer.js"></script>
- <script>
- function log(msg) {
- document.getElementById('result').textContent = msg;
- console.log(msg);
- }
- function testBasic() {
- Layer.fire('Hello World');
- }
- function testSuccess() {
- Layer.fire('Good job!', 'You clicked the button!', 'success');
- }
- function testError() {
- Layer.fire({
- icon: 'error',
- title: 'Oops...',
- text: 'Something went wrong!',
- });
- }
- function testWarning() {
- Layer.fire({
- title: 'Are you sure?',
- text: "You won't be able to revert this!",
- icon: 'warning',
- showCancelButton: true,
- confirmButtonColor: '#3085d6',
- cancelButtonColor: '#d33',
- confirmButtonText: 'Yes, delete it!'
- }).then((result) => {
- if (result.isConfirmed) {
- Layer.fire(
- 'Deleted!',
- 'Your file has been deleted.',
- 'success'
- )
- }
- });
- }
- function testConfirm() {
- Layer.fire({
- title: 'Do you want to save the changes?',
- showCancelButton: true,
- confirmButtonText: 'Save',
- }).then((result) => {
- if (result.isConfirmed) {
- log('Saved!');
- } else if (result.isDismissed) {
- log('Changes are not saved');
- }
- });
- }
- function testChaining() {
- Layer.fire({
- title: 'Step 1',
- text: 'Proceed to step 2?',
- showCancelButton: true
- }).then((result) => {
- if (result.isConfirmed) {
- return Layer.fire({
- title: 'Step 2',
- text: 'Last step!',
- icon: 'success'
- });
- }
- }).then(() => {
- log('Process completed');
- });
- }
- </script>
- </body>
- </html>
|