מדיה ויקי:Gadget-pgnviewer.js: הבדלים בין גרסאות בדף

נו כבר
ניסוי
שורה 329: שורה 329:
tds: tds,
tds: tds,
gs: gameSet});
gs: gameSet});
}
Game.prototype.moveLinkText = function(afterCommentNum, move) {
var config = this.gs.config,
notation = move.s,
turn = move.turn,
pieces = config && config.translate && config.translate.pieces,
files = config && config.translate && config.translate.files,
rows = config && config.translate && config.translate.rows;
if (pieces) {
pieces =  pieces.white && turn == 'l'
|| pieces.black && turn == 'd'
|| pieces;
try {
notation = notation.replace(/[RNBQK]/, function(c) { return pieces[c]; } );
} catch (e) {
mw.log('bad config.translate.pieces');
throw e;
}
}
if (files) {
try {
notation = notation.replace(/[abcdefgh]/, function(c) { return files[c]; } );
} catch (e) {
mw.log('bad config.translate.files');
throw e;
}
}
if (rows) {
try {
notation = notation.replace(/[12345678]/, function(c) { return rows[c]; } );
} catch (e) {
mw.log('bad config.translate.files');
throw e;
}
}
return afterCommentNum + notation.replace(/-/g, '\u2011'); // replace hyphen with unbreakable
}
}
   
   
שורה 367: שורה 406:
}
}
var link = $('<span>', {'class': (move.a ? 'pgn-steplink' : 'pgn-movelink')})
var link = $('<span>', {'class': (move.a ? 'pgn-steplink' : 'pgn-movelink')})
.text(afterCommentNum + move.s.replace(/-/g, '\u2011')) // replace hyphens with non-breakable hyphens, to avoid linebreak within O-O or 1-0
.text(this.moveLinkText(afterCommentNum, move)) // replace hyphens with non-breakable hyphens, to avoid linebreak within O-O or 1-0
.data({game: this, index: i, noAnim: move.a, moveNum: num})
.data({game: this, index: i, noAnim: move.a, moveNum: num})
.click(linkMoveClick);
.click(linkMoveClick);
שורה 729: שורה 768:
var
var
id = container.attr( 'id' ) || 'pgn-viewer-' + ind,
id = container.attr( 'id' ) || 'pgn-viewer-' + ind,
config = container.data( 'config' ) || {},
config = gameSet.config = container.data( 'config' ) || {},
notationId = 'pgn-notation-' + id,
notationId = 'pgn-notation-' + id,
infoId = 'pgn-info-' + id,
infoId = 'pgn-info-' + id,
שורה 790: שורה 829:
.css({padding: 20})
.css({padding: 20})
.appendTo(gameSet.boardDiv);
.appendTo(gameSet.boardDiv);
var fl = 'abcdefgh'.split('');
var fl = 'abcdefgh'.split('');
   
var fileCpation = config && config.translate && config.translate.file;
if (fileCpation) {
fl = fl.map(function(c) { return fileCaption[c] || '' ; } );
}
var rl = '12345678'.split('');
var rowCaption = config && config.translate && config.translate.row;
if (rowCaption) {
rl = rl.map(function(c) { return rowCaption[c] || '' ; } );
}
for (var side in sides) {
for (var side in sides) {
var
var
שורה 799: שורה 848:
for (var i = 0; i < 8; i++) {
for (var i = 0; i < 8; i++) {
var sp = $('<span>', {'class': isFile ? 'pgn-file-legend' : 'pgn-row-legend'})
var sp = $('<span>', {'class': isFile ? 'pgn-file-legend' : 'pgn-row-legend'})
.text(isFile ? fl[i] : (i + 1))
.text(isFile ? fl[i] : rl[i])
.appendTo(gameSet.boardDiv)
.appendTo(gameSet.boardDiv)
.css(gameSet.legendLocation(s, i));
.css(gameSet.legendLocation(s, i));