/*! * jQuery Cookie Plugin v1.4.1 * https://github.com/carhartl/jquery-cookie * * Copyright 2006, 2014 Klaus Hartl * Released under the MIT license */ !function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?module.exports=e(require("jquery")):e(jQuery)}(function(e){var n=/\+/g;function o(e){return t.raw?e:encodeURIComponent(e)}function i(e){return o(t.json?JSON.stringify(e):String(e))}function r(o,i){var r=t.raw?o:function(e){0===e.indexOf('"')&&(e=e.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return e=decodeURIComponent(e.replace(n," ")),t.json?JSON.parse(e):e}catch(e){}}(o);return e.isFunction(i)?i(r):r}var t=e.cookie=function(n,c,u){if(arguments.length>1&&!e.isFunction(c)){if("number"==typeof(u=e.extend({},t.defaults,u)).expires){var s=u.expires,a=u.expires=new Date;a.setMilliseconds(a.getMilliseconds()+864e5*s)}return document.cookie=[o(n),"=",i(c),u.expires?"; expires="+u.expires.toUTCString():"",u.path?"; path="+u.path:"",u.domain?"; domain="+u.domain:"",u.secure?"; secure":""].join("")}for(var d,f=n?void 0:{},p=document.cookie?document.cookie.split("; "):[],l=0,m=p.length;l=Math.abs(ofs.c2-ofs.c1); if (isTrans) { trans++; } else { if (!ofs.trans) { ofs.trans=true; trans++; } } break; } else { if (c1>ofs.c2 && c2>ofs.c1) { offset_arr.splice(i,1); } else { i++; } } } offset_arr.push({ c1:c1, c2:c2, trans:isTrans }); } else { lcss+=local_cs; local_cs=0; if (c1!=c2) { c1=c2=Math.min(c1,c2); //using min allows the computation of transpositions } //if matching characters are found, remove 1 from both cursors (they get incremented at the end of the loop) //so that we can have only one code block handling matches for (var j = 0; j < maxOffset && (c1+j= l1) || (c2 >= l2)) { lcss+=local_cs; local_cs=0; c1=c2=Math.min(c1,c2); } } lcss+=local_cs; return Math.round(Math.max(l1,l2)- lcss +trans); //add the cost of transpositions to the final result }, splitEmail: function(email) { email = email !== null ? (email.replace(/^\s*/, '').replace(/\s*$/, '')) : null; // trim() not exist in old IE! var parts = email.split('@'); if (parts.length < 2) { return false; } for (var i = 0; i < parts.length; i++) { if (parts[i] === '') { return false; } } var domain = parts.pop(); var domainParts = domain.split('.'); var sld = ''; var tld = ''; if (domainParts.length === 0) { // The address does not have a top-level domain return false; } else if (domainParts.length == 1) { // The address has only a top-level domain (valid under RFC) tld = domainParts[0]; } else { // The address has a domain and a top-level domain sld = domainParts[0]; for (var j = 1; j < domainParts.length; j++) { tld += domainParts[j] + '.'; } tld = tld.substring(0, tld.length - 1); } return { topLevelDomain: tld, secondLevelDomain: sld, domain: domain, address: parts.join('@') }; }, // Encode the email address to prevent XSS but leave in valid // characters, following this official spec: // http://en.wikipedia.org/wiki/Email_address#Syntax encodeEmail: function(email) { var result = encodeURI(email); result = result.replace('%20', ' ').replace('%25', '%').replace('%5E', '^') .replace('%60', '`').replace('%7B', '{').replace('%7C', '|') .replace('%7D', '}'); return result; } }; // Export the mailcheck object if we're in a CommonJS env (e.g. Node). // Modeled off of Underscore.js. if (typeof module !== 'undefined' && module.exports) { module.exports = Mailcheck; } // Support AMD style definitions // Based on jQuery (see http://stackoverflow.com/a/17954882/1322410) if (typeof define === "function" && define.amd) { define("mailcheck", [], function() { return Mailcheck; }); } if (typeof window !== 'undefined' && window.jQuery) { (function($){ $.fn.mailcheck = function(opts) { var self = this; if (opts.suggested) { var oldSuggested = opts.suggested; opts.suggested = function(result) { oldSuggested(self, result); }; } if (opts.empty) { var oldEmpty = opts.empty; opts.empty = function() { oldEmpty.call(null, self); }; } opts.email = this.val(); Mailcheck.run(opts); }; })(jQuery); } ;