JSFiddle - React, Tailwind, and code Playground
by gurkavcu
HTML
<ul id="results"/>
<input id="deneme" value="umut,fehmi,emre" />
CSS
#results li.pass { color: green; }
#results li.fail { color: red; }
JavaScript
(function($) {
var settings = {
};
var methods = {
init: function(options) {
options = $.extend({}, options, settings);
return this.each(function () {
$(this).data("test", options);
});
},
csv: function() {
var options = this.data("test");
return $(this).val().split(",");
}
};
$.fn.tools = function(method) {
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
return methods.init.apply(this, arguments);
} else {
$.error('Method ' + method + ' does not exist');
}
}
})(jQuery);
console.log($("#deneme").tools("csv"));
function assert(value, desc) {
var li = document.createElement("li");
li.className = value ? "pass" : "fail";
li.appendChild(document.createTextNode(desc));
document.getElementById("results").appendChild(li);
}
(function() {
var queue = [],
paused = false;
this.test = function(fn) {
queue.push(fn);
runTest();
};
this.pause = function() {
paused = true;
};
this.resume = function() {
paused = false;
setTimeout(runTest, 1);
};
function runTest() {
if (!paused && queue.length) {
queue.shift()();
if (!paused) {
resume();
}
}
}
})();
Function.prototype.bind = function() {
var fn = this,
args = Array.prototype.slice.call(arguments),
object = args.shift();
console.log("THIS: "+fn);
console.log("ARGS: "+args);
console.log("OBJECT: "+object.x);
return function() {
console.log("RETURN-A ARGS:" ,Array.prototype.slice.call(arguments));
console.log("RETURN-B ARGS:"...