-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
247 lines (219 loc) · 10.2 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<!-- Fontawesome CDN -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
<title>TeRegex</title>
<!-- Vue.js -->
<!-- development version, includes helpful console warnings -->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<!-- CDNJS :: Sortable (https://cdnjs.com/) -->
<script src="https://cdn.jsdelivr.net/npm/sortablejs/Sortable.min.js"></script>
<!-- CDNJS :: Vue.Draggable (https://cdnjs.com/) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/Vue.Draggable/2.20.0/vuedraggable.umd.min.js"></script>
<script src="components/action-item.js"></script>
<style>
.new-action-container {
position: relative;
}
.new-action {
position: absolute;
bottom: 0;
right: 0;
left: 0;
}
.list-group-item.active {
background-color: #28a745 !important;
border-color: #28a745 !important;
}
</style>
<style>
.myInlineDecoration {
background-color: #28a74570 !important;
/*color: red !important;*/
/*text-decoration: underline;*/
font-weight: bold;
/*font-style: oblique;*/
}
.myLineDecoration {
background: lightblue;
width: 5px !important;
margin-left: 3px;
}
</style>
</head>
<body>
<div id="app">
<div class="row no-gutters">
<div class="col-8" style="height: 100vh;">
<div id="editor" class="h-100"></div>
</div>
<div class="col-4 p-2">
<div class="d-flex justify-content-between mb-3">
<div class="btn-group" role="group">
<button type="button" class="btn btn-outline-dark" v-on:click="open_original">Open</button>
<button type="button" class="btn btn-outline-dark" v-on:click="import_actions">Import actions</button>
</div>
<div class="d-flex justify-content-between">
<select class="form-control form-control mr-2" v-model="revision_selected" @change="select_revision(revision_selected)">
<option v-for="revisionItem in revisions" v-bind:value="revisionItem.rev">{{ (revisionItem.rev == 0) ? 'Original' : 'Rev. ' + revisionItem.rev }}</option>
</select>
<button type="button" class="btn btn-outline-dark" v-on:click="save_revision" v-bind:disabled="!pending_changes">Save</button>
</div>
</div>
<div class="d-flex flex-column align-items-stretch" style="height: calc(100vh - 70px);">
<div class="w-100" style="overflow-y: auto;">
<div class="list-group">
<draggable v-model="actions" @start="drag_start" @end="drag_end">
<action-item id="demo1" inline-template v-for="actionItem in actions" v-bind:item="actionItem" v-bind:selected="action_selected" v-bind:select="select_action" v-bind:refresh="refresh" v-bind:delete="show_delete_action">
<div v-on:click="select(item)" class="list-group-item list-group-item-action" v-bind:class="{ 'active': (selected != null) && (+item.id == +selected.id) }">
<div class="d-flex justify-content-between">
<div class="mr-2">
<i class="fas fa-sort"></i>
<b>#{{ item.id }}</b>
</div>
<div class="flex-grow-1">{{ item.$description() }}</div>
<div>
<i class="far fa-trash-alt mr-2" v-on:click.stop="delete_action()"></i>
<i class="fas fa-eye" v-if="item.enabled" v-on:click.stop="set_enabled(false)"></i>
<i class="fas fa-eye-slash" v-if="!item.enabled" v-on:click.stop="set_enabled(true)"></i>
</div>
</div>
</div>
</action-item>
</draggable>
</div>
<h5 class="w-100 text-center" v-if="actions.length == 0">No actions</h5>
<button class="btn btn-outline-dark w-100 mt-3" v-on:click="new_action">Create Action</button>
<button class="btn w-100 mt-3 mb-3" v-bind:class="{ 'btn-outline-success': action_selected != null, 'btn-success': action_selected == null }" v-on:click="select_output">Output</button>
</div>
<div class="w-100 p-2 border-top" v-if="action_selected == null">
<h5 class="w-100 text-center">No action selected</h5>
</div>
<div class="w-100 p-2 border-top" v-if="action_selected != null">
<div class="form-group">
<div class="row no-gutters">
<div class="col-2 justify-content-center pr-2 d-flex align-items-center"><b>#{{action_selected.id}}</b></div>
<div class="col-10">
<select class="form-control form-control-sm" v-model="action_selected.type" @change="action_type_changed()">
<option value="FindAndReplaceAction">Find & Replace</option>
<option value="ReplaceSelectionAction">Replace selection</option>
<option value="ApplyDiffAction">Apply differences</option>
<option disabled>Replace</option>
<option disabled>Find</option>
<option disabled>Repeat</option>
<option disabled>Each</option>
</select>
</div>
</div>
</div>
<div class="form-group" v-for="(value, key) in action_selected.$properties()">
<div class="d-flex" v-if="value.data">
<div class="text-right pr-2 d-flex align-items-center" v-if="value.description">{{ value.description }}</div>
<div class="flex-grow-1" v-if="!value.choose"><input type="text" class="form-control form-control-sm" v-model="action_selected.data[value.data]" @change="update_selected_action"></div>
<div class="flex-grow-1" v-if="value.choose">
<select class="form-control form-control-sm">
<option v-for="chooseItem in value.choose">{{chooseItem}}</option>
</select>
</div>
</div>
<div class="d-flex" v-if="value.function">
<button class="btn btn-dark flex-grow-1 h-100" v-on:click="value.function(action_selected)">{{ value.description }}</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal" tabindex="-1" role="dialog" id="deleteModal">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Delete action</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cance</button>
<button type="button" class="btn btn-danger" v-on:click="delete_selected_action">Delete</button>
</div>
</div>
</div>
</div>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script>
var editor = null;
var diffEditor = null;
</script>
<script>
window.$ = window.jQuery = require('jquery'); // not sure if you need this at all
window.Bootstrap = require('bootstrap');
const jsdiff = require('diff');
const DiffMatchPatch = require('diff-match-patch');
</script>
<script src="actions/Action.js"></script>
<script src="actions/FindAndReplaceAction.js"></script>
<script src="actions/ReplaceSelectionAction.js"></script>
<script src="actions/ApplyDiffAction.js"></script>
<script src="app.js"></script>
<script>
(function() {
const path = require('path');
const amdLoader = require('./node_modules/monaco-editor/min/vs/loader.js');
const amdRequire = amdLoader.require;
const amdDefine = amdLoader.require.define;
function uriFromPath(_path) {
var pathName = path.resolve(_path).replace(/\\/g, '/');
if (pathName.length > 0 && pathName.charAt(0) !== '/') {
pathName = '/' + pathName;
}
return encodeURI('file://' + pathName);
}
amdRequire.config({
baseUrl: uriFromPath(path.join(__dirname, './node_modules/monaco-editor/min'))
});
// workaround monaco-css not understanding the environment
self.module = undefined;
amdRequire(['vs/editor/editor.main'], function() {
useEditor('normal');
});
})();
function useEditor(type) {
if (type.toLowerCase() == 'diff') {
if (editor) {
editor.dispose();
editor = null;
}
if (!diffEditor) {
diffEditor = monaco.editor.createDiffEditor(document.getElementById("editor"), {
language: 'text',
automaticLayout: true,
readOnly: true
});
}
} else {
if (diffEditor) {
diffEditor.dispose();
diffEditor = null;
}
if (!editor) {
editor = monaco.editor.create(document.getElementById('editor'), {
value: '',
language: 'text',
automaticLayout: true,
readOnly: true
});
}
}
}
</script>
</body>
</html>