Moderator: mrozik
kolokwium napisał(a):Sam zapis wystarczy zaznaczyć i skopiować, a jak się chce całość, to po cytowaniu. Aby to robić jednym kliknięciem, to zapewne potrzeba znać odpowiednie kody aby dopisać do skryptu.
var pgns = []; for (var i = 1; i < pgn4webTextareaIdNum; ++i) { pgns.push(document.getElementById('pgn4web_' + i).value); }; pgns
document.getElementById('pgn4web_#').value
(function () {
function create_button(doc, title, pgn) {
var link = document.createElement('A');
link.href = "data:application/x-chess-pgn;charset=utf8," + encodeURI(pgn.replace(/\]\s*/g, "]\n"));
var button = doc.createElement('BUTTON'); button.type = 'button'; button.textContent = title; button.addEventListener('click', function() { link.click(); }, false);
return button;
}
function process(id) {
var pgn = document.getElementById(id);
if (!pgn) return '';
var doc = pgn.nextElementSibling.nextElementSibling;
if (!(doc instanceof HTMLIFrameElement)) return '';
doc = doc.contentDocument;
var moves = doc.getElementById('ShowPgnText');
if (!moves) return '';
var text = pgn.value;
var button = create_button(doc, 'Zapisz pgn', text);
moves.parentNode.insertBefore(button, moves.nextElementSibling);
moves.parentNode.insertBefore(doc.createElement('BR'), button);
return text + '\n\n';
};
var whole_pgn = '';
for (var i = 1; i < pgn4webTextareaIdNum; ++i) {
whole_pgn += process('pgn4web_' + i);
}
if (whole_pgn.length > 0) {
var body = document.getElementById('page-body');
if (body && body.firstElementChild) {
var button = create_button(document, 'Zapisz wszystkie partie jako pgn', whole_pgn);
body.firstElementChild.appendChild(button);
button.parentNode.insertBefore(document.createTextNode(' '), button);
}
}
})()
Powrót do Informacje, pomysły i propozycje
Użytkownicy przeglądający ten dział: Brak zidentyfikowanych użytkowników i 2 gości