1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < meta charset ="utf-8 ">
5+ < script src ="wasm_exec.js "> </ script >
6+ < script src ="sqldef_browser.js "> </ script >
7+ < style >
8+ body {
9+ font-family : sans-serif;
10+ width : 960px ;
11+ margin : 20px auto;
12+ color : # fff ;
13+ background : # 000 ;
14+ }
15+ textarea , pre {
16+ border : 1px solid # 000 ;
17+ background : # eee ;
18+ color : # 000 ;
19+ padding : 20px ;
20+ margin-bottom : 20px ;
21+ width : 100% ;
22+ }
23+ pre {
24+ display : none;
25+ }
26+ </ style >
27+ </ head >
28+ < body >
29+ < p > You can diff these 2 schemas:</ p >
30+
31+ < textarea id ="inputA " rows ="10 ">
32+ CREATE TABLE user (
33+ id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
34+ name VARCHAR(128) DEFAULT 'konsumer'
35+ ) Engine=InnoDB DEFAULT CHARSET=utf8mb4;
36+ </ textarea >
37+
38+ < textarea id ="inputB " rows ="10 ">
39+ CREATE TABLE user (
40+ id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
41+ name VARCHAR(128) DEFAULT 'konsumer',
42+ created_at DATETIME NOT NULL
43+ ) Engine=InnoDB DEFAULT CHARSET=utf8mb4;
44+ </ textarea >
45+ < div >
46+ < select id ="dbType ">
47+ < option value ="mysql "> MySQL</ option >
48+ < option value ="postgres "> PostgreSQL</ option >
49+ </ select >
50+ < button id ="buttonDiff "> DIFF</ button >
51+ </ div >
52+ < pre id ="output "> </ pre >
53+ </ body >
54+
55+ < script >
56+ const button = document . getElementById ( 'buttonDiff' )
57+ const dbType = document . getElementById ( 'dbType' )
58+ const inputA = document . getElementById ( 'inputA' )
59+ const inputB = document . getElementById ( 'inputB' )
60+ const output = document . getElementById ( 'output' )
61+
62+ button . addEventListener ( 'click' , async ( ) => {
63+ output . style . display = 'none'
64+ output . innerHTML = await window . sqldef ( dbType . value , inputB . value , inputA . value )
65+ output . style . display = 'block'
66+ } )
67+ </ script >
68+
69+ </ html >
0 commit comments