1
0
Fork 0

handle deckEditor

1. disable deckEditor's ·DONE
2. refresh page when add new deck
This commit is contained in:
deardrops 2017-04-10 20:16:09 +08:00 committed by WEBXOSS
parent 7242d310c7
commit 1d8fe4e4c6

View file

@ -237,7 +237,7 @@ function readDeckNames() {
return JSON.parse(localStorage.getItem('deck_filenames')) || []; return JSON.parse(localStorage.getItem('deck_filenames')) || [];
} }
function initDeckSelect() { function updateDeckSelect() {
deckNames = readDeckNames(); deckNames = readDeckNames();
var hostDeckSelect = $('host-decks'); var hostDeckSelect = $('host-decks');
var guestDeckSelect = $('guest-decks'); var guestDeckSelect = $('guest-decks');
@ -259,10 +259,23 @@ function changeLanguage() {
location.reload(); location.reload();
} }
function resizeIFrameToFitContent() { function handleDeckEditor() {
var iFrame = $('deck-editor'); var iFrame = $('deck-editor');
//resizeIFrameToFitContent
iFrame.width = iFrame.contentWindow.document.body.scrollWidth; iFrame.width = iFrame.contentWindow.document.body.scrollWidth;
iFrame.height = iFrame.contentWindow.document.body.scrollHeight; iFrame.height = iFrame.contentWindow.document.body.scrollHeight;
// disable deck-editor return
iFrame.contentDocument
.getElementById('link-back-to-webxoss').href = "#"
// auto update deck names when change in deckEditor
window.addEventListener('storage', function(e) {
if (e.key === 'deck_filenames') {
updateDeckSelect();
}
});
} }
function enableButtons() { function enableButtons() {
@ -284,8 +297,8 @@ function disableButtons() {
} }
window.onload = function() { window.onload = function() {
$('select-language').value = localStorage.getItem('language'); $('select-language').value = localStorage.getItem('language');
initDeckSelect(); updateDeckSelect();
resizeIFrameToFitContent(); handleDeckEditor();
disableButtons(); disableButtons();
}; };