// the full question list
var questions = [["Find the textbook title '<b>Anthropologist on Mars</b>'."],  // 0
                 ["Find a book by <b>Hemingway, Ernest</b> as an author."],  // 1
                 [ "Check to see if the book <b>The Goldfinch</b> is available to borrow for a four week period."], // 2
                 ["Search for scholarly articles on '<b>community college students</b>'."],  // 3
                 ["Find the database '<b>Academic Search Complete</b>'."],  // 4
                 ["Find the database '<b>JSTOR</b>'."],  // 5
                 ["Find circulation policies."],  // 6
                 ["Calculate fines for a book that is five days overdue."], // 7
                 ["Find the library hours for the Spring semester of 2017."],  // 8
                 ["Use the 'Ask a Librarian' menu."],  // 9
                 ["Search to see if a document is available on eReserve."],  // 10
                 ["Open a new interlibrary loan account."],  // 11
                 ["Request an interlibrary loan."],  // 12
                 ["Find the library's Twitter feed."],  // 13
                 ["Find the library's Goodreads profile."]]  // 14

// the urls for the activities, with random questions
var urls = ["http://kbcc.cuny.libguides.com/prototype9",
            "http://kbcc.cuny.libguides.com/prototype10",
            "http://kbcc.cuny.libguides.com/prototype11",
            "http://kbcc.cuny.libguides.com/prototype12",
            "http://kbcc.cuny.libguides.com/prototype13"]

// make the table using js
var tableHTML1 = '<tr><td><div class="activity-container">Activity #';
var tableHTML2 = '<a href="" onclick="gotoactivity(';
var tableHTML3 = '); return false;" class="btn btn-default active" role="button" id="';
var tableHTML4 = '"> Try it now!</a></div></td></tr>';

// set some variables in preparation for gotoactivity()
var startHTML = '<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"><div class="alert alert-warning" style="text-align:center"><b>Activity #' 
var midHTML = '</b></div><div class="alert alert-info" style="margin:15px">';
var endHTML = '</div>';
var timer = undefined;

// what to do when the user clicks on an activity
function gotoactivity(id) {
    displayid = parseInt(id) + 1;
    var instructions = window.open('', 'instructions', 'left=20,top=20,width=160,height=300,menubar=no,titlebar=no');
    var workspace = window.open(urls[id], 'workspace', 'left=200,top=20,width=1195,height=750,menubar=no,titlebar=no,scrollbars=yes');
    instructions.document.body.innerHTML = startHTML + displayid + midHTML + questions[id] + endHTML;

    // closes one window when the other is closed
    timer = setInterval(function() {
        $(this).focus(function() {
            workspace.close();
            instructions.close();
        });
        if (instructions.closed) {
            workspace.close();
            clearInterval(timer);
        }
        else if (workspace.closed) {
            instructions.close();
            clearInterval(timer);
        }
    }, 50);
};

$(document).ready(function() {
	for (i = 0; i < urls.length; i++) {
		$("tbody").append(tableHTML1 + parseInt(i + 1) + tableHTML2 + i + tableHTML3 + i + tableHTML4);
	};
    $(".btn").click(function() {
        $(this).text('completed!').removeClass('active').addClass('disabled');
    });
});


@@ -23,16 +23,24 @@
 ist%0Avar 
+original
 question
@@ -112,16 +112,24 @@
 ,  // 0%0A
+        
         
@@ -219,16 +219,24 @@
         
+        
 %5B %22Check
@@ -340,32 +340,40 @@
                 
+       
+ 
 %5B%22Search for sch
@@ -446,32 +446,40 @@
                 
+        
 %5B%22Find the datab
@@ -535,32 +535,40 @@
                 
+       
+ 
 %5B%22Find the datab
@@ -609,24 +609,32 @@
             
+        
 %5B%22Find circu
@@ -676,16 +676,24 @@
         
+      
+  
 %5B%22Calcul
@@ -748,16 +748,24 @@
 %5D, // 7%0A
+        
         
@@ -857,16 +857,24 @@
         
+      
+  
 %5B%22Use th
@@ -908,16 +908,24 @@
 ,  // 9%0A
+        
         
@@ -1016,16 +1016,24 @@
         
+     
+   
 %5B%22Open a
@@ -1091,16 +1091,24 @@
         
+        
 %5B%22Reques
@@ -1150,32 +1150,40 @@
                 
+    
+    
 %5B%22Find the libra
@@ -1211,16 +1211,24 @@
   // 13%0A
+        
         
@@ -1287,16 +1287,384 @@
  // 14%0A%0A
+var questions1 = %5B%5B%22Find the textbook title '%3Cb%3EAnthropologist on Mars%3C/b%3E'.%22%5D,  // 0%0A                  %5B%22Search for scholarly articles on '%3Cb%3Ecommunity college students%3C/b%3E'.%22%5D,  // 3%0A                  %5B%22Find circulation policies.%22%5D, %0A                  %5B%22Open a new interlibrary loan account.%22%5D,  //11%0A                  %5B%22Find the library's Twitter feed.%22%5D%5D  // 13%0A%0A%0A
 // the u
@@ -1688,31 +1688,8 @@
 itie
-s, with random question
 s%0Ava
@@ -1983,11 +1983,35 @@
 %0A// 
-mak
+set some variables to creat
 e th
@@ -2021,17 +2021,8 @@
 able
- using js
 %0Avar
@@ -3210,17 +3210,16 @@
 idHTML +
- 
 question
@@ -3219,16 +3219,17 @@
 uestions
+1
 %5Bid%5D + e
@@ -3677,16 +3677,43 @@
 0);%0A%7D;%0A%0A
+// make the table using js%0A
 $(docume

divide questions by cohort