mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-26 13:23:25 +03:00
Fix some JS lint.
This commit is contained in:
parent
cfeba5d0cb
commit
85c23ed7dc
@ -21,16 +21,19 @@
|
|||||||
// constants
|
// constants
|
||||||
var b64chars
|
var b64chars
|
||||||
= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
||||||
var b64tab = function(bin) {
|
var b64tab = (function(bin) {
|
||||||
var t = {};
|
var t = {}, i, l;
|
||||||
for (var i = 0, l = bin.length; i < l; i++) t[bin.charAt(i)] = i;
|
for (i = 0, l = bin.length; i < l; i++) {
|
||||||
|
t[bin.charAt(i)] = i;
|
||||||
|
}
|
||||||
return t;
|
return t;
|
||||||
}(b64chars);
|
})(b64chars);
|
||||||
var fromCharCode = String.fromCharCode;
|
var fromCharCode = String.fromCharCode;
|
||||||
// encoder stuff
|
// encoder stuff
|
||||||
var cb_utob = function(c) {
|
var cb_utob = function(c) {
|
||||||
|
var cc;
|
||||||
if (c.length < 2) {
|
if (c.length < 2) {
|
||||||
var cc = c.charCodeAt(0);
|
cc = c.charCodeAt(0);
|
||||||
return cc < 0x80 ? c
|
return cc < 0x80 ? c
|
||||||
: cc < 0x800 ? (fromCharCode(0xc0 | (cc >>> 6))
|
: cc < 0x800 ? (fromCharCode(0xc0 | (cc >>> 6))
|
||||||
+ fromCharCode(0x80 | (cc & 0x3f)))
|
+ fromCharCode(0x80 | (cc & 0x3f)))
|
||||||
@ -38,7 +41,7 @@
|
|||||||
+ fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
|
+ fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
|
||||||
+ fromCharCode(0x80 | ( cc & 0x3f)));
|
+ fromCharCode(0x80 | ( cc & 0x3f)));
|
||||||
} else {
|
} else {
|
||||||
var cc = 0x10000
|
cc = 0x10000
|
||||||
+ (c.charCodeAt(0) - 0xD800) * 0x400
|
+ (c.charCodeAt(0) - 0xD800) * 0x400
|
||||||
+ (c.charCodeAt(1) - 0xDC00);
|
+ (c.charCodeAt(1) - 0xDC00);
|
||||||
return (fromCharCode(0xf0 | ((cc >>> 18) & 0x07))
|
return (fromCharCode(0xf0 | ((cc >>> 18) & 0x07))
|
||||||
@ -70,19 +73,21 @@
|
|||||||
return b.replace(/[\s\S]{1,3}/g, cb_encode);
|
return b.replace(/[\s\S]{1,3}/g, cb_encode);
|
||||||
};
|
};
|
||||||
var _encode = buffer ? function (u) {
|
var _encode = buffer ? function (u) {
|
||||||
return (u.constructor === buffer.constructor ? u : new buffer(u))
|
return (
|
||||||
.toString('base64')
|
u.constructor === buffer.constructor ? u : new buffer(u)
|
||||||
|
).toString('base64');
|
||||||
}
|
}
|
||||||
: function (u) { return btoa(utob(u)) }
|
: function (u) { return btoa(utob(u)); }
|
||||||
;
|
;
|
||||||
var encode = function(u, urisafe) {
|
var encode = function(u, urisafe) {
|
||||||
return !urisafe
|
return (
|
||||||
? _encode(String(u))
|
!urisafe ?
|
||||||
: _encode(String(u)).replace(/[+\/]/g, function(m0) {
|
_encode(String(u)) :
|
||||||
return m0 == '+' ? '-' : '_';
|
_encode(String(u)).replace(/[+\/]/g, function(m0) {
|
||||||
|
return (m0 === '+') ? '-' : '_';
|
||||||
}).replace(/=/g, '');
|
}).replace(/=/g, '');
|
||||||
};
|
};
|
||||||
var encodeURI = function(u) { return encode(u, true) };
|
var encodeURI = function(u) { return encode(u, true); };
|
||||||
// decoder stuff
|
// decoder stuff
|
||||||
var re_btou = new RegExp([
|
var re_btou = new RegExp([
|
||||||
'[\xC0-\xDF][\x80-\xBF]',
|
'[\xC0-\xDF][\x80-\xBF]',
|
||||||
|
@ -10,6 +10,63 @@ var span_count_in = [];
|
|||||||
var span_count_out = [];
|
var span_count_out = [];
|
||||||
var current_depth = -1;
|
var current_depth = -1;
|
||||||
|
|
||||||
|
function highlightSingleNode( sentence, id, color ) {
|
||||||
|
var i, j, item;
|
||||||
|
for(i=nodeIn[sentence][id].start;i<=nodeIn[sentence][id].end;i++) {
|
||||||
|
for(j=nodeIn[sentence][id].depth;j<=max_depth[sentence];j++) {
|
||||||
|
item = "in-" + sentence + "-" + i + "-" + j;
|
||||||
|
if ($(item) !== null) {
|
||||||
|
$(item).setStyle({ backgroundColor: color, borderColor: 'red' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//$("debug").innerHTML = "highlight: "+id+", of "+nodeOut[sentence].size()+"<br>";
|
||||||
|
for(i=nodeOut[sentence][id].start;i<=nodeOut[sentence][id].end;i++) {
|
||||||
|
for(j=nodeOut[sentence][id].depth;j<=max_depth[sentence];j++) {
|
||||||
|
item = "out-" + sentence + "-" + i + "-" + j;
|
||||||
|
//$("debug").innerHTML += item;
|
||||||
|
if ($(item) !== null) {
|
||||||
|
$(item).setStyle({ backgroundColor: color, borderColor: 'red' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function lowlightAllNodes( sentence ) {
|
||||||
|
var i, j, item;
|
||||||
|
for(i=0;i<span_count_in[sentence];i++) {
|
||||||
|
for(j=0;j<=max_depth[sentence];j++) {
|
||||||
|
item = "in-" + sentence + "-" + i + "-" + j;
|
||||||
|
if ($(item) !== null) {
|
||||||
|
$(item).setStyle({ backgroundColor: 'white', borderColor: 'black' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(i=0;i<span_count_out[sentence];i++) {
|
||||||
|
for(j=0;j<=max_depth[sentence];j++) {
|
||||||
|
item = "out-" + sentence + "-" + i + "-" + j;
|
||||||
|
if ($(item) !== null) {
|
||||||
|
$(item).setStyle({ backgroundColor: 'white', borderColor: 'black' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function highlightNode( sentence, id ) {
|
||||||
|
var i;
|
||||||
|
lowlightAllNodes( sentence );
|
||||||
|
highlightSingleNode( sentence, id, 'yellow' );
|
||||||
|
for(i=0; i<nodeChildren[sentence][id].size(); i++) {
|
||||||
|
var childId = nodeChildren[sentence][id][i];
|
||||||
|
var j;
|
||||||
|
highlightSingleNode( sentence, childId, '#ffffa0');
|
||||||
|
for(j=0; j<nodeChildren[sentence][childId].size(); j++) {
|
||||||
|
highlightSingleNode(
|
||||||
|
sentence, nodeChildren[sentence][childId][j], '#ffffe0');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function alignIn( sentence, word, depth ) {
|
function alignIn( sentence, word, depth ) {
|
||||||
var id, i;
|
var id, i;
|
||||||
if (current_depth < depth) {
|
if (current_depth < depth) {
|
||||||
@ -44,63 +101,7 @@ function alignOut( sentence, word, depth ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function unAlign( sentence ) {
|
function unAlign( sentence ) {
|
||||||
if (current_depth == -1) { return; }
|
if (current_depth === -1) { return; }
|
||||||
current_depth = -1;
|
current_depth = -1;
|
||||||
lowlightAllNodes( sentence );
|
lowlightAllNodes( sentence );
|
||||||
}
|
}
|
||||||
|
|
||||||
function highlightNode( sentence, id ) {
|
|
||||||
var i;
|
|
||||||
lowlightAllNodes( sentence );
|
|
||||||
highlightSingleNode( sentence, id, 'yellow' );
|
|
||||||
for(i=0; i<nodeChildren[sentence][id].size(); i++) {
|
|
||||||
var childId = nodeChildren[sentence][id][i];
|
|
||||||
var j;
|
|
||||||
highlightSingleNode( sentence, childId, '#ffffa0');
|
|
||||||
for(j=0; j<nodeChildren[sentence][childId].size(); j++) {
|
|
||||||
highlightSingleNode( sentence, nodeChildren[sentence][childId][j], '#ffffe0');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function highlightSingleNode( sentence, id, color ) {
|
|
||||||
var i, j;
|
|
||||||
for(i=nodeIn[sentence][id].start;i<=nodeIn[sentence][id].end;i++) {
|
|
||||||
for(j=nodeIn[sentence][id].depth;j<=max_depth[sentence];j++) {
|
|
||||||
var item = "in-" + sentence + "-" + i + "-" + j;
|
|
||||||
if ($(item) != null) {
|
|
||||||
$(item).setStyle({ backgroundColor: color, borderColor: 'red' });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//$("debug").innerHTML = "highlight: "+id+", of "+nodeOut[sentence].size()+"<br>";
|
|
||||||
for(i=nodeOut[sentence][id].start;i<=nodeOut[sentence][id].end;i++) {
|
|
||||||
for(j=nodeOut[sentence][id].depth;j<=max_depth[sentence];j++) {
|
|
||||||
var item = "out-" + sentence + "-" + i + "-" + j;
|
|
||||||
//$("debug").innerHTML += item;
|
|
||||||
if ($(item) != null) {
|
|
||||||
$(item).setStyle({ backgroundColor: color, borderColor: 'red' });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function lowlightAllNodes( sentence ) {
|
|
||||||
var i, j;
|
|
||||||
for(i=0;i<span_count_in[sentence];i++) {
|
|
||||||
for(j=0;j<=max_depth[sentence];j++) {
|
|
||||||
var item = "in-" + sentence + "-" + i + "-" + j;
|
|
||||||
if ($(item) != null) {
|
|
||||||
$(item).setStyle({ backgroundColor: 'white', borderColor: 'black' });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(i=0;i<span_count_out[sentence];i++) {
|
|
||||||
for(j=0;j<=max_depth[sentence];j++) {
|
|
||||||
var item = "out-" + sentence + "-" + i + "-" + j;
|
|
||||||
if ($(item) != null) {
|
|
||||||
$(item).setStyle({ backgroundColor: 'white', borderColor: 'black' });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user