-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathindex.html
272 lines (220 loc) · 9.11 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
<!doctype html>
<html xmlns:x="http://xtpl.ru/">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<title>Pilot — multifunction JavaScript router</title>
<meta name="keywords" content="pilot, router, template, browser, client, rubaxa"/>
<link rel="stylesheet" href="statics/main.css"/>
<link rel="stylesheet" href="example/app.css"/>
<script src="//cdnjs.cloudflare.com/ajax/libs/json3/3.2.4/json3.min.js"></script>
<script>!window.jQuery && document.write('<script src="/js/json3.min.js"><'+'/script>');</script>
<script src="//code.jquery.com/jquery-1.8.2.min.js"></script>
<script>!window.jQuery && document.write('<script src="/js/jquery.dev.js"><'+'/script>');</script>
<script src="http://xtpl.ru/js/xtpl.min.js"></script>
</head>
<body class="body">
<script x:ctrl="main" type="text/xhtml">
<div id="sidebar" class="sidebar">
<div>
<div class="menu">
<ul x:if="ctx.lang == 'ru'">
<li><a href="https://github.com/RubaXa/Pilot">Репозиторий на GitHub</a></li>
<li><a href="#app">Пример работы</a></li>
<li><a href="#en/{{ctx.relpath}}">{{ctx.lang == 'ru' ? 'English version' : 'Русская версия'}}</a></li>
</ul>
<ul x:if="ctx.lang != 'ru'">
<li><a href="https://github.com/RubaXa/Pilot">GitHub Repository</a></li>
<li><a href="#app">Example app</a></li>
<li><a href="#ru/{{ctx.relpath}}">Русская версия</a></li>
</ul>
</div>
<div class="menu" x:repeat="item in ctx.api">
<a href="#{{ctx.lang}}/{{item.label}}" class="menu__name">{{item['class']}}</a>
<ul>
<li x:repeat="prop in item.props">
<a href="#{{ctx.lang}}/{{prop.label}}">{{prop.name}}</a>
</li>
</ul>
<ul>
<li x:repeat="(name, item) in item.fn">
<a href="#{{ctx.lang}}/{{item.label}}">{{name}}</a>
</li>
</ul>
</div>
<div style="height: 5px;"></div>
</div>
</div>
<div style="margin-left: 280px; position: relative;">
<div class="body__glow"></div>
<div> </div>
<div class="logo"></div>
<div class="content">
<div x:if="ctx.lang == 'ru'">
<h2>Введение</h2>
<div>С каждым днем сайты становятся все сложнее и динамичнее. Уже недостаточно просто “оживить” интерфейс, все чаще требуется создать полноценное одностраничное приложение. А это значит, что задача получения данных и их отображения, в зависимости от маршрута, которая всегда была прерогативой сервера, ложится на клиент. Обычно эту проблему решают с помощью простенького роутера, на основе регулярных выражений, и дальше не развивают, в то время как на back-end, этой теме уделяют гораздо больше внимания. В этой статье я постараюсь восполнить этот пробел.</div>
</div>
<div x:if="ctx.lang != 'ru'">
<h2>Introduction</h2>
<div>With every single day web-sites are becoming more complex and dynamic. It is not enough to simply "revive" the interface. Instead, a fully functional one-page application is required to be created. This means that the task of data collection and display, depending on the route, which has always been the prerogative of the server, lies down on the client. Usually this problem is solved by a simple router, based on regular expressions, and is not developing further, while at back-end, the topic has received much more attention. In this article I will try to fill this gap.</div>
</div>
<div style="height: 50px;"></div>
<div x:repeat="item in ctx.api">
<a name="{{ctx.lang}}/{{item.label}}"></a>
<h3>{{item['class']}}</h3>
<div style="margin-bottom: 30px;">
<div>
{*item.descr[ctx.lang] | markdown*}
</div>
<br/>
<div style="margin-left: 20px;">
<div x:repeat="prop in item.props">
<a name="{{ctx.lang}}/{{prop.label}}"></a>
<h4 class="fn" data-anchor="prop">
<x:value>prop.name</x:value>
<x:if test="prop.type != -1">
<x:text value=": "/>
<span class="type">{{prop.type}}</span>
</x:if>
</h4>
<div class="descr">
{*prop.descr[ctx.lang] | markdown*}
</div>
<div x:if="prop.code" x:highlight="prop.code.type">
<highlight></highlight>
<pre>
<code>
{{prop.code.source[ctx.lang]}}
</code>
</pre>
</div>
<div x:if="prop.code" style="height: 20px;"></div>
</div>
<div x:repeat="fn in item.fn">
<div x:repeat="variant in fn.variants">
<a name="{{ctx.lang}}/{{fn.label}}"></a>
<h4 data-anchor="fn" class="fn">
<span class="fn__name">{{fn.name}}</span>
<span class="fn__args">
<span>( </span>
<span x:repeat="(idx, arg) in variant.args">
<x:if test="arg.optional">
<span class="fn__arg__optional">
<span>[</span>
<span x:if="idx">, </span>
<span>{{arg.name}}:</span>
<span class="type">{{arg.type}}</span>
<span>]</span>
</span>
</x:if>
<x:if test="!arg.optional">
<span x:if="idx">, </span>
<span>{{arg.name}}:</span>
<span class="type">{{arg.type}}</span>
</x:if>
</span>
<span> ):</span>
</span>
<span class="type">{{fn.returns}}</span>
</h4>
<div class="descr">
{*variant.descr[ctx.lang] | markdown*}
</div>
<ul>
<li x:repeat="arg in variant.args">
<b>{{arg.name}}</b>
<span> — </span>
<span>{{fn.args[arg.name][ctx.lang]}}</span>
</li>
</ul>
<div x:if="fn.code" x:highlight="fn.code.type">
<pre>
<code>{{fn.code.source[ctx.lang]}}</code>
</pre>
</div>
<div style="height: 20px;"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</script>
<div style="height: 750px; margin-left: 280px; position: relative;">
<a name="app"></a>
<div style="height: 100px;"></div>
<div class="app">
<div class="app__name">Example</div>
<div id="app-location" class="app__location">
<div class="js-spinner app__location__spinner"></div>
<span class="js-back app__location__nav">←</span>
<span class="js-forward app__location__nav">→</span>
<span class="js-address"></span>
</div>
<div id="app-view" class="app__view"></div>
<div style="text-align: center; margin-top: 20px;">
<a href="example/app.js">source: app.js</a>
</div>
</div>
</div>
<script src="//yandex.st/highlightjs/7.2/highlight.min.js"></script>
<script src="./Pilot.js"></script>
<script src="./example/app.js"></script>
<script>
xtpl.xml = true;
/** @namespace hljs -- highlight.js */
if( window.hljs ){
xtpl.decl('x:highlight', {
init: function (el, type){
if( el ){
el.className = 'language-' + (type == 'js' ? 'javascript' : type);
hljs.highlightBlock(el);
}
}
});
}
xtpl.mod('markdown', function (text){
return text ? text.replace(/`([^`]+)`/g, '<span class="code">$1</span>') : text;
});
$(window).resize(function (){
$('#sidebar').css('height', $(window).height());
});
console && console.time && console.time('main');
xtpl.ctrl('main', function (ctx){
var lang = (window.navigator.userLanguage || window.navigator.language).split('-')[0];
var _rlang = /(?:\/|^)(en|ru)\//;
var _updScroll = function (){
var anchor = location.toString().replace(/^.+#/, '');
if( anchor ){
var offset = $('a[name="'+anchor+'"]').offset();
offset && $(window).scrollTop(offset.top);
}
$(window).trigger('resize');
};
ctx.api = {};
ctx.lang = /(en|ru)/.test(lang) ? lang : 'en';
$(window).bind('hashchange', function (){
var href = location.toString().split('#').pop();
var lang = (href.match(_rlang) || [,ctx.lang])[1];
ctx.lang = lang;
ctx.relpath = href.replace(/^.+\//, '');
ctx.$apply(_updScroll);
}).trigger('hashchange');
$.getJSON('./statics/docs.json?ver='+Pilot.version, function (json){
ctx.api = json;
ctx.$apply(_updScroll);
console && console.time && console.timeEnd('main');
});
});
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-16483888-3', 'rubaxa.github.io');
ga('send', 'pageview');
</script>
</body>
</html>