/*********************************************************************
* demographics.js.php
*
* Sets up the demographics form and performs the necessary
* checks before the subject is allowed to move on.
*
* Last Modified : July 25, 2013 by Jonathan Taratuta-Titus
*
* Author: Yuechen Zhao, Jun Sup Lee, Norman Zhu,
* adapted from a version created by Nancy Chen
*
* © Copyright 2014 LabintheWild
* For questions about this file and permission to use
* the code, contact us at info@labinthewild.org
*********************************************************************/
// to input data from cookies
function inputFromCookie() {
// setting the value from cookies as default
var defLength = def.length;
for(var i = 0; i < defLength; i++) {
var temp = readCookie(def[i]);
// console.log("cookie value = " + temp);
if (temp!= null && temp!= " " && temp!= "") {
// console.log("entered condition to call select element function");
selectElement(def[i], temp);
}
}
}
// to pre-select the elements in the form
function selectElement(elementName, valueToSelect) {
// console.log("element name = " + elementName);
var element = document.getElementsByName(elementName);
if(element[0].name == "retake" || element[0].name == "gender" || element[0].name == "multinational" || element[0].name == "normalvision")
element[0][parseInt(valueToSelect) + 1].selected = true;
else if(element[0].name == "age") {
element[0][parseInt(valueToSelect) - 5].selected = true;
}
else if(element[0].name == "country0" || element[0].name == "country1" || element[0].name == "country" || element[0].name == "home" || element[0].name == "current" || element[0].name == "father" || element[0].name == "mother")
element[0][findIndex(countries_en, valueToSelect)].selected = true;
else if(element[0].name == "education")
element[0][findIndex(education_en, valueToSelect)].selected = true;
else if(element[0].name == "lang0" || element[0].name == "lang1")
element[0][findIndex(languages_en, valueToSelect)].selected = true;
/*
The language menu doesn't work for cookies because of translation and key-value issues as mentioned in research notes
*/
else if(element[0].name == "fluency1")
element[0][findIndex(fluency, valueToSelect)].selected = true;
else if(element[0].name == "years0" || element[0].name == "years1" || element[0].name == "years" || element[0].name == "homeyears" || element[0].name == "currentyears")
{
if (parseFloat(valueToSelect) == 0.5)
element[0][1].selected = true;
else
element[0][parseInt(valueToSelect) + 1].selected = true;
}
else {}
}
// find index of country in associative array, can change function parameters to take in any array if needed
function findIndex(data, content) {
var index = 0;
for(var key in data) {
if(data[key] == content)
return index;
index++;
}
}
// function to create a cookie
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = "LITW" + name+"="+value+expires+"; path=/";
}
// function to read a cookie
function readCookie(name) {
var nameEQ = "LITW" + name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
// function to erase a cookie
function eraseCookie(name) {
createCookie("LITW" + name,"",-1);
}
var countries_en = {
' ': ' ',
'Afghanistan': 'Afghanistan',
'Aland Islands': 'Aland Islands',
'Albania': 'Albania',
'Algeria': 'Algeria',
'American Samoa': 'American Samoa',
'Andorra': 'Andorra',
'Angola': 'Angola',
'Anguilla': 'Anguilla',
'Antarctica': 'Antarctica',
'Antigua And Barbuda': 'Antigua And Barbuda',
'Argentina': 'Argentina',
'Armenia': 'Armenia',
'Aruba': 'Aruba',
'Australia': 'Australia',
'Austria': 'Austria',
'Azerbaijan': 'Azerbaijan',
'Bahamas': 'Bahamas',
'Bahrain': 'Bahrain',
'Bangladesh': 'Bangladesh',
'Barbados': 'Barbados',
'Belarus': 'Belarus',
'Belgium': 'Belgium',
'Belize': 'Belize',
'Benin': 'Benin',
'Bermuda': 'Bermuda',
'Bhutan': 'Bhutan',
'Bolivia': 'Bolivia',
'Bosnia And Herzegovina': 'Bosnia And Herzegovina',
'Botswana': 'Botswana',
'Bouvet Island': 'Bouvet Island',
'Brazil': 'Brazil',
'British Indian Ocean Territory': 'British Indian Ocean Territory',
'Brunei Darussalam': 'Brunei Darussalam',
'Bulgaria': 'Bulgaria',
'Burkina Faso': 'Burkina Faso',
'Burundi': 'Burundi',
'Cambodia': 'Cambodia',
'Cameroon': 'Cameroon',
'Canada': 'Canada',
'Cape Verde': 'Cape Verde',
'Cayman Islands': 'Cayman Islands',
'Central African Republic': 'Central African Republic',
'Chad': 'Chad',
'Chile': 'Chile',
'China': 'China',
'Christmas Island': 'Christmas Island',
'Cocos (Keeling) Islands': 'Cocos (Keeling) Islands',
'Colombia': 'Colombia',
'Comoros': 'Comoros',
'Congo': 'Congo',
'The Democratic Republic Of The Congo': 'The Democratic Republic Of The Congo',
'Cook Islands': 'Cook Islands',
'Costa Rica': 'Costa Rica',
'Cote Divoire': 'Cote Divoire',
'Croatia': 'Croatia',
'Cuba': 'Cuba',
'Cyprus': 'Cyprus',
'Czech Republic': 'Czech Republic',
'Denmark': 'Denmark',
'Djibouti': 'Djibouti',
'Dominica': 'Dominica',
'Dominican Republic': 'Dominican Republic',
'Ecuador': 'Ecuador',
'Egypt': 'Egypt',
'El Salvador': 'El Salvador',
'Equatorial Guinea': 'Equatorial Guinea',
'Eritrea': 'Eritrea',
'Estonia': 'Estonia',
'Ethiopia': 'Ethiopia',
'Falkland Islands (Malvinas)': 'Falkland Islands (Malvinas)',
'Faroe Islands': 'Faroe Islands',
'Fiji': 'Fiji',
'Finland': 'Finland',
'France': 'France',
'French Guiana': 'French Guiana',
'French Polynesia': 'French Polynesia',
'French Southern Territories': 'French Southern Territories',
'Gabon': 'Gabon',
'Gambia': 'Gambia',
'Georgia': 'Georgia',
'Germany': 'Germany',
'Ghana': 'Ghana',
'Gibraltar': 'Gibraltar',
'Greece': 'Greece',
'Greenland': 'Greenland',
'Grenada': 'Grenada',
'Guadeloupe': 'Guadeloupe',
'Guam': 'Guam',
'Guatemala': 'Guatemala',
'Guernsey': 'Guernsey',
'Guinea': 'Guinea',
'Guinea-bissau': 'Guinea-bissau',
'Guyana': 'Guyana',
'Haiti': 'Haiti',
'Heard Island And Mcdonald Islands': 'Heard Island And Mcdonald Islands',
'Holy See (Vatican City State)': 'Holy See (Vatican City State)',
'Honduras': 'Honduras',
'Hong Kong': 'Hong Kong',
'Hungary': 'Hungary',
'Iceland': 'Iceland',
'India': 'India',
'Indonesia': 'Indonesia',
'Iran': 'Iran',
'Iraq': 'Iraq',
'Ireland': 'Ireland',
'Isle Of Man': 'Isle Of Man',
'Israel': 'Israel',
'Italy': 'Italy',
'Jamaica': 'Jamaica',
'Japan': 'Japan',
'Jersey': 'Jersey',
'Jordan': 'Jordan',
'Kazakhstan': 'Kazakhstan',
'Kenya': 'Kenya',
'Kiribati': 'Kiribati',
'Democratic Peoples Republic of Korea': 'Democratic Peoples Republic of Korea',
'Republic of Korea': 'Republic of Korea',
'Kuwait': 'Kuwait',
'Kyrgyzstan': 'Kyrgyzstan',
'Lao Peoples Democratic Republic': 'Lao Peoples Democratic Republic',
'Latvia': 'Latvia',
'Lebanon': 'Lebanon',
'Lesotho': 'Lesotho',
'Liberia': 'Liberia',
'Libyan Arab Jamahiriya': 'Libyan Arab Jamahiriya',
'Liechtenstein': 'Liechtenstein',
'Lithuania': 'Lithuania',
'Luxembourg': 'Luxembourg',
'Macao': 'Macao',
'Macedonia': 'Macedonia',
'Madagascar': 'Madagascar',
'Malawi': 'Malawi',
'Malaysia': 'Malaysia',
'Maldives': 'Maldives',
'Mali': 'Mali',
'Malta': 'Malta',
'Marshall Islands': 'Marshall Islands',
'Martinique': 'Martinique',
'Mauritania': 'Mauritania',
'Mauritius': 'Mauritius',
'Mayotte': 'Mayotte',
'Mexico': 'Mexico',
'Micronesia': 'Micronesia',
'Republic of Moldova': 'Republic of Moldova',
'Monaco': 'Monaco',
'Mongolia': 'Mongolia',
'Montenegro': 'Montenegro',
'Montserrat': 'Montserrat',
'Morocco': 'Morocco',
'Mozambique': 'Mozambique',
'Myanmar': 'Myanmar',
'Namibia': 'Namibia',
'Nauru': 'Nauru',
'Nepal': 'Nepal',
'Netherlands': 'Netherlands',
'Netherlands Antilles': 'Netherlands Antilles',
'New Caledonia': 'New Caledonia',
'New Zealand': 'New Zealand',
'Nicaragua': 'Nicaragua',
'Niger': 'Niger',
'Nigeria': 'Nigeria',
'Niue': 'Niue',
'Norfolk Island': 'Norfolk Island',
'Northern Mariana Islands': 'Northern Mariana Islands',
'Norway': 'Norway',
'Oman': 'Oman',
'Pakistan': 'Pakistan',
'Palau': 'Palau',
'Palestinian Territory': 'Palestinian Territory',
'Panama': 'Panama',
'Papua New Guinea': 'Papua New Guinea',
'Paraguay': 'Paraguay',
'Peru': 'Peru',
'Philippines': 'Philippines',
'Pitcairn': 'Pitcairn',
'Poland': 'Poland',
'Portugal': 'Portugal',
'Puerto Rico': 'Puerto Rico',
'Qatar': 'Qatar',
'Reunion': 'Reunion',
'Romania': 'Romania',
'Russian Federation': 'Russian Federation',
'Rwanda': 'Rwanda',
'Saint Helena': 'Saint Helena',
'Saint Kitts And Nevis': 'Saint Kitts And Nevis',
'Saint Lucia': 'Saint Lucia',
'Saint Pierre And Miquelon': 'Saint Pierre And Miquelon',
'Saint Vincent And The Grenadines': 'Saint Vincent And The Grenadines',
'Samoa': 'Samoa',
'San Marino': 'San Marino',
'Sao Tome And Principe': 'Sao Tome And Principe',
'Saudi Arabia': 'Saudi Arabia',
'Senegal': 'Senegal',
'Serbia': 'Serbia',
'Seychelles': 'Seychelles',
'Sierra Leone': 'Sierra Leone',
'Singapore': 'Singapore',
'Slovakia': 'Slovakia',
'Slovenia': 'Slovenia',
'Solomon Islands': 'Solomon Islands',
'Somalia': 'Somalia',
'South Africa': 'South Africa',
'South Georgia And The South Sandwich Islands': 'South Georgia And The South Sandwich Islands',
'Spain': 'Spain',
'Sri Lanka': 'Sri Lanka',
'Sudan': 'Sudan',
'Suriname': 'Suriname',
'Svalbard And Jan Mayen': 'Svalbard And Jan Mayen',
'Swaziland': 'Swaziland',
'Sweden': 'Sweden',
'Switzerland': 'Switzerland',
'Syrian Arab Republic': 'Syrian Arab Republic',
'Taiwan': 'Taiwan',
'Tajikistan': 'Tajikistan',
'Tanzania': 'Tanzania',
'Thailand': 'Thailand',
'Timor-leste': 'Timor-leste',
'Togo': 'Togo',
'Tokelau': 'Tokelau',
'Tonga': 'Tonga',
'Trinidad And Tobago': 'Trinidad And Tobago',
'Tunisia': 'Tunisia',
'Turkey': 'Turkey',
'Turkmenistan': 'Turkmenistan',
'Turks And Caicos Islands': 'Turks And Caicos Islands',
'Tuvalu': 'Tuvalu',
'Uganda': 'Uganda',
'Ukraine': 'Ukraine',
'United Arab Emirates': 'United Arab Emirates',
'United Kingdom': 'United Kingdom',
'United States': 'United States',
'United States Minor Outlying Islands': 'United States Minor Outlying Islands',
'Uruguay': 'Uruguay',
'Uzbekistan': 'Uzbekistan',
'Vanuatu': 'Vanuatu',
'Venezuela': 'Venezuela',
'Viet Nam': 'Viet Nam',
'British Virgin Islands': 'British Virgin Islands',
'U.S. Virgin Islands': 'U.S. Virgin Islands',
'Wallis And Futuna': 'Wallis And Futuna',
'Western Sahara': 'Western Sahara',
'Yemen': 'Yemen',
'Zambia': 'Zambia',
'Zimbabwe': 'Zimbabwe'
};
var languages_en = {
' ' : ' ',
'Persian': 'Persian',
'Indonesian': 'Indonesian',
'Catalan': 'Catalan',
'Czech': 'Czech',
'Danish': 'Danish',
'German': 'German',
'English': 'English',
'Spanish': 'Spanish',
'French': 'French',
'Croatian': 'Croatian',
'Italian': 'Italian',
'Lithuanian': 'Lithuanian',
'Hungarian': 'Hungarian',
'Dutch': 'Dutch',
'Norwegian': 'Norwegian',
'Polish': 'Polish',
'Portuguese': 'Portuguese',
'Romanian': 'Romaniam',
'Slovak': 'Slovak',
'Slovenian': 'Slovenian',
'Finnish': 'Finnish',
'Swedish': 'Swedish',
'Vietnamese': 'Vietnamese',
'Turkish': 'Turkish',
'Greek': 'Greek',
'Bulgarian': 'Bulgarian',
'Russian': 'Russian',
'Serbian': 'Serbian',
'Ukrainian': 'Ukranian',
'Hebrew': 'Hebrew',
'Arabic': 'Arabic',
'Standard Hindi': 'Standard Hindi',
'Thai': 'Thai',
'Korean': 'Korean',
'Chinese': 'Chinese',
'Japanese': 'Japanese',
'Other': 'Other'};
var havent_en = {
' ' : ' ',
'have not' : 'have not',
'have' : 'have'};
var urban_en = {
' ' : ' ',
'urban' : 'urban',
'suburban' : 'suburban',
'rural' : 'rural'};
var profession_en = {
' ' : ' ',
'Administrative' : 'Administrative',
'Medical' : 'Medical',
'Artist/Creative/Performer' : 'Artist/Creative/Performer',
'Sales/Marketing' : 'Sales/Marketing',
'Executive Management' : 'Executive Management',
'Education' : 'Education',
'Banking/Financial' : 'Banking/Financial',
'Computers/Technology' : 'Computers/Technology',
'Travel/Hospitality' : 'Travel/Hospitality',
'Legal' : 'Legal',
'Self-Employed' : 'Self-Employed',
'Architect' : 'Architect',
'Craftsman/Construction' : 'Craftsman/Construction',
'Engineer' : 'Engineer',
'Professional Trade' : 'Professional Trade',
'Homemaker' : 'Homemaker',
'Food Services' : 'Food Services',
'Military/Government/Politics' : 'Military/Government/Politics',
'Real Estate' : 'Real Estate',
'Research' : 'Research',
'Retail' : 'Retail',
'Retired' : 'Retired',
'Student' : 'Student',
'Unemployed' : 'Unemployed',
'Other' : 'Other'};
var fluency_en = {
' ' : ' ',
'fluently' : 'fluently',
'very well' : 'very well',
'well' : 'well',
'at beginner\'s level' : 'at beginner\'s level'};
var education_en = {
' ' : ' ',
'pre-high school' : 'pre-high school',
'high school' : 'high school',
'college' : 'college',
'graduate school' : 'graduate school',
'professional school' : 'professional school',
'PhD' : 'PhD',
'postdoctoral' : 'postdoctoral'};
var gender_en = {
' ' : ' ',
'male' : 'male',
'female' : 'female',
'N/A' : 'N/A' };
var countries = {
' ': ' ',
'Afghanistan': 'Afghanistan',
'Aland Islands': 'Aland Islands',
'Albania': 'Albania',
'Algeria': 'Algeria',
'American Samoa': 'American Samoa',
'Andorra': 'Andorra',
'Angola': 'Angola',
'Anguilla': 'Anguilla',
'Antarctica': 'Antarctica',
'Antigua And Barbuda': 'Antigua And Barbuda',
'Argentina': 'Argentina',
'Armenia': 'Armenia',
'Aruba': 'Aruba',
'Australia': 'Australia',
'Austria': 'Austria',
'Azerbaijan': 'Azerbaijan',
'Bahamas': 'Bahamas',
'Bahrain': 'Bahrain',
'Bangladesh': 'Bangladesh',
'Barbados': 'Barbados',
'Belarus': 'Belarus',
'Belgium': 'Belgium',
'Belize': 'Belize',
'Benin': 'Benin',
'Bermuda': 'Bermuda',
'Bhutan': 'Bhutan',
'Bolivia': 'Bolivia',
'Bosnia And Herzegovina': 'Bosnia And Herzegovina',
'Botswana': 'Botswana',
'Bouvet Island': 'Bouvet Island',
'Brazil': 'Brazil',
'British Indian Ocean Territory': 'British Indian Ocean Territory',
'Brunei Darussalam': 'Brunei Darussalam',
'Bulgaria': 'Bulgaria',
'Burkina Faso': 'Burkina Faso',
'Burundi': 'Burundi',
'Cambodia': 'Cambodia',
'Cameroon': 'Cameroon',
'Canada': 'Canada',
'Cape Verde': 'Cape Verde',
'Cayman Islands': 'Cayman Islands',
'Central African Republic': 'Central African Republic',
'Chad': 'Chad',
'Chile': 'Chile',
'China': 'China',
'Christmas Island': 'Christmas Island',
'Cocos (Keeling) Islands': 'Cocos (Keeling) Islands',
'Colombia': 'Colombia',
'Comoros': 'Comoros',
'Congo': 'Congo',
'The Democratic Republic Of The Congo': 'The Democratic Republic Of The Congo',
'Cook Islands': 'Cook Islands',
'Costa Rica': 'Costa Rica',
'Cote Divoire': 'Cote Divoire',
'Croatia': 'Croatia',
'Cuba': 'Cuba',
'Cyprus': 'Cyprus',
'Czech Republic': 'Czech Republic',
'Denmark': 'Denmark',
'Djibouti': 'Djibouti',
'Dominica': 'Dominica',
'Dominican Republic': 'Dominican Republic',
'Ecuador': 'Ecuador',
'Egypt': 'Egypt',
'El Salvador': 'El Salvador',
'Equatorial Guinea': 'Equatorial Guinea',
'Eritrea': 'Eritrea',
'Estonia': 'Estonia',
'Ethiopia': 'Ethiopia',
'Falkland Islands (Malvinas)': 'Falkland Islands (Malvinas)',
'Faroe Islands': 'Faroe Islands',
'Fiji': 'Fiji',
'Finland': 'Finland',
'France': 'France',
'French Guiana': 'French Guiana',
'French Polynesia': 'French Polynesia',
'French Southern Territories': 'French Southern Territories',
'Gabon': 'Gabon',
'Gambia': 'Gambia',
'Georgia': 'Georgia',
'Germany': 'Germany',
'Ghana': 'Ghana',
'Gibraltar': 'Gibraltar',
'Greece': 'Greece',
'Greenland': 'Greenland',
'Grenada': 'Grenada',
'Guadeloupe': 'Guadeloupe',
'Guam': 'Guam',
'Guatemala': 'Guatemala',
'Guernsey': 'Guernsey',
'Guinea': 'Guinea',
'Guinea-bissau': 'Guinea-bissau',
'Guyana': 'Guyana',
'Haiti': 'Haiti',
'Heard Island And Mcdonald Islands': 'Heard Island And Mcdonald Islands',
'Holy See (Vatican City State)': 'Holy See (Vatican City State)',
'Honduras': 'Honduras',
'Hong Kong': 'Hong Kong',
'Hungary': 'Hungary',
'Iceland': 'Iceland',
'India': 'India',
'Indonesia': 'Indonesia',
'Iran': 'Iran',
'Iraq': 'Iraq',
'Ireland': 'Ireland',
'Isle Of Man': 'Isle Of Man',
'Israel': 'Israel',
'Italy': 'Italy',
'Jamaica': 'Jamaica',
'Japan': 'Japan',
'Jersey': 'Jersey',
'Jordan': 'Jordan',
'Kazakhstan': 'Kazakhstan',
'Kenya': 'Kenya',
'Kiribati': 'Kiribati',
'Democratic Peoples Republic of Korea': 'Democratic Peoples Republic of Korea',
'Republic of Korea': 'Republic of Korea',
'Kuwait': 'Kuwait',
'Kyrgyzstan': 'Kyrgyzstan',
'Lao Peoples Democratic Republic': 'Lao Peoples Democratic Republic',
'Latvia': 'Latvia',
'Lebanon': 'Lebanon',
'Lesotho': 'Lesotho',
'Liberia': 'Liberia',
'Libyan Arab Jamahiriya': 'Libyan Arab Jamahiriya',
'Liechtenstein': 'Liechtenstein',
'Lithuania': 'Lithuania',
'Luxembourg': 'Luxembourg',
'Macao': 'Macao',
'Macedonia': 'Macedonia',
'Madagascar': 'Madagascar',
'Malawi': 'Malawi',
'Malaysia': 'Malaysia',
'Maldives': 'Maldives',
'Mali': 'Mali',
'Malta': 'Malta',
'Marshall Islands': 'Marshall Islands',
'Martinique': 'Martinique',
'Mauritania': 'Mauritania',
'Mauritius': 'Mauritius',
'Mayotte': 'Mayotte',
'Mexico': 'Mexico',
'Micronesia': 'Micronesia',
'Republic of Moldova': 'Republic of Moldova',
'Monaco': 'Monaco',
'Mongolia': 'Mongolia',
'Montenegro': 'Montenegro',
'Montserrat': 'Montserrat',
'Morocco': 'Morocco',
'Mozambique': 'Mozambique',
'Myanmar': 'Myanmar',
'Namibia': 'Namibia',
'Nauru': 'Nauru',
'Nepal': 'Nepal',
'Netherlands': 'Netherlands',
'Netherlands Antilles': 'Netherlands Antilles',
'New Caledonia': 'New Caledonia',
'New Zealand': 'New Zealand',
'Nicaragua': 'Nicaragua',
'Niger': 'Niger',
'Nigeria': 'Nigeria',
'Niue': 'Niue',
'Norfolk Island': 'Norfolk Island',
'Northern Mariana Islands': 'Northern Mariana Islands',
'Norway': 'Norway',
'Oman': 'Oman',
'Pakistan': 'Pakistan',
'Palau': 'Palau',
'Palestinian Territory': 'Palestinian Territory',
'Panama': 'Panama',
'Papua New Guinea': 'Papua New Guinea',
'Paraguay': 'Paraguay',
'Peru': 'Peru',
'Philippines': 'Philippines',
'Pitcairn': 'Pitcairn',
'Poland': 'Poland',
'Portugal': 'Portugal',
'Puerto Rico': 'Puerto Rico',
'Qatar': 'Qatar',
'Reunion': 'Reunion',
'Romania': 'Romania',
'Russian Federation': 'Russian Federation',
'Rwanda': 'Rwanda',
'Saint Helena': 'Saint Helena',
'Saint Kitts And Nevis': 'Saint Kitts And Nevis',
'Saint Lucia': 'Saint Lucia',
'Saint Pierre And Miquelon': 'Saint Pierre And Miquelon',
'Saint Vincent And The Grenadines': 'Saint Vincent And The Grenadines',
'Samoa': 'Samoa',
'San Marino': 'San Marino',
'Sao Tome And Principe': 'Sao Tome And Principe',
'Saudi Arabia': 'Saudi Arabia',
'Senegal': 'Senegal',
'Serbia': 'Serbia',
'Seychelles': 'Seychelles',
'Sierra Leone': 'Sierra Leone',
'Singapore': 'Singapore',
'Slovakia': 'Slovakia',
'Slovenia': 'Slovenia',
'Solomon Islands': 'Solomon Islands',
'Somalia': 'Somalia',
'South Africa': 'South Africa',
'South Georgia And The South Sandwich Islands': 'South Georgia And The South Sandwich Islands',
'Spain': 'Spain',
'Sri Lanka': 'Sri Lanka',
'Sudan': 'Sudan',
'Suriname': 'Suriname',
'Svalbard And Jan Mayen': 'Svalbard And Jan Mayen',
'Swaziland': 'Swaziland',
'Sweden': 'Sweden',
'Switzerland': 'Switzerland',
'Syrian Arab Republic': 'Syrian Arab Republic',
'Taiwan': 'Taiwan',
'Tajikistan': 'Tajikistan',
'Tanzania': 'Tanzania',
'Thailand': 'Thailand',
'Timor-leste': 'Timor-leste',
'Togo': 'Togo',
'Tokelau': 'Tokelau',
'Tonga': 'Tonga',
'Trinidad And Tobago': 'Trinidad And Tobago',
'Tunisia': 'Tunisia',
'Turkey': 'Turkey',
'Turkmenistan': 'Turkmenistan',
'Turks And Caicos Islands': 'Turks And Caicos Islands',
'Tuvalu': 'Tuvalu',
'Uganda': 'Uganda',
'Ukraine': 'Ukraine',
'United Arab Emirates': 'United Arab Emirates',
'United Kingdom': 'United Kingdom',
'United States': 'United States',
'United States Minor Outlying Islands': 'United States Minor Outlying Islands',
'Uruguay': 'Uruguay',
'Uzbekistan': 'Uzbekistan',
'Vanuatu': 'Vanuatu',
'Venezuela': 'Venezuela',
'Viet Nam': 'Viet Nam',
'British Virgin Islands': 'British Virgin Islands',
'U.S. Virgin Islands': 'U.S. Virgin Islands',
'Wallis And Futuna': 'Wallis And Futuna',
'Western Sahara': 'Western Sahara',
'Yemen': 'Yemen',
'Zambia': 'Zambia',
'Zimbabwe': 'Zimbabwe'};
/* dictionary and arrays so that additional fields for countries lived in
* can be added and cleared with the same code */
var multikey = {'country':0,'lang':1,'years':0,'fluency':1};
var multi1 = ['country', 'lang'];
var multi2 = ['years', 'fluency'];
// options and counters
//var def = ["multinational","country0","years0","retake","gender","age","lang0","father","mother","education","web_usage"];
//array of fields to require on demographics form:
var def = ["retake", "multinational", "country0", "years0", "gender", "age"];
var required_questions = ["multinational","home","current","currentyears","homeyears","country","years","country1","years1","country2","years2","country3","years3","country4","years4","country5","years5"];
var noyes = { ' ':' ', 'No' : 'No', 'Yes' : 'Yes' };
var numctries = 0;
var languages = {
' ' : ' ',
'Persian': ' فارسی',
'Indonesian': 'Bahasa Indonesia',
'Catalan': 'Català',
'Czech': 'Čeština',
'Danish': 'Dansk',
'German': 'Deutsch',
'English': 'English',
'Spanish': 'Español',
'French': 'Français',
'Croatian': 'Hrvatski',
'Italian': 'Italiano',
'Lithuanian': 'Lietuvių',
'Hungarian': 'Magyar',
'Dutch': 'Nederlands',
'Norwegian': 'Norsk',
'Polish': 'Polski',
'Portuguese': 'Português',
'Romanian': 'Română',
'Slovak': 'Slovenčina',
'Slovenian': 'Slovenščina',
'Finnish': 'Suomi',
'Swedish': 'Svensk',
'Vietnamese': 'Tiếng Việt',
'Turkish': 'Türkçe',
'Greek': 'Ελληνικά',
'Bulgarian': 'български език',
'Russian': 'Русский',
'Serbian': 'Српски',
'Ukrainian': 'Українська',
'Hebrew': 'עברית',
'Arabic': 'اللغة العربية',
'Standard Hindi': 'हिन्दी',
'Thai': 'ภาษาไทย',
'Korean': '한국어',
'Chinese': '中文',
'Japanese': '日本語',
'Other': 'Other'};
var numlangs = 0;
var havent = {' ':' ','have not' : 'have not', 'have' : 'have'};var years = [' ',0.5];
var web_usage = [' ',"< 1",1,2,3,4,5,6,7,8,9,"10+"];
var urban = {' ':' ','urban' : 'urban','suburban' : 'suburban','rural' : 'rural'};
var age = [' '];
var profession = {' ' : ' ','Administrative' : 'Administrative', 'Architect' : 'Architect', 'Artist/Creative/Performer' : 'Artist/Creative/Performer', 'Banking/Financial' : 'Banking/Financial', 'Computers/Technology' : 'Computers/Technology', 'Craftsman/Construction' : 'Craftsman/Construction', 'Education' : 'Education', 'Engineer' : 'Engineer', 'Executive Management' : 'Executive Management', 'Food Services' : 'Food Services', 'Homemaker' : 'Homemaker', 'Legal' : 'Legal', 'Medical' : 'Medical', 'Military/Government/Politics' : 'Military/Government/Politics', 'Professional Trade' : 'Professional Trade', 'Real Estate' : 'Real Estate', 'Research' : 'Research', 'Retail' : 'Retail', 'Retired' : 'Retired', 'Sales/Marketing' : 'Sales/Marketing', 'Self-Employed' : 'Self-Employed', 'Student' : 'Student', 'Travel/Hospitality' : 'Travel/Hospitality', 'Unemployed' : 'Unemployed', 'Other' : 'Other'};
var fluency = { ' ' : ' ','fluently' : 'fluently', 'very well' : 'very well', 'well' : 'well', 'at beginner\'s level' : 'at a beginner\'s level'};
var education = {' ' : ' ','pre-high school' : 'pre-high school','high school' : 'high school','college' : 'college','graduate school' : 'graduate school','professional school' : 'professional school','PhD' : 'PhD','postdoctoral' : 'postdoctoral'};
var gender = {' ' : ' ', 'male' : 'male', 'female' : 'female', 'N/A' : 'N/A'};
for(var i = 6;i<100;i++){
age.push(i);
}
for(var i=1; i<100; i++){
years.push(i);
}
/* the questions in order
* Each question dictionary contains first part of sentence (header), end of sentence (footer)
* and options in dropdown box (options)
*/
var questions = new Array();
questions['retake'] = {'q':"Have you taken this test before?",'options':noyes, 'translated' : true};
questions['multinational'] = {'q':"Have you lived in more than one country?",'options':noyes, "translated" : true};
questions['home'] = {'q':"Which was the first country where you lived?",'options':countries, 'translated' : true};
questions['homeyears'] = {'q':"How many years did you live there?",'options':years, 'translated' : false};
questions['country1'] = {'q':'' + "Please add countries in order from the country you were born in to the most recent." + '
' + "First Country",'options':countries, 'translated' : true};
questions['years1'] = {'q':' ' + "Year(s):",'options':years, 'translated' : false};
questions['country'] = {'q':"Next country:",'options':countries, 'translated' : true};
questions['years'] = {'q':' ' + "Year(s):",'options':years, 'translated' : false};
questions['current'] = {'q':"Current country:",'options':countries, 'translated' : true};
questions['currentyears'] = {'q':' ' + "Current Years:",'options':years, 'translated' : false};
questions['gender'] = {'q':"What is your gender?"};
questions['gender']['options'] = gender;
questions['gender']['translated'] = true;
// ************************************************************************
questions['age'] = {'q':"How old are you?",'options':age, 'translated' : false};
// ************************************************************************
// ************************************************************************
// questions['urban']= {'q':'Currently, I live in a mostly', 'options':urban, 'translated' : true};
// ************************************************************************
//questions['lang0'] = {'q':"What is your native language?",'options':languages, 'translated' : true};
//questions['lang'] = {'q':"Language:",'options':languages, 'translated' : true};
//questions['fluency'] = {'q':' ' + "Fluency:", 'translated' : true};
//questions['fluency']['options'] = fluency;
//questions['father'] = {'q':"What is your father\'s nationality?",'options':countries, 'translated' : true};
//questions['mother'] = {'q':"What is your mother\'s nationality?",'options':countries, 'translated' : true};
//questions['education'] = {'q':"What is the highest level of education you have received or are pursuing?", 'translated' : true};
//questions['education']['options'] = education;
// ************************************************************************
//questions['web_usage']= {'q':"On a normal day, I am on the Internet for approximately this many hours:",'options':web_usage, 'translated' : true};
// ************************************************************************
// questions['profession']= {'q':'My profession is','options':profession, 'translated' : true};
// ************************************************************************
// questions['normalvision'] = {'q':"Do you have normal or corrected-to-normal vision (including normal color vision)?",'options':noyes, 'translated' : true};
/* called in studyinfo(), display of demographics form */
function demographics() {
$("#study_info").css("display", "none");
$("#back_button").css("visibility", "hidden");
$("#forward_button").on("click", function() {
submit();
});
$("#top").css("display", "none");
// code to reset scroll of new slide:
$('body').scrollTop(0);
// begin form
var html = "