﻿// From: https://controls.services.live.com/scripts/base/v0.3/controls.js
// Copyright (c) Microsoft Corporation.  All rights reserved. 
// Use of this code is governed by the Terms of Use located at: http://dev.live.com/contactscontrol/gadgettou.aspx
// and http://dev.live.com/spacescontrol/gadgettou.aspx
Microsoft.Live.Platform._nsUriToName = {}; Microsoft.Live.Platform.getAttributeNS = function(c, e, b) { var d = Microsoft.Live.Platform._nsUriToName[e], a; if (d) { a = c.getAttribute(d + ":" + b); if (a) return a } return c.getAttribute(b) }; Microsoft.Live.Platform.buildNSLookup = function() { Microsoft.Live.Platform._nsUriToName = {}; if (document.namespaces) for (var a = 0; a < document.namespaces.length; a++) Microsoft.Live.Platform._nsUriToName[document.namespaces[a].urn] = document.namespaces[a].name; else { var b = document.getElementsByTagName("html"); if (b && b.length) { b = b[0]; for (var a = 0; a < b.attributes.length; a++) { var c = b.attributes[a].name, d = b.attributes[a].nodeValue; if (c.indexOf("xmlns:") == 0) Microsoft.Live.Platform._nsUriToName[d] = c.substr(6) } } } }; Microsoft.Live.Platform._controlRegistry = []; Microsoft.Live.Platform._controlRegistryIndex = {}; Microsoft.Live.Platform.registerControlLoader = function(a) { if (a.tagName.length > 0 && a.nsUri.length > 0 && a.jsUrl.length > 0 && a.loadFn.length > 0) if (Microsoft.Live.Platform._controlRegistryIndex[a.nsURI + ":" + a.tagName] == null) { Microsoft.Live.Platform._controlRegistryIndex[a.nsURI + ":" + a.tagName] = Microsoft.Live.Platform._controlRegistry.length; Microsoft.Live.Platform._controlRegistry.push(a) } else { var b = Microsoft.Live.Platform._controlRegistryIndex[a.nsURI + ":" + a.tagName]; Microsoft.Live.Platform._controlRegistry[b] = a } }; Microsoft.Live.Platform.registerControlLoader({ tagName: "contactscontrol", nsUri: "http://dev.live.com", jsUrl: window.location.protocol + "//controls.services.live.com/scripts/base/v0.3/contactscontrolloader.js", loadFn: "Microsoft.Live.Contacts.loadContactsControl" }); Microsoft.Live.Platform.registerControlLoader({ tagName: "spacescontrol", nsUri: "http://dev.live.com", jsUrl: window.location.protocol + "//controls.services.live.com/scripts/base/v0.3/storagecontrolloader.js", loadFn: "Microsoft.Live.Storage.loadStorageControl" }); Microsoft.Live.Platform.registerControlLoader({ tagName: "slscontrol", nsUri: "http://dev.live.com", jsUrl: window.location.protocol + "//silverlight.live.com/controls/v0.1/slscontrolloader.js.aspx", loadFn: "Microsoft.Live.SLS.loadSLSControl" }); Microsoft.Live.Platform.mainPageLoad = function() { Microsoft.Live.Platform.buildNSLookup(); Microsoft.Live.Platform._controls = []; for (var c = 0; c < Microsoft.Live.Platform._controlRegistry.length; c++) { var b = Microsoft.Live.Platform._controlRegistry[c], d = Microsoft.Live.Platform._nsUriToName[b.nsUri], a = document.getElementsByTagName(d + ":" + b.tagName); if (!a || a.length == 0) { d = ""; a = document.getElementsByTagName(b.tagName) } if (!a || a.length == 0) continue; loadcontrol = function() { var e = Microsoft.Live.Platform._controlRegistry[c], b = a; return function() { var h = window, g = e.loadFn.split("."), a = window; for (var f = 0; f < g.length; f++) a = a[g[f]]; if (typeof a == "function") for (var c = 0; c < b.length; c++) try { b[c]["frameborder"] = "1"; a({ tagName: e.tagName, nsUri: e.nsUri, nsName: d, el: b[c] }) } catch (i) { alert(i.toString()) } } }; Microsoft.Live.Platform.load(b.jsUrl, loadcontrol()) } }; Microsoft.Live.Platform.addEvent(window, "load", Microsoft.Live.Platform.mainPageLoad);