I am doing a project to use the webcam at phone or laptop to do the object recognition. Right now I can get the camera id and object recognition, but I can't switch the video source to the camera that I want. Could someone please help me or give me some hints that how I can select the camera I want, and then use it to do the object recognition? Thanks a lot!
var classifier; var resultsP; var msg1; var prevmsg; var video
const button = document.getElementById('button');
const select = document.getElementById('select');
let currentStream;
function voice_testing(){
var voice_message = "Voice triggered";
var message = new SpeechSynthesisUtterance(voice_message);
window.speechSynthesis.speak(message);
}
function setup() {
noCanvas();
video = createCapture(VIDEO);
classifier = ml5.imageClassifier('MobileNet', video, modelReady);
resultsP = createP('Loading model and video...');
}
function modelReady() {
console.log('Model Ready');
classifyVideo();
}
function classifyVideo() {
classifier.classify(gotResult);
}
async function gotResult(err, results) {
resultsP.html(results[0].label + ' ' + nf(results[0].confidence, 0, 2));
if(nf(results[0].confidence, 0, 2) > 0.2){
if(results[0].label != prevmsg){
msg1 = new SpeechSynthesisUtterance(results[0].label);
msg2 = results[0].label.split(',');
window.speechSynthesis.speak(msg1);
Text = msg2[0];
letters = Text.split('');
letters1 = new SpeechSynthesisUtterance(letters);
window.speechSynthesis.speak(letters1);
prevmsg = results[0].label;
}
}
setTimeout(classifyVideo, 8000);
}
function stopMediaTracks(stream) {
stream.getTracks().forEach(track => {
track.stop();
});
}
function gotDevices(mediaDevices) {
select.innerHTML = '';
select.appendChild(document.createElement('option'));
let count = 1;
mediaDevices.forEach(mediaDevice => {
if (mediaDevice.kind === 'videoinput') {
const option = document.createElement('option');
option.value = mediaDevice.deviceId;
const label = mediaDevice.label || `Camera ${count++}`;
const textNode = document.createTextNode(label);
option.appendChild(textNode);
select.appendChild(option);
}
});
}
button.addEventListener('click', event => {
if (typeof currentStream !== 'undefined') {
stopMediaTracks(currentStream);
}
const videoConstraints = {};
if (select.value === '') {
videoConstraints.facingMode = 'environment';
} else {
videoConstraints.deviceId = { exact: select.value };
}
const constraints = {
video: videoConstraints,
audio: false
};
navigator.mediaDevices
.getUserMedia(constraints)
.then(stream => {
currentStream = stream;
video.srcObject = stream;
return navigator.mediaDevices.enumerateDevices();
})
.then(gotDevices)
.catch(error => {
console.error(error);
});
});
navigator.mediaDevices.enumerateDevices().then(gotDevices);
body{
text-align: center;
}
h1 {
font-size: 40px;
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
}
p {
font-size: 20px;
font-family: Arial, Helvetica, sans-serif;
}
.startButton {
font-size: 12px;
text-align: center;
margin: 1%;
}
<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">
<title>Camera selection</title>
<link rel="stylesheet" href="./app.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/addons/p5.dom.min.js"></script>
<script src="https://unpkg.com/ml5#0.4.3/dist/ml5.min.js" type="text/javascript"></script>
</head>
<body>
<header>
<h1>Webcam Object Recognition</h1>
</header>
<main>
<button id="button">Get camera</button>
<select id="select">
<option></option>
</select>
<button id="startButtonID" onclick="voice_testing();">Voice Testing</button>
</br>
<p>If no voice, click the button</p>
<p>You can select the camera you want from the box above, and click get camera button</p>
</main>
<script src="./app.js"></script>
</body>
</html>
ks a lot!
Related
Basically, I have a function that creates N input fields based on user choice, then I want to get those inputs for processing later on, though for some reason it creates a copy of the return over and over again, unless I add something like "conj.pop()" in the return. I wouldn't like to work not knowing why it only works if I pop the last one.
I put a console.log to keep track and the returned array was something like this:
Array(3)
0: 'A'
1: 'B'
2: (3) ['A','B','Array(3)]
If you expand this last array it repeats infinitely this very same description.
OBS: The inputs I've been using were simple 2,2 and A B, C D.
OBS2: The code wasn't previously in english so I translated some stuff, and left other small ones as they were variables only.
document.getElementById("ok1").onclick = () => {
const esp_qtd = document.getElementById("esp_qtd").value;
const car_qtd = document.getElementById("car_qtd").value;
document.getElementById("parte1").classList.add("invisivel");
document.getElementById("parte2").classList.remove("invisivel");
console.log(esp_qtd, car_qtd);
const generateFields = (tipo) => {
const qtd = document.getElementById(tipo + "_qtd").value;
const parent = document.getElementById(tipo + "_lista");
for (let i = 0; i < qtd; i++) {
const input = document.createElement("input");
input.setAttribute("type", "text");
input.setAttribute("id", (tipo + i));
parent.appendChild(input);
if (qtd > 5) {
if (((i + 1) % 3) == 0) parent.appendChild(document.createElement("br"));
}
console.log(i);
}
}
generateFields("esp");
generateFields("car");
const inputFields = (tipo, conj) => {
const qtd = document.getElementById(tipo + "_qtd").value;
for (let i = 0; i < qtd; i++) {
conj[i] = document.getElementById(tipo + i).value;
console.log("Iteration: " + i, conj);
}
return conj;
}
document.getElementById("ok2").onclick = () => {
const conjE = [];
const conjC = [];
conjE.push(inputFields("esp", conjE));
conjC.push(inputFields("car", conjC));
console.log(conjE);
console.log(conjC);
}
}
* {
font-family: 'Roboto', sans-serif;
font-size: 14pt;
margin-top: 1rem;
}
.invisivel {
display: none;
}
label {
margin-top: 1rem;
}
input {
margin-top: 0.5rem;
margin-right: 1rem;
margin-bottom: 0.5rem;
}
button {
margin-top: 1rem;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DOC</title>
<link rel="stylesheet" href="style.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
</head>
<body>
<div class="container">
<!-- PART 1 -->
<div id="parte1">
<form>
<label>N1</label><br>
<input type="text" id="esp_qtd"><br>
<label>N2</label><br>
<input type="text" id="car_qtd"><br>
<button id="ok1" type="button">OK</button>
</form>
</div>
<!-- PART 2 -->
<div id="parte2" class="invisivel">
<div id="esp_lista">
<label>ELEMENTS 1</label><br>
</div>
<div id="car_lista">
<label>ELEMENTS 2</label><br>
</div>
<button id="ok2" type="button">OK</button>
</div>
</div>
<script src="index.js"></script>
</body>
</html>
Please change your JS as follows:
document.getElementById("ok1").onclick = () => {
const esp_qtd = document.getElementById("esp_qtd").value;
const car_qtd = document.getElementById("car_qtd").value;
document.getElementById("parte1").classList.add("invisivel");
document.getElementById("parte2").classList.remove("invisivel");
console.log(esp_qtd, car_qtd);
const generateFields = (tipo) => {
const qtd = document.getElementById(tipo + "_qtd").value;
const parent = document.getElementById(tipo + "_lista");
for (let i = 0; i < qtd; i++) {
const input = document.createElement("input");
input.setAttribute("type", "text");
input.setAttribute("id", tipo + i);
parent.appendChild(input);
if (qtd > 5) {
if ((i + 1) % 3 == 0) parent.appendChild(document.createElement("br"));
}
console.log(i);
}
};
generateFields("esp");
generateFields("car");
const inputFields = (tipo, conj) => {
const qtd = document.getElementById(tipo + "_qtd").value;
console.log("Conj:" + qtd);
for (let i = 0; i < qtd; i++) {
conj[i] = document.getElementById(tipo + i).value;
console.log("Iteration: " + i, conj);
}
return conj;
};
document.getElementById("ok2").onclick = () => {
const conjE = [];
const conjC = [];
inputFields("esp", conjE);
inputFields("car", conjC);
console.log(conjE);
console.log(conjC);
};
};
I have only removed conjE.push() and conjC.push().
Explanation:
You are passing an array to store your data in it. But you're also returning the same array and storing it in it again. This creates an infinite loop of values. Either pass the variable or return the list.
I'm learning java script and I'm currently working with testing in javiscritp, I've done this code that you can look at, but I don't know how to reverse now the order of these cubes to be 2 up and 1 down (see what I want in the picture) I know I need to change something for loops but I fail in any way to get what I want.
let Tabela = (function () {
const dajRed = function (tabela) {
let red = document.createElement("tr");
tabela.appendChild(red);
return red;
}
const dajCeliju = function (red, prikazi) {
let celija = document.createElement("td");
if (!prikazi) celija.style = "display:none;";
red.appendChild(celija)
return celija;
}
const crtaj = function (x, y) {
const body = document.getElementsByTagName("body")[0];
let tabelaEl = document.createElement("table");
body.appendChild(tabelaEl);
for (let i = 0; i < y; i++) {
let red = dajRed(tabelaEl);
for (let j = 0; j < x; j++) {
dajCeliju(red, j < i);
}
}
}
return {
crtaj: crtaj
}
}());
//table.crtaj(3,3)
//i=0 ⍉⍉⍉
//i=1 ⎕⍉⍉
//i=2 ⎕⎕⍉
//Tabela.crtaj(8, 8);
let assert = chai.assert;
describe('Tabela', function() {
describe('crtaj()', function() {
it('should draw 3 rows when parameter are 2,3', function() {
Tabela.crtaj(2,3);
let tabele = document.getElementsByTagName("table");
let tabela = tabele[tabele.length-1]
let redovi = tabela.getElementsByTagName("tr");
assert.equal(redovi.length, 3,"Broj redova treba biti 3");
});
it('should draw 2 columns in row 2 when parameter are 2,3', function() {
Tabela.crtaj(2,3);
let tabele = document.getElementsByTagName("table");
let tabela = tabele[tabele.length-1]
let redovi = tabela.getElementsByTagName("tr");
let kolone = redovi[2].getElementsByTagName("td");
let brojPrikazanih = 0;
for(let i=0;i<kolone.length;i++){
let stil = window.getComputedStyle(kolone[i])
if(stil.display!=='none') brojPrikazanih++;
}
assert.equal(brojPrikazanih, 2,"Broj kolona treba biti 2");
});
});
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Mocha Tests</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://unpkg.com/mocha/mocha.css" />
<style>
td{
border: 1px solid black;
height: 20px;
width: 20px;
}
</style>
</head>
<body>
<div id="ispis"></div>
<div id="mocha"></div>
<script src="https://unpkg.com/chai/chai.js"></script>
<script src="https://unpkg.com/mocha/mocha.js"></script>
<script class="mocha-init">
mocha.setup('bdd');
mocha.checkLeaks();
</script>
<script src="tabela.js"></script>
<script src="test.js"></script>
<script class="mocha-exec">
mocha.run();
</script>
</body>
</html>
Invert the check in dajCeliju:
if (prikazi) celija.style = "display:none;";
OR second option - change the params:
dajCeliju(red, j >= i);
Is this what you need?
In my current code I have two countries that display a popup when clicked and in the popup you can see some links. Links are mapped correctly but my problem is with the links name.
The way I wrote the code so far, is good for displaying the name of link for a country with one link. I'm calling the link name with ev.target.dataItem.dataContext.linkName in the code below:
chart.openPopup("<strong>" + ev.target.dataItem.dataContext.country + "</strong>" + ev.target.dataItem.dataContext.link.map(url => '<br>' + ev.target.dataItem.dataContext.linkName + '').join(""));
How can I write ev.target.dataItem.dataContext.linkName in order to display both names for a country with 2 links? I want Name 2 assigned for https://www.example2.com and Name 3 assigned for https://www.example3.com.
If anyone can help me regarding this issue, I would greatly appreciate it.
am4core.ready(function () {
// Themes begin
am4core.useTheme(am4themes_animated);
// Themes end
// Create map instance
let chart = am4core.create("map", am4maps.MapChart);
// Responsiveness enabled
chart.responsive.enabled = true;
// Set map definition
chart.geodata = am4geodata_worldHigh;
// Set projection
chart.projection = new am4maps.projections.Miller();
// Zoom control
chart.zoomControl = new am4maps.ZoomControl();
let homeButton = new am4core.Button();
homeButton.events.on("hit", function () {
chart.goHome();
});
homeButton.icon = new am4core.Sprite();
homeButton.padding(7, 5, 7, 5);
homeButton.width = 30;
homeButton.icon.path = "M16,8 L14,8 L14,16 L10,16 L10,10 L6,10 L6,16 L2,16 L2,8 L0,8 L8,0 L16,8 Z M16,8";
homeButton.marginBottom = 10;
homeButton.parent = chart.zoomControl;
homeButton.insertBefore(chart.zoomControl.plusButton);
// Center on the groups by default
chart.homeZoomLevel = 3.5;
chart.homeGeoPoint = {
longitude: 10,
latitude: 54
};
let groupData = [{
"color": chart.colors.getIndex(0),
"data": [{
"country": "Germany",
"id": "DE",
"link": ["https://www.example1.com"],
"linkName": ["Name 1"]
}, {
"country": "France",
"id": "FR",
"link": ["https://www.example2.com", "https://www.example3.com"],
"linkName": ["Name 2", "Name 3"]
}]
}];
// This array will be populated with country IDs to exclude from the world series
let excludedCountries = ["AQ"];
// Create a series for each group, and populate the above array
groupData.forEach(function (group) {
let series = chart.series.push(new am4maps.MapPolygonSeries());
series.name = group.name;
series.useGeodata = true;
let includedCountries = [];
group.data.forEach(function (country) {
includedCountries.push(country.id);
excludedCountries.push(country.id);
});
let polygonTemplate = series.mapPolygons.template;
polygonTemplate.tooltipHTML = '<b>{country}</b>';
polygonTemplate.events.on("hit", function (ev) {
chart.closeAllPopups();
// Map countries and link encoding
// How to write -> ev.target.dataItem.dataContext.linkName <- in order to display Name 2 and Name 3 separately ?
chart.openPopup("<strong>" + ev.target.dataItem.dataContext.country + "</strong>" + ev.target.dataItem.dataContext.link.map(url => '<br>' + ev.target.dataItem.dataContext.linkName + '').join(""));
});
series.include = includedCountries;
series.fill = am4core.color(group.color);
series.setStateOnChildren = true;
series.calculateVisualCenter = true;
series.tooltip.label.interactionsEnabled = false; //disable tooltip click
series.tooltip.keepTargetHover = true;
// Country shape properties & behaviors
let mapPolygonTemplate = series.mapPolygons.template;
mapPolygonTemplate.fill = am4core.color("#c4a5e8");
mapPolygonTemplate.fillOpacity = 0.8;
mapPolygonTemplate.nonScalingStroke = true;
mapPolygonTemplate.tooltipPosition = "fixed";
mapPolygonTemplate.events.on("over", function (event) {
series.mapPolygons.each(function (mapPolygon) {
mapPolygon.isHover = false;
})
event.target.isHover = false;
event.target.isHover = true;
})
mapPolygonTemplate.events.on("out", function (event) {
series.mapPolygons.each(function (mapPolygon) {
mapPolygon.isHover = false;
})
})
// States
let hoverState = mapPolygonTemplate.states.create("hover");
hoverState.properties.fill = am4core.color("#FFCC00");
series.data = JSON.parse(JSON.stringify(group.data));
});
// The rest of the world.
let worldSeries = chart.series.push(new am4maps.MapPolygonSeries());
let worldSeriesName = "world";
worldSeries.name = worldSeriesName;
worldSeries.useGeodata = true;
worldSeries.exclude = excludedCountries;
worldSeries.fillOpacity = 0.5;
worldSeries.hiddenInLegend = true;
worldSeries.mapPolygons.template.nonScalingStroke = true;
});
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
#map {
width: 100%;
height: 600px;
overflow: hidden;
}
#map a,
b {
cursor: pointer;
color: #003399;
text-align: center;
}
#map a:hover {
color: #023432;
}
.ampopup-content {
/* width: 40%; */
text-align: center;
}
.ampopup-header {
background-color: #99000d !important;
}
.ampopup-close {
filter: invert(1);
}
.ampopup-inside {
background-color: rgb(255, 255, 255);
}
.ampopup-inside a {
color: #28a86c !important;
}
.ampopup-inside a:hover {
color: #023432 !important;
}
.ampopup-curtain {
display: block !important;
background-color: rgba(7, 22, 51, 0.7) !important;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Countries popup with links</title>
<link rel="stylesheet" href="css/style.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-12">
<div id="map"></div>
</div>
</div>
</div>
<!-- Scripts for loading AmCharts Map -->
<script src="https://cdn.amcharts.com/lib/4/core.js"></script>
<script src="https://cdn.amcharts.com/lib/4/maps.js"></script>
<script src="https://cdn.amcharts.com/lib/4/geodata/worldHigh.js"></script>
<script src="https://cdn.amcharts.com/lib/4/themes/animated.js"></script>
<script src="js/custom2.js"></script>
<!-- Bootstrap -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script>
</body>
</html>
You need to use the index provided by the .map to access the nth element in the
linkName array.
let polygonTemplate = series.mapPolygons.template;
polygonTemplate.tooltipHTML = '<b>{country}</b>';
polygonTemplate.events.on("hit", function(ev) {
chart.closeAllPopups();
const {
links,
linkNames,
country
} = ev.target.dataItem.dataContext;
// Map countries and link encoding
const popupContent = `<strong>${country}</strong><br />
${
links.map((url,urlIndex)=>`${linkNames[urlIndex]}`).join('')
}`;
chart.openPopup(popupContent);
});
How to add button for each item in localstorage to remove that item?
I have code for setItem and getItem from localstorage, but I don't know how I can add a button or x for each item to remove it.
2020-03-01 March x
2020-04-01 April x
It looks like add item to card or remove item from card.
plz help me
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(function () {
$("#inpkey").datepicker();
});
</script>
<style>
fieldset{
margin-bottom:20px;
}
input{
padding: 7px;
height:40px;
}
</style>
</head>
<body>
<fieldset>
<input type="text" id="inpkey" placeholder="Click and select date">
<input type="text" id="inpvalue">
<button type="button" id="btninsert">Save</button>
</fieldset>
<fieldset>
<div id="output"></div>
</fieldset>
<script>
const inpkey = document.getElementById("inpkey");
const inpavv = document.getElementById("inpvalue");
const spara = document.getElementById("btninsert");
const output = document.getElementById("output");
spara.onclick = function () {
const key = inpkey.value;
const value = inpavv.value;
console.log(key);
console.log(value);
if (key && value ) {
localStorage.setItem(key, value );
location.reload();
}
};
for (let i = 0; i < localStorage.length; i++) {
const key = localStorage.key(i);
const value = localStorage.getItem(key);
console.log(localStorage.getItem(key));
output.innerHTML += `${key}:     ${value} <p />`;
}
</script>
</body>
</html>
Something like this: Note JSFiddle had trouble removing the last element. Might be something I overlooked in the code. Good luck.
const setup = () => {
const spara = document.querySelector('#btninsert');
const output = document.querySelector('#output');
spara.addEventListener('click', addMyEntry);
output.addEventListener('click', removeMyEntry);
insertEntries(output);
};
const insertEntries = (target) => target.insertAdjacentHTML('beforeend', loadEntryHTML());
const loadEntryHTML = () => {
let html = '';
if(localStorage.length !== 0) {
for (let i = 0; i < localStorage.length; i++) {
const key = localStorage.key(i);
const value = localStorage.getItem(key);
html += createEntryHTML(key, value);
}
}
return html;
};
const createEntryHTML = (key, value) => `<p><label class="lbl_key">${key}:</label><span class="sp_value">${value}</span> remove<p/>`;
const addMyEntry = () => {
const inpkey = document.querySelector('#inpkey');
const inpavv = document.querySelector('#inpvalue');
const key = inpkey.value;
const value = inpavv.value;
if (key && value ) {
localStorage.setItem(key, value );
const output = document.querySelector('#output');
output.insertAdjacentHTML('beforeend', createEntryHTML(key, value));
}
};
const removeMyEntry = (event) => {
const target = event.target;
if(target.nodeName === 'A') {
event.currentTarget.removeChild(target.parentNode);
localStorage.removeItem(target.dataset.key);
}
};
//load
window.addEventListener('load', setup);
.lbl_key {
padding-right: 1em;
}
<fieldset>
<input type="text" id="inpkey" placeholder="Click and select date">
<input type="text" id="inpvalue">
<button type="button" id="btninsert">Save</button>
</fieldset>
<fieldset>
<div id="output"></div>
</fieldset>
A better solution to build elements dynamically.
const app = document.getElementById("app");
const localStorage = [1, 2, 3, 4];
for (let index = 0; index < localStorage.length; index++) {
// const key = localStorage.key(index);
// const value = localStorage.getItem(key);
let div = document.createElement("div");
div.className = "cart_item";
div.id = "cart_item_" + index;
div.textContent = localStorage[index] + new Date().toUTCString() + "";
let cross = document.createElement("span");
cross.className = "cross";
cross.textContent = " X";
cross.addEventListener("click", function remove() {
alert("Remove item");
});
div.appendChild(cross);
app.appendChild(div);
}
<!DOCTYPE html>
<html lang="en">
<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" />
<title>Static Template</title>
<link rel="stylesheet" href="app.css" />
<!-- <script src="https://deepak-proxy-server.herokuapp.com/https://gist.githubusercontent.com/deepakshrma/4b6a0a31b4582d6418ec4f76b7439781/raw/e7377474ce9e411b4d8de4b10f4437a24774c0e2/Mapper.js"></script> -->
<style>
.cart_item{
border: 1px solid;
padding: 20px 40px;
}
.cross {
color: red;
cursor: pointer;
}
</style>
</head>
<body>
<div id="app">
</div>
</body>
</html>
I'm completely new nopCommerce. One of my client is getting error during check out with VISA card. He is getting the following screen. I'm not sure where do I start to troubleshoot. Can you please help me? Some how I'm not able to post exact HTML document. But please consider below code as properly formatted HTML.
<script type="text/javascript">
(function (f, b) {
if (!b.__SV) {
var a, e, i, g;
window.mixpanel = b;
b._i = [];
b.init = function (a, e, d) {
function f(b, h) {
var a = h.split(".");
2 == a.length && (b = b[a[0]], h = a[1]);
b[h] = function () {
b.push([h].concat(Array.prototype.slice.call(arguments, 0)))
}
}
var c = b;
"undefined" !== typeof d ? c = b[d] = [] : d = "mixpanel";
c.people = c.people || [];
c.toString = function (b) {
var a = "mixpanel";
"mixpanel" !== d && (a += "." + d);
b || (a += " (stub)");
return a
};
c.people.toString = function () {
return c.toString(1) + ".people (stub)"
};
i = "disable track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.append people.track_charge people.clear_charges people.delete_user".split(" ");
for (g = 0; g < i.length; g++) f(c, i[g]);
b._i.push([a, e, d])
};
b.__SV = 1.2;
a = f.createElement("script");
a.type = "text/javascript";
a.async = !0;
a.src = "//cdn.mxpnl.com/libs/mixpanel-2.2.min.js";
e = f.getElementsByTagName("script")[0];
e.parentNode.insertBefore(a, e)
}
})(document, window.mixpanel || []);
var mode = 'prd'.toLowerCase();
var token = '';
if (mode == 'demo') {
token = 'xxxxxxxxxxxxxxxxxxxxxx';
} else if (mode == 'prd' || mode == 'prda' || mode == 'prdk') {
token = 'xxxxxxxxxxxxxxxxxxxxxx';
} else if (mode == 'test') {
token = 'xxxxxxxxxxxxxxxxxxx';
} else {
token = 'xxxxxxxxxxxxxxxxxxxxxxxxx';
}
if (token != '') {
mixpanel.init(token, {
persistence: 'localStorage'
});
}
</script><!-- end Mixpanel -->
<script type="text/javascript">
if (self !== top && typeof mixpanel !== "undefined") {
mixpanel.track("inFrame", {
"merchant_id": "XXXX(actual number here)",
"tid": "XXXX(actual number here)"
});
}
</script>
<style type="text/css">
BODY, TD, INPUT, SELECT, TEXTAREA, BUTTON, .normal {
font-family: arial,helvetica,sans-serif;
font-size: 10pt;
font-weight: normal;
}
.small {
font-size: 10pt;
}
.medium {
font-size: 14pt;
}
.large {
font-size: 18pt;
}
</style>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- process-transaction-response -->
<html>
<head>
<meta http-equiv="refresh" content="1;url=http://www.myvirtualmerchant.com?
ssl_approval_code=++++++&
ssl_cvv2_response=&
ssl_exp_date=XXXX(actual number here)&
ssl_account_balance=0.00&
ssl_get_token=&
ssl_token=&
ssl_departure_date=&
ssl_token_response=&
ssl_result_message=DECLINED&
ssl_invoice_number=XXXX(actual number here)&
ssl_description=Name1+Name2&
ssl_amount=184.48&
ssl_txn_id=GUID&
ssl_result=1&
ssl_card_number=XXXX(actual number here)&
ssl_completion_date=&
ssl_txn_time=10%2F28%2F2016+04%3A03%3A18+PM&
ssl_avs_response=G">
<style type="text/css">
BODY, TD, INPUT, SELECT, TEXTAREA, BUTTON, .normal {
font-family: arial,helvetica,sans-serif;
font-size: 10pt;
font-weight: normal;
}
.small {
font-size: 10pt;
}
.medium {
font-size: 14pt;
}
.large {
font-size: 18pt;
}
</style>
</head>
<form name="frmMenu" action="#" method="POST">
<input type="hidden" name="dispatchMethod" />
<input type="hidden" name="permissionDesc" />
<input type="hidden" name="menuAction" />
<input type="hidden" name="thClientID" value="" />
</form> <!-- start Mixpanel -->
</body>
</html>