1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | var __extends = this.__extends || function (d, b) {
|
12 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
13 | function __() { this.constructor = d; }
|
14 | __.prototype = b.prototype;
|
15 | d.prototype = new __();
|
16 | };
|
17 | var OfficeExt;
|
18 | (function (OfficeExt) {
|
19 | var MicrosoftAjaxFactory = (function () {
|
20 | function MicrosoftAjaxFactory() {
|
21 | }
|
22 | MicrosoftAjaxFactory.prototype.isMsAjaxLoaded = function () {
|
23 | 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") {
|
24 | return true;
|
25 | } else {
|
26 | return false;
|
27 | }
|
28 | };
|
29 | MicrosoftAjaxFactory.prototype.loadMsAjaxFull = function (callback) {
|
30 | var msAjaxCDNPath = (window.location.protocol.toLowerCase() === 'https:' ? 'https:' : 'http:') + '//ajax.aspnetcdn.com/ajax/3.5/MicrosoftAjax.js';
|
31 | OSF.OUtil.loadScript(msAjaxCDNPath, callback);
|
32 | };
|
33 | Object.defineProperty(MicrosoftAjaxFactory.prototype, "msAjaxError", {
|
34 | get: function () {
|
35 | if (this._msAjaxError == null && this.isMsAjaxLoaded()) {
|
36 | this._msAjaxError = Error;
|
37 | }
|
38 | return this._msAjaxError;
|
39 | },
|
40 | set: function (errorClass) {
|
41 | this._msAjaxError = errorClass;
|
42 | },
|
43 | enumerable: true,
|
44 | configurable: true
|
45 | });
|
46 | Object.defineProperty(MicrosoftAjaxFactory.prototype, "msAjaxSerializer", {
|
47 | get: function () {
|
48 | if (this._msAjaxSerializer == null && this.isMsAjaxLoaded()) {
|
49 | this._msAjaxSerializer = Sys.Serialization.JavaScriptSerializer;
|
50 | }
|
51 | return this._msAjaxSerializer;
|
52 | },
|
53 | set: function (serializerClass) {
|
54 | this._msAjaxSerializer = serializerClass;
|
55 | },
|
56 | enumerable: true,
|
57 | configurable: true
|
58 | });
|
59 | Object.defineProperty(MicrosoftAjaxFactory.prototype, "msAjaxString", {
|
60 | get: function () {
|
61 | if (this._msAjaxString == null && this.isMsAjaxLoaded()) {
|
62 | this._msAjaxSerializer = String;
|
63 | }
|
64 | return this._msAjaxString;
|
65 | },
|
66 | set: function (stringClass) {
|
67 | this._msAjaxString = stringClass;
|
68 | },
|
69 | enumerable: true,
|
70 | configurable: true
|
71 | });
|
72 | Object.defineProperty(MicrosoftAjaxFactory.prototype, "msAjaxDebug", {
|
73 | get: function () {
|
74 | if (this._msAjaxDebug == null && this.isMsAjaxLoaded()) {
|
75 | this._msAjaxDebug = Sys.Debug;
|
76 | }
|
77 | return this._msAjaxDebug;
|
78 | },
|
79 | set: function (debugClass) {
|
80 | this._msAjaxDebug = debugClass;
|
81 | },
|
82 | enumerable: true,
|
83 | configurable: true
|
84 | });
|
85 | return MicrosoftAjaxFactory;
|
86 | })();
|
87 | OfficeExt.MicrosoftAjaxFactory = MicrosoftAjaxFactory;
|
88 | })(OfficeExt || (OfficeExt = {}));
|
89 | var OsfMsAjaxFactory = new OfficeExt.MicrosoftAjaxFactory();
|
90 | var OSF = OSF || {};
|
91 | var OfficeExt;
|
92 | (function (OfficeExt) {
|
93 | var SafeStorage = (function () {
|
94 | function SafeStorage(_internalStorage) {
|
95 | this._internalStorage = _internalStorage;
|
96 | }
|
97 | SafeStorage.prototype.getItem = function (key) {
|
98 | try {
|
99 | return this._internalStorage && this._internalStorage.getItem(key);
|
100 | } catch (e) {
|
101 | return null;
|
102 | }
|
103 | };
|
104 | SafeStorage.prototype.setItem = function (key, data) {
|
105 | try {
|
106 | this._internalStorage && this._internalStorage.setItem(key, data);
|
107 | } catch (e) {
|
108 | }
|
109 | };
|
110 | SafeStorage.prototype.clear = function () {
|
111 | try {
|
112 | this._internalStorage && this._internalStorage.clear();
|
113 | } catch (e) {
|
114 | }
|
115 | };
|
116 | SafeStorage.prototype.removeItem = function (key) {
|
117 | try {
|
118 | this._internalStorage && this._internalStorage.removeItem(key);
|
119 | } catch (e) {
|
120 | }
|
121 | };
|
122 | SafeStorage.prototype.getKeysWithPrefix = function (keyPrefix) {
|
123 | var keyList = [];
|
124 | try {
|
125 | var len = this._internalStorage && this._internalStorage.length || 0;
|
126 | for (var i = 0; i < len; i++) {
|
127 | var key = this._internalStorage.key(i);
|
128 | if (key.indexOf(keyPrefix) === 0) {
|
129 | keyList.push(key);
|
130 | }
|
131 | }
|
132 | } catch (e) {
|
133 | }
|
134 | return keyList;
|
135 | };
|
136 | return SafeStorage;
|
137 | })();
|
138 | OfficeExt.SafeStorage = SafeStorage;
|
139 | })(OfficeExt || (OfficeExt = {}));
|
140 | OSF.OUtil = (function () {
|
141 | var _uniqueId = -1;
|
142 | var _xdmInfoKey = '&_xdm_Info=';
|
143 | var _serializerVersionKey = '&_serializer_version=';
|
144 | var _xdmSessionKeyPrefix = '_xdm_';
|
145 | var _serializerVersionKeyPrefix = '_serializer_version=';
|
146 | var _fragmentSeparator = '#';
|
147 | var _loadedScripts = {};
|
148 | var _defaultScriptLoadingTimeout = 30000;
|
149 | var _safeSessionStorage = null;
|
150 | var _safeLocalStorage = null;
|
151 |
|
152 | var _rndentropy = new Date().getTime();
|
153 | function _random() {
|
154 | var nextrand = 0x7fffffff * (Math.random());
|
155 | nextrand ^= _rndentropy ^ ((new Date().getMilliseconds()) << Math.floor(Math.random() * (31 - 10)));
|
156 |
|
157 | return nextrand.toString(16);
|
158 | }
|
159 | ;
|
160 | function _getSessionStorage() {
|
161 | if (!_safeSessionStorage) {
|
162 | try {
|
163 | var sessionStorage = window.sessionStorage;
|
164 | } catch (ex) {
|
165 | sessionStorage = null;
|
166 | }
|
167 | _safeSessionStorage = new OfficeExt.SafeStorage(sessionStorage);
|
168 | }
|
169 | return _safeSessionStorage;
|
170 | }
|
171 | ;
|
172 | return {
|
173 | set_entropy: function OSF_OUtil$set_entropy(entropy) {
|
174 | if (typeof entropy == "string") {
|
175 | for (var i = 0; i < entropy.length; i += 4) {
|
176 | var temp = 0;
|
177 | for (var j = 0; j < 4 && i + j < entropy.length; j++) {
|
178 | temp = (temp << 8) + entropy.charCodeAt(i + j);
|
179 | }
|
180 | _rndentropy ^= temp;
|
181 | }
|
182 | } else if (typeof entropy == "number") {
|
183 | _rndentropy ^= entropy;
|
184 | } else {
|
185 | _rndentropy ^= 0x7fffffff * Math.random();
|
186 | }
|
187 | _rndentropy &= 0x7fffffff;
|
188 | },
|
189 | extend: function OSF_OUtil$extend(child, parent) {
|
190 | var F = function () {
|
191 | };
|
192 | F.prototype = parent.prototype;
|
193 | child.prototype = new F();
|
194 | child.prototype.constructor = child;
|
195 | child.uber = parent.prototype;
|
196 | if (parent.prototype.constructor === Object.prototype.constructor) {
|
197 | parent.prototype.constructor = parent;
|
198 | }
|
199 | },
|
200 | setNamespace: function OSF_OUtil$setNamespace(name, parent) {
|
201 | if (parent && name && !parent[name]) {
|
202 | parent[name] = {};
|
203 | }
|
204 | },
|
205 | unsetNamespace: function OSF_OUtil$unsetNamespace(name, parent) {
|
206 | if (parent && name && parent[name]) {
|
207 | delete parent[name];
|
208 | }
|
209 | },
|
210 | loadScript: function OSF_OUtil$loadScript(url, callback, timeoutInMs) {
|
211 | if (url && callback) {
|
212 | var doc = window.document;
|
213 | var _loadedScriptEntry = _loadedScripts[url];
|
214 | if (!_loadedScriptEntry) {
|
215 | var script = doc.createElement("script");
|
216 | script.type = "text/javascript";
|
217 | _loadedScriptEntry = { loaded: false, pendingCallbacks: [callback], timer: null };
|
218 | _loadedScripts[url] = _loadedScriptEntry;
|
219 | var onLoadCallback = function OSF_OUtil_loadScript$onLoadCallback() {
|
220 | if (_loadedScriptEntry.timer != null) {
|
221 | clearTimeout(_loadedScriptEntry.timer);
|
222 | delete _loadedScriptEntry.timer;
|
223 | }
|
224 | _loadedScriptEntry.loaded = true;
|
225 | var pendingCallbackCount = _loadedScriptEntry.pendingCallbacks.length;
|
226 | for (var i = 0; i < pendingCallbackCount; i++) {
|
227 | var currentCallback = _loadedScriptEntry.pendingCallbacks.shift();
|
228 | currentCallback();
|
229 | }
|
230 | };
|
231 | var onLoadError = function OSF_OUtil_loadScript$onLoadError() {
|
232 | delete _loadedScripts[url];
|
233 | if (_loadedScriptEntry.timer != null) {
|
234 | clearTimeout(_loadedScriptEntry.timer);
|
235 | delete _loadedScriptEntry.timer;
|
236 | }
|
237 | var pendingCallbackCount = _loadedScriptEntry.pendingCallbacks.length;
|
238 | for (var i = 0; i < pendingCallbackCount; i++) {
|
239 | var currentCallback = _loadedScriptEntry.pendingCallbacks.shift();
|
240 | currentCallback();
|
241 | }
|
242 | };
|
243 | if (script.readyState) {
|
244 | script.onreadystatechange = function () {
|
245 | if (script.readyState == "loaded" || script.readyState == "complete") {
|
246 | script.onreadystatechange = null;
|
247 | onLoadCallback();
|
248 | }
|
249 | };
|
250 | } else {
|
251 | script.onload = onLoadCallback;
|
252 | }
|
253 | script.onerror = onLoadError;
|
254 |
|
255 | timeoutInMs = timeoutInMs || _defaultScriptLoadingTimeout;
|
256 | _loadedScriptEntry.timer = setTimeout(onLoadError, timeoutInMs);
|
257 | script.src = url;
|
258 | doc.getElementsByTagName("head")[0].appendChild(script);
|
259 | } else if (_loadedScriptEntry.loaded) {
|
260 | callback();
|
261 | } else {
|
262 | _loadedScriptEntry.pendingCallbacks.push(callback);
|
263 | }
|
264 | }
|
265 | },
|
266 | loadCSS: function OSF_OUtil$loadCSS(url) {
|
267 | if (url) {
|
268 | var doc = window.document;
|
269 | var link = doc.createElement("link");
|
270 | link.type = "text/css";
|
271 | link.rel = "stylesheet";
|
272 | link.href = url;
|
273 | doc.getElementsByTagName("head")[0].appendChild(link);
|
274 | }
|
275 | },
|
276 | parseEnum: function OSF_OUtil$parseEnum(str, enumObject) {
|
277 | var parsed = enumObject[str.trim()];
|
278 | if (typeof (parsed) == 'undefined') {
|
279 | OsfMsAjaxFactory.msAjaxDebug.trace("invalid enumeration string:" + str);
|
280 | throw OsfMsAjaxFactory.msAjaxError.argument("str");
|
281 | }
|
282 | return parsed;
|
283 | },
|
284 | delayExecutionAndCache: function OSF_OUtil$delayExecutionAndCache() {
|
285 | var obj = { calc: arguments[0] };
|
286 | return function () {
|
287 | if (obj.calc) {
|
288 | obj.val = obj.calc.apply(this, arguments);
|
289 | delete obj.calc;
|
290 | }
|
291 | return obj.val;
|
292 | };
|
293 | },
|
294 | getUniqueId: function OSF_OUtil$getUniqueId() {
|
295 | _uniqueId = _uniqueId + 1;
|
296 | return _uniqueId.toString();
|
297 | },
|
298 | formatString: function OSF_OUtil$formatString() {
|
299 | var args = arguments;
|
300 | var source = args[0];
|
301 | return source.replace(/{(\d+)}/gm, function (match, number) {
|
302 | var index = parseInt(number, 10) + 1;
|
303 | return args[index] === undefined ? '{' + number + '}' : args[index];
|
304 | });
|
305 | },
|
306 | generateConversationId: function OSF_OUtil$generateConversationId() {
|
307 | return [_random(), _random(), (new Date()).getTime().toString()].join('_');
|
308 | },
|
309 | getFrameNameAndConversationId: function OSF_OUtil$getFrameNameAndConversationId(cacheKey, frame) {
|
310 | var frameName = _xdmSessionKeyPrefix + cacheKey + this.generateConversationId();
|
311 | frame.setAttribute("name", frameName);
|
312 | return this.generateConversationId();
|
313 | },
|
314 | addXdmInfoAsHash: function OSF_OUtil$addXdmInfoAsHash(url, xdmInfoValue) {
|
315 | return OSF.OUtil.addInfoAsHash(url, _xdmInfoKey, xdmInfoValue);
|
316 | },
|
317 | addSerializerVersionAsHash: function OSF_OUtil$addSerializerVersionAsHash(url, serializerVersion) {
|
318 | return OSF.OUtil.addInfoAsHash(url, _serializerVersionKey, serializerVersion);
|
319 | },
|
320 | addInfoAsHash: function OSF_OUtil$addInfoAsHash(url, keyName, infoValue) {
|
321 | url = url.trim() || '';
|
322 | var urlParts = url.split(_fragmentSeparator);
|
323 | var urlWithoutFragment = urlParts.shift();
|
324 | var fragment = urlParts.join(_fragmentSeparator);
|
325 | return [urlWithoutFragment, _fragmentSeparator, fragment, keyName, infoValue].join('');
|
326 | },
|
327 | parseXdmInfo: function OSF_OUtil$parseXdmInfo(skipSessionStorage) {
|
328 | return OSF.OUtil.parseXdmInfoWithGivenFragment(skipSessionStorage, window.location.hash);
|
329 | },
|
330 | parseXdmInfoWithGivenFragment: function OSF_OUtil$parseXdmInfoWithGivenFragment(skipSessionStorage, fragment) {
|
331 | return OSF.OUtil.parseInfoWithGivenFragment(_xdmInfoKey, _xdmSessionKeyPrefix, skipSessionStorage, fragment);
|
332 | },
|
333 | parseSerializerVersion: function OSF_OUtil$parseSerializerVersion(skipSessionStorage) {
|
334 | return OSF.OUtil.parseSerializerVersionWithGivenFragment(skipSessionStorage, window.location.hash);
|
335 | },
|
336 | parseSerializerVersionWithGivenFragment: function OSF_OUtil$parseSerializerVersionWithGivenFragment(skipSessionStorage, fragment) {
|
337 | return parseInt(OSF.OUtil.parseInfoWithGivenFragment(_serializerVersionKey, _serializerVersionKeyPrefix, skipSessionStorage, fragment));
|
338 | },
|
339 | parseInfoWithGivenFragment: function OSF_OUtil$parseInfoWithGivenFragment(infoKey, infoKeyPrefix, skipSessionStorage, fragment) {
|
340 | var fragmentParts = fragment.split(infoKey);
|
341 | var xdmInfoValue = fragmentParts.length > 1 ? fragmentParts[fragmentParts.length - 1] : null;
|
342 | var osfSessionStorage = _getSessionStorage();
|
343 | if (!skipSessionStorage && osfSessionStorage) {
|
344 | var sessionKeyStart = window.name.indexOf(infoKeyPrefix);
|
345 | if (sessionKeyStart > -1) {
|
346 | var sessionKeyEnd = window.name.indexOf(";", sessionKeyStart);
|
347 | if (sessionKeyEnd == -1) {
|
348 | sessionKeyEnd = window.name.length;
|
349 | }
|
350 | var sessionKey = window.name.substring(sessionKeyStart, sessionKeyEn |
\ | No newline at end of file |