MCPcopy Create free account
hub / github.com/mailru/FileAPI / addHistoryEntry

Function addHistoryEntry

flash/image/html-template/history/history.js:224–285  ·  view source on GitHub ↗
(baseUrl, newUrl, flexAppUrl)

Source from the content-addressed store, hash-verified

222 * flexAppUrl: the portion of the location following the '#' only
223 */
224 function addHistoryEntry(baseUrl, newUrl, flexAppUrl) {
225
226 //delete all the history entries
227 forwardStack = [];
228
229 if (browser.ie) {
230 //Check to see if we are being asked to do a navigate for the first
231 //history entry, and if so ignore, because it's coming from the creation
232 //of the history iframe
233 if (flexAppUrl == defaultHash && document.location.href == initialHref && window['_ie_firstload']) {
234 currentHref = initialHref;
235 return;
236 }
237 if ((!flexAppUrl || flexAppUrl == defaultHash) && window['_ie_firstload']) {
238 newUrl = baseUrl + '#' + defaultHash;
239 flexAppUrl = defaultHash;
240 } else {
241 // for IE, tell the history frame to go somewhere without a '#'
242 // in order to get this entry into the browser history.
243 getHistoryFrame().src = historyFrameSourcePrefix + flexAppUrl;
244 }
245 setHash(flexAppUrl);
246 } else {
247
248 //ADR
249 if (backStack.length == 0 && initialState.flexAppUrl == flexAppUrl) {
250 initialState = createState(baseUrl, newUrl, flexAppUrl);
251 } else if(backStack.length > 0 && backStack[backStack.length - 1].flexAppUrl == flexAppUrl) {
252 backStack[backStack.length - 1] = createState(baseUrl, newUrl, flexAppUrl);
253 }
254
255 if (browser.safari) {
256 // for Safari, submit a form whose action points to the desired URL
257 if (browser.version <= 419.3) {
258 var file = window.location.pathname.toString();
259 file = file.substring(file.lastIndexOf("/")+1);
260 getFormElement().innerHTML = '<form name="historyForm" action="'+file+'#' + flexAppUrl + '" method="GET"></form>';
261 //get the current elements and add them to the form
262 var qs = window.location.search.substring(1);
263 var qs_arr = qs.split("&");
264 for (var i = 0; i < qs_arr.length; i++) {
265 var tmp = qs_arr[i].split("=");
266 var elem = document.createElement("input");
267 elem.type = "hidden";
268 elem.name = tmp[0];
269 elem.value = tmp[1];
270 document.forms.historyForm.appendChild(elem);
271 }
272 document.forms.historyForm.submit();
273 } else {
274 top.location.hash = flexAppUrl;
275 }
276 // We also have to maintain the history by hand for Safari
277 historyHash[history.length] = flexAppUrl;
278 _storeStates();
279 } else {
280 // Otherwise, just tell the browser to go there
281 setHash(flexAppUrl);

Callers 1

history.jsFile · 0.70

Calls 5

getHistoryFrameFunction · 0.70
setHashFunction · 0.70
createStateFunction · 0.70
getFormElementFunction · 0.70
_storeStatesFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…