Add php.net lookup
This commit is contained in:
parent
2f35f0d9a3
commit
815b598b09
|
@ -46,4 +46,4 @@ Licensed under the <a href="http://www.opensource.org/licenses/mit-license.php">
|
|||
|
||||
<a href="http://jquery.com/">jQuery</a>
|
||||
Copyright 2014 jQuery Foundation and other contributors
|
||||
Licensed under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a>
|
||||
Licensed under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a>
|
||||
|
|
|
@ -17,13 +17,10 @@ form { padding: 0; margin: 0; }
|
|||
|
||||
|
||||
.button {
|
||||
|
||||
-moz-border-radius:3px;
|
||||
-webkit-border-radius:3px;
|
||||
border-radius:3px;
|
||||
|
||||
border: 1px solid #000;
|
||||
|
||||
display:inline-block;
|
||||
font-family:arial;
|
||||
font-size:13px;
|
||||
|
@ -31,16 +28,9 @@ form { padding: 0; margin: 0; }
|
|||
padding: 6px 15px;
|
||||
line-height:normal;
|
||||
text-decoration:none;
|
||||
|
||||
}
|
||||
.button:hover {
|
||||
background-color:#646464;
|
||||
cursor: pointer;
|
||||
}
|
||||
.button:active {
|
||||
position:relative;
|
||||
top:1px;
|
||||
}
|
||||
.button:hover { background-color:#646464; cursor: pointer; }
|
||||
.button:active { position: relative; top: 1px; }
|
||||
a.button { padding: 6px 0; }
|
||||
|
||||
.icon { vertical-align: text-top; }
|
||||
|
@ -72,6 +62,15 @@ a.button { padding: 6px 0; }
|
|||
.subdrop > div { position: absolute; top: -5px; left: -9999px; z-index: 9997; width: 200px; background-color: #222; padding: 5px 0; box-shadow: 5px 5px 10px #111;
|
||||
-webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;user-select: none; cursor: default; }
|
||||
|
||||
.php_logo { display: inline-block; background-color: #8892bf; color: #000; font-style: italic; font-weight: bold; padding: 0 5px; font-size: 14px; height: 22px; line-height: 22px; border-top-left-radius: 3px; border-bottom-left-radius: 3px; }
|
||||
#php_search { width: 150px; border: 1px solid #000; padding: 2px; margin: 0; }
|
||||
#php_search_drop { position: absolute; top: 40px; left: -100px; z-index: 9999; background-color: #000; width: 300px; display: none; }
|
||||
#php_search_drop .backend { height: 30px; line-height: 30px; font-size: 14px; background-color: #8892bf; color: #fff; border-bottom: 2px solid #4F5B93; padding-left: 10px; font-weight: bold; }
|
||||
#php_search_drop .container { max-height: 200px; overflow-y: auto; overflow-x: hidden; }
|
||||
#php_search_drop .search_result { background-color: #e2e4ef; color: #333; border-bottom: 1px solid #4f5b93; line-height: normal; padding: 2px; cursor: pointer; }
|
||||
#php_search_drop .search_result .desc { font-size: 10px; }
|
||||
#php_search_drop .search_result:hover { background-color: #4f5b93; color: #fff; }
|
||||
|
||||
#help_window { text-align: center; }
|
||||
#help_window .button { margin-left: 0; }
|
||||
#help_window h2 { margin-top: 0; }
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
|
@ -69,6 +69,7 @@ if (isset($_POST['runphp_data'])) {
|
|||
<script type="text/javascript" src="js/jquery-ui-1.10.3.custom.min.js"></script>
|
||||
<script type="text/javascript" src="js/ace/ace.js" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="js/knockout-3.1.0.js"></script>
|
||||
<script type="text/javascript" src="js/php_search.js"></script>
|
||||
<script type="text/javascript" src="js/run_php_code.js"></script>
|
||||
|
||||
<link rel="shortcut icon" href="favicon.ico" >
|
||||
|
@ -135,7 +136,7 @@ if (isset($_POST['runphp_data'])) {
|
|||
<h2>Run PHP Code</h2>
|
||||
|
||||
<p>
|
||||
<img src="img/website_duck.png" alt="" style="width: 40px; height: 40px;" /><br>
|
||||
<img src="img/website_duck.png" alt="" style="width: 40px; height: 40px;"><br>
|
||||
© Website Duck LLC<br />
|
||||
</p>
|
||||
|
||||
|
@ -171,6 +172,11 @@ if (isset($_POST['runphp_data'])) {
|
|||
<button class="button" type="button" data-bind="click: clear"><i class="fa fa-eraser"></i> Clear</button>
|
||||
<button class="button" type="button" title="Run (Ctrl+Enter)" data-bind="click: run">Run <i class="fa fa-play"></i></button>
|
||||
</div>
|
||||
|
||||
<div style="position: relative; display: inline-block; margin-left: 10px;">
|
||||
<span class="php_logo">php</span><input type="text" id="php_search">
|
||||
<div id="php_search_drop"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="code_div" data-bind="style: { width: code_width() + 'px' }"></div>
|
||||
|
|
|
@ -0,0 +1,144 @@
|
|||
/**
|
||||
* A jQuery plugin to add typeahead search functionality to the navbar search
|
||||
* box. This requires Hogan for templating and typeahead.js for the actual
|
||||
* typeahead functionality.
|
||||
*
|
||||
* Stolen from php.net and modified for use with Run PHP Code
|
||||
*
|
||||
*/
|
||||
(function ($) {
|
||||
|
||||
$.fn.search = function (options) {
|
||||
var element = this;
|
||||
|
||||
options.language = options.language || "en";
|
||||
options.limit = options.limit || 30;
|
||||
|
||||
var backends = {
|
||||
"function": { label: "Functions", elements: [] },
|
||||
"variable": { label: "Variables", elements: [] },
|
||||
"class": { label: "Classes", elements: [] },
|
||||
"exception": { label: "Exceptions", elements: [] },
|
||||
"extension": { label: "Extensions", elements: [] },
|
||||
"general": { label: "Other Matches", elements: [] }
|
||||
};
|
||||
|
||||
$.get('php_search_index.json', function(index) {
|
||||
$.each(index, function (id, item) {
|
||||
// If the item has a name, then we should figure out what type
|
||||
// of data this is, and hence which backend this should go into.
|
||||
if (item[0]) {
|
||||
var tokens = [item[0]];
|
||||
var type = null;
|
||||
|
||||
/*
|
||||
if (item[0].indexOf("_") != -1) {
|
||||
tokens.push(item[0].replace("_", ""));
|
||||
}
|
||||
if (item[0].indexOf("::") != -1) {
|
||||
// We'll add tokens to make the autocompletion more
|
||||
// useful: users can search for method names and can
|
||||
// specify that they only want method names by
|
||||
// prefixing their search with ::.
|
||||
tokens.push(item[0].split("::")[1]);
|
||||
tokens.push("::" + item[0].split("::")[1]);
|
||||
}
|
||||
*/
|
||||
|
||||
switch(item[2]) {
|
||||
case "phpdoc:varentry": type = "variable"; break;
|
||||
case "refentry": type = "function"; break;
|
||||
case "phpdoc:exceptionref": type = "exception"; break;
|
||||
case "phpdoc:classref": type = "class"; break;
|
||||
|
||||
case "set":
|
||||
case "book":
|
||||
case "reference":
|
||||
type = "extension"; break;
|
||||
|
||||
case "section":
|
||||
case "chapter":
|
||||
case "appendix":
|
||||
case "article":
|
||||
default:
|
||||
type = "general";
|
||||
}
|
||||
|
||||
if (type) {
|
||||
backends[type].elements.push({ id: id, name: item[0], description: item[1], tokens: tokens });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$.each(backends, function(id, backend) {
|
||||
$('#php_search_drop').append('<div class="backend" data-backend-id="' + id + '">' + backend.label + '</div><div class="container" data-backend-id="' + id + '"></div>');
|
||||
|
||||
backend.elements.sort(function (a, b) {
|
||||
var a = a.name;
|
||||
var b = b.name;
|
||||
|
||||
var aIsMethod = (a.indexOf("::") != -1);
|
||||
var bIsMethod = (b.indexOf("::") != -1);
|
||||
|
||||
// Methods are always after regular functions.
|
||||
if (aIsMethod && !bIsMethod) return 1;
|
||||
else if (bIsMethod && !aIsMethod) return -1;
|
||||
|
||||
// If one function name is the exact prefix of the other, we want
|
||||
// to sort the shorter version first (mostly for things like date()
|
||||
// versus date_format()).
|
||||
if (a.length > b.length && a.indexOf(b) == 0) return 1;
|
||||
else if (b.indexOf(a) == 0) return -1;
|
||||
|
||||
if (a > b) return 1;
|
||||
else if (a < b) return -1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}, 'json');
|
||||
|
||||
$(element).keyup(function() {
|
||||
var search_string = $(this).val();
|
||||
if (search_string === '') $('#php_search_drop').hide();
|
||||
else {
|
||||
$.each(backends, function(id, backend) {
|
||||
var items = [];
|
||||
var add = false;
|
||||
for (var i = 0; i < backend.elements.length; i++) {
|
||||
var element = backend.elements[i];
|
||||
var token = element.tokens.join(' ');
|
||||
if (token.toLowerCase().indexOf(search_string.toLowerCase()) > -1) {
|
||||
items.push('<div class="search_result" data-php-id="' + element.id + '">' + element.name + '<br><span class="desc">' + element.description + '</span></div>');
|
||||
}
|
||||
if (items.length > 100) break;
|
||||
}
|
||||
$header = $('#php_search_drop .backend[data-backend-id="' + id + '"]');
|
||||
$container = $('#php_search_drop .container[data-backend-id="' + id + '"]');
|
||||
$container.html('');
|
||||
$.fn.append.apply($('#php_search_drop .container[data-backend-id="' + id + '"]'), items);
|
||||
if (items.length > 0) $header.show();
|
||||
else $header.hide();
|
||||
});
|
||||
$('#php_search_drop').show();
|
||||
}
|
||||
});
|
||||
|
||||
$('#php_search_drop').on('click', '.search_result', function() {
|
||||
window.open('http://www.php.net/manual/en/' + $(this).data('php-id') + '.php');
|
||||
$('#php_search_drop').hide();
|
||||
});
|
||||
|
||||
$(element).click(function() {
|
||||
if ($(this).val() !== '') $('#php_search_drop').show();
|
||||
});
|
||||
|
||||
$(document).click(function(e) {
|
||||
if( $(e.target).closest("#php_search_drop").length > 0 ) return false;
|
||||
if (e.target.id === 'php_search') return false;
|
||||
$('#php_search_drop').hide();
|
||||
});
|
||||
};
|
||||
|
||||
})(jQuery);
|
|
@ -205,8 +205,15 @@ var View_Model = function() {
|
|||
.css('border-color', shadeColor(bgcolor,-20))
|
||||
.css('box-shadow', '0px 1px 0px 0px ' + shadeColor(bgcolor,20) + ' inset')
|
||||
.css('color', color);
|
||||
if (self.light_theme()) $('#resize_bar').css('backgroundColor', shadeColor(bgcolor,-20));
|
||||
else $('#resize_bar').css('backgroundColor', shadeColor(bgcolor,20));
|
||||
$('#php_search').css('color', color);
|
||||
if (self.light_theme()) {
|
||||
$('#resize_bar').css('backgroundColor', shadeColor(bgcolor,-20));
|
||||
$('#php_search').css('border-color', shadeColor(bgcolor,-20)).css('backgroundColor', shadeColor(bgcolor,20));
|
||||
}
|
||||
else {
|
||||
$('#resize_bar').css('backgroundColor', shadeColor(bgcolor,20));
|
||||
$('#php_search').css('border-color', shadeColor(bgcolor,20)).css('backgroundColor', shadeColor(bgcolor,-20));
|
||||
}
|
||||
if (self.settings.colorize()) {
|
||||
$('#result_frame').css('backgroundColor', shadeColor(bgcolor,-2));
|
||||
$('#result_frame').contents().find('html')
|
||||
|
@ -265,6 +272,7 @@ var View_Model = function() {
|
|||
});
|
||||
|
||||
$(window).resize(function() { self.resize_window($(this).width(), $(this).height()); }).resize();
|
||||
$('#php_search').search({language: 'en', limit: 30});
|
||||
};
|
||||
|
||||
var vm;
|
||||
|
@ -363,7 +371,7 @@ $(function() {
|
|||
}
|
||||
});
|
||||
|
||||
$('#title_bar').click(function() { setTimeout(function() {vm.editor.focus();}, 50); });
|
||||
$('#title_bar .drop, #title_bar button').click(function() { setTimeout(function() {vm.editor.focus();}, 50); });
|
||||
});
|
||||
|
||||
//http://stackoverflow.com/questions/5560248/programmatically-lighten-or-darken-a-hex-color
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue