source map exposed
analyzed
https://www.disonsdemain.fr/build/js/match-14ed34ad15.js
map: https://www.lexa.nl/build/js/match-14ed34ad15.js.map
7 source files
190.2 KB map size
0 endpoints found
0 secrets found
discovered 6 hours, 40 minutes ago
7
source files
190.2 KB
map size
0
secrets
0
endpoints
source file tree (7)
7 files with original sourcebootstrap.js
//jQuery plugins
(function ($) {
if (!$.isArray) {
$.isArray = Array.isArray || function (obj) {
return Object.prototype.toString.call(obj) == '[object Array]';
};
}
$.url = function () { function l(a) { for (var b = "", c = 0, f = 0, d = 0; c < a.length;) { f = a.charCodeAt(c); if (f < 128) { b += String.fromCharCode(f); c++ } else if (f > 191 && f < 224) { d = a.charCodeAt(c + 1); b += String.fromCharCode((f & 31) << 6 | d & 63); c += 2 } else { d = a.charCodeAt(c + 1); c3 = a.charCodeAt(c + 2); b += String.fromCharCode((f & 15) << 12 | (d & 63) << 6 | c3 & 63); c += 3 } } return b } function m(a, b) { var c = {}, f = { "true": true, "false": false, "null": null }; $.each(a.replace(/\+/g, " ").split("&"), function (d, j) { var e = j.split("="); d = k(e[0]); j = c; var i = 0, g = d.split("]["), h = g.length - 1; if (/\[/.test(g[0]) && /\]$/.test(g[h])) { g[h] = g[h].replace(/\]$/, ""); g = g.shift().split("[").concat(g); h = g.length - 1 } else h = 0; if (e.length === 2) { e = k(e[1]); if (b) e = e && !isNaN(e) ? +e : e === "undefined" ? undefined : f[e] !== undefined ? f[e] : e; if (h) for (; i <= h; i++) { d = g[i] === "" ? j.length : g[i]; j = j[d] = i < h ? j[d] || (g[i + 1] && isNaN(g[i + 1]) ? {} : []) : e } else if ($.isArray(c[d])) c[d].push(e); else c[d] = c[d] !== undefined ? [c[d], e] : e } else if (d) c[d] = b ? undefined : "" }); return c } function n(a) { a = a || window.location; var b = ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"]; a = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(a); for (var c = {}, f = b.length; f--;) c[b[f]] = a[f] || ""; if (c.query) c.params = m(c.query, true); return c } function o(a) { if (a.source) return encodeURI(a.source); var b = []; if (a.protocol) if (a.protocol == "file") b.push("file:///"); else a.protocol == "mailto" ? b.push("mailto:") : b.push(a.protocol + "://"); if (a.authority) b.push(a.authority); else { if (a.userInfo) b.push(a.userInfo + "@"); else if (a.user) { b.push(a.user); a.password && b.push(":" + a.password); b.push("@") } if (a.host) { b.push(a.host); a.port && b.push(":" + a.port) } } if (a.path) b.push(a.path); else { a.directory && b.push(a.directory); a.file && b.push(a.file) } if (a.query) b.push("?" + a.query); else a.params && b.push("?" + $.param(a.params, true)); a.anchor && b.push("#" + a.anchor); return b.join("") } function p(a) { return encodeURIComponent(a) } function k(a) { a = a || window.location.toString(); return l(unescape(a.replace(/\+/g, " "))) } return { encode: p, decode: k, parse: n, build: o } }();
$.fn.msg = function (cmd) {
try {
if (cmd) {
var msgArgs = Array.prototype.slice.call(arguments).slice(1);
this.each(function () {
var elem = this;
var all = Cortado.Behaviors.allFrom(elem);
for (behavior in all) {
if (all.hasOwnProperty(behavior)) { //some idiots like to modify built in object prototypes
all[behavior].getInstance(function (instance) {
if (cmd in instance && $.isFunction(instance[cmd])) {
instance[cmd].apply(elem, msgArgs);
}
});
}
}
});
}
} catch (e) { Cortado.Helpers.log(e.name + ": " + e.message); }
return this;
};
$.fn.broadcast = function (cmd) {
var origArgs = Array.prototype.slice.call(arguments);
this.each(function () {
$('*[data-behavior]', this).andSelf().each(function () {
$.fn.msg.apply($(this), origArgs);
});
});
return this;
};
$.fn.replaceClass = function (old, current) {
this.removeClass(old).addClass(current);
return this;
};
$.initBehaviorsFor = function (elem) {
Cortado.Behaviors.parse(elem);
};
$.fn.replaceClass = function (old, current) {
this.removeClass(old).addClass(current);
return this;
};
$.ns = $.namespace = function (namespace) {
var parts = namespace.split('.');
var current = window;
for (var i = 0; i < parts.length; i++) {
if (!current[parts[i]])
current[parts[i]] = {};
current = current[parts[i]];
}
return current;
};
$.ns('Cortado');
Cortado.Promise = function () {
var _state = 'pending';
var _onResolved = null;
var _onRejected = null;
var _arguments = null;
var notify = function () {
if (_state == "resolved" && _onResolved) {
_onResolved.call(this, _arguments);
}
if (_state == "rejected" && _onRejected)
_onRejected.call(this, _arguments);
};
var self = {
then: function (onResolved, onRejected) {
_onResolved = onResolved;
_onRejected = onRejected;
if (_state != 'pending') { //execute
notify();
}
},
resolve: function (data) {
if (_state == 'pending') {
_arguments = data;
_state = 'resolved';
notify();
}
},
reject: function (data) {
if (_state == 'pending') {
_state = 'rejected';
_arguments = data;
notify();
}
}
};
return self;
};
Cortado.Uri = function (uriString) {
var _parsed = $.url.parse(uriString);
return {
pieces: function () {
return _parsed;
},
params: function (key, val) {
if (!_parsed.params)
_parsed.params = {};
if (arguments.length == 0)
return _parsed.params;
if (arguments.length > 1) {
//set flow
_parsed.params[key] = val;
}
else {
//get flow
return _parsed.params[key];
}
},
toString: function () {
//wipe source
_parsed.source = null;
return $.url.build(_parsed);
}
};
};
Cortado.ScriptUri = function (uriString) {
var _baseUri = new Cortado.Uri(uriString);
return {
seedValue: function () {
return _baseUri.params('v');
}
};
};
Cortado.Behaviors = function () {
var _autoInit = false;
var self = {
parse: function (elem) {
var typeDef = $(elem).attr('data-behavior');
if (typeDef) {
var types = typeDef.split(' ');
for (var i = 0; i < types.length; i++) {
var type = types[i];
var wrapper = new Cortado.Behaviors.BehaviorWrapper(type, elem);
if (!elem.behaviors)
elem.behaviors = [];
elem.behaviors[type] = wrapper;
if ($(elem).attr('data-init') == 'true' || _autoInit)
wrapper.touch();
}
}
},
wireupEvents: function () {
if (!window.opera && !/webkit/i.test(navigator.userAgent) && !/Firefox/i.test(navigator.userAgent) && ($.browser.msie && $.browser.version < 9)) return;
document.addEventListener("DOMContentLoaded", function (event) {
$('.extend').each(function () {
Cortado.Behaviors.parse(this);
});
}, true);
document.addEventListener("DOMNodeInserted", function (event) {
$('.extend', event.target).andSelf().each(function () {
if (/MSIE 10.0/i.test(navigator.userAgent) || /Trident\/7.0/i.test(navigator.userAgent)) {
// Temporary fix for IE10 and 11 to prevent mulitple instances of DomNodeInserted from firing.
var element = $(this);
if (element.attr('data-inserted') !== "true" && element.hasClass('extend')) {
Cortado.Behaviors.parse(this);
element.attr('data-inserted', 'true');
}
} else {
Cortado.Behaviors.parse(this);
}
});
}, true);
},
allFrom: function (elem) {
self.ensure(elem);
if (!elem.behaviors)
return [];
return elem.behaviors;
},
ensure: function (elem) {
if (!elem.behaviors && $(elem).attr('data-behavior')) {
self.parse(elem);
}
},
autoInit: function (enabled) {
if (enabled != _autoInit && enabled) {
$('BODY').broadcast('wakeUp');
}
_autoInit = enabled;
}
};
return self;
}();
Cortado.Behaviors.BehaviorWrapper = function (typeName, container) {
var _typeName = typeName;
var _container = container;
var _instance = null;
var _awake = false;
var wakeUp = function (onInstantiate) {
Cortado.Bootloader.requireByType(_typeName, function () {
_instance = eval('new ' + _typeName + '()');
if ('wakeFrom' in _instance && $.isFunction(_instance['wakeFrom'])) {
_instance.wakeFrom(_container);
}
_awake = true;
if ($.isFunction(onInstantiate)) onInstantiate(_instance);
});
};
return {
getInstance: function (onInstantiate) {
if (!_awake) {
wakeUp(onInstantiate);
}
else {
onInstantiate(_instance);
}
},
touch: function () {
if (!_awake) {
wakeUp();
}
}
};
};
Cortado.Behaviors.wireupEvents();
Cortado.ErrorManager = function () {
var ignoreList = [],
errorQueue = [];
function init() {
errorQueue = [];
window.onerror = function (errorMessage, url, line) {
logError(errorMessage, 'Unhandled script error at line ' + line + '(' + url + ')');
};
}
function initAjaxHandler() {
setTimeout(sendErrorsToAjax, 9950);
window.onbeforeunload = function () { //when browser closed
sendErrorsToAjax();
};
}
function sendErrorsToAjax() {
if (errorQueue && errorQueue.length > 0) {
//Cortado.Helpers.info('Cortado.ErrorManager.sendErrorsToAjax: ' + JSON.stringify(prepareErrorsForAjax()));
$jq.ajax({
type: 'POST',
url: '/Site/LogError',
contentType: 'application/json; charset=UTF-8',
data: JSON.stringify({ errorSummary: prepareErrorsForAjax() })
});
errorQueue = [];
}
}
function prepareErrorsForAjax() {
var params = {
Errors: errorQueue,
Path: location.pathname + location.hash
};
return params;
}
function addToIgnoreList(str) {
ignoreList.push(str);
}
function isInIgnoreList(str) {
for (var i = 0; i < ignoreList.length; i++) {
if (str.indexOf(ignoreList[i]) !== -1) return true;
}
return false;
}
function isDuplicateError(errorMessage, errorDetails) {
for (var i = 0; i < errorQueue.length; i++) {
if (errorMessage == errorQueue[i].message) {
errorQueue[i].errorCount++;
return true;
}
}
return false;
}
function logError(errorMessage, details) {
Cortado.Helpers.error(errorMessage + '\n' + details);
if (isInIgnoreList(errorMessage) || isDuplicateError(errorMessage, details)) return;
if (errorQueue.length === 0)
initAjaxHandler();
errorQueue.push({
message: errorMessage,
details: details,
errorCount: 1
});
}
return {
init: init,
flushErrors: sendErrorsToAjax,
addToIgnoreList: addToIgnoreList,
logError: logError
};
}();
Cortado.Bootloader = function () {
var _loadListeners = [];
var _allowCache = true;
var _fetchedByLoader = {};
var _loadedByLoader = {};
var determineSeedValue = function () {
if (!_allowCache)
return (new Date()).getTime().toString();
var seedValue = null;
$('script').each(function () {
if ($(this).attr('src') && $(this).attr('src').toLowerCase().indexOf('/cortado/bootstrap') >= 0) {
var scriptUri = new Cortado.ScriptUri($(this).attr('src'));
seedValue = scriptUri.seedValue();
}
});
return seedValue;
};
var maskSrc = function (src) {
return (src.indexOf('~') == 0) ? src.substring(1) : src;
};
var maskSrcForFetch = function (src) {
src = maskSrc(src);
var uri = new Cortado.Uri(src);
uri.params('v', determineSeedValue());
return uri.toString();
};
var referenced = function (src) {
var masked = maskSrc(src).toLowerCase();
var found = false;
$('script').each(function () {
if (this.src && this.src.toLowerCase().indexOf(masked) >= 0) {
found = true;
}
});
return found;
};
var addListenerFor = function (path, onLoaded) {
if (_loadListeners[path] == null)
_loadListeners[path] = [];
_loadListeners[path][_loadListeners[path].length] = onLoaded;
};
var fireAllListenersFor = function (path) {
if (path in _loadListeners) {
for (var i = 0; i < _loadListeners[path].length; i++) {
if ($.isFunction(_loadListeners[path][i])) _loadListeners[path][i]();
}
}
_loadListeners[path] = []; //detach listeners
};
var getTypeByString = function (typeString) {
var parts = typeString.split('.');
var current = window;
for (var i = 0; i < parts.length; i++) {
if (!current[parts[i]])
return null;
current = current[parts[i]];
}
return current;
};
var self = {
init: function () {
_allowCache = Cortado.Helpers.querystring().get('caching') != '0'; //default to on
},
requireByType: function (typeName, onLoaded) {
if (getTypeByString(typeName) != null) {
onLoaded();
}
else {
var requirePath = '/scripts/' + typeName.replace('.', '/') + '.js';
self.require(requirePath, onLoaded);
}
},
requireBundle: function (src, onLoaded) {
$.getJSON("/asset-manifest.json", function (data) {
if (data[src]) {
self.require('/' + data[src].scripts, onLoaded);
}
});
},
require: function (src, onLoaded) {
if ($.isFunction(onLoaded))
addListenerFor(src, onLoaded);
if (referenced(src)) {
if (!_fetchedByLoader[src] || _loadedByLoader[src]) {
fireAllListenersFor(src);
}
return;
}
_fetchedByLoader[src] = true;
var script = document.createElement('script');
script.src = maskSrcForFetch(src);
script.async = true;
script.type = 'text/javascript';
var head = document.getElementsByTagName('head')[0];
if (!head) {
head = document.body.parentNode.appendChild(document.createElement('head'));
}
if (script.readyState) { // Ensure IE9 only fires once
script.onreadystatechange = function () {
if (script.readyState == 'complete' || script.readyState == 'loaded') { // Fire for all versions of IE
_loadedByLoader[src] = true;
fireAllListenersFor(src);
}
};
} else {
script.onload = function () {
_loadedByLoader[src] = true;
fireAllListenersFor(src);
};
}
head.appendChild(script);
},
caching: function (allowCache) {
_allowCache = allowCache;
}
};
return self;
}();
Cortado.Helpers = function () {
//make calls to console.log safe, lifted from Twitter
if (!window.console) {
(function () {
var names = ["log", "debug", "info", "warn", "error",
"assert", "dir", "dirxml", "group", "groupEnd", "time",
"timeEnd", "count", "trace", "profile", "profileEnd"],
i, l = names.length;
window.console = {};
for (i = 0; i < l; i++) {
window.console[names[i]] = function () { };
}
}());
}
if (typeof String.prototype.trim !== 'function') {
String.prototype.trim = function () {
return this.replace(/^\s+|\s+$/g, '');
};
}
return {
safeInvoke: function (method, data) {
if ($.isFunction(method))
method();
},
log: function (msg) {
console.log(msg); //see window.console fix above
},
info: function (msg) {
console.info(msg);
},
warn: function (msg) {
console.warn(msg);
},
error: function (msg) {
console.error(msg);
},
array: {
any: function (arr) {
if (arr.length) {
return arr.length > 0;
}
//associative
for (var key in arr) {
if (arr.hasOwnProperty(key)) {
return true;
}
}
return false;
}
},
querystring: function (fromUrl) {
var _target = "";
if (arguments.length > 0) {
var idx = fromUrl.indexOf('?');
if (idx >= 0) {
_target = fromUrl.substring(idx); //assumes ? is start character
}
} else {
_target = window.location.search;
}
return {
get: function (name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(_target);
if (results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
};
},
scaleImage: function (data, img) {
var Width = (img.width == null) ? 80 : img.width;
var Height = (img.height == null) ? 100 : img.height;
var ratio = Math.min(data.width / Width, data.height / Height);
if (typeof (img) == "object" && img.nodeName == "IMG") {
img.width = Math.round(ratio * Width);
img.height = Math.round(ratio * Height);
return img;
} else {
return {
width: Math.round(ratio * Width),
height: Math.round(ratio * Height)
};
}
},
serializeObject: function (form) {
var obj = {};
var values = form.serializeArray();
for (var i = 0; i < values.length; i++) {
obj[values[i].name] = values[i].value;
}
return obj;
},
isScrolledIntoView: function (element) {
var docTop = $(window).scrollTop(),
docBottom = docTop + $(window).height(),
elemTop = $(element).offset().top,
elemBottom = elemTop + $(element).height();
return ((elemTop <= docBottom) && (elemTop >= docTop));
},
localStorage: function () {
if (!window.localStorage) {
// Browser does not support localstorage
return false;
}
return {
add: function (key, value) {
localStorage[key] = JSON.stringify(value);
},
remove: function (key) {
localStorage.removeItem(key);
},
getItemByKey: function (key) {
if (localStorage[key]) {
return JSON.parse(localStorage[key]);
}
return false;
}
};
}
};
}();
Cortado.ServiceProxy = function () {
var request = null;
var promise = null;
return {
invoke: function (data) {
promise = new Cortado.Promise();
if (request !== null) {
request.abort();
request = null;
}
var options = {
url: '',
type: 'json',
method: 'get',
data: {}
};
$.extend(options, data);
request = $.ajax({
url: options.url,
dataType: options.type,
type: options.method,
data: options.data,
success: function (response) {
promise.resolve(response);
},
error: function (xmlhttp, status, exception) {
promise.reject(xmlhttp);
}
});
return promise;
},
abort: function () {
if (request !== null) {
request.abort();
request = null;
promise.reject();
}
}
};
};
Cortado.ChunkLoader = function () {
return {
load: function (data) {
$.ajax({
type: 'GET',
cache: false,
url: data.url,
beforeSend: function (xhr) {
xhr.setRequestHeader('X-Cortado-ChunkLoad', 'true');
if (data.requestHeaders) {
for (var key in data.requestHeaders) {
if (data.requestHeaders.hasOwnProperty(key)) {
xhr.setRequestHeader(key, data.requestHeaders[key]);
}
}
}
},
success: function (response, status, xhr) {
data.success(response, status, xhr);
},
error: function (xmlhttp, status, exception) {
if (xmlhttp.status == 401) {
//for now, login will redirect
window.location.href = '/login/login.aspx';
} else {
data.error(xmlhttp, status, exception);
}
}
});
}
};
}();
Cortado.Session = function () {
var _service = new Cortado.ServiceProxy(),
_login = new Cortado.Promise(),
_modal = null,
_submitting = false,
_form = null;
var login = function () {
var data = _form.serialize();
var errors = $('.errors', _form);
if (_submitting) return;
_submitting = true;
_form.msg('busy', true);
errors.hide();
$.ajax({
type: "GET",
url: '/Membership/EnsureSession/',
success: function () {
// INCEPTION! WE NEED TO GO DEEPER!
$.ajax({
url: '/Membership/Login/',
type: "POST",
data: data,
dataType: "json",
success: function (response) {
if (response.hasOwnProperty('success')) {
if (!response.success) {
var message = response.reason;
errors.html(message).show();
_form.msg('busy', false);
_submitting = false;
return false;
}
if (response.uid !== undefined) {
//compare previous uid to logged in
var uid = $('#cuid');
var oldUid = (uid.val().length > 0) ? parseInt(uid.val()) : 0;
if (parseInt(response.uid) != oldUid) {
//refresh the page
window.location.reload(true);
return false;
}
}
_login.resolve();
if (_modal !== null) {
_modal.msg('dismiss');
}
}
_login.reject();
},
error: function () {
console.log('Failed to login via /membership/login/');
_login.reject();
}
});
}
});
};
var ensureLogin = function () {
// Return service promise
return _service.invoke({
url: '/Membership/IsLoggedIn/',
type: '',
method: 'GET'
});
};
var getLoginPanel = function (callback) {
Cortado.ChunkLoader.load({
url: '/Membership/LoginPanel/',
success: function (response) {
callback(response);
},
error: function () {
console.log('failed to get login panel');
}
});
};
var clearForm = function (container) {
_form = $('form', container);
_form.msg('busy', false).get(0).reset();
$('.errors', container).hide();
};
var wireUpEvents = function (container) {
clearForm(container);
container.off().on('click', '.login_confirm', function (e) {
e.preventDefault();
login();
}).on('keypress', 'form', function (e) {
if (e.which == 13) {
login();
}
}).on('click', '.prompt_dismiss', function () {
_modal.msg('dismiss');
_login.reject({ 'Success': false, 'Reason': 'UserAbandon' });
});
};
var insertDialog = function () {
var dialog = '<div class="dialog dialog-login extend" id="sessionLogin" data-behavior="Cortado.dialog Cortado.refreshable" data-refresh="/Membership/LoginPanel/" data-init="true" data-autoload="true"></div>';
var count = 5;
var promise = new Cortado.Promise();
// Prevent duplicates then check if dialog is inserted before resolving promise.
var getDialog = window.setInterval(function () {
_modal = $('#sessionLogin');
if (_modal.length < 1) {
$('body').append(dialog);
}
if (_modal.length > 0) {
clearInterval(getDialog);
if (_modal[0].style.display == 'none') {
_modal.msg('show');
}
promise.resolve();
}
if (_modal.length == 0 && count == 0) {
clearInterval(getDialog);
promise.reject();
}
count--;
}, 500);
return promise;
};
return {
ensureLoggedIn: function () {
return ensureLogin();
},
loginBy: {
dialog: function () {
insertDialog().then(function () {
wireUpEvents(_modal);
});
return _login;
},
panel: function (container) {
getLoginPanel(function (response) {
container.html(response);
wireUpEvents(container);
});
return _login;
}
}
};
};
Cortado.Facebook = function () {
$.ns('Facebook');
return {
connect: function (context) {
Cortado.Bootloader.require('/scripts/facebook/connect.js', function () {
if (context) {
Facebook.Controller.Connect(context);
} else {
Facebook.Controller.Load();
}
});
}
};
}();
Cortado.Advertising = function () {
var cache = [];
var serviceEnabled = false;
var slots = {};
var calledAmzn = false;
var PREBID_WAIT = 700;
var _timeout = setTimeout(function () { }, PREBID_WAIT);
function publishAdUnit(ad) {
var protocol = document.location.protocol;
Cortado.Bootloader.require('/scripts/prebid/prebid_20170816.js', function () {
Cortado.Bootloader.require(protocol + "//match-d.openx.net/w/1.0/jstag?nc=7214-Match", function () {
Cortado.Bootloader.require(protocol + "//c.amazon-adsystem.com/aax2/amzn_ads.js", function () {
Cortado.Bootloader.require(protocol + "//www.googletagservices.com/tag/js/gpt.js", function () {
var value,
values;
// API documentation https://developers.google.com/doubleclick-gpt/reference
googletag.cmd.push(function () {
//we need to wait for bids to come back, refresh gets called by header bidder!
googletag.pubads().disableInitialLoad();
var adUnit;
if (slots[ad.id]) {
if (calledAmzn == false) {
amznads.getAdsCallback('3121', function () {
try {
amznads.setTargetingForGPTAsync('amznslots');
} catch (e) { /*ignore*/
}
});
calledAmzn = true;
}
// googletag.pubads().clearTargeting('amznslots');
googletag.pubads().refresh([slots[ad.id]]);
console.log('called refresh...');
return;
}
if (ad.isOutOfPageSlot) {
slots[ad.id] = googletag.defineOutOfPageSlot(ad.path, ad.id).setTargeting('ad_group', adomikRandomGroup());
adUnit = slots[ad.id].addService(googletag.pubads());
} else {
slots[ad.id] = googletag.defineSlot(ad.path, ad.adSize, ad.id).setTargeting('ad_group', adomikRandomGroup());
adUnit = slots[ad.id].addService(googletag.pubads());
}
for (key in ad.targeting) {
value = ad.targeting[key];
values = value.split(",");
// Determine if key has multiple values
if (values.length > 1) {
// Key with multiple values
adUnit.setTargeting(key, values);
} else {
// Key with single value
adUnit.setTargeting(key, value);
}
}
// Fire once per page life cycle.
if (serviceEnabled === false) {
serviceEnabled = true;
if (window.Krux !== undefined) {
googletag.pubads().setTargeting("ksg", Krux.segments);
googletag.pubads().setTargeting("kuid", Krux.user);
}
googletag.pubads().enableAsyncRendering();
googletag.enableServices();
}
// Render ad placement
if (calledAmzn == false) {
amznads.getAdsCallback('3121', function () {
try {
amznads.setTargetingForGPTAsync('amznslots');
} catch (e) { /*ignore*/
}
calledAmzn = false;
});
calledAmzn = true;
googletag.display(ad.id);
} else {
googletag.display(ad.id);
}
});
//let's kick off the prebid process here?
Cortado.Bootloader.require('/scripts/cortado/header-bidder.js', function () {
var headerBidder = Cortado.HeaderBidder();
headerBidder.createAdUnit(ad);
_timeout = headerBidder.resetTimeout(_timeout, headerBidder.requestBids, PREBID_WAIT);
});
});
});
});
});
}
function adomikRandomGroup() {
var rand = Math.random();
switch (false) {
case !(rand < 0.09): return "ad_ex" + (Math.floor(100 * rand));
case !(rand < 0.10): return "ad_bc";
default: return "ad_opt";
}
}
function eas_load(ad) {
var scriptSrc = ad.scriptSrc();
var element = document.getElementById(ad.id);
if (element == null) {
return;
}
element.innerHTML = '';
EAS_load_fif(ad.id, "/ads/matchAdsIframe.htm", scriptSrc, ad.adwidth, ad.adheight);
}
var refresh = function (ad) {
Cortado.Bootloader.require('/scripts/EAS_Tag.1.0.js', function () {
try {
if (typeof (EAS_load_fif) == "function") {
if (ad.version && ad.version === 2) {
// New hotness
publishAdUnit(ad);
} else {
// Legacy ad method
eas_load(ad);
}
}
} catch (error) {
console.log(ad.id + ' failed to load');
console.log(error);
}
});
};
return {
add: function (placement) {
var key = placement.id;
cache[key] = placement;
if (placement.autoLoad === true) {
refresh(placement);
}
return this;
},
load: function (placements) {
if ($.isArray(placements)) {
for (var i = 0; i < placements.length; i++) {
if (cache[placements[i]]) {
refresh(cache[placements[i]]);
}
}
} else {
if (cache[placements]) {
refresh(cache[placements]);
}
}
},
loadAll: function (byZone) {
for (var key in cache) {
if (byZone) {
if (cache[key].adzone === byZone) {
refresh(cache[key]);
}
} else {
refresh(cache[key]);
}
}
},
info: function () {
return cache;
},
allowAmznCall: function () {
calledAmzn = false;
}
};
}();
Cortado.Bootloader.init();
/* IE-specific shims to work around bugs in MS Internet Explorer */
//167532: bug fix for IE where img element nested within a label does not fire the click event of the label's associated control.
// Only apply gobal handler on pages using updated version of jQuery
if ($.browser.msie && $.fn.jquery !== '1.2.6') {
$(document).on("click", "label>img", function (e) {
e.preventDefault();
var label = $(this).parent();
if (label.attr("for")) {
$("#" + label.attr("for")).click();
} else {
label.find("input,select,button").first().click();
}
});
if (!Date.prototype.toISOString) {
(function () {
function pad(number) {
if (number < 10) {
return '0' + number;
}
return number;
}
Date.prototype.toISOString = function () {
return this.getUTCFullYear() +
'-' + pad(this.getUTCMonth() + 1) +
'-' + pad(this.getUTCDate()) +
'T' + pad(this.getUTCHours()) +
':' + pad(this.getUTCMinutes()) +
':' + pad(this.getUTCSeconds()) +
'.' + (this.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) +
'Z';
};
}());
}
}
/* End of IE-specific shims*/
})(jQuery);
Controller.js
(function ($) {
$.ns('Notifications');
Notifications.Controller = function () {
var _poller = null,
_service = new Cortado.ServiceProxy(),
_attempts = 0,
_pollDuration = 10000,
_parameters = new ServiceParameters(),
_skipIM = false,
_promise = null;
var handlers = {
TopSpot: function (model) {
$('#topspot-dash').msg('onMessageRecieved', model);
},
IM: function (model) {
if (model.Count > 0 && Match.Chat.PollManager.enabled() === true) {
$('#globalChatAlertList').msg('refresh');
}
}
};
function ServiceParameters() {
return {
url : '/alert/GetAllAlerts/',
data : {}
};
};
var getNotifications = function (publish) {
_promise = new Cortado.Promise();
if (_attempts >= 3) {
_promise.reject({ "HttpStatusCode": 408 });
self.Poller.Stop();
return _promise;
};
_service.invoke(_parameters).then(
function (response) {
// Stop polling on session timeout
if (response.StatusCode === 401) {
self.Poller.Stop();
_promise.reject({ "HttpStatusCode": response.StatusCode });
return _promise;
}
// Update endpoint after initial request.
_parameters.url = '/alert/TopSpotPoller/';
_parameters.data.lastImpressionDt = new Date().getTime();
_parameters.data.skipIM = _skipIM;
if (_parameters.data.pollCt >= 0) {
_parameters.data.pollCt++;
} else {
_parameters.data.pollCt = 0;
}
if (publish) {
notify(response.Notifications);
}
_attempts = 0;
_promise.resolve(response.Notifications);
},
function (response) {
_attempts++;
console.log('Failed to return notifications. Attempts ' + _attempts + '. Reason : ' + response.statusText);
_promise.reject({ "HttpStatusCode": 408 });
}
);
return _promise;
};
var notify = function (notifications) {
for (var notification in notifications) {
if (handlers.hasOwnProperty(notification)) {
handlers[notification](notifications[notification]);
}
}
};
var poll = function () {
if (_poller === null) {
_poller = setInterval(function () {
getNotifications(true);
}, _pollDuration);
}
};
var self = {
Poller: {
Status: _poller,
Stop: function () {
_service.abort();
if (_promise)
_promise.reject({ "HttpStatusCode": 409 });
_service = new Cortado.ServiceProxy();
if (_poller)
clearInterval(_poller);
_poller = null;
return self;
},
Start: function (skipIm, topspotOn) {
_skipIM = skipIm;
if (topspotOn) {
getNotifications(true)
.then(function() {
poll();
});
}
},
Resume: function () {
poll();
},
Timeout: _pollDuration
},
GetAllNotifications: function (type, callback) {
// Set last impression date to 20 sceonds into the future.
// Testing to see if this resolves race condition after successful purchase
var dateNow = new Date();
dateNow.setSeconds(dateNow.getSeconds() + 20);
_attempts = 0;
_parameters.data.lastImpressionDt = dateNow.toISOString();
getNotifications(false).then(function(response) {
var notifications = response;
if (type && notifications.hasOwnProperty(type)) {
notifications = response[type];
}
if (callback) {
callback(notifications);
}
});
}
};
return self;
}();
$(document).ready(function () {
var cuid = document.getElementById('cuid');
var skipIm = false, topspotOn = false;
if (document.getElementById('rtnLongPoll')) {
skipIm = true;
}
if (document.getElementById('topspotActive')) {
topspotOn = true;
}
if (cuid !== null) {
var isLoggedIn = cuid.value !== '0';
if (isLoggedIn) {
Notifications.Controller.Poller.Start(skipIm, topspotOn);
}
}
});
})(jQuery);
core.js
$.ajaxSetup({
jsonp: false
});
var $jq = jQuery.noConflict();
/* jQuery selectbox related plugins */
jQuery.fn.containsOption = function (query) {
var found = false;
this.each(
function () {
if (this.nodeName.toLowerCase() == 'select') {
for (var i = 0; i < this.options.length; i++) {
if (query.value) {
found = (query.value.constructor == RegExp) ?
this.options[i].value.match(query.value) :
this.options[i].value == query.value;
} else if (query.text) {
found = (query.text.constructor == RegExp) ?
this.options[i].text.match(query.text) :
this.options[i].text == query.text;
}
if (found)
break;
}
} else return this;
}
);
return found;
};
jQuery.fn.addOption = function (o) {
var opt = o;
this.each(
function () {
if (this.nodeName.toLowerCase() == 'select') {
var option = document.createElement('OPTION');
option.value = opt.value;
option.text = opt.text;
if (opt.selected)
option.selected = opt.selected;
this.options[this.options.length] = option;
}
else return this;
}
);
return this;
};
jQuery.fn.clearOptions = function () {
this.each(
function () {
if (this.nodeName.toLowerCase() == 'select') {
this.options.length = 0;
}
}
);
};
jQuery.fn.removeOption = function (val) {
this.each(
function () {
if (this.nodeName.toLowerCase() == 'select') {
for (var i = 0; i < this.options.length; i++) {
if (this.options[i].value == val) {
this.options[i] = null;
}
}
} else return this;
}
);
return this;
};
jQuery.fn.selectOptionByValue = function (val) {
this.each(
function () {
if (this.nodeName.toLowerCase() == 'select') {
for (var i = 0; i < this.options.length; i++) {
if (this.options[i].value == val) {
this.options[i].selected = true;
}
else {
this.options[i].selected = false;
}
}
} else return this;
}
);
return this;
};
jQuery.fn.radioSelectByValue = function (val) {
this.each(
function () {
if (this.nodeName.toLowerCase() == 'input' && jQuery(this).attr('type').toLowerCase() == 'radio') {
if (jQuery(this).val() == val) {
this.checked = true;
}
else {
this.checked = false;
}
} else return this;
}
);
return this;
};
jQuery.fn.radioSelectedValue = function () {
var val = null;
this.each(
function () {
if (val == null) {
if (this.nodeName.toLowerCase() == 'input' && jQuery(this).attr('type').toLowerCase() == 'radio') {
if (this.checked) {
val = jQuery(this).val();
}
}
}
}
);
return val;
};
jQuery.createCookie = function (name, value, days, isArray, setDomain) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
}
else var expires = "";
var domain = '';
if (setDomain) {
domain = "; domain=" + jQuery.getDomain();
}
if (arguments.length > 3 && isArray) {
value = jQuery.serializeKeyValues(value);
}
document.cookie = name + "=" + value + expires + domain + "; path=/";
};
jQuery.readCookie = function (name, nullable) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) {
var val = c.substring(nameEQ.length, c.length);
if (val.indexOf('&')) {
return jQuery.parseKeyValueString(val);
}
else return val;
}
}
if (nullable == false) {
return '';
} else {
return null;
}
};
jQuery.getDomain = function() {
var domain = '';
if (typeof document !== 'undefined') {
var hostname = document.location.hostname;
if (hostname === 'localhost' || hostname === '127.0.0.1') {
domain = null;
} else {
if (hostname.indexOf('.') >= 0) {
domain = hostname.substring(hostname.indexOf('.')+1, hostname.length);
} else {
domain = hostname;
}
}
}
return domain;
};
jQuery.updateCookie = function (name, val, isDomain) {
var _name = name + "=";
var cookieCollection = document.cookie.split(';');
for (var i = 0; i < cookieCollection.length; i++) {
var cookie = cookieCollection[i];
while (cookie.charAt(0) == ' ') cookie = cookie.substring(1, cookie.length);
if (cookie.indexOf(_name) == 0) {
//var cookieVal = cookie.substring(_name.length, cookie.length);
cookie = cookie + "&" + val;
jQuery.createCookie(name, "", -1, false, isDomain);
document.cookie = cookie;
}
}
};
jQuery.eraseCookie = function (name, isDomain) {
jQuery.createCookie(name, "", -1, false, isDomain);
};
jQuery.parseKeyValueString = function (val) {
var hash = [];
var pieces = val.split('&');
for (var i = 0; i < pieces.length; i++) {
var pair = pieces[i].split('=');
hash[pair[0]] = pair[1];
}
return hash;
};
jQuery.serializeKeyValues = function (hash) {
if (hash != null) {
var pairs = [];
for (var key in hash) {
pairs.push(key + '=' + hash[key]);
}
return pairs.join('&');
}
return null;
};
jQuery.namespace = function (namespace) {
var parts = namespace.split('.');
var current = window;
for (var i = 0; i < parts.length; i++) {
if (!current[parts[i]])
current[parts[i]] = {};
current = current[parts[i]];
}
return current;
};
jQuery.logException = function (e) {
try {
if (!navigator.userAgent.match(/msie/i)) {
if (typeof debugging != undefined && typeof window.console != undefined) {
console.log(e.stack)
}
}
} catch (ex) { };
return this;
}
jQuery.queryString = function () {
var _keyVals = [];
var _loaded = false;
var load = function () {
if (!_loaded) {
var raw = (window.location.search.length > 0) ? window.location.search.substring(1) : '';
var pairs = raw.split("&");
for (i = 0; i < pairs.length; i++) {
var pair = pairs[i].split("=");
_keyVals[pair[0]] = pair[1];
}
_loaded = true;
}
}
return {
get: function (key) {
if (!_loaded)
load();
for (var currentKey in _keyVals) {
if (currentKey.toLowerCase() == key.toLowerCase())
return _keyVals[currentKey];
}
return null;
}
};
} ();
jQuery.fn.addBehavior = function (behaviorName, instance) {
this.each(
function () {
if (!this.behaviors)
this.behaviors = [];
this.behaviors[behaviorName] = instance;
}
);
return this;
};
jQuery.initBehavior = function (container, behaviorName, meta) {
try {
var ctl = eval('new ' + behaviorName + '()');
ctl.init({
"container": container,
"meta": meta
});
jQuery(container).addBehavior(behaviorName, ctl);
return ctl;
}
catch (e) {
$jq.logException(e);
}
return null;
};
jQuery.fn.parseBehavior = function () {
this.each(function () {
try {
var type = $jq(this).attr('behavior');
if (type != null && type != '') {
var metaData = null;
try {
metaData = jQuery(this).metadata({ type: 'attr', name: 'meta' });
}
catch (e) {
$jq.logException(e);
}
var types = type.split(',');
for (var i = 0; i < types.length; i++) {
jQuery.initBehavior(this, types[i], metaData);
}
}
}
catch (e) {
$jq.logException(e);
}
});
return this;
};
jQuery.getBehavior = function (container, behaviorName) {
if (container.behaviors)
return container.behaviors[behaviorName];
};
jQuery.fn.behavior = function (behaviorName, eachFunc) {
this.each(
function () {
var behavior = jQuery.getBehavior(this, behaviorName);
if (behavior != null)
eachFunc(behavior);
}
);
return this;
};
jQuery.behaviorAction = function (behaviorElem, behaviorAction) {
if (behaviorElem.behaviors) {
for (var key in behaviorElem.behaviors) {
var behavior = behaviorElem.behaviors[key];
if (behavior != null
&& jQuery.isFunction(behavior[behaviorAction.action])
&& (('behavior' in behaviorAction && behaviorAction.behavior == key) || !behaviorAction.behavior)
)
behavior[behaviorAction.action]();
}
}
};
/*
* Metadata - jQuery plugin for parsing metadata from elements
*
* Copyright (c) 2006 John Resig, Yehuda Katz, J�örn Zaefferer, Paul McLanahan
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Revision: $Id: jquery.metadata.js 3620 2007-10-10 20:55:38Z pmclanahan $
*
*/
eval(function (p, a, c, k, e, r) { e = function (c) { return (c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)) }; if (!''.replace(/^/, String)) { while (c--) r[e(c)] = k[c] || e(c); k = [function (e) { return r[e] } ]; e = function () { return '\\w+' }; c = 1 }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p } ('(9($){$.r({3:{7:{8:\'l\',h:\'3\',q:/({.*})/,4:\'3\'},w:9(a,b){g.7.8=a;g.7.h=b},j:9(b,c){5 d=$.r({},g.7,c);2(!d.4.o)d.4=\'3\';5 a=$.n(b,d.4);2(a)6 a;a="{}";2(d.8=="l"){5 m=d.q.v(b.u);2(m)a=m[1]}k 2(d.8=="t"){2(!b.i)6;5 e=b.i(d.h);2(e.o)a=$.s(e[0].C)}k 2(b.p!=A){5 f=b.p(d.h);2(f)a=f}2(a.z(\'{\')<0)a="{"+a+"}";a=y("("+a+")");$.n(b,d.4,a);6 a}}});$.x.3=9(a){6 $.3.j(g[0],a)}})(B);', 39, 39, '||if|metadata|single|var|return|defaults|type|function|||||||this|name|getElementsByTagName|get|else|class||data|length|getAttribute|cre|extend|trim|elem|className|exec|setType|fn|eval|indexOf|undefined|jQuery|innerHTML'.split('|'), 0, {}))
$jq.namespace('MatchCore');
$jq.namespace('MatchCore.Types');
MatchCore.Session = function () {
var self = {
SID: function () {
if ($jq.readCookie('SECU') != null) {
//return _sid;
return $jq.readCookie('SECU')['ESID'];
}
},
ServerId: function () {
if ($jq.readCookie('SECU') != null) {
//return _serverId;
return $jq.readCookie('SECU')['THEME'];
}
},
UserId: function () {
if ($jq.readCookie('Match') != null) {
return $jq.readCookie('Match')['uid'];
}
},
isTimedOut: function () {
var sid = self.SID();
var serverId = self.ServerId();
return !(
sid != null &&
sid != undefined &&
sid.length > 0 &&
serverId != null &&
serverId != undefined &&
serverId.length > 0
);
}
};
return self;
} ();
MatchCore.Delegate = function () {
var _handlers = [];
return {
add: function (handler) {
_handlers.push(handler);
},
fire: function () {
for (var i = 0; i < _handlers.length; i++) {
_handlers[i](arguments);
}
_handlers = [];
},
fireAndPreserve: function () {
for (var i = 0; i < _handlers.length; i++) {
_handlers[i](arguments);
}
},
count: function () {
return _handlers.length;
}
};
};
MatchCore.DelegateEnhanced = function () {
var _handlers = [];
return {
add: function (handler) {
_handlers.push(handler);
},
fire: function () {
for (var i = 0; i < _handlers.length; i++) {
_handlers[i].apply(this, arguments);
}
_handlers = [];
},
fireAndPreserve: function () {
for (var i = 0; i < _handlers.length; i++) {
_handlers[i].apply(this, arguments);
}
},
count: function () {
return _handlers.length;
}
};
};
MatchCore.ServiceProxy = function (baseUrl) {
var _baseUrl;
var _methodName;
if (baseUrl)
_baseUrl = baseUrl;
return {
invoke: function (opts) {
if (opts) {
var verb = (opts.verb) ? opts.verb : "GET";
var dataType = (opts.dataType) ? opts.dataType : "json";
if (opts.method) {
var proxyUrl = (dataType.toLowerCase() == 'json') ? _baseUrl + '/' + opts.method : _baseUrl + '/' + opts.method + '/' + dataType;
} else {
var proxyUrl = baseUrl;
}
}
var async = ('async' in opts) ? opts.async : true;
$jq.ajax({
type: verb,
url: proxyUrl,
data: opts.data,
dataType: dataType,
success: function (response) {
if (opts.success)
opts.success(response);
},
error: function (xmlhttp, status, exception) {
if (opts.failure)
opts.failure(xmlhttp, status, exception);
if (opts.error)
opts.error(xmlhttp, status, exception);
},
async: async
});
}
};
};
MatchCore.templateProxy = function (baseUrl) {
var _baseUrl;
_baseUrl = baseUrl;
return {
invoke: function (opts) {
var verb = (opts.verb) ? opts.verb : "GET";
var dataType = "html";
$jq.ajax({
type: verb,
url: _baseUrl,
dataType: dataType,
success: function (response) {
if (opts.success)
opts.success(response);
},
error: function (xmlhttp, status, exception) {
if (opts.failure)
opts.failure(xmlhttp, status, exception);
if (opts.error)
opts.error(xmlhttp, status, exception);
}
});
}
}
};
MatchCore.APIProxy = function (baseUrl) {
var _baseUrl;
var _methodName;
if (baseUrl)
_baseUrl = baseUrl;
return {
invoke: function (opts) {
var verb = (opts.verb) ? opts.verb : "GET";
var dataType = (opts.dataType) ? opts.dataType : "json";
var data = (dataType.toLowerCase() == "json") ? JSON.stringify(opts.data) : opts.data;
var subLink = (opts.subLink) ? '/' + opts.subLink : "";
var proxyUrl = _baseUrl + subLink;
var contentType = (opts.contentType) ? opts.contentType : "application/json; charset=utf-8";
var async = ('async' in opts) ? opts.async : true;
var auth = MatchCore.CP.Mauth();
if (proxyUrl.indexOf('?') == -1)
proxyUrl += '?Authorization=' + auth;
else
proxyUrl += '&Authorization=' + auth;
$jq.ajax({
type: verb,
url: proxyUrl,
data: data,
dataType: dataType,
contentType: contentType,
success: function (response) {
if (opts.success)
opts.success(response);
},
error: function (xmlhttp, status, exception) {
if (opts.failure)
opts.failure(xmlhttp, status, exception);
if (opts.error)
opts.error(xmlhttp, status, exception);
},
async: async
});
}
};
};
MatchCore.Messaging = function () {
var _messages = null;
var hasMessageSummary = function () {
return getMessageSummary().length > 0;
};
var getMessageSummary = function () {
return $jq('.userMessageSummary');
};
return {
reset: function () {
if (hasMessageSummary) {
getMessageSummary().html('');
getMessageSummary().hide();
}
if (_messages) {
for (var i = 0; i < _messages.length; i++) {
var field = $jq('INPUT[name="' + _messages[i].field + '"]')[0];
var label = $jq('LABEL[for="' + _messages[i].field + '"]')[0];
$jq(label).removeClass('invalidFieldLabel');
$jq(field).removeClass('invalidField');
}
}
_messages = null;
},
show: function (messages) {
this.reset();
_messages = messages;
if (hasMessageSummary()) {
getMessageSummary().html('<ul></ul>');
getMessageSummary().show();
}
for (var i = 0; i < messages.length; i++) {
if (messages[i].Field) {
var field = $jq('INPUT[name="' + messages[i].Field + '"]');
var label = $jq('LABEL[for="' + messages[i].Field + '"]');
label.addClass('invalidFieldLabel');
field.addClass('invalidField');
if (i == 0 && field.length > 0)
field[0].focus();
}
if (hasMessageSummary())
$jq('UL', getMessageSummary()[0]).append('<li>' + messages[i].Text + '</li>');
}
}
};
} ();
MatchCore.Query = function (array) {
var _array = array;
return {
filter: function (method) {
if (method != null) {
var filtered = [];
for (var i = 0; i < _array.length; i++) {
var item = _array[i];
if (method(item))
filtered.push(item);
}
return new MatchCore.Query(filtered);
}
else return this;
},
sort: function (method) {
return new MatchCore.Query(_array.sort(method));
},
data: function (array) {
if (array)
_array = array;
else
return _array;
}
}
};
MatchCore.PhotoConfig = {
Ids: [
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z'
]
};
// a polyfill to support the startsWith method below...you can safely remove this when all browsers;...so like never, yeah
if (!String.prototype.startsWith) {
String.prototype.startsWith = function (searchString, position) {
position = position || 0;
return this.indexOf(searchString, position) === position;
};
}
MatchCore.Photo = function (uid, photoId) {
var _uid = uid;
var _id = photoId;
var generateUrl = function (type) {
var photoID = MatchCore.PhotoConfig.Ids[_id - 1];
var lastFour = _uid.toString().substring(_uid.toString().length - 4);
var folder1 = lastFour.substring(0, 2);
var folder2 = lastFour.substring(2);
var schemePart = 'http://';
if (window.location.href.startsWith('https:')) {
schemePart = 'https://secure';
}
return schemePart + type + '.match.com/' + type + '/' + folder1 + '/' + folder2 + '/' + _uid.toString() + photoID + '.jpeg';
};
var self = {
smallThumbnail: function () {
if (self.isValid()) {
return generateUrl("sthumbnails");
}
return '';
},
thumbnail: function () {
if (self.isValid()) {
return generateUrl("thumbnails");
}
return '';
},
fullSize: function () {
if (self.isValid()) {
return generateUrl("pictures");
}
return '';
},
isValid: function () {
return (_uid > 0 && _id > 0 && _id <= MatchCore.PhotoConfig.Ids.length);
}
}
return self;
};
MatchCore.UI = {
busy: function () {
$jq('BODY').addClass('ui_busy');
},
done: function () {
$jq('BODY').removeClass('ui_busy');
}
};
MatchCore.UI.PopupWindow = function () {
var _container;
var _dimensions = { height: 220, width: 400 };
var _position = { left: 0, top: 0 };
var _url = 'about:blank';
var _win;
var self = {
init: function (opts) {
if (opts != undefined && opts.container != undefined) {
_container = opts.container;
if (opts.meta != undefined) {
if (opts.meta.url != undefined)
_url = opts.meta.url;
if (opts.meta.height != undefined)
_dimensions.height = parseInt(opts.meta.height);
if (opts.meta.width != undefined)
_dimensions.width = parseInt(opts.meta.width);
if (opts.meta.top != undefined)
_position.top = parseInt(opts.meta.top);
if (opts.meta.left != undefined)
_position.left = parseInt(opts.meta.left);
if (opts.meta.timeout != undefined) {
setTimeout(
function () {
self.show();
},
opts.meta.timeout
);
}
}
}
},
show: function () {
_win = window.open(_url, "popupWindow", 'toolbar=0,titlebar=0,scrollbars=0,resizable=0,menubar=0,Height=' + _dimensions.height.toString() + ',Width=' + _dimensions.width.toString() + ',top=' + _position.top + ',left=' + _position.left);
if (_win) {
if (_win.focus) { _win.focus() }
}
},
dismiss: function () {
_win.close();
}
};
return self;
};
MatchCore.Page = function () {
var _initComplete = new MatchCore.Delegate();
var _beginFormSubmit = new MatchCore.Delegate();
var _readyToSubmitForm = new MatchCore.Delegate();
var _initialized = false;
var initBehaviors = function () {
$jq('*[behavior]').parseBehavior();
initComplete();
};
var initComplete = function () {
_initialized = true;
_initComplete.fire();
};
var self = {
init: function () {
initBehaviors();
},
onInitComplete: function (handler) {
_initComplete.add(handler);
if (_initialized)
_initComplete.fire();
},
onBeginFormSubmit: function (handler) {
_beginFormSubmit.add(handler);
},
beginSubmitForm: function () {
_beginFormSubmit.fire();
_readyToSubmitForm.fire();
},
onReadyToSubmitForm: function (handler) {
_readyToSubmitForm.add(handler);
}
};
return self;
} ();
MatchCore.Types.Byte = function (raw) {
var _raw = raw;
var self = {
isValid: function () {
if (_raw) {
if ((_raw - 0) == _raw) {
var converted = parseInt(_raw);
return converted >= 0 && converted <= 255;
}
}
return false;
},
value: function () {
if (self.isValid())
return parseInt(_raw);
else
return null;
},
getValueOrDefault: function (defaultVal) {
if (self.isValid())
return self.value();
else
return defaultVal;
}
};
return self;
};
MatchCore.UI.Navigation = {
redirectNonLoggedIn: function () {
var registered = $jq.readCookie('IsRegistered');
if (registered) {
window.location.href = '/login/login.aspx';
}
else {
window.location.href = '/registration/registration.aspx';
}
}
};
MatchCore.HtmlString = function (str) {
var _raw = str;
var self = {
html: function () {
var processed = _raw.replace(/</g, '<').replace(/>/g, '>');
return processed;
}
};
return self;
};
MatchCore.Mask = function (raw) {
var _raw = raw;
var self = {
asString: function () {
return (_raw == null) ? "" : _raw;
},
asHtml: function () {
return (new MatchCore.HtmlString(self.asString())).html();
},
asBoolean: function () {
if (typeof (_raw) == 'boolean') {
return (_raw) ? 'true' : 'false';
}
return '';
}
};
return self;
};
MatchCore.UniversalTemplate = function () {
var construct = function (src) {
var _templateSrc = src;
var _pattern = /{@((.*?):(.*?)|(.*?))}/g;
var databind = function (property, container, mask) {
var pieces = property.split('.');
var databound = null;
if (pieces != null) {
databound = container[pieces[0]];
for (var i = 1; i < pieces.length; i++) {
databound = databound[pieces[i]];
}
}
else {
databound = container[property];
}
if (arguments.length > 2 && mask != undefined && mask != null) {
var masker = new MatchCore.Mask(databound);
try {
databound = masker[mask]();
}
catch (e) { }
}
return databound;
};
var self = {
bindTo: function (container) {
var processed = _templateSrc;
processed = processed.replace(_pattern, function (_0, _1, _2, _3, _4) {
if (_3 != undefined && _3 != "" && _3 != null)
return databind(_2, container, _3);
else
return databind(_4, container);
});
return processed;
}
};
return self;
};
var factory = {
processElement: function (elem, container) {
var instance = construct($jq(elem).html());
$jq(elem).html(instance.bindTo(container));
},
processTemplate: function (templateSrc, container) {
var instance = construct(templateSrc);
return instance.bindTo(container);
}
};
return factory;
} ();
MatchCore.UI.form = function () {
var _formData = {}, _url, _method, _formElm, _fields, _onSuccess, _onFailure;
var serializeObject = function () {
_fields = $jq(":input:not(button)", _formElm);
$jq(_fields).each(function (n, i) {
_formData[i.name] = $jq(i).val();
});
};
var failure = function (response) {
var handled = false;
$jq('.field-validation-error', _formElm).remove();
$jq('.input-validation-error', _formElm).removeClass('input-validation-error');
if (response.Messages) {
for (var i = 0; i < response.Messages.length; i++) {
if (response.Messages[i].Code && response.Messages[i].Code == 401) {
MatchCore.UI.Elements.loginPrompt({ success: function () { handled = true; } });
} else if (response.Messages[i].Field && response.Messages[i].Field != "") {
$jq('[name="' + response.Messages[i].Field + '"]', _formElm).addClass('input-validation-error');
$jq("<span class='field-validation-error'>" + response.Messages[i].Text + "</span>").insertAfter($jq('[name="' + response.Messages[i].Field + '"]', _formElm)[0]);
handled = true;
}
}
}
if (handled == false) {
if (_onFailure)
_onFailure(response, _formElm);
}
$jq(_formElm).removeClass("submitting").addClass("failure").removeClass("success");
};
var success = function (response) {
if (_onSuccess)
_onSuccess(response, _formElm);
$jq(_formElm).removeClass("submitting").removeClass("failure").addClass("success");
}
var submitForm = function () {
var _data;
if (_method.toLowerCase() == "post" && !_formData.noStringify) {
_data = JSON.stringify(_formData);
} else {
_data = _formData;
}
$jq('.field-validation-error', _formElm).remove();
$jq('.input-validation-error', _formElm).removeClass('input-validation-error');
$jq.ajax({
type: _method,
url: _url,
data: _data,
dataType: 'json',
success: function (response) {
if (response.Success == false) {
failure(response);
return;
}
success(response)
},
error: function (xmlhttp, status, exception) {
if (xmlhttp.status == 200) {
success(xmlhttp);
return;
}
failure(response);
}
});
};
var self = {
submit: function (elm, success, failure) {
if (elm.tagName != "FORM") {
$jq.logException("this is not a form tag");
return;
}
_formElm = elm, _onSuccess = success, _onFailure = failure, _url = $jq(_formElm).attr('action');
_method = $jq(_formElm).attr('method');
$jq(_formElm).addClass("submitting").removeClass("failure").removeClass("success");
serializeObject();
submitForm();
}
};
return self;
};
MatchCore.UI.FormCollection = function () {
var _forms;
var addForm = function (id, form, success, failure) {
_forms[id] = { form: form };
};
var addCallbacks = function (id, success, failure) {
if (_forms[id]) {
_forms[id].onSuccess = success;
_forms[id].onFailure = failure;
}
};
var wireUpSubmit = function () {
$jq('a[type="submit"]').unbind();
$jq('a[type="submit"]').click(function (e) {
$jq(e.target).parents('form').submit();
e.preventDefault();
});
};
var unbindForms = function () {
$jq('form[ajaxify="1"]').unbind('submit');
}
var self = {
getForm: function (id) {
return _forms[id];
},
addForm: function (elm) {
var form = new MatchCore.UI.form();
addForm(elm.id, form);
$jq(elm).submit(function (e) {
$jq(e.target).submitForm(function () {
}, function () {
});
e.preventDefault();
return false;
});
},
loadForms: function () {
_forms = [];
unbindForms();
wireUpSubmit();
$jq('form[ajaxify="1"]').each(function (key, elm) {
var form = new MatchCore.UI.form();
addForm(elm.id, form);
$jq(elm).submit(function (e) {
$jq(e.target).submitForm(function () {
}, function () {
});
e.preventDefault();
return false;
});
});
},
addCallbacks: function (id, success, failure) {
addCallbacks(id, success, failure);
}
}
return self;
} ();
jQuery.fn.submitForm = function (success, failure) {
return this.each(function () {
var form = MatchCore.UI.FormCollection.getForm(this.id);
form.form.submit(this, form.onSuccess, form.onFailure);
});
};
jQuery.fn.registerCallbacks = function (success, failure) {
return this.each(function () {
MatchCore.UI.FormCollection.addCallbacks(this.id, success, failure);
});
};
//This function replaces the asp.net default button functionality.
$jq(document).ready(function () {
MatchCore.UI.FormCollection.loadForms();
var btn = $jq('.defaultButton');
btn.parents('.defaultForm').keydown(function (e) {
if (e.which == 13 && e.target.type != 'textarea') {
if (btn[0].type == 'submit' || btn[0].type == 'image' || btn[0].type == 'button') {
$jq(btn[0]).click();
} else {
eval(btn[0].href);
}
return false;
}
});
//look for custom behaviors
MatchCore.Page.init();
});
/*
json2.js
2007-12-02
Public Domain
No warranty expressed or implied. Use at your own risk.
See http://www.JSON.org/js.html
This file creates a global JSON object containing two methods:
JSON.stringify(value, whitelist)
value any JavaScript value, usually an object or array.
whitelist an optional array prameter that determines how object
values are stringified.
This method produces a JSON text from a JavaScript value.
There are three possible ways to stringify an object, depending
on the optional whitelist parameter.
If an object has a toJSON method, then the toJSON() method will be
called. The value returned from the toJSON method will be
stringified.
Otherwise, if the optional whitelist parameter is an array, then
the elements of the array will be used to select members of the
object for stringification.
Otherwise, if there is no whitelist parameter, then all of the
members of the object will be stringified.
Values that do not have JSON representaions, such as undefined or
functions, will not be serialized. Such values in objects will be
dropped; in arrays will be replaced with null.
JSON.stringify(undefined) returns undefined. Dates will be
stringified as quoted ISO dates.
Example:
var text = JSON.stringify(['e', {pluribus: 'unum'}]);
// text is '["e",{"pluribus":"unum"}]'
JSON.parse(text, filter)
This method parses a JSON text to produce an object or
array. It can throw a SyntaxError exception.
The optional filter parameter is a function that can filter and
transform the results. It receives each of the keys and values, and
its return value is used instead of the original value. If it
returns what it received, then structure is not modified. If it
returns undefined then the member is deleted.
Example:
// Parse the text. If a key contains the string 'date' then
// convert the value to a date.
myData = JSON.parse(text, function (key, value) {
return key.indexOf('date') >= 0 ? new Date(value) : value;
});
This is a reference implementation. You are free to copy, modify, or
redistribute.
Use your own copy. It is extremely unwise to load third party
code into your pages.
*/
/*jslint evil: true */
/*global JSON */
/*members "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
charCodeAt, floor, getUTCDate, getUTCFullYear, getUTCHours,
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join, length,
parse, propertyIsEnumerable, prototype, push, replace, stringify, test,
toJSON, toString
*/
if (!this.JSON) {
JSON = function () {
function f(n) { // Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
Date.prototype.toJSON = function () {
// Eventually, this method will be based on the date.toISOString method.
return this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z';
};
var m = { // table of character substitutions
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"': '\\"',
'\\': '\\\\'
};
function stringify(value, whitelist) {
var a, // The array holding the partial texts.
i, // The loop counter.
k, // The member key.
l, // Length.
r = /["\\\x00-\x1f\x7f-\x9f]/g,
v; // The member value.
switch (typeof value) {
case 'string':
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe sequences.
return r.test(value) ?
'"' + value.replace(r, function (a) {
var c = m[a];
if (c) {
return c;
}
c = a.charCodeAt();
return '\\u00' + Math.floor(c / 16).toString(16) +
(c % 16).toString(16);
}) + '"' :
'"' + value + '"';
case 'number':
// JSON numbers must be finite. Encode non-finite numbers as null.
return isFinite(value) ? String(value) : 'null';
case 'boolean':
case 'null':
return String(value);
case 'object':
// Due to a specification blunder in ECMAScript,
// typeof null is 'object', so watch out for that case.
if (!value) {
return 'null';
}
// If the object has a toJSON method, call it, and stringify the result.
if (typeof value.toJSON === 'function') {
return stringify(value.toJSON());
}
a = [];
if (typeof value.length === 'number' &&
!(value.propertyIsEnumerable('length'))) {
// The object is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.
l = value.length;
for (i = 0; i < l; i += 1) {
a.push(stringify(value[i], whitelist) || 'null');
}
// Join all of the elements together and wrap them in brackets.
return '[' + a.join(',') + ']';
}
if (whitelist) {
// If a whitelist (array of keys) is provided, use it to select the components
// of the object.
l = whitelist.length;
for (i = 0; i < l; i += 1) {
k = whitelist[i];
if (typeof k === 'string') {
v = stringify(value[k], whitelist);
if (v) {
a.push(stringify(k) + ':' + v);
}
}
}
} else {
// Otherwise, iterate through all of the keys in the object.
for (k in value) {
if (typeof k === 'string') {
v = stringify(value[k], whitelist);
if (v) {
a.push(stringify(k) + ':' + v);
}
}
}
}
// Join all of the member texts together and wrap them in braces.
return '{' + a.join(',') + '}';
}
}
return {
stringify: stringify,
parse: function (text, filter) {
var j;
function walk(k, v) {
var i, n;
if (v && typeof v === 'object') {
for (i in v) {
if (Object.prototype.hasOwnProperty.apply(v, [i])) {
n = walk(i, v[i]);
if (n !== undefined) {
v[i] = n;
}
}
}
}
return filter(k, v);
}
// Parsing happens in three stages. In the first stage, we run the text against
// regular expressions that look for non-JSON patterns. We are especially
// concerned with '()' and 'new' because they can cause invocation, and '='
// because it can cause mutation. But just to be safe, we want to reject all
// unexpected forms.
// We split the first stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace all backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
if (/^[\],:{}\s]*$/.test(text.replace(/\\./g, '@').
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(:?[eE][+\-]?\d+)?/g, ']').
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
// In the second stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.
j = eval('(' + text + ')');
// In the optional third stage, we recursively walk the new structure, passing
// each name/value pair to a filter function for possible transformation.
return typeof filter === 'function' ? walk('', j) : j;
}
// If the text is not JSON parseable, then a SyntaxError is thrown.
throw new SyntaxError('parseJSON');
}
};
} ();
}
$jq.namespace('MatchCore.UI.Site');
$jq.namespace('MatchCore.UI.Site.Modal');
MatchCore.UI.Site.ModalDialog = function () {
var _container;
var _showDelegate = new MatchCore.Delegate();
var _dismissDelegate = new MatchCore.Delegate();
var _templateManager = new MatchCore.UI.Site.Modal.templateManager();
var _doc = $jq(document);
var _dismissed = false;
var _modalVisible = false;
var _effects = {
"fadeIn": null,
"fadeOut": null
};
var _settings = {
autoShow: false,
autoCenter: false,
enableScroll: {}
};
var wireupControls = function () {
$jq('.modal_dismiss', _container).bind('click', function (e) {
self.dismiss();
e.preventDefault();
});
if (_settings.autoCenter) {
$jq(window).resize(function () {
self.center();
});
$jq(document).ready(function () {
self.center();
});
}
};
var centerToBrowser = function () {
var div = _container;
var browserX;
var browserY;
var browserW;
var browserH;
var HorizontalReference;
var VerticalReference;
var modalTopOffset;
var modalLeftOffset;
if (typeof (window.innerWidth) == 'number') {
browserW = window.innerWidth;
}
else {
browserW = document.documentElement.clientWidth;
}
if (document.documentElement && (document.documentElement.scrollLeft)) {
browserX = document.documentElement.scrollLeft;
}
else {
browserX = document.body.scrollLeft;
}
if (typeof (window.innerHeight) == 'number') {
browserH = window.innerHeight;
}
else {
browserH = document.documentElement.clientHeight;
}
if (document.documentElement && (document.documentElement.scrollTop)) {
browserY = document.documentElement.scrollTop;
}
else {
browserY = document.body.scrollTop;
}
var divHeight = $jq(div).height();
var divWidth = $jq(div).width();
VerticalReference = browserH;
if (browserW > 1024) {
HorizontalReference = 1024;
} else {
HorizontalReference = browserW;
}
if (browserW < divWidth) {
modalLeftOffset = 0;
} else {
modalLeftOffset = (HorizontalReference / 2) - (divWidth / 2) + browserX + 'px';
}
if (browserH < divHeight) {
modalTopOffset = 0;
} else {
modalTopOffset = (VerticalReference / 2) - (divHeight / 2) + browserY + 'px';
}
if (_settings.enableScroll.isEnabled && _modalVisible) {
if (browserH < divHeight || browserW < divWidth) {
_dismissed = true;
} else {
if (_dismissed) {
overtakePage();
dismissed = false;
}
}
}
$jq(div).css("top", modalTopOffset);
$jq(div).css("left", modalLeftOffset);
}
var obscureNonZindexElements = function () {
$jq(".obscureFromModal").each(function () {
if ($jq(this).parents('.modal_dialog').length == -1) {
$jq(this).addClass('obscuredFromModal');
}
});
$jq("object").each(function () {
if ($jq(this).parents('.modal_dialog').length == -1) {
$jq(this).attr('modal_obscured', '1');
$jq(this).css('visibility', 'hidden');
}
});
if (navigator.userAgent.match(/msie/i)) {
$jq('SELECT').each(function () {
if ($jq(this).parents('.modal_dialog').length == -1) {
$jq(this).attr('modal_obscured', '1');
$jq(this).css('visibility', 'hidden');
}
});
}
};
var overtakePage = function () {
_modalVisible = true;
//window.scrollTo("0", "0");
};
var restorePage = function () {
$jq('*[modal_obscured="1"]').css('visibility', 'visible');
$jq('.obscuredFromModal').removeClass('obscuredFromModal');
_modalVisible = false;
};
var setupModal = function (opts) {
_container = opts.container;
$jq(_container).addClass('client_modal');
$jq(_container).hide();
parseMeta(opts.meta);
wireupControls();
}
var parseMeta = function (options) {
if (options) {
(options.onShow) ? self.onShow(opts.meta.onShow) : undefined;
(options.onDismiss) ? self.onDismiss(opts.meta.onDismiss) : undefined;
if (options.moveOutHierarchy) {
options.moveOutHierarchy = false;
$jq(_container).attr("meta", JSON.stringify(options));
$jq(_container).remove();
if (options.appendToElement) {
$jq(options.appendToElement).append(_container);
} else {
$jq("body").append(_container);
}
}
if (options.fadeIn)
_effects.fadeIn = options.fadeIn;
if (options.fadeOut)
_effects.fadeOut = options.fadeOut;
if (options.autoShow)
_settings.autoShow = options.autoShow;
if (options.autoCenter)
_settings.autoCenter = options.autoCenter;
if (options.enableScroll) {
_settings.enableScroll = { elem: _container, isEnabled: options.enableScroll };
}
}
};
var self = {
init: function (opts) {
if (!opts) return false;
if (opts.meta && opts.meta.templateUrl) {
_templateManager.createModalFromTemplate(opts, setupModal);
} else {
setupModal(opts);
}
MatchCore.UI.Site.ModalMaster.addModal(this);
if (_settings.autoShow) {
self.show();
}
},
dismiss: function () {
_dismissDelegate.fireAndPreserve();
restorePage();
//$jq(".modal_overlay").remove();
$jq("#dialog-overlay").hide();
if (_effects.fadeOut != null) {
$jq(_container).fadeOut(_effects.fadeOut);
}
else {
$jq(_container).hide();
}
},
show: function () {
_showDelegate.fireAndPreserve();
$jq("#dialog-overlay").show();
$jq('#bodyWrapper').addClass("hasModal");
overtakePage();
obscureNonZindexElements();
if (_settings.autoCenter) {
centerToBrowser();
}
if (_effects.fadeIn != null) {
$jq(_container).fadeIn(_effects.fadeIn);
}
else {
$jq(_container).show();
}
},
center: function () {
centerToBrowser();
},
id: function () {
return $jq(_container).attr('id');
},
onShow: function (handler) {
_showDelegate.add(handler);
},
onDismiss: function (handler) {
_dismissDelegate.add(handler);
}
}
return self;
};
MatchCore.UI.Site.Modal.templateManager = function () {
var _opts, _callback;
var _bindModalData = function (resp) {
if (_opts.meta.data) {
$jq(_opts.container).setTemplate(resp);
$jq(_opts.container).processTemplate(_opts.meta.data);
} else {
$jq(_opts.container).html(resp);
}
_callback(_opts);
};
return {
createModalFromTemplate: function (opts, callback) {
_opts = opts;
_callback = callback;
var _tp = new MatchCore.templateProxy(_opts.meta.templateUrl);
_tp.invoke({ success: _bindModalData });
}
};
}
MatchCore.UI.Site.ModalMaster = function () {
var _modals = [];
var hideAll = function (except) {
for (var key in _modals) {
try {
if (key != except)
_modals[key].dismiss();
}
catch (e) { }
}
};
var self = {
addModal: function (modal) {
var thisId = modal.id();
modal.onShow(function () {
hideAll(thisId);
});
_modals[modal.id()] = modal;
},
getModal: function (id) {
return _modals[id];
},
hideAll: function () {
hideAll();
}
};
return self;
} ();
jQuery.fn.showClientModal = function () {
return this.each(function () {
//check for attached behavior
jQuery(this).behavior('MatchCore.UI.Site.ModalDialog', function (modal) {
modal.show();
});
});
};
jQuery.fn.dismissClientModal = function () {
return this.each(function () {
//check for attached behavior
jQuery(this).behavior('MatchCore.UI.Site.ModalDialog', function (modal) {
modal.dismiss();
});
});
};
//define global chat initiation method (defined in lib.im.js for flash chat)
function MatchChatAddConvo(arg) {
var args = Cortado.Helpers.querystring(arg);
var peerId = args.get("idto");
if (!peerId) {
return true;
}
Match.Chat.Controller.initiateConversationWith(peerId);
return true;
};
signedin.js
$jq.namespace('MatchCore.UI.Site');
MatchCore.UI.Site.StillThere = function () {
return true;
};
header.js
$jq.namespace('MatchCore.Header');
$jq.namespace('MatchCore.UI.Site.Header');
MatchCore.UI.Site.Header.ReactivateSubscription = function() {
var _container;
var _resub = new MatchCore.Header.Subscription();
var showConfirmation = function() {
$jq(".view1").hide();
$jq(".view2").show();
setTimeout(function () { $jq(_container).fadeOut(); }, 3000);
};
var wireUpControls = function() {
$jq(_container).bind('mouseenter',
function() {
$jq(".prompt", _container).show()
}).bind('mouseleave',
function() {
if ($jq(".tooltip", _container).hasClass("prompt")) {
$jq(".prompt", _container).hide()
} else {
}
}
);
$jq(".resubBtn", _container).click(function() {
$jq(".tooltip", _container).removeClass("prompt");
var opts = {};
opts.success = showConfirmation;
_resub.reactivateSubscription(opts);
});
};
var self = {
init: function(opts) {
if (opts && opts.container)
_container = opts.container;
wireUpControls();
}
};
return self;
};
MatchCore.Header.Subscription = function() {
var _service = new MatchCore.ServiceProxy('/rest/MainService.ashx');
var self = {
reactivateSubscription: function(opts) {
_service.invoke({
method: 'ReactivateSubscription',
data: {
'sid': MatchCore.Session.SID(),
'theme': MatchCore.Session.ServerId()
},
failure: function(xmlhttp, status, exception) {
if (opts.failure)
opts.failure(xmlhttp, status, exception);
},
success: function(response) {
if (opts.success)
opts.success(response);
}
});
}
};
return self;
};
MatchCore.Header.ShowProfile = function() {
var _service = new MatchCore.ServiceProxy('/rest/MainService.ashx');
var self = {
init: function(opts) {
if (opts.container)
$jq(opts.container).click(
function() {
_service.invoke(
{
method: 'UnhideProfile',
data: {
'sid': MatchCore.Session.SID(),
'theme': MatchCore.Session.ServerId()
},
failure: function(xmlhttp, status, exception) {
},
success: function(response) {
if (response.Success) {
$jq("#SharkFinModal").behavior('MatchCore.UI.Site.ModalDialog', function(modal) {
modal.show();
});
}
}
});
}
);
}
};
return self;
}
MatchCore.Header.Navigation = function () {
var _container = null;
var _minWidth = ($jq('body').hasClass('ie6')) ? "width" : "minWidth";
var wireUpControls = function () {
$jq(_container).children('li').bind('mouseenter touchstart',
function(e) {
if (!$jq(this).children('a').hasClass('navItemHighlight') && !$jq(this).hasClass('noMenu')) {
//console.log(e);
if(e.type !== "touchstart")
e.preventDefault();
}
$jq(".menuItem").hide();
$jq(".navItem").removeClass("navItemHighlight");
$jq(".menuItem", this).show().css(_minWidth, $jq(this).outerWidth());
$jq(".navItem", this).addClass("navItemHighlight");
}).bind('mouseleave',
function () {
$jq(".menuItem", this).hide();
$jq(".navItem", this).removeClass("navItemHighlight");
}
);
};
var self = {
init: function (opts) {
if (opts.container) {
_container = opts.container;
wireUpControls();
}
}
};
return self;
};
elements.js
MatchCore.UI.StandardPrompt = function () {
var _container = null;
var _confirmAction = null;
var _dismissAction = null;
//var _content = null;
var _effects = {
autoShow: null,
autoDismissIn: null,
fadeIn: null,
fadeOut: null
};
//var _onClosedDelegate = new MatchCore.Delegate();
var render = function () {
$jq(_container).wrapInner('<div class="promptContent"/>').prepend('<div class="close prompt_dismiss"><span>x</span></div>').addClass('standardPrompt');
$jq.initBehavior(_container, 'MatchCore.UI.Site.ModalDialog', { autoShow: _effects.autoShow, autoCenter: true, fadeIn: _effects.fadeIn, fadeOut: _effects.fadeOut });
};
var parseMeta = function (options) {
if (options) {
if (options.moveOutOfHierarchy) {
options.moveOutOfHierarchy = false;
$jq(_container).attr("meta", JSON.stringify(options));
$jq(_container).remove();
$jq("body").append(_container);
}
if (options.fadeIn)
_effects.fadeIn = options.fadeIn;
if (options.fadeOut)
_effects.fadeOut = options.fadeOut;
if (options.autoDismissIn)
_effects.autoDismissIn = options.autoDismissIn;
if (options.autoShow)
_effects.autoShow = options.autoShow;
}
};
var wireupControls = function () {
$jq('.prompt_dismiss', _container).click(function (event) {
$jq('.handle, .password', _container).val('');
//_onClosedDelegate.fireAndPreserve();
if ($jq.browser.msie) {
event.cancelBubble = true;
} else {
event.stopPropagation();
}
event.preventDefault();
self.dismiss();
});
$jq('.prompt_confirm', _container).click(function (event) {
if ($jq.browser.msie) {
event.cancelBubble = true;
} else {
event.stopPropagation();
}
event.preventDefault();
self.confirm();
});
};
var self = {
init: function (opts) {
_container = opts.container;
if (opts.meta != undefined) {
parseMeta(opts.meta);
}
if ($jq('.promptContent', _container).length < 1) {
render();
}
wireupControls();
},
invoke: function (opts) {
if (opts) {
_confirmAction = (opts.confirm) ? opts.confirm : null;
_dismissAction = (opts.dismiss) ? opts.dismiss : null;
}
else {
_confirmAction = null;
_dismissAction = null;
}
if (_effects.autoDismissIn) {
setTimeout(function () {
$jq(_container).dismissClientModal();
}, _effects.autoDismissIn);
}
$jq(_container).showClientModal();
},
dismiss: function () {
$jq(_container).dismissClientModal();
if (_dismissAction != null)
_dismissAction();
},
confirm: function () {
$jq(_container).dismissClientModal();
if (_confirmAction != null)
_confirmAction();
}//,
//on_ShowPrompt: function (opts) {
// this.invoke(opts);
//},
//on_setDismissAction: function (action) {
// _onClosedDelegate = null;
// _onClosedDelegate = new MatchCore.Delegate();
// _onClosedDelegate.add(action);
//},
//on_dismiss: function () {
// $jq(_container).dismissClientModal();
// if (_dismissAction != null)
// _dismissAction();
//}
};
return self;
};
MatchCore.UI.Site.LoginPrompt = function () {
var _container = null;
var _successAction = null;
var _failAction = null;
var _effects = {
fadeIn: null,
fadeOut: null
};
var render = function () {
$jq.initBehavior(_container, 'MatchCore.UI.StandardPrompt', { fadeIn: _effects.fadeIn, fadeOut: _effects.fadeOut });
};
var wireupControls = function () {
$jq('.login_confirm', _container).click(function (event) {
if ($jq.browser.msie) {
event.cancelBubble = true;
} else {
event.stopPropagation();
}
event.preventDefault();
self.confirm();
});
};
var promptError = function (msg) {
$jq('.errors', _container).html(msg);
$jq('.errors', _container).show();
};
var callLoginService = function(handle, password) {
ensureSession(function() {
var url = '/Membership/Login/';
$jq.ajax({
type: "POST",
url: url,
data: {
'handle': handle,
'password': password
},
dataType: "json",
success: function (response) {
if (response.success != undefined) {
if (!response.success) {
var responseCode = response.reason;
if (typeof displayErrorMessage != 'undefined') {
responseCode = displayErrorMessage(responseCode);
}
promptError(responseCode);
return;
}
$jq(_container).behavior('MatchCore.UI.StandardPrompt', function (dialog) {
dialog.dismiss();
});
if (response.uid != undefined) {
//compare previous uid to logged in
var oldUid = ($jq('#cuid').val().length > 0) ? parseInt($jq('#cuid').val()) : 0;
if (parseInt(response.uid) != oldUid) {
//refresh the page
window.location.reload(true);
return;
}
}
if (_successAction) {
_successAction(response);
}
return;
}
promptError(MatchCore.UI.Site.Translate.getTranslation('MatchContent.Account.AccountSettings.LoginFailed'));
_failAction(response);
},
error: function (response) {
promptError(MatchCore.UI.Site.Translate.getTranslation('MatchContent.Account.AccountSettings.LoginFailed'));
_failAction(response);
}
});
});
};
var ensureSession = function (callback) {
$jq.ajax({
type: "GET",
url: '/Membership/EnsureSession/',
success: function(response) {
callback();
}
});
};
var self = {
init: function (opts) {
_container = opts.container;
render();
wireupControls();
},
invoke: function (opts) {
$jq('.errors', _container).hide();
if (opts) {
_successAction = (opts.success) ? opts.success : null;
_failAction = (opts.fail) ? opts.fail : null;
}
else {
_successAction = null;
_failAction = null;
}
$jq(_container).prompt();
},
confirm: function () {
$jq('.errors', _container).hide();
var handleField = $jq('*[name="handle"]', _container);
var passwordField = $jq('*[name="password"]', _container);
var handle = handleField.val();
var password = passwordField.val();
if (handle == null || handle.length <= 0) {
if (typeof handleNullErrorMsg == 'undefined') {
handleNullErrorMsg = MatchCore.UI.Site.Translate.getTranslation('MatchContent.Account.AccountSettings.EnterUserName');
}
promptError(handleNullErrorMsg);
return false;
}
if (password == null || password.length <= 0) {
if (typeof passwordNullErrorMsg == 'undefined') {
passwordNullErrorMsg = MatchCore.UI.Site.Translate.getTranslation('MatchContent.Error.ErrorMessages.ErrorPasswordMissing');
}
promptError(passwordNullErrorMsg);
return false;
}
callLoginService(handle, password);
}
};
return self;
};
MatchCore.UI.Site.MessageSummary = function () {
var _container = null;
var self = {
init: function (opts) {
_container = opts.container;
},
clear: function () {
},
yield: function (messages) {
}
};
return self;
};
MatchCore.UI.Elements = function () {
var _loginLoaded = false;
var ensureLoginLoaded = function (callback) {
if (!_loginLoaded) {
var url = '/Membership/LoginPanel/';
$jq.ajax({
type: "GET",
url: url,
success: function (response) {
$jq('BODY').append('<div id="globalLogin"></div>');
$jq('#globalLogin').hide();
$jq('#globalLogin').append(response);
$jq.initBehavior($jq('#globalLogin'), 'MatchCore.UI.Site.LoginPrompt', null);
_loginLoaded = true;
callback();
}
});
}
else {
callback();
}
};
var self = {
loginPrompt: function(opts) {
ensureLoginLoaded(function() {
$jq('#globalLogin').behavior('MatchCore.UI.Site.LoginPrompt', function(login) {
login.invoke(opts);
});
});
},
ensureLoggedInBefore: function(callback) {
$jq.ajax({
type: "GET",
url: MatchCore.Application.resolveUrl('~/Membership/IsLoggedIn/'),
success: function(response) {
if (response == "true" || response == true) {
callback();
} else {
self.loginPrompt({ success: callback });
}
}
});
}
};
return self;
}(); //static class
jQuery.fn.prompt = function(opts) {
return this.each(function() {
//check for attached behavior
jQuery(this).behavior('MatchCore.UI.StandardPrompt', function (instance) {
instance.invoke(opts);
});
});
};
textTranslation.js
$jq.namespace('MatchCore.UI.Site');
MatchCore.UI.Site.Translate = function () {
var _translationKeys;
var retrieved = false;
//To consume, Add key to Client Resource Controller
var self = {
getTranslation: function (key) {
if (!embeddedTranslations && retrieved === false) {
var url = '/ClientResource/GetTranslations/';
if (MatchCore.Application) {
url = '/ClientResource/GetTranslations/?cc=' + MatchCore.Application.CultureCode;
}
$jq.ajax({
type: "GET",
url: url,
async: false,
cache: true,
success: function(response) {
_translationKeys = JSON.parse(response);
cb(_translationKeys[key]);
retrieved = true;
},
failure: function() {
// TODO : Add error handling
return '';
}
});
}
if (!_translationKeys && embeddedTranslations) {
_translationKeys = embeddedTranslations;
}
if (_translationKeys) {
if (!_translationKeys[key] && console && console.log) {
console.log(key);
}
return _translationKeys[key];
}
console.log(key);
return '';
},
stringFormat: function( str ,args) {
var regex = new RegExp("{-?[0-9]+}", "g");
return str.replace(regex, function (item) {
var intVal = parseInt(item.substring(1, item.length - 1));
var replace;
if (intVal >= 0) {
replace = args[intVal];
} else if (intVal === -1) {
replace = "{";
} else if (intVal === -2) {
replace = "}";
} else {
replace = "";
}
return replace;
});
}
};
return self;
}();