This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function () { | |
$('.nav-toggle').click(function () { | |
var collapse_content_selector = $(this).attr('href'); | |
var toggle_switch = $(this); | |
$(collapse_content_selector).toggle(function () { | |
if ($(this).css('display') == 'none') { | |
toggle_switch.html('Background History of Government Transparency'); | |
} else { | |
toggle_switch.html('Background History of Government Transparency'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Creación tabla con miembros y filtro | |
function createTable(members, filter1, filter2) { | |
houseData.innerHTML = ""; | |
let tableBody = document.getElementById("houseData"); | |
let membersinfo = ["first_name", "party", "state", "seniority", "votes_with_party_pct"]; | |
for (let i = 0; i < members.length; i++) { | |
if (filter1.includes(members[i].party) || filter1.length < 1) { | |
let newTr = document.createElement("tr"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function () { | |
$('.nav-toggle').click(function () { | |
var collapse_content_selector = $(this).attr('href'); | |
var toggle_switch = $(this); | |
$(collapse_content_selector).toggle(function () { | |
if ($(this).css('display') == 'none') { | |
toggle_switch.html('Background History of Government Transparency'); | |
} else { | |
toggle_switch.html('Background History of Government Transparency'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html lang="en"> | |
<!DOCTYPE html> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<link rel="stylesheet" href="./styles/css.css"> | |
<link href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" rel="stylesheet"> | |
<title>House</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const members = data.results[0].members; //Constante para entrar en el objeto del JSON | |
var tbody = document.getElementById("thestatisticsobject"); //getElementById para introducir cada "id" con ese nombre en el HTML. En este caso en las tablas(tbody) | |
var tbody = document.getElementById("thestatisticsobject1"); | |
var numbmissed = document.getElementById("numbermissed"); //Id en las tablas con el % de votos missed | |
var congress = { //Objeto creado de 0 para almacenar los resultados de cada congresista. Se pone 0 en todos ellos ya que dicho valor se modificará en base a la función o cálculo que hagamos. Son contenedores para almacenar información | |
dem: 0, | |
rep: 0, | |
ind: 0, | |
porcentrep: 0, | |
porcentdem: 0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var result = "", | |
y = null, | |
z = ""; | |
for (i = 0; i < leastoftenvoteArray.length; i++) { | |
if (leastoftenvoteArray[i].middle_name == y) { | |
result += "<tr>" + "<td>" + '<a href="' + leastoftenvoteArray[i].url + '">' + leastoftenvoteArray[i].first_name + ' ' + z + ' ' + leastoftenvoteArray[i].last_name + "</a>" + "</td>"; | |
} else { | |
result += "<tr>" + "<td>" + '<a href="' + leastoftenvoteArray[i].url + '">' + leastoftenvoteArray[i].first_name + ' ' + leastoftenvoteArray[i].middle_name + ' ' + leastoftenvoteArray[i].last_name + "</a>" + "</td>"; | |
} | |
result += "<td class='party'>" + leastoftenvoteArray[i].missed_votes + "</td>"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Bloque declarando todas las variables y datos necesarios | |
const myMembers = data.results[0].members; | |
let fieldsInserted = ["first_name", "party", "state", "seniority", "votes_with_party_pct"]; | |
let tBody = document.getElementById("houseData"); //Se incrustará en la id houseData de la tabla | |
for (let i=0; i< myMembers.length; i++) { // iniciamos 1er loop para coger todos los miembros | |
let newTr = document.createElement("tr"); //crea variable nueva que crea el TR | |
for (let j=0; j< fieldsInserted.length; j++) { //Loop para coger todos los datos necesarios de cada miembro | |
let dataInserted = fieldsInserted[j]; //Nueva variable con todos los datos ya cogidos por el loop con condición J | |
let newTd = document.createElement("td"); //creamos variable nueva que crea el TD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myMembers = data.results[0].members; | |
let fieldsInserted = ["first_name", "party", "state", "seniority", "votes_with_party_pct"]; | |
let tBody = document.getElementById("houseData"); | |
let link = ["url"]; //he creado otra variable con el atributo ''url'' que se encuentra en el JS, pero no se en que momento colocarlo ni que poner. | |
for (let i=0; i< myMembers.length; i++) { | |
let newTr = document.createElement("tr"); | |
for (let j=0; j< fieldsInserted.length; j++) { | |
let dataInserted = fieldsInserted[j]; | |
let newTd = document.createElement("td"); | |
newTd.innerHTML = myMembers[i][dataInserted] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const myMembers = data.results[0].members; //creo una constante con nombre myMembers para englobar esa lista tan grande (data, results[0], etc) | |
let fieldsInserted = [“first_name”, “party”, “state”, “seniority”, “votes_with_party_pct”]; //variable con los datos que necesito de cada miembro | |
let tBody = document.getElementById(“houseData”); //houseData es el ID en mi tbody del html, donde se van a construir los TRs y TDs | |
for (let i=0; i< myMembers.length; i++) { | |
let newTr = document.createElement(“tr”); | |
for (let j=0; j< fieldsInserted.length; j++) { | |
let dataInserted = fieldsInserted[j]; | |
let newTd = document.createElement(“td”); | |
newTd.innerHTML = myMembers[i][dataInserted] | |
if (j==0 && myMembers[i].middle_name != null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html lang="en"> | |
<!DOCTYPE html> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<link rel="stylesheet" href="./styles/css.css"> | |
<link href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" rel="stylesheet"> | |
<title>House</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> |
NewerOlder