To check if a button that is pressed on a webpage i want to get the last pushed button on a page
To do this i want to save the pressed button with flow.set and when a button is pressed again check the current button input id with the previous by getting it by flow.get
But flow.get is not working. Checking google / forums i found tips with {{ or {{{ and with a $
None of these works
What is the correct way to do this inside a function?
what i have now is this
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Bomb</title>
<style>
body {
background-image: url(https://www.parkvakanties.nl/media/blog/1016/1016_1000x670.jpg);
background-repeat: no-repeat;
background-position: center;
}
.nr-dashboard-theme ui-card-panel {
background-color: rgba(255,255,255,0);
border: 0px ;
}
body.nr-dashboard-theme md-content md-card {
background-color:#12312300 !important;
border: 0px ;
}
img:visited,
img:active,
img:focus {
outline:none;
}
.image {
text-align: center;
border-style:0;
border: 0;
border: none !important;
background: transparent !important
outline: none;
}
.sevenseg {
color: rgba(255, 0, 0, 0.8);
font-size: 85px;
font-family: "Seven Segment";
text-align: center;
margin-top:10px;
}
</style>
</head>
<body>
<table width="95%" border="0" class="image">
<tbody>
<tr>
<td><img src="/image.png" width="65" height="65" alt="" data-clicked="0" id="imageOne" ng-click="changeImage($event)" />
</td>
<td><img src="/image.png" width="65" height="65" alt="" data-clicked="0" id="imageTwo" ng-click="changeImage($event)" />
</td>
</tr>
<tr>
<td><img src="/image.png" width="65" height="65" alt="" data-clicked="0" id="imageThree" ng-click="changeImage($event)" />
</td>
<td><img src="/image.png" width="65" height="65" alt="" data-clicked="0" id="imageFour" ng-click="changeImage($event)" />
</td>
</tr>
</tbody>
</table>
<pre class="sevenseg" >{{msg.payload}}</pre>
<script>
var button;
var lastButton;
(function(scope) {
scope.changeImage = function(event) {
//console.log("Triggered", event)
button = event.target.id; // current button id
lastButton = flow.get("lastButton")||0; // get last button id
if (event.target.dataset.clicked == "0")
{
scope.send({ payload: { image: event.target.id, selected: true, pannekoek: event.target.src }})
event.target.dataset.clicked = 1 // increment clicks to 1
event.target.src = "/imageNeg.png"; // change image src
}
else {
scope.send({ payload: { image: event.target.id, selected: false, pannekoek: event.target.src }})
event.target.dataset.clicked = 0 // reset clicks to 0
event.target.src = "/image.png"; // change back to original image src
//flow.set("lastButton",button);
}
}
})(scope);
</script>
</body>
</html>