Skip to content

Commit

Permalink
Add .js files from Grant He's repository
Browse files Browse the repository at this point in the history
There might be some extraneous .js files but this should help insure that
things work as Grant intended them to.
  • Loading branch information
mgage committed Feb 26, 2012
1 parent 739bafb commit 23dca36
Show file tree
Hide file tree
Showing 10 changed files with 701 additions and 0 deletions.
40 changes: 40 additions & 0 deletions htdocs/js/ajax_reload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* This is the javascript that creates the AJAX object and attaches it to the reload button*/
/* Reference: w3schools.com, http://www.w3schools.com/ajax/ajax_examples.asp*/

function ajax_Reload() {
var xmlhttp;

if(window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
}
else{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200){
document.getElementById("problem_viewer_content").innerHTML=xmlhttp.responseText;
}
};

var tempEditFileDirectory = document.getElementById("temp_url_id").getAttribute("value");
alert(location.protocol+"//"+location.host+tempEditFileDirectory+"/temp_body.txt");
xmlhttp.open("GET", location.protocol+"//"+location.host+tempEditFileDirectory+"/temp_body.txt", true);
xmlhttp.send();
}

/*This method of adding to the onload event listener is taken from tabber.js, which in turn takes from http://simon.incutio.com/archive/2004/05/26/addLoadEvent*/

// var oldonload;

// oldonload = window.onload;

// if(typeof window.onload != "function"){
// window.onload = function() { document.getElementById("reload_button").onclick = ajax_Reload; };
// }
// else{
// window.onload = function() {
// oldonload();
// document.getElementById("reload_button").onclick = ajax_Reload;
// };
// }
32 changes: 32 additions & 0 deletions htdocs/js/classlist_handlers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*This is the Javascript which applies some handlers to various input elements*/

function classlist_add_filter_elements() {
var filter_select = document.getElementById("filter_select");
var filter_elements = document.getElementById("filter_elements");

if(filter_select.selectedIndex == 3){
filter_elements.style.display = "block";
}
else{
filter_elements.style.display = "none";
}
}

function classlist_add_export_elements() {
var export_select_target = document.getElementById("export_select_target");
var export_elements = document.getElementById("export_elements");

if(export_select_target.selectedIndex == 0){
export_elements.style.display = "block";
}
else{
export_elements.style.display = "none";
}
}

addOnLoadEvent(function() {
document.getElementById("filter_select").onchange = classlist_add_filter_elements;
classlist_add_filter_elements();
document.getElementById("export_select_target").onchange = classlist_add_export_elements;
classlist_add_export_elements();
});
18 changes: 18 additions & 0 deletions htdocs/js/form_checker_hmwksets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*This is the javascript which checks the forms for errors on the Hmwksets editor page.*/

function check_form_hmwk_sets() {
var filter_text = document.getElementById("filter_text");
var filter_select = document.getElementById("filter_select");
var filter_err_msg = document.getElementById("filter_err_msg");
var filter_radio = document.getElementById("filter_id");

if(filter_radio.checked && filter_select.selectedIndex == 3 && filter_text.value == ""){
filter_err_msg.style.display = "inline";
return false;
}
}


addOnLoadEvent(function (){
document.getElementById("take_action").onclick = check_form_hmwk_sets;
});
23 changes: 23 additions & 0 deletions htdocs/js/getInputTable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*This gets the input table for the XMLRPC call*/

function getInputTable(){
var problem_viewer = document.getElementById("problem_viewer_form");
var inputElems = problem_viewer.getElementsByTagName("input");

var inputTable = new Array();

var type,name,value;
for(i in inputElems){
type = inputElems[i].getAttribute("type");
name = inputElems[i].getAttribute("name");
value = inputElems[i].getAttribute("value");
if(type == "submit" || type == "button" || type == "reset"){
continue;
}
else{
inputTable[name] = value;
}
}

return inputTable;
}
18 changes: 18 additions & 0 deletions htdocs/js/hmwksets_handlers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*This contains the Javascripts for the handlers on the hmwk sets page.*/

function hmwksets_add_filter_elements() {
var filter_select = document.getElementById("filter_select");
var filter_elements = document.getElementById("filter_elements");

if(filter_select.selectedIndex == 3){
filter_elements.style.display = "block";
}
else{
filter_elements.style.display = "none";
}
}

addOnLoadEvent(function() {
document.getElementById("filter_select").onchange = hmwksets_add_filter_elements;
hmwksets_add_filter_elements();
});
9 changes: 9 additions & 0 deletions htdocs/js/java_init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*This is the file where the proper functions are initialized for the problem applets which use them.*/

function initWW(){
if (typeof(initializeWWquestion) == 'function') {
initializeWWquestion();
}
}

addOnLoadEvent(initWW);
Loading

0 comments on commit 23dca36

Please sign in to comment.