diffido/dist/diff.html

84 lines
2.1 KiB
HTML
Raw Normal View History

2018-01-16 22:24:30 +01:00
{% extends "base.html" %}
{% block body %}
2018-01-21 11:20:42 +01:00
<div id="app">
<div class="md-layout">
2018-01-23 22:41:32 +01:00
<div class="md-layout-item">
<md-card id="main-card">
<md-card-header>
<div class="md-title">
<md-button href="/" class="md-icon-button md-primary">
<md-icon>home</md-icon>
</md-button>
Diffido: ${schedule && schedule.title} diff
</div>
</md-card-header>
<md-card-content id="diffpanel-container">
<div id="diffpanel"></div>
</md-card-content>
</md-card>
2018-01-21 11:20:42 +01:00
</div>
</div>
</div>
<script>
Vue.use(VueMaterial.default);
var app = new Vue({
el: '#app',
delimiters: ['${', '}'],
data: {
2018-01-23 22:41:32 +01:00
schedule: {},
2018-01-21 11:20:42 +01:00
history: [],
difftext: '',
id: "{{id}}",
{% try %}
{% if diff %}
diff: "{{diff}}",
{% end %}
{% except %}
diff: null,
{% end %}
{% try %}
{% if oldid %}
oldid: "{{oldid}}",
{% end %}
{% except %}
oldid: null,
{% end %}
},
mounted: function() {
this.getDiff();
},
methods: {
getDiff: function() {
self = this;
var data = axios.get('/api/diff/' + this.id + '/' + this.diff + '/' + (this.oldid || '')).then(function(response) {
2018-01-23 22:41:32 +01:00
self.schedule = response.data.schedule;
2018-01-21 11:20:42 +01:00
self.difftext = response.data.diff;
2018-01-23 22:41:32 +01:00
var current_size = document.getElementById('diffpanel').offsetWidth;
var pretty_diff = Diff2Html.getPrettyHtml(self.difftext, {showFiles: true, matching: 'none'});
2018-01-21 11:20:42 +01:00
document.getElementById('diffpanel').innerHTML = pretty_diff;
2018-01-23 22:41:32 +01:00
document.getElementById('diffpanel').style['max-width'] = (current_size - 20) + 'px';
2018-01-21 11:20:42 +01:00
});
}
}
});
</script>
<style>
body {
background-color: white;
2018-01-23 22:41:32 +01:00
padding: 6px;
2018-01-21 11:20:42 +01:00
}
.md-table {
2018-01-23 22:41:32 +01:00
height: 80%;
2018-01-21 11:20:42 +01:00
}
</style>
2018-01-16 22:24:30 +01:00
{% end %}