Skip to content

Instantly share code, notes, and snippets.

@ngocdon0127
Last active June 29, 2018 01:08
Show Gist options
  • Select an option

  • Save ngocdon0127/e15e5bde3f40cc83896562d6553479bc to your computer and use it in GitHub Desktop.

Select an option

Save ngocdon0127/e15e5bde3f40cc83896562d6553479bc to your computer and use it in GitHub Desktop.
$(window).off('blur')
$(window).blur(function () {
var count = $.cookie("lost_focus_count_" + UserTest);
if (!count || isNaN(count)) count = 0;
count++;
TestCertificate.Common.showMessenger(TestCertificate.Common.getResource("LOST_FOCUS", count));
$.ajax({
type: "POST",
url: "/service/exam.asmx/pushViolationLog",
dataType: "json",
data: {
UserTestId: UserTest
},
timeout: 10000
});
$.cookie("lost_focus_count_" + UserTest, count);
});
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment