@microsoft/office-js
Version:
Office JavaScript APIs
1,224 lines (1,220 loc) • 296 kB
JavaScript
/* Project specific JavaScript API library */
/* Version: 16.0.7310.1000 */
/*
Copyright (c) Microsoft Corporation. All rights reserved.
*/
/*
Your use of this file is governed by the Microsoft Services Agreement http://go.microsoft.com/fwlink/?LinkId=266419.
*/
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var OfficeExt;
(function (OfficeExt) {
var MicrosoftAjaxFactory = (function () {
function MicrosoftAjaxFactory() {
}
MicrosoftAjaxFactory.prototype.isMsAjaxLoaded = function () {
if (typeof (Sys) !== 'undefined' && typeof (Type) !== 'undefined' &&
Sys.StringBuilder && typeof (Sys.StringBuilder) === "function" &&
Type.registerNamespace && typeof (Type.registerNamespace) === "function" &&
Type.registerClass && typeof (Type.registerClass) === "function" &&
typeof (Function._validateParams) === "function" &&
Sys.Serialization && Sys.Serialization.JavaScriptSerializer && typeof (Sys.Serialization.JavaScriptSerializer.serialize) === "function") {
return true;
}
else {
return false;
}
};
MicrosoftAjaxFactory.prototype.loadMsAjaxFull = function (callback) {
var msAjaxCDNPath = (window.location.protocol.toLowerCase() === 'https:' ? 'https:' : 'http:') + '//ajax.aspnetcdn.com/ajax/3.5/MicrosoftAjax.js';
OSF.OUtil.loadScript(msAjaxCDNPath, callback);
};
Object.defineProperty(MicrosoftAjaxFactory.prototype, "msAjaxError", {
get: function () {
if (this._msAjaxError == null && this.isMsAjaxLoaded()) {
this._msAjaxError = Error;
}
return this._msAjaxError;
},
set: function (errorClass) {
this._msAjaxError = errorClass;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MicrosoftAjaxFactory.prototype, "msAjaxSerializer", {
get: function () {
if (this._msAjaxSerializer == null && this.isMsAjaxLoaded()) {
this._msAjaxSerializer = Sys.Serialization.JavaScriptSerializer;
}
return this._msAjaxSerializer;
},
set: function (serializerClass) {
this._msAjaxSerializer = serializerClass;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MicrosoftAjaxFactory.prototype, "msAjaxString", {
get: function () {
if (this._msAjaxString == null && this.isMsAjaxLoaded()) {
this._msAjaxSerializer = String;
}
return this._msAjaxString;
},
set: function (stringClass) {
this._msAjaxString = stringClass;
},
enumerable: true,
configurable: true
});
Object.defineProperty(MicrosoftAjaxFactory.prototype, "msAjaxDebug", {
get: function () {
if (this._msAjaxDebug == null && this.isMsAjaxLoaded()) {
this._msAjaxDebug = Sys.Debug;
}
return this._msAjaxDebug;
},
set: function (debugClass) {
this._msAjaxDebug = debugClass;
},
enumerable: true,
configurable: true
});
return MicrosoftAjaxFactory;
})();
OfficeExt.MicrosoftAjaxFactory = MicrosoftAjaxFactory;
})(OfficeExt || (OfficeExt = {}));
var OsfMsAjaxFactory = new OfficeExt.MicrosoftAjaxFactory();
var OSF = OSF || {};
var OfficeExt;
(function (OfficeExt) {
var SafeStorage = (function () {
function SafeStorage(_internalStorage) {
this._internalStorage = _internalStorage;
}
SafeStorage.prototype.getItem = function (key) {
try {
return this._internalStorage && this._internalStorage.getItem(key);
}
catch (e) {
return null;
}
};
SafeStorage.prototype.setItem = function (key, data) {
try {
this._internalStorage && this._internalStorage.setItem(key, data);
}
catch (e) {
}
};
SafeStorage.prototype.clear = function () {
try {
this._internalStorage && this._internalStorage.clear();
}
catch (e) {
}
};
SafeStorage.prototype.removeItem = function (key) {
try {
this._internalStorage && this._internalStorage.removeItem(key);
}
catch (e) {
}
};
SafeStorage.prototype.getKeysWithPrefix = function (keyPrefix) {
var keyList = [];
try {
var len = this._internalStorage && this._internalStorage.length || 0;
for (var i = 0; i < len; i++) {
var key = this._internalStorage.key(i);
if (key.indexOf(keyPrefix) === 0) {
keyList.push(key);
}
}
}
catch (e) {
}
return keyList;
};
return SafeStorage;
})();
OfficeExt.SafeStorage = SafeStorage;
})(OfficeExt || (OfficeExt = {}));
OSF.XdmFieldName = {
ConversationUrl: "ConversationUrl",
AppId: "AppId"
};
OSF.WindowNameItemKeys = {
BaseFrameName: "baseFrameName",
HostInfo: "hostInfo",
XdmInfo: "xdmInfo",
SerializerVersion: "serializerVersion",
AppContext: "appContext"
};
OSF.OUtil = (function () {
var _uniqueId = -1;
var _xdmInfoKey = '&_xdm_Info=';
var _serializerVersionKey = '&_serializer_version=';
var _xdmSessionKeyPrefix = '_xdm_';
var _serializerVersionKeyPrefix = '_serializer_version=';
var _fragmentSeparator = '#';
var _fragmentInfoDelimiter = '&';
var _classN = "class";
var _loadedScripts = {};
var _defaultScriptLoadingTimeout = 30000;
var _safeSessionStorage = null;
var _safeLocalStorage = null;
var _rndentropy = new Date().getTime();
function _random() {
var nextrand = 0x7fffffff * (Math.random());
nextrand ^= _rndentropy ^ ((new Date().getMilliseconds()) << Math.floor(Math.random() * (31 - 10)));
return nextrand.toString(16);
}
;
function _getSessionStorage() {
if (!_safeSessionStorage) {
try {
var sessionStorage = window.sessionStorage;
}
catch (ex) {
sessionStorage = null;
}
_safeSessionStorage = new OfficeExt.SafeStorage(sessionStorage);
}
return _safeSessionStorage;
}
;
function _reOrderTabbableElements(elements) {
var bucket0 = [];
var bucketPositive = [];
var i;
var len = elements.length;
var ele;
for (i = 0; i < len; i++) {
ele = elements[i];
if (ele.tabIndex) {
if (ele.tabIndex > 0) {
bucketPositive.push(ele);
}
else if (ele.tabIndex === 0) {
bucket0.push(ele);
}
}
else {
bucket0.push(ele);
}
}
bucketPositive = bucketPositive.sort(function (left, right) {
var diff = left.tabIndex - right.tabIndex;
if (diff === 0) {
diff = bucketPositive.indexOf(left) - bucketPositive.indexOf(right);
}
return diff;
});
return [].concat(bucketPositive, bucket0);
}
;
return {
set_entropy: function OSF_OUtil$set_entropy(entropy) {
if (typeof entropy == "string") {
for (var i = 0; i < entropy.length; i += 4) {
var temp = 0;
for (var j = 0; j < 4 && i + j < entropy.length; j++) {
temp = (temp << 8) + entropy.charCodeAt(i + j);
}
_rndentropy ^= temp;
}
}
else if (typeof entropy == "number") {
_rndentropy ^= entropy;
}
else {
_rndentropy ^= 0x7fffffff * Math.random();
}
_rndentropy &= 0x7fffffff;
},
extend: function OSF_OUtil$extend(child, parent) {
var F = function () { };
F.prototype = parent.prototype;
child.prototype = new F();
child.prototype.constructor = child;
child.uber = parent.prototype;
if (parent.prototype.constructor === Object.prototype.constructor) {
parent.prototype.constructor = parent;
}
},
setNamespace: function OSF_OUtil$setNamespace(name, parent) {
if (parent && name && !parent[name]) {
parent[name] = {};
}
},
unsetNamespace: function OSF_OUtil$unsetNamespace(name, parent) {
if (parent && name && parent[name]) {
delete parent[name];
}
},
loadScript: function OSF_OUtil$loadScript(url, callback, timeoutInMs) {
if (url && callback) {
var doc = window.document;
var _loadedScriptEntry = _loadedScripts[url];
if (!_loadedScriptEntry) {
var script = doc.createElement("script");
script.type = "text/javascript";
_loadedScriptEntry = { loaded: false, pendingCallbacks: [callback], timer: null };
_loadedScripts[url] = _loadedScriptEntry;
var onLoadCallback = function OSF_OUtil_loadScript$onLoadCallback() {
if (_loadedScriptEntry.timer != null) {
clearTimeout(_loadedScriptEntry.timer);
delete _loadedScriptEntry.timer;
}
_loadedScriptEntry.loaded = true;
var pendingCallbackCount = _loadedScriptEntry.pendingCallbacks.length;
for (var i = 0; i < pendingCallbackCount; i++) {
var currentCallback = _loadedScriptEntry.pendingCallbacks.shift();
currentCallback();
}
};
var onLoadError = function OSF_OUtil_loadScript$onLoadError() {
delete _loadedScripts[url];
if (_loadedScriptEntry.timer != null) {
clearTimeout(_loadedScriptEntry.timer);
delete _loadedScriptEntry.timer;
}
var pendingCallbackCount = _loadedScriptEntry.pendingCallbacks.length;
for (var i = 0; i < pendingCallbackCount; i++) {
var currentCallback = _loadedScriptEntry.pendingCallbacks.shift();
currentCallback();
}
};
if (script.readyState) {
script.onreadystatechange = function () {
if (script.readyState == "loaded" || script.readyState == "complete") {
script.onreadystatechange = null;
onLoadCallback();
}
};
}
else {
script.onload = onLoadCallback;
}
script.onerror = onLoadError;
timeoutInMs = timeoutInMs || _defaultScriptLoadingTimeout;
_loadedScriptEntry.timer = setTimeout(onLoadError, timeoutInMs);
script.src = url;
doc.getElementsByTagName("head")[0].appendChild(script);
}
else if (_loadedScriptEntry.loaded) {
callback();
}
else {
_loadedScriptEntry.pendingCallbacks.push(callback);
}
}
},
loadCSS: function OSF_OUtil$loadCSS(url) {
if (url) {
var doc = window.document;
var link = doc.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = url;
doc.getElementsByTagName("head")[0].appendChild(link);
}
},
parseEnum: function OSF_OUtil$parseEnum(str, enumObject) {
var parsed = enumObject[str.trim()];
if (typeof (parsed) == 'undefined') {
OsfMsAjaxFactory.msAjaxDebug.trace("invalid enumeration string:" + str);
throw OsfMsAjaxFactory.msAjaxError.argument("str");
}
return parsed;
},
delayExecutionAndCache: function OSF_OUtil$delayExecutionAndCache() {
var obj = { calc: arguments[0] };
return function () {
if (obj.calc) {
obj.val = obj.calc.apply(this, arguments);
delete obj.calc;
}
return obj.val;
};
},
getUniqueId: function OSF_OUtil$getUniqueId() {
_uniqueId = _uniqueId + 1;
return _uniqueId.toString();
},
formatString: function OSF_OUtil$formatString() {
var args = arguments;
var source = args[0];
return source.replace(/{(\d+)}/gm, function (match, number) {
var index = parseInt(number, 10) + 1;
return args[index] === undefined ? '{' + number + '}' : args[index];
});
},
generateConversationId: function OSF_OUtil$generateConversationId() {
return [_random(), _random(), (new Date()).getTime().toString()].join('_');
},
getFrameName: function OSF_OUtil$getFrameName(cacheKey) {
return _xdmSessionKeyPrefix + cacheKey + this.generateConversationId();
},
addXdmInfoAsHash: function OSF_OUtil$addXdmInfoAsHash(url, xdmInfoValue) {
return OSF.OUtil.addInfoAsHash(url, _xdmInfoKey, xdmInfoValue, false);
},
addSerializerVersionAsHash: function OSF_OUtil$addSerializerVersionAsHash(url, serializerVersion) {
return OSF.OUtil.addInfoAsHash(url, _serializerVersionKey, serializerVersion, true);
},
addInfoAsHash: function OSF_OUtil$addInfoAsHash(url, keyName, infoValue, encodeInfo) {
url = url.trim() || '';
var urlParts = url.split(_fragmentSeparator);
var urlWithoutFragment = urlParts.shift();
var fragment = urlParts.join(_fragmentSeparator);
var newFragment;
if (encodeInfo) {
newFragment = [keyName, encodeURIComponent(infoValue), fragment].join('');
}
else {
newFragment = [fragment, keyName, infoValue].join('');
}
return [urlWithoutFragment, _fragmentSeparator, newFragment].join('');
},
parseHostInfoFromWindowName: function OSF_OUtil$parseHostInfoFromWindowName(skipSessionStorage, windowName) {
return OSF.OUtil.parseInfoFromWindowName(skipSessionStorage, windowName, OSF.WindowNameItemKeys.HostInfo);
},
parseXdmInfo: function OSF_OUtil$parseXdmInfo(skipSessionStorage) {
var xdmInfoValue = OSF.OUtil.parseXdmInfoWithGivenFragment(skipSessionStorage, window.location.hash);
if (!xdmInfoValue) {
xdmInfoValue = OSF.OUtil.parseXdmInfoFromWindowName(skipSessionStorage, window.name);
}
return xdmInfoValue;
},
parseXdmInfoFromWindowName: function OSF_OUtil$parseXdmInfoFromWindowName(skipSessionStorage, windowName) {
return OSF.OUtil.parseInfoFromWindowName(skipSessionStorage, windowName, OSF.WindowNameItemKeys.XdmInfo);
},
parseXdmInfoWithGivenFragment: function OSF_OUtil$parseXdmInfoWithGivenFragment(skipSessionStorage, fragment) {
return OSF.OUtil.parseInfoWithGivenFragment(_xdmInfoKey, _xdmSessionKeyPrefix, false, skipSessionStorage, fragment);
},
parseSerializerVersion: function OSF_OUtil$parseSerializerVersion(skipSessionStorage) {
var serializerVersion = OSF.OUtil.parseSerializerVersionWithGivenFragment(skipSessionStorage, window.location.hash);
if (isNaN(serializerVersion)) {
serializerVersion = OSF.OUtil.parseSerializerVersionFromWindowName(skipSessionStorage, window.name);
}
return serializerVersion;
},
parseSerializerVersionFromWindowName: function OSF_OUtil$parseSerializerVersionFromWindowName(skipSessionStorage, windowName) {
return parseInt(OSF.OUtil.parseInfoFromWindowName(skipSessionStorage, windowName, OSF.WindowNameItemKeys.SerializerVersion));
},
parseSerializerVersionWithGivenFragment: function OSF_OUtil$parseSerializerVersionWithGivenFragment(skipSessionStorage, fragment) {
return parseInt(OSF.OUtil.parseInfoWithGivenFragment(_serializerVersionKey, _serializerVersionKeyPrefix, true, skipSessionStorage, fragment));
},
parseInfoFromWindowName: function OSF_OUtil$parseInfoFromWindowName(skipSessionStorage, windowName, infoKey) {
try {
var windowNameObj = JSON.parse(windowName);
var infoValue = windowNameObj != null ? windowNameObj[infoKey] : null;
var osfSessionStorage = _getSessionStorage();
if (!skipSessionStorage && osfSessionStorage && windowNameObj != null) {
var sessionKey = windowNameObj[OSF.WindowNameItemKeys.BaseFrameName] + infoKey;
if (infoValue) {
osfSessionStorage.setItem(sessionKey, infoValue);
}
else {
infoValue = osfSessionStorage.getItem(sessionKey);
}
}
return infoValue;
}
catch (Exception) {
return null;
}
},
parseInfoWithGivenFragment: function OSF_OUtil$parseInfoWithGivenFragment(infoKey, infoKeyPrefix, decodeInfo, skipSessionStorage, fragment) {
var fragmentParts = fragment.split(infoKey);
var infoValue = fragmentParts.length > 1 ? fragmentParts[fragmentParts.length - 1] : null;
if (decodeInfo && infoValue != null) {
if (infoValue.indexOf(_fragmentInfoDelimiter) >= 0) {
infoValue = infoValue.split(_fragmentInfoDelimiter)[0];
}
infoValue = decodeURIComponent(infoValue);
}
var osfSessionStorage = _getSessionStorage();
if (!skipSessionStorage && osfSessionStorage) {
var sessionKeyStart = window.name.indexOf(infoKeyPrefix);
if (sessionKeyStart > -1) {
var sessionKeyEnd = window.name.indexOf(";", sessionKeyStart);
if (sessionKeyEnd == -1) {
sessionKeyEnd = window.name.length;
}
var sessionKey = window.name.substring(sessionKeyStart, sessionKeyEnd);
if (infoValue) {
osfSessionStorage.setItem(sessionKey, infoValue);
}
else {
infoValue = osfSessionStorage.getItem(sessionKey);
}
}
}
return infoValue;
},
getConversationId: function OSF_OUtil$getConversationId() {
var searchString = window.location.search;
var conversationId = null;
if (searchString) {
var index = searchString.indexOf("&");
conversationId = index > 0 ? searchString.substring(1, index) : searchString.substr(1);
if (conversationId && conversationId.charAt(conversationId.length - 1) === '=') {
conversationId = conversationId.substring(0, conversationId.length - 1);
if (conversationId) {
conversationId = decodeURIComponent(conversationId);
}
}
}
return conversationId;
},
getInfoItems: function OSF_OUtil$getInfoItems(strInfo) {
var items = strInfo.split("$");
if (typeof items[1] == "undefined") {
items = strInfo.split("|");
}
if (typeof items[1] == "undefined") {
items = strInfo.split("%7C");
}
return items;
},
getXdmFieldValue: function OSF_OUtil$getXdmFieldValue(xdmFieldName, skipSessionStorage) {
var fieldValue = '';
var xdmInfoValue = OSF.OUtil.parseXdmInfo(skipSessionStorage);
if (xdmInfoValue) {
var items = OSF.OUtil.getInfoItems(xdmInfoValue);
if (items != undefined && items.length >= 3) {
switch (xdmFieldName) {
case OSF.XdmFieldName.ConversationUrl:
fieldValue = items[2];
case OSF.XdmFieldName.AppId:
fieldValue = items[1];
}
}
}
return fieldValue;
},
validateParamObject: function OSF_OUtil$validateParamObject(params, expectedProperties, callback) {
var e = Function._validateParams(arguments, [{ name: "params", type: Object, mayBeNull: false },
{ name: "expectedProperties", type: Object, mayBeNull: false },
{ name: "callback", type: Function, mayBeNull: true }
]);
if (e)
throw e;
for (var p in expectedProperties) {
e = Function._validateParameter(params[p], expectedProperties[p], p);
if (e)
throw e;
}
},
writeProfilerMark: function OSF_OUtil$writeProfilerMark(text) {
if (window.msWriteProfilerMark) {
window.msWriteProfilerMark(text);
OsfMsAjaxFactory.msAjaxDebug.trace(text);
}
},
outputDebug: function OSF_OUtil$outputDebug(text) {
if (typeof (OsfMsAjaxFactory) !== 'undefined' && OsfMsAjaxFactory.msAjaxDebug && OsfMsAjaxFactory.msAjaxDebug.trace) {
OsfMsAjaxFactory.msAjaxDebug.trace(text);
}
},
defineNondefaultProperty: function OSF_OUtil$defineNondefaultProperty(obj, prop, descriptor, attributes) {
descriptor = descriptor || {};
for (var nd in attributes) {
var attribute = attributes[nd];
if (descriptor[attribute] == undefined) {
descriptor[attribute] = true;
}
}
Object.defineProperty(obj, prop, descriptor);
return obj;
},
defineNondefaultProperties: function OSF_OUtil$defineNondefaultProperties(obj, descriptors, attributes) {
descriptors = descriptors || {};
for (var prop in descriptors) {
OSF.OUtil.defineNondefaultProperty(obj, prop, descriptors[prop], attributes);
}
return obj;
},
defineEnumerableProperty: function OSF_OUtil$defineEnumerableProperty(obj, prop, descriptor) {
return OSF.OUtil.defineNondefaultProperty(obj, prop, descriptor, ["enumerable"]);
},
defineEnumerableProperties: function OSF_OUtil$defineEnumerableProperties(obj, descriptors) {
return OSF.OUtil.defineNondefaultProperties(obj, descriptors, ["enumerable"]);
},
defineMutableProperty: function OSF_OUtil$defineMutableProperty(obj, prop, descriptor) {
return OSF.OUtil.defineNondefaultProperty(obj, prop, descriptor, ["writable", "enumerable", "configurable"]);
},
defineMutableProperties: function OSF_OUtil$defineMutableProperties(obj, descriptors) {
return OSF.OUtil.defineNondefaultProperties(obj, descriptors, ["writable", "enumerable", "configurable"]);
},
finalizeProperties: function OSF_OUtil$finalizeProperties(obj, descriptor) {
descriptor = descriptor || {};
var props = Object.getOwnPropertyNames(obj);
var propsLength = props.length;
for (var i = 0; i < propsLength; i++) {
var prop = props[i];
var desc = Object.getOwnPropertyDescriptor(obj, prop);
if (!desc.get && !desc.set) {
desc.writable = descriptor.writable || false;
}
desc.configurable = descriptor.configurable || false;
desc.enumerable = descriptor.enumerable || true;
Object.defineProperty(obj, prop, desc);
}
return obj;
},
mapList: function OSF_OUtil$MapList(list, mapFunction) {
var ret = [];
if (list) {
for (var item in list) {
ret.push(mapFunction(list[item]));
}
}
return ret;
},
listContainsKey: function OSF_OUtil$listContainsKey(list, key) {
for (var item in list) {
if (key == item) {
return true;
}
}
return false;
},
listContainsValue: function OSF_OUtil$listContainsElement(list, value) {
for (var item in list) {
if (value == list[item]) {
return true;
}
}
return false;
},
augmentList: function OSF_OUtil$augmentList(list, addenda) {
var add = list.push ? function (key, value) { list.push(value); } : function (key, value) { list[key] = value; };
for (var key in addenda) {
add(key, addenda[key]);
}
},
redefineList: function OSF_Outil$redefineList(oldList, newList) {
for (var key1 in oldList) {
delete oldList[key1];
}
for (var key2 in newList) {
oldList[key2] = newList[key2];
}
},
isArray: function OSF_OUtil$isArray(obj) {
return Object.prototype.toString.apply(obj) === "[object Array]";
},
isFunction: function OSF_OUtil$isFunction(obj) {
return Object.prototype.toString.apply(obj) === "[object Function]";
},
isDate: function OSF_OUtil$isDate(obj) {
return Object.prototype.toString.apply(obj) === "[object Date]";
},
addEventListener: function OSF_OUtil$addEventListener(element, eventName, listener) {
if (element.addEventListener) {
element.addEventListener(eventName, listener, false);
}
else if ((Sys.Browser.agent === Sys.Browser.InternetExplorer) && element.attachEvent) {
element.attachEvent("on" + eventName, listener);
}
else {
element["on" + eventName] = listener;
}
},
removeEventListener: function OSF_OUtil$removeEventListener(element, eventName, listener) {
if (element.removeEventListener) {
element.removeEventListener(eventName, listener, false);
}
else if ((Sys.Browser.agent === Sys.Browser.InternetExplorer) && element.detachEvent) {
element.detachEvent("on" + eventName, listener);
}
else {
element["on" + eventName] = null;
}
},
getCookieValue: function OSF_OUtil$getCookieValue(cookieName) {
var tmpCookieString = RegExp(cookieName + "[^;]+").exec(document.cookie);
return tmpCookieString.toString().replace(/^[^=]+./, "");
},
xhrGet: function OSF_OUtil$xhrGet(url, onSuccess, onError) {
var xmlhttp;
try {
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
onSuccess(xmlhttp.responseText);
}
else {
onError(xmlhttp.status);
}
}
};
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
catch (ex) {
onError(ex);
}
},
xhrGetFull: function OSF_OUtil$xhrGetFull(url, oneDriveFileName, onSuccess, onError) {
var xmlhttp;
var requestedFileName = oneDriveFileName;
try {
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
onSuccess(xmlhttp, requestedFileName);
}
else {
onError(xmlhttp.status);
}
}
};
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
catch (ex) {
onError(ex);
}
},
encodeBase64: function OSF_Outil$encodeBase64(input) {
if (!input)
return input;
var codex = "ABCDEFGHIJKLMNOP" + "QRSTUVWXYZabcdef" + "ghijklmnopqrstuv" + "wxyz0123456789+/=";
var output = [];
var temp = [];
var index = 0;
var c1, c2, c3, a, b, c;
var i;
var length = input.length;
do {
c1 = input.charCodeAt(index++);
c2 = input.charCodeAt(index++);
c3 = input.charCodeAt(index++);
i = 0;
a = c1 & 255;
b = c1 >> 8;
c = c2 & 255;
temp[i++] = a >> 2;
temp[i++] = ((a & 3) << 4) | (b >> 4);
temp[i++] = ((b & 15) << 2) | (c >> 6);
temp[i++] = c & 63;
if (!isNaN(c2)) {
a = c2 >> 8;
b = c3 & 255;
c = c3 >> 8;
temp[i++] = a >> 2;
temp[i++] = ((a & 3) << 4) | (b >> 4);
temp[i++] = ((b & 15) << 2) | (c >> 6);
temp[i++] = c & 63;
}
if (isNaN(c2)) {
temp[i - 1] = 64;
}
else if (isNaN(c3)) {
temp[i - 2] = 64;
temp[i - 1] = 64;
}
for (var t = 0; t < i; t++) {
output.push(codex.charAt(temp[t]));
}
} while (index < length);
return output.join("");
},
getSessionStorage: function OSF_Outil$getSessionStorage() {
return _getSessionStorage();
},
getLocalStorage: function OSF_Outil$getLocalStorage() {
if (!_safeLocalStorage) {
try {
var localStorage = window.localStorage;
}
catch (ex) {
localStorage = null;
}
_safeLocalStorage = new OfficeExt.SafeStorage(localStorage);
}
return _safeLocalStorage;
},
convertIntToCssHexColor: function OSF_Outil$convertIntToCssHexColor(val) {
var hex = "#" + (Number(val) + 0x1000000).toString(16).slice(-6);
return hex;
},
attachClickHandler: function OSF_Outil$attachClickHandler(element, handler) {
element.onclick = function (e) {
handler();
};
element.ontouchend = function (e) {
handler();
e.preventDefault();
};
},
getQueryStringParamValue: function OSF_Outil$getQueryStringParamValue(queryString, paramName) {
var e = Function._validateParams(arguments, [{ name: "queryString", type: String, mayBeNull: false },
{ name: "paramName", type: String, mayBeNull: false }
]);
if (e) {
OsfMsAjaxFactory.msAjaxDebug.trace("OSF_Outil_getQueryStringParamValue: Parameters cannot be null.");
return "";
}
var queryExp = new RegExp("[\\?&]" + paramName + "=([^&#]*)", "i");
if (!queryExp.test(queryString)) {
OsfMsAjaxFactory.msAjaxDebug.trace("OSF_Outil_getQueryStringParamValue: The parameter is not found.");
return "";
}
return queryExp.exec(queryString)[1];
},
isiOS: function OSF_Outil$isiOS() {
return (window.navigator.userAgent.match(/(iPad|iPhone|iPod)/g) ? true : false);
},
isChrome: function OSF_Outil$isChrome() {
return (window.navigator.userAgent.indexOf("Chrome") > 0) && !OSF.OUtil.isEdge();
},
isEdge: function OSF_Outil$isEdge() {
return window.navigator.userAgent.indexOf("Edge") > 0;
},
isIE: function OSF_Outil$isIE() {
return window.navigator.userAgent.indexOf("Trident") > 0;
},
isFirefox: function OSF_Outil$isFirefox() {
return window.navigator.userAgent.indexOf("Firefox") > 0;
},
shallowCopy: function OSF_Outil$shallowCopy(sourceObj) {
var copyObj = sourceObj.constructor();
for (var property in sourceObj) {
if (sourceObj.hasOwnProperty(property)) {
copyObj[property] = sourceObj[property];
}
}
return copyObj;
},
createObject: function OSF_Outil$createObject(properties) {
var obj = null;
if (properties) {
obj = {};
var len = properties.length;
for (var i = 0; i < len; i++) {
obj[properties[i].name] = properties[i].value;
}
}
return obj;
},
addClass: function OSF_OUtil$addClass(elmt, val) {
if (!OSF.OUtil.hasClass(elmt, val)) {
var className = elmt.getAttribute(_classN);
if (className) {
elmt.setAttribute(_classN, className + " " + val);
}
else {
elmt.setAttribute(_classN, val);
}
}
},
hasClass: function OSF_OUtil$hasClass(elmt, clsName) {
var className = elmt.getAttribute(_classN);
return className && className.match(new RegExp('(\\s|^)' + clsName + '(\\s|$)'));
},
focusToFirstTabbable: function OSF_OUtil$focusToFirstTabbable(all, backward) {
var next;
var focused = false;
var candidate;
var setFlag = function (e) {
focused = true;
};
var findNextPos = function (allLen, currPos, backward) {
if (currPos < 0 || currPos > allLen) {
return -1;
}
else if (currPos === 0 && backward) {
return -1;
}
else if (currPos === allLen - 1 && !backward) {
return -1;
}
if (backward) {
return currPos - 1;
}
else {
return currPos + 1;
}
};
all = _reOrderTabbableElements(all);
next = backward ? all.length - 1 : 0;
if (all.length === 0) {
return null;
}
while (!focused && next >= 0 && next < all.length) {
candidate = all[next];
window.focus();
candidate.addEventListener('focus', setFlag);
candidate.focus();
candidate.removeEventListener('focus', setFlag);
next = findNextPos(all.length, next, backward);
if (!focused && candidate === document.activeElement) {
focused = true;
}
}
if (focused) {
return candidate;
}
else {
return null;
}
},
focusToNextTabbable: function OSF_OUtil$focusToNextTabbable(all, curr, shift) {
var currPos;
var next;
var focused = false;
var candidate;
var setFlag = function (e) {
focused = true;
};
var findCurrPos = function (all, curr) {
var i = 0;
for (; i < all.length; i++) {
if (all[i] === curr) {
return i;
}
}
return -1;
};
var findNextPos = function (allLen, currPos, shift) {
if (currPos < 0 || currPos > allLen) {
return -1;
}
else if (currPos === 0 && shift) {
return -1;
}
else if (currPos === allLen - 1 && !shift) {
return -1;
}
if (shift) {
return currPos - 1;
}
else {
return currPos + 1;
}
};
all = _reOrderTabbableElements(all);
currPos = findCurrPos(all, curr);
next = findNextPos(all.length, currPos, shift);
if (next < 0) {
return null;
}
while (!focused && next >= 0 && next < all.length) {
candidate = all[next];
candidate.addEventListener('focus', setFlag);
candidate.focus();
candidate.removeEventListener('focus', setFlag);
next = findNextPos(all.length, next, shift);
if (!focused && candidate === document.activeElement) {
focused = true;
}
}
if (focused) {
return candidate;
}
else {
return null;
}
}
};
})();
OSF.OUtil.Guid = (function () {
var hexCode = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"];
return {
generateNewGuid: function OSF_Outil_Guid$generateNewGuid() {
var result = "";
var tick = (new Date()).getTime();
var index = 0;
for (; index < 32 && tick > 0; index++) {
if (index == 8 || index == 12 || index == 16 || index == 20) {
result += "-";
}
result += hexCode[tick % 16];
tick = Math.floor(tick / 16);
}
for (; index < 32; index++) {
if (index == 8 || index == 12 || index == 16 || index == 20) {
result += "-";
}
result += hexCode[Math.floor(Math.random() * 16)];
}
return result;
}
};
})();
window.OSF = OSF;
OSF.OUtil.setNamespace("OSF", window);
OSF.AppName = {
Unsupported: 0,
Excel: 1,
Word: 2,
PowerPoint: 4,
Outlook: 8,
ExcelWebApp: 16,
WordWebApp: 32,
OutlookWebApp: 64,
Project: 128,
AccessWebApp: 256,
PowerpointWebApp: 512,
ExcelIOS: 1024,
Sway: 2048,
WordIOS: 4096,
PowerPointIOS: 8192,
Access: 16384,
Lync: 32768,
OutlookIOS: 65536,
OneNoteWebApp: 131072,
OneNote: 262144,
ExcelWinRT: 524288,
WordWinRT: 1048576,
PowerpointWinRT: 2097152,
OutlookAndroid: 4194304,
OneNoteWinRT: 8388608
};
OSF.InternalPerfMarker = {
DataCoercionBegin: "Agave.HostCall.CoerceDataStart",
DataCoercionEnd: "Agave.HostCall.CoerceDataEnd"
};
OSF.HostCallPerfMarker = {
IssueCall: "Agave.HostCall.IssueCall",
ReceiveResponse: "Agave.HostCall.ReceiveResponse",
RuntimeExceptionRaised: "Agave.HostCall.RuntimeExecptionRaised"
};
OSF.AgaveHostAction = {
"Select": 0,
"UnSelect": 1,
"CancelDialog": 2,
"InsertAgave": 3,
"CtrlF6In": 4,
"CtrlF6Exit": 5,
"CtrlF6ExitShift": 6,
"SelectWithError": 7,
"NotifyHostError": 8,
"RefreshAddinCommands": 9,
"PageIsReady": 10,
"TabIn": 11,
"TabInShift": 12,
"TabExit": 13,
"TabExitShift": 14,
"EscExit": 15,
"F2Exit": 16,
"ExitNoFocusable": 17,
"ExitNoFocusableShift": 18
};
OSF.SharedConstants = {
"NotificationConversationIdSuffix": '_ntf'
};
OSF.DialogMessageType = {
DialogMessageReceived: 0,
DialogClosed: 12006
};
OSF.OfficeAppContext = function OSF_OfficeAppContext(id, appName, appVersion, appUILocale, dataLocale, docUrl, clientMode, settings, reason, osfControlType, eToken, correlationId, appInstanceId, touchEnabled, commerceAllowed, appMinorVersion, requirementMatrix, hostCustomMessage, hostFullVersion, clientWindowHeight, clientWindowWidth, addinName) {
this._id = id;
this._appName = appName;
this._appVersion = appVersion;
this._appUILocale = appUILocale;
this._dataLocale = dataLocale;
this._docUrl = docUrl;
this._clientMode = clientMode;
this._settings = settings;
this._reason = reason;
this._osfControlType = osfControlType;
this._eToken = eToken;
this._correlationId = correlationId;
this._appInstanceId = appInstanceId;
this._touchEnabled = touchEnabled;
this._commerceAllowed = commerceAllowed;
this._appMinorVersion = appMinorVersion;
this._requirementMatrix = requirementMatrix;
this._hostCustomMessage = hostCustomMessage;
this._hostFullVersion = hostFullVersion;
this._isDialog = false;
this._clientWindowHeight = clientWindowHeight;
this._clientWindowWidth = clientWindowWidth;
this._addinName = addinName;
this.get_id = function get_id() { return this._id; };
this.get_appName = function get_appName() { return this._appName; };
this.get_appVersion = function get_appVersion() { return this._appVersion; };
this.get_appUILocale = function get_appUILocale() { return this._appUILocale; };
this.get_dataLocale = function get_dataLocale() { return this._dataLocale; };
this.get_docUrl = function get_docUrl() { return this._docUrl; };
this.get_clientMode = function get_clientMode() { return this._clientMode; };
this.get_bindings = function get_bindings() { return this._bindings; };
this.get_settings = function get_settings() { return this._settings; };
this.get_reason = function get_reason() { return this._reason; };
this.get_osfControlType = function get_osfControlType() { return this._osfControlType; };
this.get_eToken = function get_eToken() { return this._eToken; };
this.get_correlationId = function get_correlationId() { return this._correlationId; };
this.get_appInstanceId = function get_appInstanceId() { return this._appInstanceId; };
this.get_touchEnabled = function get_touchEnabled() { return this._touchEnabled; };
this.get_commerceAllowed = function get_commerceAllowed() { return this._commerceAllowed; };
this.get_appMinorVersion = function get_appMinorVersion() { return this._appMinorVersion; };
this.get_requirementMatrix = function get_requirementMatrix() { return this._requirementMatrix; };
this.get_hostCustomMessage = function get_hostCustomMessage() { return this._hostCustomMessage; };
this.get_hostFullVersion = function get_hostFullVersion() { return this._hostFullVersion; };
this.get_isDialog = function get_isDialog() { return this._isDialog; };
this.get_clientWindowHeight = function get_clientWindowHeight() { return this._clientWindowHeight; };
this.get_clientWindowWidth = function get_clientWindowWidth() { return this._clientWindowWidth; };
this.get_addinName = function get_addinName() { return this._addinName; };
};
OSF.OsfControlType = {
DocumentLevel: 0,
ContainerLevel: 1
};
OSF.ClientMode = {
ReadOnly: 0,
ReadWrite: 1
};
OSF.OUtil.setNamespace("Microsoft", window);
OSF.OUtil.setNamespace("Office", Microsoft);
OSF.OUtil.setNamespace("Client", Microsoft.Office);
OSF.OUtil.setNamespace("WebExtension", Microsoft.Office);
Microsoft.Office.WebExtension.InitializationReason = {
Inserted: "inserted",
DocumentOpened: "documentOpened"
};
Microsoft.Office.WebExtension.ValueFormat = {
Unformatted: "unformatted",
Formatted: "formatted"
};
Microsoft.Office.WebExtension.FilterType = {
All: "all"
};
Microsoft.Office.WebExtension.Parameters = {
BindingType: "bindingType",
CoercionType: "coercionType",
ValueFormat: "valueFormat",
FilterType: "filterType",
Columns: "columns",
SampleData: "sampleData",
GoToType: "goToType",
SelectionMode: "selectionMode",
Id: "id",
PromptText: "promptText",
ItemName: "itemName",
FailOnCollision: "failOnCollision",
StartRow: "startRow",
StartColumn: "startColumn",
RowCount: "rowCount",
ColumnCount: "columnCount",
Callback: "callback",
AsyncContext: "asyncContext",
Data: "data",
Rows: "rows",
OverwriteIfStale: "overwriteIfStale",
FileType: "fileType",
EventType: "eventType",
Handler: "handler",
SliceSize: "sliceSize",
SliceIndex: "sliceIndex",
ActiveView: "activeView",
Status: "status",
Xml: "xml",
Namespace: "namespace",
Prefix: "prefix",
XPath: "xPath",
Text: "text",
ImageLeft: "imageLeft",
ImageTop: "imageTop",
ImageWidth: "imageWidth",
ImageHeight: "imageHeight",
TaskId: "taskId",
FieldId: "fieldId",
FieldValue: "fieldValue",
ServerUrl: "serverUrl",
ListName: "listName",
ResourceId: "resourceId",
ViewType: "viewType",
ViewName: "viewName",
GetRawValue: "getRawValue",
CellFormat: "cellFormat",
TableOptions: "tableOptions",
TaskIndex: "taskIndex",
ResourceIndex: "resourceIndex",
CustomFieldId: "customFieldId",
Url: "url",
MessageHandler: "messageHandler",
Width: "width",
Height: "height",
RequireHTTPs: "requireHTTPS",
MessageToParent: "messageToParent",
DisplayInIframe: "displayInIframe"
};
OSF.OUtil.setNamespace("DDA", OSF);
OSF.DDA.DocumentMode = {
ReadOnly: 1,
ReadWrite: 0
};
OSF.DDA.PropertyDescriptors = {
AsyncResultStatus: "AsyncResultStatus"
};
OSF.DDA.EventDescriptors = {};
OSF.DDA.ListDescriptors = {};
OSF.DDA.UI = {};
OSF.DDA.getXdmEventName = function OSF_DDA$GetXdmEventName(id, eventType) {
if (eventType == Microsoft.Office.WebExtension.EventType.BindingSelectionChanged ||
eventType == Microsoft.Office.WebExtension.EventType.BindingDataChanged ||
eventType == Microsoft.Office.WebExtension.EventType.DataNodeDeleted ||
eventType == Microsoft.Office.WebExtension.EventType.DataNodeInserted ||
eventType == Microsoft.Office.WebExtension.EventType.DataNodeReplaced) {
return id + "_" + eventType;
}
else {
return eventType;
}
};
OSF.DDA.MethodDispId = {
dispidMethodMin: 64,
dispidGetSelectedDataMethod: 64,
dispidSetSelectedDataMethod: 65,
dispidAddBindingFromSelectionMethod: 66,
dispidAddBindingFromPromptMethod: 67,
dispidGetBindingMethod: 68,
dispidReleaseBindingMethod: 69,
dispidGetBindingDataMethod: 70,
dispidSetBindingDataMethod: 71,
dispidAddRowsMethod: 72,
dispidClearAllRowsMethod: 73,
dispidGetAllBindingsMethod: 74,
dispidLoadSettingsMethod: 75,
dispidSaveSettingsMethod: 76,
dispidGetDocumentCopyMethod: 77,
dispidAddBindingFromNamedItemMethod: 78,
dispidAddColumnsMethod: 79,
dispidGetDocumentCopyChunkMethod: 80,
dispidReleaseDocumentCopyMethod: 81,
dispidNavigateToMethod: 82,
dispidGetActiveViewMethod: 83,
dispidGetDocumentThemeMethod: 84,
dispidGetOfficeThemeMethod: 85,
dispidGetFilePropertiesMethod: 86,
dispidClearFormatsMethod: 87,
dispidSetTableOptionsMethod: 88,
dispidSetFormatsMethod: 89,
dispidExecuteRichApiRequestMethod: 93,
dispidAppCommandInvocationCompletedMethod: 94,
dispidCloseContainerMethod: 97,
dispidAddDataPartMethod: 128,
dispidGetDataPartByIdMethod: 129,
dispidGetDataPartsByNamespaceMethod: 130,
dispidGetDataPartXmlMethod: 131,
dispidGetDataPartNodesMethod: 132,
dispidDeleteDataPartMethod: 133,
dispidGetDataNodeValueMethod: 134,
dispidGetDataNodeXmlMethod: 135,
dispidGetDataNodesMethod: 136,
dispidSetDataNodeValueMethod: 137,
dispidSetDataNodeXmlMethod: 138,
dispidAddDataNamespaceMethod: 139,