Skip to content

Commit

Permalink
Merge branch '2018-09-12-diff'
Browse files Browse the repository at this point in the history
  • Loading branch information
qiujiayu committed Sep 13, 2018
2 parents 8cfe5e3 + f77f79c commit 62bc4f4
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ class Diff extends Component {
this.setState({
historyConfigText: rsp.data.propertySource,
historyVersionId: rsp.data.version
}, () => {
const iframe = document.createElement('iframe');
iframe.src = '/static/diffhtml.html';
iframe.width = '100%';
iframe.setAttribute("frameborder", 0);
iframe.setAttribute("id", 'diffIframe');
document.getElementById('prettydiff').appendChild(iframe);
});
}
});

const iframe = document.createElement('iframe');
iframe.src = '/static/diffhtml.html';
iframe.width = '100%';
iframe.setAttribute("frameborder", 0);
iframe.setAttribute("id", 'diffIframe');
document.getElementById('prettydiff').appendChild(iframe);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ class DiffComponent extends Component {
this.setState({
historyConfigText: rsp.data.propertySource,
historyVersionId: rsp.data.version
}, () => {
const iframe = document.createElement('iframe');
iframe.src = '/static/diffhtml.html';
iframe.width = '100%';
iframe.setAttribute("frameborder", 0);
iframe.setAttribute("id", 'diffIframe');
document.getElementById('prettydiff').appendChild(iframe);
});
}
});
Expand All @@ -32,13 +39,6 @@ class DiffComponent extends Component {
currentConfigText: editText,
currentVersionId: '当前修改内容',
});

const iframe = document.createElement('iframe');
iframe.src = '/static/diffhtml.html';
iframe.width = '100%';
iframe.setAttribute("frameborder", 0);
iframe.setAttribute("id", 'diffIframe');
document.getElementById('prettydiff').appendChild(iframe);
}

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ class Diff extends Component {
this.setState({
historyConfigText: rsp.data.propertySource,
historyVersionId: rsp.data.version
}, () => {
const iframe = document.createElement('iframe');
iframe.src = '/static/diffhtml.html';
iframe.width = '100%';
iframe.setAttribute("frameborder", 0);
iframe.setAttribute("id", 'diffIframe');
document.getElementById('prettydiff').appendChild(iframe);
});
}
});

const iframe = document.createElement('iframe');
iframe.src = '/static/diffhtml.html';
iframe.width = '100%';
iframe.setAttribute("frameborder", 0);
iframe.setAttribute("id", 'diffIframe');
document.getElementById('prettydiff').appendChild(iframe);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ class DiffComponent extends Component {
this.setState({
historyConfigText: rsp.data.propertySource,
historyVersionId: rsp.data.version
}, () => {
const iframe = document.createElement('iframe');
iframe.src = '/static/diffhtml.html';
iframe.width = '100%';
iframe.setAttribute("frameborder", 0);
iframe.setAttribute("id", 'diffIframe');
document.getElementById('prettydiff').appendChild(iframe);
});
}
});
Expand All @@ -28,13 +35,6 @@ class DiffComponent extends Component {
currentConfigText: editText,
currentVersionId: '当前修改内容',
});

const iframe = document.createElement('iframe');
iframe.src = '/static/diffhtml.html';
iframe.width = '100%';
iframe.setAttribute("frameborder", 0);
iframe.setAttribute("id", 'diffIframe');
document.getElementById('prettydiff').appendChild(iframe);
}

render() {
Expand Down
39 changes: 19 additions & 20 deletions suixingpay-config-front/static/diffhtml.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,26 @@
<script src="js/diffview.js" type="application/javascript"></script>
<script src="js/prettydiff.js" type="application/javascript"></script>
<script src="js/jquery.min.js"></script>
<div class="btn-view">
<button type="button" value="Execute" onclick="viewDiffLine()">只查看被修改行</button>
<button type="button" value="Execute" onclick="viewAllLine()">查看全部行</button>
</div>
<div id="prettydiff"></div>

<script type="text/javascript">
setTimeout(function () {
var historyConfigText = window.parent.document.getElementById('historyConfigText').defaultValue;
var currentConfigText = window.parent.document.getElementById('currentConfigText').defaultValue;
args = {
source: historyConfigText,
diff: currentConfigText,
lang: "text"
};
var output = global.prettydiff.prettydiff(args);
document.getElementById("prettydiff").innerHTML = output;
var historyConfigText = window.parent.document.getElementById('historyConfigText').defaultValue;
var currentConfigText = window.parent.document.getElementById('currentConfigText').defaultValue;
args = {
source: historyConfigText,
diff: currentConfigText,
lang: "text"
};
var output = global.prettydiff.prettydiff(args);
document.getElementById("prettydiff").innerHTML = output;

// 设置 iframe 高度
var iframeHeight = document.getElementById('prettydiff').clientHeight;
window.parent.document.getElementById('diffIframe').setAttribute("height", iframeHeight + 40);
}, 100);
// 设置 iframe 高度
var iframeHeight = document.getElementById('prettydiff').clientHeight;
window.parent.document.getElementById('diffIframe').setAttribute("height", iframeHeight + 40);

// 只查看修改行内容
function viewDiffLine() {
Expand All @@ -45,23 +48,19 @@
}
setIframeHeight();
}

// 查看全部内容
function viewAllLine() {
$(".data .equal").show();
$(".diff ol.count").find("li").show();
setIframeHeight();
}

//设置 iframe 高度
function setIframeHeight() {
var iframeHeight = document.getElementById('prettydiff').clientHeight;
window.parent.document.getElementById('diffIframe').setAttribute("height", iframeHeight + 40);
}
</script>
<div class="btn-view">
<button type="button" value="Execute" onclick="viewDiffLine()">只查看被修改行</button>
<button type="button" value="Execute" onclick="viewAllLine()">查看全部行</button>
</div>
<div id="prettydiff"></div>
</body>
</html>

0 comments on commit 62bc4f4

Please sign in to comment.