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

66 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 class="row">
<div class="span3">
<?= $this->partial('author/navi.phtml'); ?>
</div>
<div class="span9">
<div>
<ul class="nav nav-pills">
<li><a href="/author/version">所有版本概况</a></li>
<li><a 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>
</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>