xining.westgis.ac.cn/application/default/views/scripts/author/version-diff.phtml

63 lines
2.2 KiB
PHTML
Raw Normal View History

2019-10-09 09:20:52 +00:00
<?php
$this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->author);
$this->headTitle()->setSeparator(' - ');
$this->headScript()->appendFile('/js/jquery-1.7.min.js');
$this->headScript()->appendFile('/js/diffview.js');
$this->headScript()->appendFile('/js/difflib.js');
$this->headScript()->appendFile('/static/js/menuctrl.js');
$this->headLink()->appendStylesheet('/css/author.css');
$this->headLink()->appendStylesheet('/css/diffview.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/author">数据管理</a>');
$this->breadcrumb('查看数据作者');
$this->breadcrumb()->setSeparator(' > ');
?>
<div id="page">
<div class="subnav">
</div>
<script type="text/javascript" language="javascript" src="/js/jquery-1.7.min.js"></script>
<script type="text/javascript" language="javascript" src="/js/diffview.js"></script>
<script type="text/javascript" language="javascript" src="/js/difflib.js"></script>
<script type="text/javascript" language="javascript" src="/static/js/menuctrl.js"></script>
<link href="/css/diffview.css" rel="stylesheet" type="text/css" media="screen" />
<?php
if(!empty($this->error))
{
echo $this->error;
}
else
{?>
<h2><?php echo $this->info['title'];?></h2>
<div id="diffoutput" style="width:100%;"> </div>
<textarea id="basetext" style="display:none;"><?php echo $this->data[1]['xml'];?></textarea>
<textarea id="newtext" style="display:none;"><?php echo $this->data[0]['xml'];?></textarea>
<?php
}
?>
<!-- //页面内容 -->
</div>
<script>
function diffUsingJS() {
var base = difflib.stringAsLines($('#basetext').val());
var newtxt = difflib.stringAsLines($('#newtext').val());
var sm = new difflib.SequenceMatcher(base, newtxt);
var opcodes = sm.get_opcodes();
$("#diffoutput").append(diffview.buildView({
baseTextLines: base,
newTextLines: newtxt,
opcodes: opcodes,
// set the display titles for each resource
baseTextName: "<?php echo date("Y-m-d H:i",strtotime($this->data[1]['ts_created'])); ?>",
newTextName: "<?php echo date("Y-m-d H:i",strtotime($this->data[0]['ts_created'])); ?>",
contextSize: null,
viewType: 0
}));
}
diffUsingJS();
</script>