westdc-zf1/application/default/views/scripts/author/version-diff.phtml

71 lines
2.2 KiB
PHTML

<?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->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='sidebar'>
<div id='leftnavi'>
<?= $this->partial('author/navi.phtml'); ?>
</div>
</div>
<!-- //左侧导航 -->
<!-- 页面内容 -->
<div id="wapper">
<div id="tabs-controller">
<ul>
<li class="box-shadow"><a class="text-shadow" href="/author/version">所有版本概况</a></li>
<li class="box-shadow"><a class="text-shadow" href="/author/version/ac/bydata">逐数据浏览</a></li>
</ul>
</div>
<?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>
$('#wapper').width($('body').width()-300);
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>