2009-08-20 05:07:50 +04:00
|
|
|
<?php
|
|
|
|
require_once('init.php');
|
|
|
|
get_ldap_connection();
|
|
|
|
require_once('templates/header.php');
|
|
|
|
?>
|
2009-08-20 00:16:54 +04:00
|
|
|
<div id="results">
|
|
|
|
</div>
|
2009-07-29 05:51:51 +04:00
|
|
|
|
2009-08-20 00:16:54 +04:00
|
|
|
<script type="text/javascript">
|
|
|
|
Function.prototype.lazify = function() {
|
|
|
|
var cache = {};
|
|
|
|
return this.wrap(function(original, x) {
|
|
|
|
return cache[x] ? cache[x] : (cache[x] = original(x));
|
|
|
|
});
|
|
|
|
};
|
2009-07-29 05:51:51 +04:00
|
|
|
|
2009-08-20 00:16:54 +04:00
|
|
|
Number.emToPx = function(x) {
|
|
|
|
var div = new Element("div").setStyle({
|
|
|
|
position: "absolute", margin: "0", padding: "0", visibility: "none",
|
|
|
|
width: x + "em", height: "9px", top: "-100000em", left: "-100000em"
|
|
|
|
});
|
|
|
|
$(document.body).insert(div);
|
|
|
|
var px = div.getWidth();
|
|
|
|
div.remove();
|
|
|
|
return px;
|
|
|
|
}.lazify();
|
2009-07-29 05:51:51 +04:00
|
|
|
|
2009-08-20 00:16:54 +04:00
|
|
|
(function() {
|
|
|
|
var cards = 2;
|
|
|
|
Event.observe(Prototype.resizeTarget, "resize", function() {
|
|
|
|
var c = Math.floor(document.viewport.getWidth() / Number.emToPx(1) / 31);
|
|
|
|
if (cards != c && c != 0) {
|
|
|
|
$("results").setStyle({width: ((cards = c) * 31) + "em"});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})();
|
2009-07-29 05:51:51 +04:00
|
|
|
|
2009-08-20 00:16:54 +04:00
|
|
|
$(document).observe("keypress", function(e) {
|
|
|
|
if ((e.charCode || e.keyCode) == 47) { // KEY_SLASH
|
|
|
|
$("text").focus(); e.stop();
|
|
|
|
}
|
|
|
|
});
|
2009-07-29 05:51:51 +04:00
|
|
|
|
2009-08-20 00:16:54 +04:00
|
|
|
$(document).observe("dom:loaded", function() {
|
2009-08-21 14:26:36 +04:00
|
|
|
$("menu").down("a.card").addClassName("selected");
|
|
|
|
$(document).observe("hash:changed", function(e) {
|
|
|
|
$("text").value = e.memo.hash.replace("search/", '');
|
2009-08-20 00:16:54 +04:00
|
|
|
startSearch();
|
|
|
|
});
|
2009-07-29 05:51:51 +04:00
|
|
|
|
2009-08-20 00:16:54 +04:00
|
|
|
$("phonebook-search").observe("submit", function(e) {
|
|
|
|
e.stop();
|
|
|
|
window.location.hash = "#search/" + $F("text");
|
|
|
|
});
|
2009-07-29 05:51:51 +04:00
|
|
|
|
2009-08-20 00:16:54 +04:00
|
|
|
var stoppedResizing = false;
|
|
|
|
if (window.location.hash.startsWith("#search/")) {
|
|
|
|
$(document).fire("hash:changed", {hash: window.location.hash.substring(1)});
|
|
|
|
} else {
|
|
|
|
$("phonebook-search").addClassName("large");
|
|
|
|
$("header").verticallyCenter();
|
|
|
|
Event.observe(Prototype.resizeTarget, "resize", centralize);
|
|
|
|
$("text").focus();
|
|
|
|
}
|
2009-07-29 05:51:51 +04:00
|
|
|
|
2009-08-20 00:16:54 +04:00
|
|
|
function centralize() {
|
|
|
|
if (!arguments.callee.stop) {
|
|
|
|
$("header").verticallyCenter();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function startSearch() {
|
|
|
|
if (!$F("text").strip()) {
|
|
|
|
window.location = "./";
|
|
|
|
}
|
|
|
|
if (!stoppedResizing) {
|
|
|
|
centralize.stop = true;
|
|
|
|
stoppedResizing = true;
|
|
|
|
$("header").stopVerticallyCentering();
|
|
|
|
$("phonebook-search").removeClassName("large");
|
|
|
|
}
|
|
|
|
$("phonebook-search").request({onSuccess: function onSuccess(r) {
|
|
|
|
$("results").update('').update(r.responseText ||
|
|
|
|
'<div style="text-align: center; margin-top: 5em;">' +
|
|
|
|
'<img src="./img/ohnoes.jpg" />' +
|
|
|
|
'<h2>OH NOES! No ones were foundz.</h2>' +
|
|
|
|
'</div>'
|
|
|
|
);
|
|
|
|
$("text").releaseFocus();
|
|
|
|
}});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
<?php require_once('templates/footer.php'); ?>
|