📄 common.js
字号:
} if (image.width <= 700 && image.width > 300) image.width = image.width * 0.7 if (image.height > 270){ width.value = image.width + 84 }else{ width.value = image.width + 144 } height.value = image.height + 24 if (width.value < 180) width.value = 180 if (height.value < 160) height.value = 160}function imageChanged(event) { var id = event.currentTarget.getAttribute('id'); var elementId = id.substring(3, id.length); var image = document.getElementById('img'+elementId); var width = document.getElementById('width'+elementId); var height = document.getElementById('height'+elementId); width.value = image.width; height.value = image.height;}function changeImageWidth(elementId) { var image = document.getElementById('img'+elementId); var width = document.getElementById('width'+elementId); var height = document.getElementById('height'+elementId); image.removeAttribute('height'); if (width.value) { image.width = width.value; } else if (image.hasAttribute('src')) { image.removeAttribute('width'); width.value = image.width; } else { width.value = ""; } height.value = image.height;}function changeImageHeight(elementId) { var image = document.getElementById('img'+elementId); var width = document.getElementById('width'+elementId); var height = document.getElementById('height'+elementId); image.removeAttribute('width'); if (height.value) { image.height = height.value; } else if (image.hasAttribute('src')) { image.removeAttribute('height'); height.value = image.height; } else { height.value = ""; } width.value = image.width;}function changeMagnifierImageWidth(elementId) { var image = document.getElementById('img'+elementId); var width = document.getElementById('width'+elementId); var height = document.getElementById('height'+elementId); image.removeAttribute('height'); if (width.value) { image.width = width.value - 84; } else { image.removeAttribute('width'); } if (image.width > 600){ image.removeAttribute('height') image.width = 600; } if (image.height > 270){ width.value = image.width + 84 }else{ width.value = image.width + 144 } height.value = image.height + 24 if (width.value < 180) width.value = 180 if (height.value < 160) height.value = 160}function changeMagnifierImageHeight(elementId) { var image = document.getElementById('img'+elementId); var width = document.getElementById('width'+elementId); var height = document.getElementById('height'+elementId); image.removeAttribute('width'); if (height.value) { image.height = height.value - 24; } else { image.removeAttribute('height'); } if (image.width > 600){ image.removeAttribute('height'); image.width = 600 } if (image.height > 270){ width.value = image.width + 84 }else{ width.value = image.width + 144 } height.value = image.height + 24 if (width.value < 180) width.value = 180 if (height.value < 160) height.value = 160}// Called by the user to provide a flash movie file name to add to the packagefunction addFlashMovie(blockId) { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var nsIFilePicker = Components.interfaces.nsIFilePicker; var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); fp.init(window, SELECT_A_FILE, nsIFilePicker.modeOpen); fp.appendFilter(FLASH_MOVIE, "*.flv"); fp.appendFilters(nsIFilePicker.filterAll); var res = fp.show(); if (res == nsIFilePicker.returnOK) { var path = document.getElementById('path'+blockId); path.type = 'text'; path.value = fp.file.path; }}// Called by the user to provide a flash file name to add to the packagefunction addFlash(blockId) { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var nsIFilePicker = Components.interfaces.nsIFilePicker; var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); fp.init(window, SELECT_A_FILE, nsIFilePicker.modeOpen); fp.appendFilter(FLASH_OBJECT, "*.swf"); fp.appendFilters(nsIFilePicker.filterAll); var res = fp.show(); if (res == nsIFilePicker.returnOK) { var path = document.getElementById('path'+blockId); path.type = 'text'; path.value = fp.file.path; }}function addMp3(blockId) { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var nsIFilePicker = Components.interfaces.nsIFilePicker; var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); fp.init(window, SELECT_AN_MP3_FILE, nsIFilePicker.modeOpen); fp.appendFilter(MP3_AUDIO, "*.mp3"); fp.appendFilters(nsIFilePicker.filterAll); var res = fp.show(); if (res == nsIFilePicker.returnOK) { var path = document.getElementById('path'+blockId); path.type = 'text'; path.value = fp.file.path; }}// Called by the user to provide a package name in order to get the user created idevices// used by idevice editorfunction addFile(blockId) { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var nsIFilePicker = Components.interfaces.nsIFilePicker; var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); fp.init(window, SELECT_A_PACKAGE, nsIFilePicker.modeOpen); fp.appendFilters(nsIFilePicker.filterAll); var res = fp.show(); if (res == nsIFilePicker.returnOK) { var path = document.getElementById('path'+blockId); path.value = fp.file.path; }}function uploadFile(blockId) { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var nsIFilePicker = Components.interfaces.nsIFilePicker; var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); fp.init(window, SELECT_A_FILE, nsIFilePicker.modeOpen); fp.appendFilters(nsIFilePicker.filterAll); var res = fp.show(); if (res == nsIFilePicker.returnOK) { var path = document.getElementById('path'+blockId); path.value = fp.file.path; } var theForm = top["authoringIFrame1"].document.getElementById('contentForm') if (!theForm) { // try and find the form for the authoring page theForm = document.getElementById('contentForm') } theForm.submit();}function showMe(ident, w, h){ var elmDiv = document.getElementById('popupmessage'); hideMe(); if (!elmDiv || elmDiv.innerHTML != document.getElementById(ident).innerHTML){ elmDiv = document.createElement('div'); elmDiv.id = 'popupmessage'; elmDiv.className="popupDiv"; elmDiv.style.cssText = 'position:absolute; left: ' + (xpos) + 'px; top: '+(ypos - h/2) + 'px; width: ' + w + 'px;'; elmDiv.innerHTML = document.getElementById(ident).innerHTML; document.body.appendChild(elmDiv); new dragElement('popupmessage'); }} function hideMe() { var elmDiv = document.getElementById('popupmessage'); if (elmDiv) { // removes the div from the document elmDiv.parentNode.removeChild(elmDiv); }}function updateCoords(e) { if (objBrowse == "Microsoft Internet Explorer") { xpos = e.offsetX; ypos = e.offsetY; } else { xpos = e.pageX; ypos = e.pageY; }}// Called upon loading the page this function clears the hidden// action and object fields so they can be used by submitLinkfunction clearHidden(){ var theForm = top["authoringIFrame1"].document.getElementById('contentForm') if (!theForm) { // try and find the form for the authoring page theForm = document.getElementById('contentForm') } theForm.action.value = ""; theForm.object.value = "";}// Sets the hidden action and object fields, then submits the // contentForm to the serverfunction submitLink(action, object, changed) { var theForm = top["authoringIFrame1"].document.getElementById('contentForm') if (!theForm) { // try and find the form for the authoring page theForm = document.getElementById('contentForm') } theForm.action.value = action; theForm.object.value = object; theForm.isChanged.value = changed; runFuncArray(beforeSubmitHandlers) theForm.submit();}// Check the user really really wants to do this before submittingfunction confirmThenSubmitLink(message, action, object, changed) { if (confirm(message)) { submitLink(action, object, changed); }}function getFeedback(optionId, optionsNum, ideviceId, mode) { for (i = 0; i< optionsNum; i++) { if (mode == "multi") id = "sa" + i + "b" +ideviceId else id = "s" + i + "b" +ideviceId if(i == optionId) document.getElementById(id).style.display = "block"; else document.getElementById(id).style.display = "None"; } if (mode == 'truefalse') { document.getElementById("sfbk" + ideviceId).style.display = "block"; }}// Cloze Field Stuff /////////////////////////////////////////////////// Constants NOT_ATTEMPTED = 0WRONG = 1CORRECT = 2// Functions // Called when a learner types something into a cloze word spacefunction onClozeChange(ele) { var ident = getClozeIds(ele)[0]; var instant = eval(document.getElementById( 'clozeFlag'+ident+'.instantMarking').value); if (instant) { checkAndMarkClozeWord(ele); // Hide the score paragraph if visible var scorePara = document.getElementById('clozeScore' + ident); scorePara.innerHTML = ""; }}// Recieves and marks answers from studentfunction clozeSubmit(ident) { // Mark all of the words showClozeScore(ident, 1); // Hide Submit toggleElementVisible('submit'+ident); // Show Restart toggleElementVisible('restart'+ident); // Show Show Answers Button toggleElementVisible('showAnswersButton'+ident); // Show feedback toggleClozeFeedback(ident);}// Makes cloze idevice like new :)function clozeRestart(ident) { // Hide Feedback toggleClozeFeedback(ident); // Clear the answers (Also hides score) toggleClozeAnswers(ident, true); // Hide Restart toggleElementVisible('restart'+ident); // Hide Show Answers Button toggleElementVisible('showAnswersButton'+ident); // Show Submit toggleElementVisible('submit'+ident);}// Show/Hide all answers in the cloze idevice// 'clear' is an optional argument, that forces all the answers to be cleared// whether they are all finished and correct or notfunction toggleClozeAnswers(ident, clear){ // See if any have not been answered yet var allCorrect = true; var inputs = getCloseInputs(ident) if (!clear) { for (var i=0; i<inputs.length; i++) { var input = inputs[i]; if (getClozeMark(input) != 2) { allCorrect = false; break; } } } if (allCorrect) { // Clear all answers clearClozeInputs(ident, inputs); } else { // Write all answers fillClozeInputs(ident, inputs); } // Hide the score paragraph, irrelevant now var scorePara = document.getElementById('clozeScore' + ident); scorePara.innerHTML = ""; // If the get score button is visible and we just filled in all the right // answers, disable it until they clear the scores again. var getScoreButton = document.getElementById('getScore' + ident); if (getScoreButton) { getScoreButton.disabled = !allCorrect; }}// Shows all answers for a cloze field// 'inputs' is an option argument containing a list of the 'input' elements for// the fieldfunction fillClozeInputs(ident, inputs) { if (!inputs) { var inputs = getCloseInputs(ident) } for (var i=0; i<inputs.length; i++) { input = inputs[i]; input.value = getClozeAnswer(input); markClozeWord(input, CORRECT); // Toggle the readonlyness of the answers also input.setAttribute('readonly', 'readonly'); }}// Blanks all the answers for a cloze field// 'inputs' is an option argument containing a list of the 'input' elements for// the fieldfunction clearClozeInputs(ident, inputs) { if (!inputs) { var inputs = getCloseInputs(ident) } for (var i=0; i<inputs.length; i++) { input = inputs[i]; input.value=""; markClozeWord(input, NOT_ATTEMPTED); // Toggle the readonlyness of the answers also input.removeAttribute('readonly'); }}// Marks a cloze word in view mode.// Returns NOT_ATTEMPTED, CORRECT, or WRONGfunction checkAndMarkClozeWord(ele) { var result = checkClozeWord(ele); if (result != '') { markClozeWord(ele, CORRECT); ele.value = result; return CORRECT;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -