Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var currentTab = "";
- function showHometab() {
- if (currentTab != "TabA") {
- currentTab = "TabA";
- showNoTabs();
- document.getElementById("TabA").style.backgroundColor = "lightBlue";
- document.getElementById("SectionA").style.display = "inline";
- }
- }
- function showTabB() {
- if (currentTab != "TabB") {
- currentTab = "TabB";
- showNoTabs();
- document.getElementById("TabB").style.backgroundColor = "lightBlue";
- document.getElementById("SectionB").style.display = "inline";
- }
- var uri = "http://redsox.uoa.auckland.ac.nz/BC/Open/Service.svc/brlist";
- var list = new XMLHttpRequest();
- list.open("GET", uri, true);
- list.setRequestHeader('Accept', 'application/json');
- list.onload = function () {
- var version_d = document.getElementById("showbrTab");
- version_d.innerHTML = list.responseText;
- console.log(list.responseText);
- var res = JSON.parse(list.responseText);
- console.log(JSON.stringify(res))
- showbrlist(res);
- }
- list.send(null);
- }
- function showTabC() {
- if (currentTab != "TabC") {
- currentTab = "TabC";
- showNoTabs();
- document.getElementById("TabC").style.backgroundColor = "lightBlue";
- document.getElementById("SectionC").style.display = "inline";
- }
- var uri2 = "http://redsox.uoa.auckland.ac.nz/BC/Open/Service.svc/booklist";
- var list = new XMLHttpRequest();
- list.open("GET", uri2, true);
- list.setRequestHeader('Accept', 'application/json');
- list.onload = function () {
- var version_d = document.getElementById("bookl");
- version_d.innerHTML = list.responseText;
- console.log(list.responseText);
- var res = JSON.parse(list.responseText);
- console.log(JSON.stringify(res))
- showbooklist(res);
- }
- list.send(null);
- }
- function showTabD() {
- if (currentTab != "TabD") {
- currentTab = "TabD";
- showNoTabs();
- document.getElementById("TabD").style.backgroundColor = "lightBlue";
- document.getElementById("SectionD").style.display = "inline";
- }
- }
- function showTabE() {
- if (currentTab != "TabE") {
- currentTab = "TabE";
- showNoTabs();
- document.getElementById("TabE").style.backgroundColor = "lightBlue";
- document.getElementById("SectionE").style.display = "inline";
- }
- }
- function showNoTabs() {
- document.getElementById("TabA").style.backgroundColor = "transparent";
- document.getElementById("TabB").style.backgroundColor = "transparent";
- document.getElementById("TabC").style.backgroundColor = "transparent";
- document.getElementById("TabD").style.backgroundColor = "transparent";
- document.getElementById("TabE").style.backgroundColor = "transparent";
- document.getElementById("SectionA").style.display = "none";
- document.getElementById("SectionB").style.display = "none";
- document.getElementById("SectionC").style.display = "none";
- document.getElementById("SectionD").style.display = "none";
- document.getElementById("SectionE").style.display = "none";
- }
- window.onload = function () {
- showHometab();
- }
- function searchbluray() {
- document.getElementById("showbrTab").innerHTML = null;
- action = document.getElementById("searchbr").value;
- var uri = "http://redsox.uoa.auckland.ac.nz/BC/Open/Service.svc/brsearch?term=" + action;
- var list = new XMLHttpRequest();
- list.open("GET", uri, true);
- list.setRequestHeader('Accept', 'application/json');
- list.onload = function () {
- var version_d = document.getElementById("showbrTab");
- version_d.innerHTML = list.responseText;
- console.log(list.responseText);
- var res = JSON.parse(list.responseText);
- console.log(JSON.stringify(res))
- showbrlist(res);
- }
- list.send(null);
- }
- function searchbooklist() {
- document.getElementById("bookl").innerHTML = null;
- action = document.getElementById("searchbl").value;
- var uri = "http://redsox.uoa.auckland.ac.nz/BC/Open/Service.svc/booksearch?term=" + action;
- var list = new XMLHttpRequest();
- list.open("GET", uri, true);
- list.setRequestHeader('Accept', 'application/json');
- list.onload = function () {
- var version_d = document.getElementById("bookl");
- version_d.innerHTML = list.responseText;
- console.log(list.responseText);
- var res = JSON.parse(list.responseText);
- console.log(JSON.stringify(res))
- showbooklist(res);
- }
- list.send(null);
- }
- function showbrlist(li) {
- var tableContent = "<tr class='blurays'></tr>\n";
- for (var i = 0; i < li.length; ++i) {
- var record = li[i];
- var addrs = record.Title;
- if (i & 1 == 1) { // odd row
- tableContent += "<tr class='orderOdd'>";
- }
- else { // even row
- tableContent += "<tr class='orderEven'>";
- }
- tableContent += "<td>" + "<img src=http://redsox.uoa.auckland.ac.nz/BC/Open/Service.svc/brimg?id="+ record.Id +"></td><td>" + addrs + "</td><td>" + "<button onclick=Buybr(" + JSON.stringify(record.Id) + ")>Buy</button><br><br>" + "</td></tr>\n";
- }
- document.getElementById("showbrTab").innerHTML = tableContent;
- }
- function showbooklist(dest) {
- var tableContent = "<tr class='bookTitles'></tr>\n";
- for (var i = 0; i < dest.length; ++i) {
- var record = dest[i];
- var addrs = record.Title;
- if (i & 1 == 1) { // odd row
- tableContent += "<tr class='orderOdd'>";
- }
- else { // even row
- tableContent += "<tr class='orderEven'>";
- }
- tableContent += "<td>" + "<img src=http://redsox.uoa.auckland.ac.nz/BC/Open/Service.svc/bookimg?id="+ record.Id + "></td><td>" + addrs + "</td><td>" + "<button onclick=Buy(" + JSON.stringify(record.Id) + ")>Buy</button><br><br>" + "</td></tr>\n";
- }
- document.getElementById("bookl").innerHTML = tableContent;
- }
- function Buy(item) {
- window.open("http://redsox.uoa.auckland.ac.nz/BC/Closed/Service.svc/bookbuy?id=" + item );
- }
- function Buybr(item) {
- window.open("http://redsox.uoa.auckland.ac.nz/BC/Closed/Service.svc/brbuy?id=" + item );
- }
- function Register() {
- Username = document.getElementById("Username").value;
- Pw = document.getElementById("Pw").value;
- Address = document.getElementById("Address").value;
- var uri= "http://redsox.uoa.auckland.ac.nz/BC/Open/Service.svc/register";
- var xhr= new XMLHttpRequest();
- xhr.open("POST", uri, true);
- xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
- var info = "{\"Address\":" + "\"" + Address + "\" , \"Name\":" + "\"" + Username + "\" , \"Password\":" + "\"" + Pw + "\"}";
- xhr.onload= function() {
- window.alert("you have been registered!")
- }
- xhr.send(info);
- }
- function Save() {
- comment = document.getElementById("comment").value;
- name = document.getElementById("name").value;
- var uri= "http://redsox.uoa.auckland.ac.nz/BC/Open/Service.svc/comment?name=" + name;
- var xhr= new XMLHttpRequest();
- xhr.open("POST", uri, true);
- xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
- xhr.onload= function() {
- document.getElementById("com").src = document.getElementById("com").src
- }
- xhr.send(JSON.stringify(comment));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement