var Element = function (id, name, top, left, value, isReadable, isFixable, isTester, isReplacer) {
this.ID = id;
this.top = top;
this.left = left;
this.value = value;
this.name = name;
this.isReadable = isReadable;
this.isFixable = isFixable;
this.isTester = isTester;
this.isReplacer = isReplacer;
}
var HistoryElement = function (id, action)
{
this.id = id;
this.action = action;
}
var ViewModel = function () {
var self = this; // self is being used to maintain a reference to the original this even as the context is changing.
self.TesterOn = false;
self.ReplacerOn = false;
self.elements = ko.observableArray([]);
self.history = new Array();
self.addElement = function (id, name, top, left, value, isReadable, isFixable, isTester, isReplacer ) {
var element = new Element(id, name, top, left, value, isReadable, isFixable, isTester, isReplacer);
self.elements.push(element);
};
//In case we want to change image from toolbar
self.TesterEvent = function (on_off)
{
if (on_off == true)
{
alert ("ON tester");
}
else
{
alert ("OFF tester");
}
self.TesterOn = on_off;
};
//In case we want to change image from toolbar
self.ReplacerEvent = function (on_off)
{
if (on_off == true)
{
alert ("ON replacer");
}
else
{
alert ("OFF replacer");
}
self.ReplacerOn = on_off;
};
self.clickedElement = function (element)
{
if (self.TesterOn)
{
if (element.isReadable)
{
alert(element.value);
//element.diagnosed = true;
var trackElement = new HistoryElement(element.ID, "Tested");
self.history.push(trackElement);
}
}
if (self.ReplacerOn)
{
if (element.isFixable)
{
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.