mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
RGL Browse: version 2, including API search
Also using a jquery panel framework for layout stuff.
This commit is contained in:
@@ -10,6 +10,7 @@ basedir=${dir}/../../src
|
||||
tagsdir=${dir}/tags
|
||||
index=${dir}/index.json
|
||||
ignore="demo old-demo tmp"
|
||||
start=`date +%s`
|
||||
|
||||
# Function for testing array membership
|
||||
in_ignore() {
|
||||
@@ -34,8 +35,12 @@ do
|
||||
echo " \"${dir}\": [" >> $index
|
||||
find -maxdepth 1 -name '*.gf' | while read -r file
|
||||
do
|
||||
gf --batch --quiet --tags --output-dir=${tagsdir} $file 2>/dev/null
|
||||
echo " \""`echo $file | sed 's|./||;s|.gf||'`"\"," >> $index
|
||||
filemtime=`stat -c %Y "${tagsdir}/${file}-tags"` 2>/dev/null
|
||||
if [ -z "$filemtime" ] || [ "$filemtime" -lt "$start" ]
|
||||
then
|
||||
gf --batch --quiet --tags --output-dir=${tagsdir} $file 2>/dev/null
|
||||
fi
|
||||
done
|
||||
echo " \"\"\n ]," >> $index
|
||||
fi
|
||||
|
||||
@@ -1,55 +1,75 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>RGL Source Browser</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<link rel="shortcut icon" href="icon.png" type="image/png">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<link rel="stylesheet" href="google-code-prettify/prettify-gf.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<img src="../../../doc/Logos/gf0.png" alt="" />
|
||||
<h1 title="...or ‘GFRGLSB’ as we like to call it">GF Resource Grammar Library Source Browser</h1>
|
||||
<a class="tab help" href="#help">Help</a>
|
||||
<a href="http://www.grammaticalframework.org/lib/doc/synopsis.html" target="_blank">Synopsis...</a>
|
||||
</header>
|
||||
<div id="loading">
|
||||
<img src="ajax-loader.gif" /> Loading...
|
||||
</div>
|
||||
<div role="main">
|
||||
<div class="pane left">
|
||||
<div id="languages"></div>
|
||||
<div id="modules" class="maxheight scroll-y"></div>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>RGL Source Browser</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<link rel="shortcut icon" href="icon.png" type="image/png">
|
||||
<link rel="stylesheet" href="google-code-prettify/prettify-gf.css">
|
||||
<link rel="stylesheet" href="http://layout.jquery-dev.net/lib/css/layout-default-latest.css" />
|
||||
<link rel="stylesheet" href="style.css">
|
||||
|
||||
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
|
||||
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
|
||||
<script type="text/javascript" src="http://layout.jquery-dev.net/lib/js/jquery.layout-latest.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
$('body').layout({
|
||||
applyDemoStyles: false,
|
||||
north: {
|
||||
closable: false,
|
||||
resizable: false,
|
||||
spacing_open: 0,
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script src="jquery.history.min.js"></script>
|
||||
<script src="google-code-prettify/prettify.js"></script>
|
||||
<script src="google-code-prettify/lang-gf.js"></script>
|
||||
<script src="script.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="loading">
|
||||
<img src="ajax-loader.gif" /> Loading...
|
||||
</div>
|
||||
<div class="pane right">
|
||||
|
||||
<div class="ui-layout-center">
|
||||
|
||||
<div id="tabbar">
|
||||
Module: <span id="module_name">...</span>
|
||||
<a class="tab scope" href="#scope">scope</a>
|
||||
<a class="tab code" href="#code">code</a>
|
||||
<a class="tab api" href="#api">API</a>
|
||||
</div>
|
||||
<div id="scope" class="panel scope maxheight">
|
||||
<div id="scope_controls">
|
||||
<div id="scope" class="panel scope">
|
||||
<div id="controls">
|
||||
<input type="text" id="search" />
|
||||
<span id="scope_count">0</span> items
|
||||
<input type="submit" id="submit" value="Filter" />
|
||||
<span id="count">0</span> items
|
||||
<input type="reset" id="clear" value="Clear" />
|
||||
<input type="checkbox" id="case_sensitive" /><label for="case_sensitive">Case sensitive?</label>
|
||||
<!-- input type="checkbox" id="case_sensitive" /><label for="case_sensitive">Case sensitive?</label -->
|
||||
<input type="radio" name="show" id="show_all" checked="checked" /><label for="show_all">Show all</label>
|
||||
<input type="radio" name="show" id="show_local" /><label for="show_local">Local only</label>
|
||||
</div>
|
||||
<div class="maxheight scroll-y">
|
||||
<table id="scope_list"></table>
|
||||
<table id="results"></table>
|
||||
</div>
|
||||
<div id="code" class="panel code">
|
||||
<pre class="prettyprint lang-gf linenums"></pre>
|
||||
</div>
|
||||
<div id="api" class="panel api">
|
||||
Search the API by constructor name <strong>or</strong> type signature:
|
||||
<div id="controls">
|
||||
<input type="text" id="search" />
|
||||
<span id="count">0</span> items
|
||||
<input type="reset" id="clear" value="Clear" />
|
||||
</div>
|
||||
<table id="results"></table>
|
||||
|
||||
</div>
|
||||
<div id="code" class="panel code maxheight">
|
||||
<pre class="prettyprint lang-gf linenums maxheight scroll-y"></pre>
|
||||
</div>
|
||||
<div id="help" class="panel help maxheight">
|
||||
<div class="maxheight scroll-y">
|
||||
<div id="help" class="panel help">
|
||||
|
||||
<h3>About</h3>
|
||||
<p>A basic tool for looking through scopes and quickly jumping to code within GF's resource grammar library (RGL), created out of necessity. All feedback is welcome.</p>
|
||||
@@ -87,23 +107,26 @@
|
||||
<h4>Something is missing or out of date</h4>
|
||||
<p>All the scoping information shown is not read directly from the RGL on-demand. There is an in-between processing stage which must be run, so if something seems out of date just let me know and I can udpate things manually.</p>
|
||||
|
||||
<h4>To-Do</h4>
|
||||
<ul>
|
||||
<li>Some way of browsing just the API</li>
|
||||
<li>The page sometimes stalls when handling large files (in particular the dictionary modules)</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br style="clear:both" />
|
||||
</div>
|
||||
<footer id="footer">
|
||||
John J. Camilleri<br/><em>Updated 2013-05-24</em>
|
||||
</footer>
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
|
||||
<script src="jquery.history.min.js"></script>
|
||||
<script src="google-code-prettify/prettify.js"></script>
|
||||
<script src="google-code-prettify/lang-gf.js"></script>
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<div class="ui-layout-north">
|
||||
<header>
|
||||
<img src="../../../doc/Logos/gf0.png" alt="" />
|
||||
<h1 title="...or ‘GFRGLSB’ as we like to call it">GF Resource Grammar Library Source Browser</h1>
|
||||
<a class="tab help" href="#help">Help</a>
|
||||
<a href="http://www.grammaticalframework.org/lib/doc/synopsis.html" target="_blank">Synopsis...</a>
|
||||
</header>
|
||||
|
||||
<footer id="footer">
|
||||
John J. Camilleri<br/><em>Updated 2013-07-23</em>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
<div class="ui-layout-west">
|
||||
<div id="languages"></div>
|
||||
<div id="modules"></div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
18
lib/doc/browse/jquery.history.min.js
vendored
18
lib/doc/browse/jquery.history.min.js
vendored
@@ -1,15 +1,3 @@
|
||||
/*
|
||||
MIT License {@link http://creativecommons.org/licenses/MIT/}
|
||||
MIT License {@link http://creativecommons.org/licenses/MIT/}
|
||||
*/
|
||||
"undefined"===typeof window.console&&(window.console={});
|
||||
"undefined"===typeof window.console.emulated&&("function"===typeof window.console.log?window.console.hasLog=!0:("undefined"===typeof window.console.log&&(window.console.log=function(){}),window.console.hasLog=!1),"function"===typeof window.console.debug?window.console.hasDebug=!0:("undefined"===typeof window.console.debug&&(window.console.debug=!window.console.hasLog?function(){}:function(){for(var b=["console.debug:"],a=0;a<arguments.length;a++)b.push(arguments[a]);window.console.log.apply(window.console,
|
||||
b)}),window.console.hasDebug=!1),"function"===typeof window.console.warn?window.console.hasWarn=!0:("undefined"===typeof window.console.warn&&(window.console.warn=!window.console.hasLog?function(){}:function(){for(var b=["console.warn:"],a=0;a<arguments.length;a++)b.push(arguments[a]);window.console.log.apply(window.console,b)}),window.console.hasWarn=!1),"function"===typeof window.console.error?window.console.hasError=!0:("undefined"===typeof window.console.error&&(window.console.error=function(){var b=
|
||||
"An error has occured.";if(window.console.hasLog){for(var b=["console.error:"],a=0;a<arguments.length;a++)b.push(arguments[a]);window.console.log.apply(window.console,b);b="An error has occured. More information is available in your browser's javascript console."}for(a=0;a<arguments.length;++a){if(typeof arguments[a]!=="string")break;b=b+("\n"+arguments[a])}if(typeof Error!=="undefined")throw Error(b);throw b;}),window.console.hasError=!1),"function"===typeof window.console.trace?window.console.hasTrace=
|
||||
!0:("undefined"===typeof window.console.trace&&(window.console.trace=function(){window.console.error("console.trace does not exist")}),window.console.hasTrace=!1),window.console.emulated=!0);
|
||||
(function(b){if(b.History)window.console.warn("$.History has already been defined...");else{b.History={options:{debug:false},state:"",$window:null,$iframe:null,handlers:{generic:[],specific:{}},extractHash:function(a){return a.replace(/^[^#]*#/,"").replace(/^#+|#+$/,"")},getState:function(){return b.History.state},setState:function(a){var c=b.History,a=c.extractHash(a);c.state=a;return c.state},getHash:function(){return b.History.extractHash(window.location.hash||location.hash)},setHash:function(a){a=
|
||||
b.History.extractHash(a);if(typeof window.location.hash!=="undefined"){if(window.location.hash!==a)window.location.hash=a}else if(location.hash!==a)location.hash=a;return a},go:function(a){var c=b.History,a=c.extractHash(a),d=c.getHash(),f=c.getState();if(a!==d)c.setHash(a);else{a!==f&&c.setState(a);c.trigger()}return true},hashchange:function(){var a=b.History,c=a.getHash();a.go(c);return true},bind:function(a,c){var d=b.History;if(c){typeof d.handlers.specific[a]==="undefined"&&(d.handlers.specific[a]=
|
||||
[]);d.handlers.specific[a].push(c)}else d.handlers.generic.push(a);return true},trigger:function(a){var c=b.History;typeof a==="undefined"&&(a=c.getState());var d,f,g,e;if(typeof c.handlers.specific[a]!=="undefined"){e=c.handlers.specific[a];d=0;for(f=e.length;d<f;++d){g=e[d];g(a)}}e=c.handlers.generic;d=0;for(f=e.length;d<f;++d){g=e[d];g(a)}return true},construct:function(){var a=b.History;b(document).ready(function(){a.domReady()});return true},configure:function(a){var c=b.History;c.options=b.extend(c.options,
|
||||
a);return true},domReadied:false,domReady:function(){var a=b.History;if(!a.domRedied){a.domRedied=true;a.$window=b(window);a.$window.bind("hashchange",this.hashchange);setTimeout(a.hashchangeLoader,200);return true}},nativeSupport:function(a){var a=a||b.browser,c=a.version,d=parseInt(c,10),f=c.split(/[^0-9]/g),c=parseInt(f[0],10),g=parseInt(f[1],10),f=parseInt(f[2],10),e=false;a.msie&&d>=8?e=true:a.webkit&&d>=528?e=true:a.mozilla?c>1?e=true:c===1&&(g>9?e=true:g===9&&f>=2&&(e=true)):a.opera&&(c>10?
|
||||
e=true:c===10&&g>=60&&(e=true));return e},hashchangeLoader:function(){var a=b.History;if(a.nativeSupport())a.getHash()&&a.$window.trigger("hashchange");else{var c;if(b.browser.msie){a.$iframe=b('<iframe id="jquery-history-iframe" style="display: none;"></$iframe>').prependTo(document.body)[0];a.$iframe.contentWindow.document.open();a.$iframe.contentWindow.document.close();var d=false;c=function(){var b=a.getHash(),c=a.getState(),e=a.extractHash(a.$iframe.contentWindow.document.location.hash);if(c!==
|
||||
b){if(!d){a.$iframe.contentWindow.document.open();a.$iframe.contentWindow.document.close();a.$iframe.contentWindow.document.location.hash=b}d=false;a.$window.trigger("hashchange")}else if(c!==e){d=true;a.setHash(e)}}}else c=function(){var b=a.getHash();a.getState()!==b&&a.$window.trigger("hashchange")};setInterval(c,200)}return true}};b.History.construct()}})(jQuery);
|
||||
/*! jQuery.history v1.1.0 | Copyright 2013 yeikos - MIT license | https://github.com/yeikos/jquery.history */
|
||||
|
||||
;(function(e,t){var n=function(t){var i=e.Event("push");n.context.trigger(i,[t,u]);if(i.isDefaultPrevented())return n;if(u==="pathname"){if(c!==t)window.history.pushState({},null,c=t)}else if(u==="hash"){if(c!==t){location.hash=c=t;if(o){if(!e("#jQueryHistory").length)throw new Error("jQuery."+r+".push: iframe not found.");if(l){l=0;f.contentWindow.document.open().close();f.contentWindow.location.hash="/"}f.contentWindow.document.open().close();f.contentWindow.location.hash=t}}}else{throw new Error("jQuery."+r+".push: the listening is not active.")}n.context.trigger("pushed",[t,u]);return n},r="history";n.context=e({});e.each(["on","off","trigger"],function(e,t){n[t]=function(){n.context[t].apply(n.context,arguments);return n}});n.push=n;n.type=function(){return u};n.url=function(e){e=e||location;if(u===null)throw new Error("jQuery."+r+".url: the listening has not started.");if(u==="pathname")return e.pathname+e.search+e.hash;if(e.hash.length>1){spl=e.href.split("#");spl.shift();spl=spl.join("#");return spl}return""};n.listen=function(l,h){n.unlisten();var p=arguments.length;if(!p||l==="auto"){l=i?"pathname":"hash";p=1}else if(l!=="pathname"&&l!=="hash"){throw new Error("jQuery."+r+".listen: type is not valid.")}if(l==="hash"){if(!s&&p===1||h===true){h=n.config.interval;p=2}if(p===2&&(isNaN(h)||h<1))throw new Error("jQuery."+r+".listen: interval delay is not valid.")}if((u=l)==="pathname"){if(!i)throw new Error("jQuery."+r+".listen: this browser has not support to pushState.");e(window).on("popstate.history",function(e){if(e.originalEvent&&e.originalEvent.state&&c!==location.pathname)n.trigger("change",[c=n.url(),"pathname"])});if(location.pathname.length>1)n.trigger("load",[n.url(),"pathname"])}else{if(s&&!h){e(window).on("hashchange.history",function(e){var t=n.url();if(c!==t)n.trigger("change",[c=t,"hash"])})}else{if(o===t)o=n.ieCondition("lte IE 7");if(o){if(!(p=e("body")).length)throw new Error("jQuery."+r+".listen: document is not ready.");f=e('<iframe id="jQueryHistory" style="display:none" src="javascript:void(0);" />').appendTo(p)[0];var d=f.contentWindow;if(location.hash.length>1){d.document.open().close();d.location.hash="#"+n.url()}a=setInterval(function(){if((c="#"+n.url())!=="#"+n.url(d.location)){d.document.open().close();d.location.hash=c;n.trigger("change",[c.substr(1),"hash"])}},h)}else{c=n.url();a=setInterval(function(){var e=n.url();if(c!==e)n.trigger("change",[c=e,"hash"])},h)}}if(location.hash.length>1){n.trigger("load",[n.url(),"hash"])}}return n};n.unlisten=function(){u=c=f=null;e(window).off("popstate.history hashchange.history");e("#jQueryHistory").remove();clearInterval(a);return n};n.getSupports=function(e){var n={},r=arguments.length,i;if(!r||e==="pushState")n.pushState="pushState"in window.history;if(!r||e==="onhashchange")n.onhashchange="onhashchange"in window&&((i=document.documentMode)===t||i>7);if(r)return n[e];return n};n.ieCondition=function(n){var r=Math.random().toString(36).substring(2),i="_ie_condition_"+r,s,o;s=e("<span><!--[if "+e("<i/>").html(n).text()+']><script type="text/javascript">window.'+i+"=true;</script><![endif]--></span>").appendTo(document.body);o=window[i]===true;try{delete window[i]}catch(u){window[i]=t}s.remove();return o};n.supports=n.getSupports();n.config={interval:100};var i=n.supports.pushState,s=n.supports.onhashchange,o=n.ieCondition("lte IE 7"),u=null,a,f,l=1,c;e[r]=n})(jQuery);
|
||||
@@ -2,11 +2,44 @@
|
||||
GF RGL Browser
|
||||
John J. Camilleri, 2012
|
||||
*/
|
||||
$(document).ready(function() {
|
||||
|
||||
var thing = null;
|
||||
$(document).ready(function(){
|
||||
|
||||
thing = new Thing();
|
||||
|
||||
// ===== URL history =====
|
||||
$.history.on('load change push pushed', function(event, url, type) {
|
||||
var stripExt = function(s) {
|
||||
var i = s.lastIndexOf('.');
|
||||
return (i>-1) ? s.substr(0, i) : s;
|
||||
};
|
||||
|
||||
var s = url.split("/");
|
||||
var lang = s[0];
|
||||
var module = stripExt(s[1]);
|
||||
var parseLineNo = s[1].match(/:(\d+)(-(\d+))?$/);
|
||||
|
||||
if (thing.state.current.equals(lang, module)) {
|
||||
if (parseLineNo) {
|
||||
scrollToCodeLine(parseInt(parseLineNo[1]));
|
||||
}
|
||||
// else there's nothing to do!
|
||||
} else {
|
||||
if (parseLineNo != null)
|
||||
thing.loadFile(lang, module, parseInt(parseLineNo[1]));
|
||||
else
|
||||
thing.loadFile(lang, module);
|
||||
}
|
||||
}).listen('hash');
|
||||
});
|
||||
|
||||
function Thing() {
|
||||
var t = this;
|
||||
|
||||
// ===== State information =====
|
||||
|
||||
state = {
|
||||
this.state = {
|
||||
index: undefined,
|
||||
lookup: {},
|
||||
loadCount: 0,
|
||||
@@ -15,14 +48,14 @@ $(document).ready(function() {
|
||||
language: undefined,
|
||||
module: undefined,
|
||||
set: function(lang, module) {
|
||||
state.current.language = lang;
|
||||
state.current.module = module;
|
||||
t.state.current.language = lang;
|
||||
t.state.current.module = module;
|
||||
},
|
||||
equals: function(a, b) {
|
||||
if (!b)
|
||||
return (a == state.current.module);
|
||||
return (a == t.state.current.module);
|
||||
else
|
||||
return (a == state.current.language) && (b == state.current.module);
|
||||
return (a == t.state.current.language) && (b == t.state.current.module);
|
||||
}
|
||||
},
|
||||
title: "RGL Source Browser",
|
||||
@@ -31,33 +64,32 @@ $(document).ready(function() {
|
||||
} ;
|
||||
|
||||
var lookupModuleLanguage = function(module) {
|
||||
var l = state.lookup[module];
|
||||
var l = t.state.lookup[module];
|
||||
if (l==undefined || l.length==0)
|
||||
return null;
|
||||
else if (l.length==1)
|
||||
return l[0];
|
||||
else {
|
||||
for (i in l) {
|
||||
if ($.inArray(l[i], state.defaultLangs))
|
||||
if ($.inArray(l[i], t.state.defaultLangs))
|
||||
return l[i];
|
||||
}
|
||||
return l[0]; // no preferred default, just return first...
|
||||
}
|
||||
}
|
||||
var lookupAllModuleLanguages = function(module) {
|
||||
return state.lookup[module];
|
||||
return t.state.lookup[module];
|
||||
}
|
||||
|
||||
|
||||
// ===== Utility/UI functions =====
|
||||
|
||||
var showLoading = function(){
|
||||
state.loadCount++;
|
||||
t.state.loadCount++;
|
||||
$("#loading").show();
|
||||
}
|
||||
var hideLoading = function(){
|
||||
state.loadCount = Math.max(state.loadCount-1, 0);
|
||||
if (state.loadCount == 0)
|
||||
t.state.loadCount = Math.max(t.state.loadCount-1, 0);
|
||||
if (t.state.loadCount == 0)
|
||||
$("#loading").hide();
|
||||
}
|
||||
|
||||
@@ -82,14 +114,14 @@ $(document).ready(function() {
|
||||
}
|
||||
|
||||
var clearScope = function(msg) {
|
||||
$('#scope_list').empty();
|
||||
$('#scope #results').empty();
|
||||
updateScopeCount();
|
||||
if (msg) {
|
||||
$('#scope_list').html("<em>"+msg+"</em>");
|
||||
$('#scope #results').html("<em>"+msg+"</em>");
|
||||
}
|
||||
}
|
||||
var setScope = function(code) {
|
||||
$('#scope_list').html(code);
|
||||
$('#scope #results').html(code);
|
||||
}
|
||||
var clearCode = function(msg) {
|
||||
$('#code pre').empty();
|
||||
@@ -102,22 +134,24 @@ $(document).ready(function() {
|
||||
prettyPrint();
|
||||
}
|
||||
var updateScopeCount = function(){
|
||||
$('#scope_count').text( $("#scope_list tr:visible").length );
|
||||
$('#scope #count').text( $("#scope #results tr:visible").length );
|
||||
}
|
||||
var updateAPICount = function(){
|
||||
$('#api #count').text( $("#api #results tr:visible").length );
|
||||
}
|
||||
|
||||
var setLanguage = function(lang){
|
||||
state.language = lang;
|
||||
t.state.language = lang;
|
||||
$("#languages select").val(lang);
|
||||
initModules(lang);
|
||||
}
|
||||
|
||||
// obj can be just a plain selector or a jQuery object
|
||||
var showPanel = function(obj, callback){
|
||||
this.showPanel = function(obj, callback){
|
||||
showLoading();
|
||||
setTimeout(function(){
|
||||
$(".panel:visible").hide();
|
||||
$(obj).show(0, callback);
|
||||
recalculateHeights();
|
||||
updateScopeCount();
|
||||
hideLoading();
|
||||
}, 500); // this ensures the loading displays
|
||||
@@ -128,28 +162,36 @@ $(document).ready(function() {
|
||||
|
||||
var setTitle = function(s){
|
||||
$('#module_name').html(s);
|
||||
$('title').html(state.title + ": " + s);
|
||||
$('title').html(t.state.title + ": " + s);
|
||||
}
|
||||
|
||||
|
||||
// ===== Initialization =====
|
||||
|
||||
// Initialize the panels, tabs
|
||||
$("a.tab").click(function(){
|
||||
var panel = $(this).attr("href");
|
||||
t.showPanel(panel);
|
||||
return false;
|
||||
});
|
||||
t.showPanel(".panel:first");
|
||||
|
||||
// Load the index file and populate language & module lists
|
||||
$.ajax({
|
||||
url: "index.json",
|
||||
dataType: "json",
|
||||
type: "GET",
|
||||
success: function(data) {
|
||||
state.index = data;
|
||||
if (data['urlprefix']) state.urlPrefix = data['urlprefix'];
|
||||
t.state.index = data;
|
||||
if (data['urlprefix']) t.state.urlPrefix = data['urlprefix'];
|
||||
|
||||
// Build language lookup index
|
||||
for (var lang in data['languages']) {
|
||||
for (var i in data['languages'][lang]) {
|
||||
var module = data['languages'][lang][i];
|
||||
if (!module) continue;
|
||||
if (!state.lookup[module]) state.lookup[module] = [];
|
||||
state.lookup[module].push(lang);
|
||||
if (!t.state.lookup[module]) t.state.lookup[module] = [];
|
||||
t.state.lookup[module].push(lang);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,6 +211,11 @@ $(document).ready(function() {
|
||||
.appendTo(lang_select);
|
||||
}
|
||||
setLanguage("english");
|
||||
|
||||
// Initialize API results
|
||||
initAPI();
|
||||
|
||||
// Done
|
||||
hideLoading();
|
||||
},
|
||||
error: function(){
|
||||
@@ -177,50 +224,15 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
// Initialize the panels, tabs
|
||||
$("a.tab").click(function(){
|
||||
var panel = $(this).attr("href");
|
||||
showPanel(panel);
|
||||
return false;
|
||||
});
|
||||
showPanel(".panel:first");
|
||||
|
||||
|
||||
// ===== URL history =====
|
||||
|
||||
$.History.bind(function(hash){
|
||||
var s = hash.split("/");
|
||||
var lang = s[0];
|
||||
var module = stripExt(s[1]);
|
||||
var parseLineNo = s[1].match(/:(\d+)(-(\d+))?$/);
|
||||
|
||||
if (state.current.equals(lang, module)) {
|
||||
if (parseLineNo) {
|
||||
scrollToCodeLine(parseInt(parseLineNo[1]));
|
||||
}
|
||||
// else there's nothing to do!
|
||||
} else {
|
||||
if (parseLineNo != undefined)
|
||||
loadFile(lang, module, parseInt(parseLineNo[1]));
|
||||
else
|
||||
loadFile(lang, module);
|
||||
}
|
||||
});
|
||||
|
||||
var stripExt = function(s) {
|
||||
var i = s.lastIndexOf('.');
|
||||
return (i>-1) ? s.substr(0, i) : s;
|
||||
};
|
||||
|
||||
|
||||
// ===== Loading functionality =====
|
||||
|
||||
// Initialize the module list
|
||||
var initModules = function(lang){
|
||||
state.index['languages'][lang] = state.index['languages'][lang].sort();
|
||||
t.state.index['languages'][lang] = t.state.index['languages'][lang].sort();
|
||||
$("#modules").empty();
|
||||
for (var i in state.index['languages'][lang]) {
|
||||
var module = state.index['languages'][lang][i];
|
||||
for (var i in t.state.index['languages'][lang]) {
|
||||
var module = t.state.index['languages'][lang][i];
|
||||
if (!module) continue;
|
||||
$('<a>')
|
||||
.html(module)
|
||||
@@ -230,9 +242,9 @@ $(document).ready(function() {
|
||||
};
|
||||
|
||||
// Load both scope & source for a file
|
||||
var loadFile = function(lang, module, lineNo){
|
||||
this.loadFile = function(lang, module, lineNo){
|
||||
setTitle(lang+"/"+module);
|
||||
state.current.set(lang, module);
|
||||
t.state.current.set(lang, module);
|
||||
loadTagsFile(module);
|
||||
loadSourceFile(lang, module, lineNo);
|
||||
}
|
||||
@@ -279,7 +291,7 @@ $(document).ready(function() {
|
||||
clearCode();
|
||||
showLoading();
|
||||
$.ajax({
|
||||
url: state.urlPrefix + "lib/src/"+lang+"/"+module+".gf",
|
||||
url: t.state.urlPrefix + "lib/src/"+lang+"/"+module+".gf",
|
||||
type: "GET",
|
||||
dataType: "text",
|
||||
success: function(data, status, xhr){
|
||||
@@ -296,6 +308,74 @@ $(document).ready(function() {
|
||||
});
|
||||
}
|
||||
|
||||
// Which modules do we include for API?
|
||||
var apiModules = [
|
||||
// api
|
||||
"Constructors",
|
||||
// abstract
|
||||
"Adjective",
|
||||
"Adverb",
|
||||
"Backward",
|
||||
"Cat",
|
||||
"Common",
|
||||
"Compatibility",
|
||||
"Conjunction",
|
||||
"Extra",
|
||||
"Grammar",
|
||||
"Idiom",
|
||||
"Lang",
|
||||
"Lexicon",
|
||||
"Noun",
|
||||
"Numeral",
|
||||
"NumeralTransfer",
|
||||
"Phrase",
|
||||
"Question",
|
||||
"Relative",
|
||||
"Sentence",
|
||||
"Structural",
|
||||
"Symbol",
|
||||
"Tense",
|
||||
"Text",
|
||||
"Transfer",
|
||||
"Verb",
|
||||
];
|
||||
var initAPI = function() {
|
||||
showLoading();
|
||||
$('#api #results').empty();
|
||||
for (var i in apiModules) {
|
||||
var module = apiModules[i];
|
||||
$.ajax({
|
||||
url: "tags/"+module+".gf-tags",
|
||||
type: "GET",
|
||||
dataType: "text",
|
||||
success: function(data){
|
||||
data = data.replace(/^(\S+)\s(\S+)\s(.+)?$/gm, function(a,b,c,d){
|
||||
var out = '';
|
||||
var s = d.split("\t");
|
||||
if (c != "indir") {
|
||||
var type = s[1];
|
||||
if (type) {
|
||||
var bits = s[0].split("/"); // ["lib", "src", "english", "AdjectiveEng.gf:43-46"]
|
||||
var name = bits[3]+"/"+bits[4];
|
||||
var url = "#"+bits[3]+"/"+bits[4];
|
||||
var anchor = '<a href="'+url+'">'+name+'</a>';
|
||||
out += '<tr name="'+b+'"><th>'+b+'</th><td>'+c+'</td><td>'+anchor+'</td><td>'+s[1]+'</td></tr>'
|
||||
}
|
||||
}
|
||||
return out;
|
||||
});
|
||||
$('#api #results').append($(data));
|
||||
$("#api #results tr").removeClass('odd');
|
||||
$("#api #results tr:odd").addClass('odd');
|
||||
},
|
||||
error: function(data){
|
||||
console.log("Error loading tags file: " + module);
|
||||
},
|
||||
});
|
||||
}
|
||||
hideLoading();
|
||||
}
|
||||
|
||||
|
||||
// ===== Filtering of scope info =====
|
||||
|
||||
@@ -306,7 +386,7 @@ $(document).ready(function() {
|
||||
var haystack = obj.attr('name');
|
||||
if (haystack == undefined)
|
||||
return false;
|
||||
if ($("#case_sensitive").is(":checked"))
|
||||
if ($("#scope #case_sensitive").is(":checked"))
|
||||
return haystack.indexOf(needle)>=0;
|
||||
else
|
||||
return haystack.toLowerCase().indexOf(needle.toLowerCase())>=0;
|
||||
@@ -314,97 +394,107 @@ $(document).ready(function() {
|
||||
|
||||
var runFilter = function() {
|
||||
showLoading();
|
||||
var s = $("#search").val();
|
||||
$("#scope #results tr").removeClass('odd');
|
||||
var s = $("#scope #search").val();
|
||||
try {
|
||||
if (s) {
|
||||
$("#scope_list tr:match(\""+s+"\")").show();
|
||||
$("#scope_list tr:not(:match(\""+s+"\"))").hide();
|
||||
$("#scope #results tr").hide();
|
||||
$("#scope #results tr:match(\""+s+"\")").show();
|
||||
} else {
|
||||
$("#scope_list tr").show();
|
||||
$("#scope #results tr").show();
|
||||
}
|
||||
if ($("#show_local").is(":checked") ) {
|
||||
$("#scope_list tr.indir").hide();
|
||||
if ($("#scope #show_local").is(":checked") ) {
|
||||
$("#scope #results tr.indir").hide();
|
||||
}
|
||||
} catch (error) {
|
||||
alert(error.message);
|
||||
}
|
||||
updateScopeCount();
|
||||
$("#scope #results tr:visible:odd").addClass('odd');
|
||||
hideLoading();
|
||||
}
|
||||
|
||||
// Instant results
|
||||
var prevSearch = $("#search").val();
|
||||
$("#search").keyup(function(){
|
||||
var s = $("#search").val();
|
||||
var prevSearch = $("#scope #search").val();
|
||||
$("#scope #search").keyup(function(){
|
||||
var s = $("#scope #search").val();
|
||||
if (s!=prevSearch) {
|
||||
runFilter();
|
||||
prevSearch = s;
|
||||
}
|
||||
});
|
||||
$("#submit").hide();
|
||||
|
||||
// Filter & clear buttons
|
||||
// $("#submit").click(runFilter);
|
||||
|
||||
$("#search").keypress(function(e){
|
||||
$("#scope #search").keypress(function(e){
|
||||
var code = (e.keyCode ? e.keyCode : e.which);
|
||||
if(code == 13) { // Enter
|
||||
runFilter();
|
||||
}
|
||||
});
|
||||
$("#clear").click(function(){
|
||||
$("#search")
|
||||
$("#scope #clear").click(function(){
|
||||
$("#scope #search")
|
||||
.val('')
|
||||
.focus()
|
||||
runFilter();
|
||||
});
|
||||
$("#case_sensitive").change(runFilter);
|
||||
$("#show_all").change(runFilter);
|
||||
$("#show_local").change(runFilter);
|
||||
$("#scope #case_sensitive").change(runFilter);
|
||||
$("#scope #show_all").change(runFilter);
|
||||
$("#scope #show_local").change(runFilter);
|
||||
|
||||
// ===== API search =====
|
||||
|
||||
// ===== Window resizing stuff =====
|
||||
// Custom selector
|
||||
$.expr[':'].matchAPI = function(a,b,c) {
|
||||
var obj = $(a); // tr
|
||||
var ident = $(obj.children().get(0)).text();
|
||||
var type = $(obj.children().get(3)).text();
|
||||
var needle = c[3];
|
||||
var match_ident = ident.toLowerCase().indexOf(needle.toLowerCase())>=0;
|
||||
var match_type = type.toLowerCase().indexOf(needle.toLowerCase())>=0;
|
||||
// if ($("#scope #case_sensitive").is(":checked"))
|
||||
// return haystack.indexOf(needle)>=0;
|
||||
// else
|
||||
return match_ident || match_type ;
|
||||
};
|
||||
|
||||
// refer: http://paulirish.com/2009/throttled-smartresize-jquery-event-handler/
|
||||
(function($,sr){
|
||||
// debouncing function from John Hann
|
||||
// http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
|
||||
var debounce = function (func, threshold, execAsap) {
|
||||
var timeout;
|
||||
return function debounced () {
|
||||
var obj = this, args = arguments;
|
||||
function delayed () {
|
||||
if (!execAsap)
|
||||
func.apply(obj, args);
|
||||
timeout = null;
|
||||
};
|
||||
|
||||
if (timeout)
|
||||
clearTimeout(timeout);
|
||||
else if (execAsap)
|
||||
func.apply(obj, args);
|
||||
|
||||
timeout = setTimeout(delayed, threshold || 100);
|
||||
};
|
||||
var runFilterAPI = function() {
|
||||
showLoading();
|
||||
$("#api #results tr").removeClass('odd');
|
||||
var s = $("#api #search").val();
|
||||
try {
|
||||
if (s) {
|
||||
$("#api #results tr").hide();
|
||||
$("#api #results tr:matchAPI(\""+s+"\")").show();
|
||||
} else {
|
||||
$("#api #results tr").show();
|
||||
}
|
||||
} catch (error) {
|
||||
alert(error.message);
|
||||
}
|
||||
// smartresize
|
||||
jQuery.fn[sr] = function(fn){ return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); };
|
||||
})(jQuery,'smartresize');
|
||||
|
||||
// usage:
|
||||
$(window).smartresize(function() {
|
||||
recalculateHeights();
|
||||
});
|
||||
|
||||
var recalculateHeights = function() {
|
||||
var x = 55; // just found empirically
|
||||
$('body').height( $(window).height()-x);
|
||||
$('.maxheight').each(function(){
|
||||
var obj = $(this);
|
||||
var parent = obj.parent();
|
||||
obj.height(parent.height() - (obj.offset().top - parent.offset().top) - parseInt(parent.css('padding-bottom')));
|
||||
});
|
||||
updateAPICount();
|
||||
$("#api #results tr:visible:odd").addClass('odd');
|
||||
hideLoading();
|
||||
}
|
||||
|
||||
recalculateHeights();
|
||||
});
|
||||
// Instant results
|
||||
var prevAPISearch = $("#api #search").val();
|
||||
$("#api #search").keyup(function(){
|
||||
var s = $("#api #search").val();
|
||||
if (s!=prevAPISearch) {
|
||||
runFilterAPI();
|
||||
prevAPISearch = s;
|
||||
}
|
||||
});
|
||||
|
||||
$("#api #search").keypress(function(e){
|
||||
var code = (e.keyCode ? e.keyCode : e.which);
|
||||
if(code == 13) { // Enter
|
||||
runFilterAPI();
|
||||
}
|
||||
});
|
||||
$("#api #clear").click(function(){
|
||||
$("#api #search")
|
||||
.val('')
|
||||
.focus()
|
||||
runFilterAPI();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
body {
|
||||
background-color: white;
|
||||
margin:0;
|
||||
font: 13px sans-serif;
|
||||
}
|
||||
|
||||
h1,h2,h3,h4 {
|
||||
@@ -14,13 +15,7 @@ h1,h2,h3,h4 {
|
||||
text-shadow: rgba(0,0,0,0.25) 2px 2px 5px;
|
||||
}
|
||||
|
||||
.scroll-y {
|
||||
overflow-y:auto;
|
||||
}
|
||||
|
||||
header {
|
||||
background:#f2f2f2;
|
||||
padding:10px;
|
||||
}
|
||||
header img {
|
||||
height:2em;
|
||||
@@ -28,45 +23,30 @@ header img {
|
||||
}
|
||||
header h1 {
|
||||
margin:0 1em 0 0;
|
||||
font-size:1em;
|
||||
font-size:110%;
|
||||
display: inline-block;
|
||||
}
|
||||
header .tab {
|
||||
font-size: 90%;
|
||||
|
||||
.ui-layout-north {
|
||||
background:#ddd;
|
||||
border:none;
|
||||
}
|
||||
div[role='main'] {
|
||||
overflow:hidden;
|
||||
width:100%;
|
||||
height:100%;
|
||||
font: 13px sans-serif;
|
||||
.ui-layout-resizer-north {
|
||||
}
|
||||
|
||||
.pane {
|
||||
display:block;
|
||||
height:100%;
|
||||
.ui-layout-center,
|
||||
.ui-layout-west {
|
||||
}
|
||||
.pane.left {
|
||||
width:170px;
|
||||
float:left;
|
||||
background:#f2f2f2;
|
||||
}
|
||||
.pane.right {
|
||||
margin-left:170px;
|
||||
padding:5px 0 0 10px;
|
||||
|
||||
border-width:1px 0 0 1px;
|
||||
border-style:solid;
|
||||
border-color:#ddd;
|
||||
}
|
||||
#language_select {
|
||||
#language_select {
|
||||
width:100%;
|
||||
}
|
||||
#modules a {
|
||||
#modules a {
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
margin: 2px 5px;
|
||||
}
|
||||
#modules a:hover {
|
||||
#modules a:hover {
|
||||
text-decoration:underline;
|
||||
}
|
||||
|
||||
@@ -74,11 +54,11 @@ div[role='main'] {
|
||||
border-bottom: 1px dotted #ccc;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
#module_name {
|
||||
#module_name {
|
||||
font-weight: bold;
|
||||
margin-right: 2em;
|
||||
}
|
||||
.tab {
|
||||
.tab {
|
||||
cursor:pointer;
|
||||
padding:0.5em 0.5em;
|
||||
margin-right:0.5em;
|
||||
@@ -107,12 +87,15 @@ div[role='main'] {
|
||||
color: #333;
|
||||
vertical-align: top;
|
||||
font: bold 13px sans-serif;
|
||||
z-index:100;
|
||||
}
|
||||
.scope {
|
||||
.scope {
|
||||
}
|
||||
.code {
|
||||
.code {
|
||||
}
|
||||
.help {
|
||||
.api {
|
||||
}
|
||||
.help {
|
||||
}
|
||||
input#search {
|
||||
font-family:monospace;
|
||||
@@ -125,37 +108,50 @@ input#search {
|
||||
padding:10px 5px;
|
||||
}
|
||||
|
||||
#scope_controls {
|
||||
.panel.code,
|
||||
.panel.api,
|
||||
.panel.help {
|
||||
display:none;
|
||||
}
|
||||
|
||||
|
||||
#controls {
|
||||
border-bottom: 1px solid #CCC;
|
||||
padding-bottom: 0.5em;
|
||||
}
|
||||
#scope_list {
|
||||
#results {
|
||||
font: 12px monospace;
|
||||
width:100%;
|
||||
margin-top:1em;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
#scope_list tr:hover {
|
||||
#results tr:hover {
|
||||
background:#f9f9f9;
|
||||
}
|
||||
#scope_list tr.indir {
|
||||
/* this is set in code */
|
||||
#results tr.odd {
|
||||
background:ghostwhite;
|
||||
}
|
||||
#results tr.indir {
|
||||
font-style:italic;
|
||||
}
|
||||
#scope_list tr.local td:nth-child(2) {
|
||||
#results tr.local td:nth-child(2) {
|
||||
font-weight:bold;
|
||||
}
|
||||
#scope_list th {
|
||||
#results th {
|
||||
text-align:left;
|
||||
}
|
||||
#scope_list th, #scope_list td {
|
||||
#results th, #results td {
|
||||
padding:0.4em;
|
||||
/*
|
||||
border-style: solid;
|
||||
border-width: 0 0 1px 0;
|
||||
border-color: #eee;
|
||||
*/
|
||||
background:none;
|
||||
white-space:nowrap;
|
||||
}
|
||||
#scope_list td:nth-child(6) {
|
||||
#results td:nth-child(6) {
|
||||
white-space:normal;
|
||||
}
|
||||
#code pre {
|
||||
@@ -168,15 +164,14 @@ input#search {
|
||||
color: #aaa;
|
||||
margin: 0;
|
||||
}
|
||||
dt {
|
||||
dt {
|
||||
font-weight:bold;
|
||||
}
|
||||
footer {
|
||||
footer {
|
||||
padding:3px 6px;
|
||||
color:#333;
|
||||
font-size:13px;
|
||||
text-align:right;
|
||||
position:fixed;
|
||||
top:0;
|
||||
right:0;
|
||||
position:absolute;
|
||||
top:0; right:0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user