-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
150 lines (119 loc) · 5.13 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Room SQLite Difference Finder</title>
<link rel="stylesheet" href="reset.css" type="text/css" media="screen">
<link rel="stylesheet" href="throbber.css" type="text/css" media="screen">
<link rel="stylesheet" href="jdd.css" type="text/css" media="screen">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="jsl/jsl.format.js" type="text/javascript" charset="utf-8"></script>
<script src="jsl/jsl.parser.js" type="text/javascript" charset="utf-8"></script>
<script src="jdd.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div id="main">
<div class="header">
<h1>Room SQLite Difference Finder</h1>
<h3>Find difference when migrating from Sqlite to Room.</h3>
<div class="weak">
<p>
When migrating from Sqlite to Room, it gets pretty difficult to find the changes. This script converts the output to json and Validate, format, and compare two JSON documents. See the differences between the objects instead of just the new lines and mixed up properties.
</p>
<p>
Created by <a href="https://github.com/hrankit">HRAnkit</a>.
</p>
<p>
Big thanks owed to <a href="http://www.zackgrossbart.com">Zack Grossbart</a> author of <a href="http://www.jsondiff.com/">JSON Diff</a> along with the team behind <a href="http://www.jsonlint.com">JSONLint</a>.
</p>
</div>
</div>
<div class="initContainer">
<div class="left">
<p>Expected: TableInfo{ ........ , indices=[]} </p>
<textarea spellcheck="false" id="textarealeft" placeholder="Enter Expected output from Android Studio Logcat console. Start with TableInfo and end with indices=[]}"></textarea>
<pre id="errorLeft" class="error"></pre>
</div>
<div class="center">
<button id="compare">Compare</button>
<button id="processGo" onclick="performAction()" class="shown">Go.</button>
<div class="throbber-loader"></div>
<br/><br/><br/><br/>
or try some <a href="#" id="sample">sample data</a>
</div>
<div class="right">
<p>Found: TableInfo{ ........ , indices=[]}</p>
<textarea spellcheck="false" class="right" id="textarearight" placeholder="Enter Found output from Android Studio Logcat console. Start with TableInfo and end with indices=[]}"></textarea>
<pre id="errorRight" class="error"></pre>
</div>
</div>
<div class="diffcontainer">
<div id="report">
</div>
<pre id="out" class="left" class="codeBlock"></pre>
<pre id="out2" class="right" class="codeBlock"></pre>
<ul id="toolbar" class="toolbar"></ul>
</div>
</div>
<script type="text/javascript">
function IsJsonString(str) {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
}
function replaceAll(str, find, replace) {
return str.replace(new RegExp(find, 'g'), replace);
}
function replace(string){
var res = replaceAll(string, "=", '":');
res = replaceAll(res,"TableInfo", '');
res = replaceAll(res,", ", ',');
res = replaceAll(res,",", ',"');
res = replaceAll(res,"{", '{"');
res = replaceAll(res,":Column{", ':{');
res = replaceAll(res,"'", '"');
res = replaceAll(res,"'", '"');
return res;
}
function showErrors(){
$('#errorLeft').text("Please Enter Expected Output from Android Logcat").show();
$('#textarealeft').addClass('error');
$("errorRight").text("Please Enter Found Output from Android Logcat").show();
$('#textarearight').addClass('error');
}
function performAction(){
var expected = document.getElementById("textarealeft").value;
var found = document.getElementById("textarearight").value;
if (!expected || !found){
showErrors();
return;
}
var res = replace(expected);
var count = 0;
if (IsJsonString(res)){
document.getElementById("textarealeft").value = res;
count = count + 1;
}else{
document.getElementById("textarealeft").value = "Json Invalid\n Please paste from Expected TableInfo: till the ending curly braces of indices=[] }";
}
var res = replace(found);
if (IsJsonString(res)){
document.getElementById("textarearight").value = res;
count = count + 1;
}else{
document.getElementById("textarearight").value = "Json Invalid\nPlease paste from Expected TableInfo: till the ending curly braces of indices=[] }";
}
if (count == 2){
$("#processGo").hide();
$("#compare").show();
}
}
$('#textarealeft').val("");
$('#textarearight').val("");
$("#compare").hide();
</script>
</body>
</html>