Skip to content

Instantly share code, notes, and snippets.

@KushalP
Created May 10, 2010 09:25
Show Gist options
  • Save KushalP/395860 to your computer and use it in GitHub Desktop.
Save KushalP/395860 to your computer and use it in GitHub Desktop.
/*
HTTP Host: static.ak.fbcdn.net
Generated: April 28th 2010 3:07:47 PM PDT
Machine: 10.16.140.106
Locale: nu_ll
Path: js/iphone/fb.js
*/
if (window.CavalryLogger) {
CavalryLogger.start_js(["js\/iphone\/fb.js"]);
}
(function () {
var a = 1000 * 60 * 10;
setInterval(refreshPage, a);
window.fb = {
searchInterval: 300,
showComposer: function (c, b) {
hide(c);
if (b) {
$("composer_textarea").value = "";
show($("composer_placeholder_button"));
} else {
show($("composer"));
$("composer_textarea").focus();
}
},
clearNotificationCount: function () {
hide($("notification_icon_count"));
show($("notification_icon_image"));
},
onSearchShow: function (b) {
if (this.search) delete(this.search);
this.search = new QuickSearch('search_results', $('search_box'), false, '/s.php', {}, fb.searchInterval, true);
},
onToolbarSearchShow: function (c, d, b) {
if (this.search) delete(this.search);
this.search = new QuickSearch('tabpage', $('search_box'), true, b, {
v: d,
s: 0
}, fb.searchInterval, false);
},
onPlacesToolbarSearchShow: function (b, c, d) {
if (this.search) delete this.search;
this.search = new QuickSearch('tabpage', $('search_box'), true, b, {
latitude: c,
longitude: d
}, fb.searchInterval, false);
},
toggleSearchProgress: function (b) {
if (b) {
show($("search_progress"));
hide($("search_results"));
} else {
hide($("search_progress"), true);
show($("search_results"));
}
},
submitForm: function (b, c) {
if (c.value !== '') {
disableForm(b);
iui.submitForm(b);
}
},
showAlerts: function (b) {
if (b.responseText) iui.displayMessage($("loading_page"), b.responseText);
},
changeLocale: function () {
var b = $('localeForm');
ajax("POST", "change_locale.php", {
locale: b.locale.value,
post_form_id: b.post_form_id.value,
fb_dtsg: b.fb_dtsg.value
}, function (c) {
window.location.href = '/index.php?' + Math.random();
});
},
clearSearch: function () {
iui.focusEditor($("search_box"), false, true);
this.search.reset();
},
updateUnreadMessagesCount: function () {
iui.ajaxReplaceNonPage('/ajax/inbox_count.php', null, $('unread_msg'), false);
},
updateNotificationsCount: function () {
iui.ajaxReplaceNonPage('/ajax/notification_count.php', null, $('notification'), false);
},
updatePager: function (b) {
iui.replaceElementWithSource($('UIIPhonePagerContainer'), b);
},
updateToolbar: function (b) {
iui.replaceElementWithSource($('toolbar'), b);
},
actOnRequest: function (b, f, d, e) {
var c = {
action: b,
id: f,
post_form_id: e
};
ajax('GET', '/reqs.php', c, function (g) {
iui.replaceElementWithSource($(d), '');
}, function (g) {
alert(g.responseText);
});
},
friendRequest: function (d, g, b, e, f) {
if (confirm(e)) {
var c = {
id: g,
action: b,
post_form_id: f
};
ajax('GET', '/reqs.php', c, function (h) {
iui.replaceElementWithSource($(d), '<div>' + h.responseText + '</div>');
}, function (h) {
alert(h.responseText);
});
}
},
expandLikes: function (b, c, event) {
iui.ajaxLink('/like_fans.php?story_id=' + c);
event.stopPropagation();
},
updateCurrentPage: function () {
iui.currentPage = $('page').firstElementChild;
},
updateHomePage: function () {
this.updateCurrentPage();
places.updatePlacesTab();
}
};
addEventListener("focus", function (event) {
if (event.target.form && !iui.currentDialog) {
var b = getElementsByClass(iui.currentPage, "editorBar", [])[0];
if (b) {
if (hasClass(b, "autoHide")) show(b);
b.scrollIntoView();
}
}
}, true);
addEventListener("blur", function (event) {
if (!iui.currentDialog) {
var b = getElementsByClass(iui.currentPage, "editorBar", [])[0];
if (b && hasClass(b, "autoHide")) setTimeout(function () {
hide(b);
}, 500);
}
}, true);
})();
function disableForm(b, a) {
for (var e in {
input: 0,
textarea: 0
}) {
var d = b.getElementsByTagName(e);
for (var c = 0; c < d.length; ++c) d[c].disabled = a;
}
}
function refreshPage() {
if (iui.currentPage.getAttribute("autoRefresh") == "true") iui.refresh();
fb.updateUnreadMessagesCount();
fb.updateNotificationsCount();
}
function QuickSearch(f, g, e, c, a, b, i) {
this.resultsBoxId = f;
this.searchBox = g;
this.lastSearchText = "";
this.args = a;
var h = this;
var d;
iui.addClass(g, 'input_placeholder');
g.onfocus = function () {
d = setInterval(k, b);
g.addEventListener("blur", j, false);
};
this.reset = function () {
iui.focusEditor(this.searchBox, false, true);
$(this.resultsBoxId).innerHTML = this.lastSearchText = "";
};
function j() {
g.removeEventListener("blur", j, false);
clearInterval(d);
if (h.req) h.req.abort();
if (g.getAttribute("resetSearch") == "true") h.reset();
}
function k(event) {
var n = h.searchBox.value;
if (h.lastSearchText != n) {
h.lastSearchText = n;
if (h.req) h.req.abort();
if (i) fb.toggleSearchProgress(true);
var l = h.args;
l.q = n;
var m = function (o) {
if (o.responseText) {
if (i) fb.toggleSearchProgress(false);
if (e) {
iui.replaceElementWithSource($(h.resultsBoxId), o.responseText);
} else {
$(h.resultsBoxId).innerHTML = o.responseText;
iui.prepContent($(h.resultsBoxId));
}
delete h.req;
}
};
h.req = ajax('GET', c, l, m);
}
}
}
function gotoFullSite(b) {
var c = null;
var a = document.getElementById("active_tab_page");
if (a) c = a.getAttribute("full_site_uri");
if (c == null || c.length == 0) c = b;
window.location.href = c;
}
places = {
pending: false,
onFailure: function () {
places.pending = false;
alert('Failed to obtain your current location.');
},
onGotoPlacesPageSuccess: function (a) {
if (places.pending) {
var b = '/places.php?t&latitude=' + a.coords.latitude + '&longitude=' + a.coords.longitude;
iui.ajaxLink(b);
places.pending = false;
}
},
gotoPlacesPage: function () {
if (places.pending) return;
if (navigator.geolocation) {
places.pending = true;
navigator.geolocation.getCurrentPosition(places.onGotoPlacesPageSuccess, places.onFailure, {
enableHighAccuracy: true
});
} else alert('GeoLocation is not supported by your browser');
},
showCheckInForm: function () {
$("places_checkin_button_inative").style.display = "none";
$("composer_form").style.display = "block";
},
submitCheckin: function (a) {
if (places.pending) {
var b = ["latitude", "longitude", "accuracy", "altitude", "altitudeAccuracy", "heading", "speed"];
$("position").value = JSON.stringify(a.coords, b);
iui.submitForm($("composer_form"));
places.pending = false;
}
},
onCheckInFormSubmit: function () {
if (places.pending) return;
if (navigator.geolocation) {
places.pending = true;
navigator.geolocation.getCurrentPosition(places.submitCheckin, places.onFailure, {
enableHighAccuracy: true
});
} else alert('GeoLocation is not supported by your browser');
},
updatePlacesTab: function () {
if (!navigator.geolocation) $("places_tab").style.display = "none";
}
};
if (window.Bootloader) {
Bootloader.done(["js\/iphone\/fb.js"]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment