/* this file is to accompany repmap.html in the same folder */
//members
const REP_LIST = [
{
terr: ['TX2'],
repNo: [10],
cName: "South Central Enterprises",
reps: [
{
name: "Frank Mazzella",
loc: "Houston, TX",
cell: "(713) 410-8354",
email: "mazsce@me.com",
note: null
}
]
},
{
terr: ['QC','ON'],
repNo: [11],
cName: "ADS Group",
reps:[
{
name: "Sion Rainham",
loc: "Waterloo, Ontario",
cell: "(416) 523-5739",
email: "sion@adsgroup.ca",
note: null
},
{
name: "Marcus Rainham",
loc: "Waterloo, Ontario",
cell: "(226) 600-1350",
email: "marcus@adsgroup.ca",
note: null
}
]
},
{
terr: ['NM','OK','TX1'],
repNo: [18],
cName: "South Central Enterprises",
reps:[
{
name: "Dean Bridges",
loc: "Pflugerville, TX",
cell: "(512) 638-0267",
email: "dbridgessce@gmail.com",
note: null
}
]
},
{
terr: ['AL','AR','LA','MS'],
repNo: [30],
cName: "JACC Group",
reps:[
{
name: "Joe Cazedessus",
loc: "Geismar, LA",
cell: "225-405-4692",
email: "JoeCaz@knowjacc.com",
note: null
},
{
name: "Dylan DeLee",
loc: "Dallas, TX",
cell: "225-328-2580",
email: "Dylan@knowjacc.com",
note: null
},
{
name: "Ben Berard",
loc: "Breaux Bridge, LA",
cell: "337-207-2655",
email: "Ben@knowjacc.com",
note: null
},
{
name: "Stephen Battye",
loc: "Bentonville, AR",
cell: "479-899-2819",
email: "Stephen@knowjacc.com",
note: null
}
]
},
{
terr: ['AK','HI','ID','MT','OR','WA'],
repNo: [40],
cName: "Priority Sales NW",
reps: [
{
name: "Paul Drake",
loc: "Garden Valley, ID",
cell: "(208) 880-0122",
email: "paul.drake@prioritysalesnw.com",
note: null
},
{
name: "Dawn Drake",
loc: "Garden Valley, ID",
cell: "(208) 949-5999",
email: "dawn.drake@prioritysalesnw.com",
note: null
}
]
},
{
terr: ['AB','BC','MB','SK'],
repNo: [45],
cName: "CEI Sales",
reps: [
{
name: "Jamieson Byrt",
loc: "Edmonton, AB",
cell: "(780) 278-8319",
email: "jamieson@ceisales.ca",
note: null
},
{
name: "Kevin Robb",
loc: "Delta, BC",
cell: "(604) 653-0790",
email: "kevin@ceisales.ca",
note: null
}
]
},
{
terr: ['AZ','CA','NV'],
repNo: [50, 55],
cName: "Core West Rep Group, LLC",
reps: [
{
name: "Randall Willson",
loc: "covers CA west of I-5 and north of Orange & Los Angeles Counties",
cell: "(562) 451-9367",
email: "randall@corewestreps.com",
note: null
},
{
name: "Nick Rizzo",
loc: "covers CA east of I-5 and north of Riverside County",
cell: "(909) 618-6304",
email: "nick@corewestreps.com",
note: null
},
{
name: "Marc Rizzo",
loc: "covers Sandiego & Imperial County, CA, Arizona, and Nevada",
cell: "(909) 450-9791",
email: "marc@corewestreps.com",
note: null
}
]
},
{
terr: ['CO','UT','WY'],
repNo: [60],
cName: "Flame Technologies",
reps: [
{
name: "Chuck Faught",
loc: "Lexington, KY",
cell: "(512) 638-3533",
email: "cfaught@flametechnologies.com",
note: null
}
]
},
{
terr: ['IA','IL','KS','MO','NE','ND','SD','MN','WI'],
repNo: [65, 80],
cName: "Rock Island Industrial Tools",
reps: [
{
name: "Blake Williams",
loc: "Rock Island, IL",
cell: "(309) 592-0134",
email: "lexadd1@hotmail.com",
note: null
}
]
},
{
terr: ['IN','KY','MI','OH','PA1','WV'],
repNo: [70],
cName: "A-Tech Welding Products",
reps: [
{
name: "Ron Williams",
loc: "North Ridgeville, OH",
cell: "(614) 296-1573",
email: "atwpllc@gmail.com",
note: null
}
]
},
{
terr: ['NC','SC','TN','VA1'],
repNo: [75],
cName: "Knight Vision Strategic",
reps:[
{
name:"Mike Moore",
loc: "Charlotte, NC",
cell: "(980) 333-3314",
email: "osuwe@outlook.com",
note: null
}
]
},
{
terr: ['DC','DE','MD','NJ','NY','PA2','VA2'],
repNo: [85],
cName: "Manufacturers Alliance Group",
reps: [
{
name: "Bruce Ferraro",
loc: "Bethlehem, PA",
cell: "(973) 493-7477",
email: "bruceferraro60@gmail.com",
note: null
},
{
name: "Paul Giorgi",
loc: "Chalfont, PA",
cell: "(215) 827-9048",
email: "pdgiorgi26@gmail.com",
note: null
}
]
},
{
terr: ['CT','MA','ME','NH','RI','VT'],
repNo: [86],
cName: "Flame Technologies",
reps:[
{
name: "Chuck Faught",
loc: "Lexington, KY",
cell: "(512) 638-3533",
email: "cfaught@flametechnologies.com",
note: null
}
]
},
{
terr: ['FL','GA'],
repNo: [91],
cName: "AMS Solutions",
reps: [
{
name: "Jimmy Singley",
loc: "Middleburg, FL",
cell: "(904) 716-8181",
email: "jimmysingley@gmail.com",
note: null
}
]
},
{
terr: ['MX'],
repNo: [94,95,97,98],
cName: "Flame Technologies",
reps:[
{
name: "Felipe Minero",
loc: "Tecamac, Mexico",
cell: "011-52-55-5469-9868",
email: "fminero@flametechnologies.com",
note: null
}
]
},
];
/*
const NA_PROVINCES = [
//USA
{iso: 'AL', name: 'Alabama'},
{iso: 'AK', name: 'Alaska'},
{iso: 'AZ', name: 'Arizona'},
{iso: 'AR', name: 'Arkansas'},
{iso: 'AA', name: '?'},
{iso: 'AE', name: '?'},
{iso: 'AP', name: '?'},
'CA',
'CO',
'CT',
'DE',
'DC',
'FL',
'GA',
'HI',
'ID',
'IL',
'IN',
'IA',
'KS',
'KY',
'LA',
'ME',
'MD',
'MA',
'MI',
'MN',
'MS',
'MO',
'MT',
'NE',
'NV',
'NH',
'NJ',
'NM',
'NY',
'NC',
'ND',
'OH',
'OK',
'OR',
'PA',
'RI',
'SC',
'SD',
'TN',
'TX',
'UT',
'VT',
'VA',
'WA',
'WV',
'WI',
'WY',
//Canada
'AB',
'BC',
'MB',
'NB',
'NL',
'NT',
'NS',
'NU',
'ON',
'PE',
'QC',
'SK',
'YT'
];
*/
var lastTerrs = [];
var fill = 'yellow';
var noFill = 'transparent';
//methods
function makeRepDataList(data){
const repList = document.getElementById('repList');
let names = [];
data.forEach(t =>{
t.reps.forEach(r =>{
names.push('')
});
});
terrList.innerHTML = terrs.join('');
}
*/
function displayData(found){
console.log(found);
if(found){
let terrList = [];
let repsData = '';
found.forEach(x => {
if(!terrList.find(y => y.reps[0].name == x.reps[0].name)){
terrList.push(x);
}
});
terrList.forEach(x => {
x.reps.forEach(y => {
repsData +=
''+y.name+'
'+
y.loc+"
"+
'Cell: '+y.cell+'
'+
''+y.email+'
'+
(y.note !== null ? 'Note: ' +y.note+'
' : '')+
'
'
});
});
document.getElementById('showRep').innerHTML = ''+found[0].cName+'
'+repsData;
}
else{
document.getElementById('showRep').innerHTML = 'Select a territory for contact details.';
document.getElementById('terrSelect').value = '';
}
}
function jsFadeTo(id, opVal){
document.getElementById(id).animate(
{
opacity: opVal,
// fill: opVal,
},
{
duration: 250,
easing: "linear",
iterations: 1,
fill: "both"
}
)
}
/*
function shapeSelect(shapeID, tF = true){
if(tF === false){jsFadeTo(shapeID, 'transparent');} // 1
else{jsFadeTo(shapeID, 'yellow');} // 0.15
}
*/
function jsChangeFill(id, fillVal){
document.getElementById(id).animate(
{
fill: fillVal,
stroke: (fillVal == 'yellow' ? 'black' : 'transparent'),
},
{
duration: 250,
easing: "linear",
iterations: 1,
fill: "both"
}
)
}
/*
function shapeColor(shapeID, tF = true){
let oldColor = '';
if(tF === false){jsChangeFill(shapeID, 'goldenrod');}
else{jsChangeFill(shapeID, oldColor);}
}
*/
document.addEventListener('DOMContentLoaded', () => {
const terrShapes = document.querySelectorAll('#xTerritories path, #xTerritories polygon');
const terrSelect = document.getElementById('terrSelect');
const repInput = document.getElementById('repInput');
const clrInput = document.getElementById('clrInput');
//suppress rep names list until typing match
repInput.addEventListener('focus', e => {dataListFocus(e)});
repInput.addEventListener('keydown', e => {dataListClick(e)});
function dataListFocus(e){
var input = e.target,
list = input.getAttribute('list');
if(list) {
input.setAttribute('data-list', list);
input.removeAttribute('list');
}
}
function dataListClick(e){
var input = e.target,
list = input.getAttribute('data-list');
if(list) {
input.setAttribute('list', list);
input.removeAttribute('data-list');
}
}
//click on map
for(const shape of terrShapes){
shape.addEventListener('mouseover', () => {
//lastTerrs.forEach(e => shapeSelect('x'+e, false));
//shapeSelect(shape.id)
jsFadeTo(shape.id.substring(1), 0.25);
});
shape.addEventListener('mouseout', () => jsFadeTo(shape.id.substring(1), 1));
shape.addEventListener('click', () => {
let found =[]
found.push(REP_LIST.find(x => x.terr.find(y => y === shape.id.substring(1))));
/*
if(found[0]){
*/
repInput.value = '';
lastTerrs.forEach(e => jsChangeFill('x'+e, noFill));
lastTerrs = [];
lastTerrs = found[0].terr;
//lastTerrs.push(shape.id.substring(1));
lastTerrs.forEach(e => jsChangeFill('x'+e, fill));
document.getElementById('terrSelect').value = shape.id.substring(1);
displayData(found);
/*
}
else{
terrSelect.value = '';
}
*/
});
}
//select terr from list
terrSelect.addEventListener('change', e => {
if(e.target.value != 0){
let found = []
found.push(REP_LIST.find(x => x.terr.find(y => y === e.target.value)));
repInput.value = '';
lastTerrs.forEach(e => jsChangeFill('x'+e, noFill));
lastTerrs = [];
lastTerrs = found[0].terr;
found[0].terr.forEach(e => jsChangeFill('x'+e, fill));
displayData(found);
}
});
//type rep's name or company
repInput.addEventListener('change', e => {
let filter = REP_LIST.filter(x => x.cName === e.target.value || x.reps.find(y => y.name === e.target.value));
if(filter){
terrSelect.selectedIndex = -1;
lastTerrs.forEach(e => jsChangeFill('x'+e, noFill));
lastTerrs = [];
filter.forEach(e => lastTerrs = lastTerrs.concat(e.terr));
filter.forEach(x => {x.terr.forEach(y => jsChangeFill('x'+y, fill))});
displayData(filter);
}
});
//clear the text input field
clrInput.addEventListener('click', ()=>{
repInput.value = '';
terrSelect.value = '';
document.getElementById('showRep').innerHTML = '';
lastTerrs.forEach(e => jsChangeFill('x'+e, noFill));
lastTerrs = [];
});
makeRepDataList(REP_LIST);
// makeTerrDataList(REP_LIST);
});