﻿function search() {
    $("#result").html("Please wait...");
    var rate = $("#txtRate").val();
    var context = $("#context").val();
    $.ajax({
        url: "ListServices.asmx/Search",
        type: "POST",
        contentType: "application/json; charset=utf-8",
        data: '{ context:"' + context + '", minRate:"' + rate + '"}',
        dataType: "json",
        error: function () {
            alert("Hata oluştu");
        },
        success: function (data) {
            $("#result").html('<h4 style="padding-left:15px;">' + data.d.RecordCount + ' benzeşme, ' + data.d.ElapsedTime + ' milisaniyede bulundu</h4>');
            jQuery.each(data.d.Matches, function (rec) {
                var html = '';
                html += '<ul style="display:block; position:relative; padding:15px; margin:0px;" class="items">';
                html += '<li style="display:block; font-size:20px; font-weight:bold; list-style:none; height:30px;">' + this.EntityName + '</li>';
                html += '<li style="display:block; position:absolute; top:20px; right:20px; width:140px; height:15px; font-size:13px; font-weight:bold;"><div>Benzerlik : %' + this.MatchRate + '</div><div style="display:block; height:4px; width:' + this.MatchRate + 'px; background-color:red;">&nbsp;</div></li>';
                html += '<li style="display:block; list-style:none;">' + this.Context + '</li>';
                html += '</ul>';
                $("#result").append(html);
            });
            $(".items").mouseover(function () {
                $(this).css("background-color", "#eeeeee");
            });
            $(".items").mouseout(function () {
                $(this).css("background-color", "#ffffff");
            });
        }
    });
}

function OnError(result) {
    alert("Error: " + result.get_message());
    alert("Stack Trace: " + result.get_stackTrace());
}

