Файл: error-kitty/lib/error-kitty/views/script.js
Строк: 157
<?php
/**
* This debug page is based on Better Errors, under MIT LICENSE.
* https://github.com/charliesome/better_errors
*
* Copyright (c) 2014 Charlie Somerville
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
(function () {
var previousFrame = null;
var previousFrameInfo = null;
var allFrames = document.querySelectorAll("ul.frames li");
var allFrameInfos = document.querySelectorAll(".frame_info");
function escapeHTML(html) {
return html.replace(/&/, "&").replace(/</g, "<");
}
function switchTo(el) {
if(previousFrameInfo) previousFrameInfo.style.display = "none";
previousFrameInfo = el;
el.style.display = "block";
var replInput = el.querySelector(".console input");
if (replInput) replInput.focus();
}
function selectFrameInfo(index) {
var el = allFrameInfos[index];
if (el) return switchTo(el);
}
for(var i = 0; i < allFrames.length; i++) {
(function (i, el) {
var el = allFrames[i];
el.onclick = function () {
if(previousFrame) {
previousFrame.className = "";
}
el.className = "selected";
previousFrame = el;
selectFrameInfo(el.attributes["data-index"].value);
};
})(i);
}
// Click the first application frame
(
document.querySelector(".frames li.application") ||
document.querySelector(".frames li")
).onclick();
// This is the second query performed for frames; maybe the "allFrames" list
// currently used and this list can be better used to avoid the repetition:
var applicationFramesCount = document.querySelectorAll(
"ul.frames li[data-context=application]"
).length;
var applicationFramesButtonIsInstalled = false;
var applicationFramesButton = document.getElementById("application_frames");
var allFramesButton = document.getElementById("all_frames");
// The application frames button only needs to be bound if
// there are actually any application frames to look at.
var installApplicationFramesButton = function () {
applicationFramesButton.onclick = function () {
allFramesButton.className = "";
applicationFramesButton.className = "selected";
for(var i = 0; i < allFrames.length; i++) {
if(allFrames[i].attributes["data-context"].value == "application") {
allFrames[i].style.display = "block";
} else {
allFrames[i].style.display = "none";
}
}
return false;
};
applicationFramesButtonIsInstalled = true;
}
allFramesButton.onclick = function () {
if(applicationFramesButtonIsInstalled) {
applicationFramesButton.className = "";
}
allFramesButton.className = "selected";
for(var i = 0; i < allFrames.length; i++) {
allFrames[i].style.display = "block";
}
return false;
};
// If there are no application frames, select the "All Frames"
// tab by default.
if(applicationFramesCount > 0) {
installApplicationFramesButton();
applicationFramesButton.onclick();
} else {
applicationFramesButton.className = "disabled";
applicationFramesButton.title = "No application frames available";
allFramesButton.onclick();
}
})();
?>