mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-23 11:56:36 +11:00
Clean up: Drop redundant attributes, minor JS clean up, gitignore
* Dropped redundant `type` attribute from script elements (some had them removed already). * Dropped redundant `media` attribute from link elements. * <div> is not a valid self-closing tag. * Dropped redundant / in self-closing tags in <hr/>, <br/>, <input/>. Just like was done for <img> and <link> already). * Aliasing $ to jQuery (local reference is cheaper and using jQuery as global seems more stable, bootstrap.js does this too). * Unminified it a bit (nothing extreme, just more consistent other code here already). * Consistently used single quotes in the js code (most code used singled quotes already). * Quoting attribute selectors $('input[name="foo"]'). Unquoted selectors have been deprecated. * Ignore .pyc files (so they don't show up in `git status`, and aren't accidentally committed with `git add`).
This commit is contained in:
parent
32dc8e5928
commit
b2265b1af8
7 changed files with 38 additions and 35 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
*.pyc
|
||||
dpaste/settings_local.py
|
||||
dpaste.egg-info
|
||||
|
|
|
@ -16,5 +16,5 @@ Testing
|
|||
```
|
||||
$ pip install -r requirements.txt
|
||||
$ pip install -e .
|
||||
$ manage.py test dpaste
|
||||
$ manage.py test dpaste
|
||||
```
|
||||
|
|
|
@ -47,16 +47,16 @@
|
|||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<div class="clearfix"/>
|
||||
<hr class="clearfix"/>
|
||||
<div class="clearfix"></div>
|
||||
<hr class="clearfix">
|
||||
|
||||
<h3>Imprint</h3>
|
||||
|
||||
<p><strong>Address:</strong></p>
|
||||
<p>
|
||||
Martin Mahner<br/>
|
||||
Lauterbacher Str. 4<br/>
|
||||
DE-18581 Putbus<br/>
|
||||
Martin Mahner<br>
|
||||
Lauterbacher Str. 4<br>
|
||||
DE-18581 Putbus<br>
|
||||
Germany
|
||||
</p>
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>dpaste.de: {% block title %}{% trans "New snippet" %}{% endblock %}</title>
|
||||
<link href="{% static "dpaste/bootstrap/css/bootstrap.min.css" %}" rel="stylesheet" media="screen">
|
||||
<link href="{% static "dpaste/theme.css" %}" rel="stylesheet" media="screen">
|
||||
<link rel="stylesheet" href="{% static "dpaste/bootstrap/css/bootstrap.min.css" %}">
|
||||
<link rel="stylesheet" href="{% static "dpaste/theme.css" %}">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{% block extrahead %}{% endblock %}
|
||||
</head>
|
||||
|
@ -30,15 +30,17 @@
|
|||
{% block script_footer %}
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
|
||||
<script src="{% static "dpaste/bootstrap/js/bootstrap.min.js" %}"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('#guess_lexer_btn').click(function(){
|
||||
<script>
|
||||
jQuery(document).ready(function($) {
|
||||
$('#guess_lexer_btn').click(function() {
|
||||
$.getJSON('{% url "snippet_guess_lexer" %}',
|
||||
{'codestring': $('#id_content').val()},
|
||||
function(data){
|
||||
if(data.lexer == "unknown"){
|
||||
{
|
||||
codestring: $('#id_content').val()
|
||||
},
|
||||
function(data) {
|
||||
if (data.lexer === 'unknown') {
|
||||
$('#guess_lexer_btn').css('color', 'red');
|
||||
}else{
|
||||
} else {
|
||||
$('#id_lexer').val(data.lexer);
|
||||
$('#guess_lexer_btn').css('color', 'inherit');
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
{% if structure.new_level %}<ul><li>{% else %}</li><li>{% endif %}
|
||||
<div>
|
||||
<span class="diff">
|
||||
<input type="radio" name="a" value="{{ tree_item.id }}" {% ifequal tree_item.id snippet.parent_id %}checked="checked"{% endifequal %}/>
|
||||
<input type="radio" name="b" value="{{ tree_item.id }}" {% ifequal snippet tree_item %}checked="checked"{% endifequal %}/>
|
||||
<input type="radio" name="a" value="{{ tree_item.id }}" {% ifequal tree_item.id snippet.parent_id %}checked="checked"{% endifequal %}>
|
||||
<input type="radio" name="b" value="{{ tree_item.id }}" {% ifequal snippet tree_item %}checked="checked"{% endifequal %}>
|
||||
</span>
|
||||
{% ifequal snippet tree_item %}
|
||||
<strong>#{{ tree_item.id }}</strong>
|
||||
|
@ -36,7 +36,7 @@
|
|||
{% for level in structure.closed_levels %}</li></ul>{% endfor %}
|
||||
{% endfor %}
|
||||
<div class="submit">
|
||||
<input type="submit" value="{% trans "Compare" %}"/>
|
||||
<input type="submit" value="{% trans "Compare" %}">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -66,7 +66,7 @@
|
|||
<!-- ======================================================================
|
||||
Snippet Reply
|
||||
======================================================================= -->
|
||||
<hr/>
|
||||
<hr>
|
||||
|
||||
<div class="snippet-reply snippet-reply-hidden">
|
||||
<h3>{% trans "Reply to this snippet" %} →</h3>
|
||||
|
@ -77,8 +77,8 @@
|
|||
|
||||
{% block script_footer %}
|
||||
{{ block.super }}
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
<script>
|
||||
jQuery(document).ready(function($){
|
||||
$('.snippet-reply-hidden').click(function(e){
|
||||
$(this).removeClass('snippet-reply-hidden');
|
||||
});
|
||||
|
@ -93,10 +93,10 @@ $(document).ready(function(){
|
|||
});
|
||||
|
||||
|
||||
$("form#diffform").submit(function() {
|
||||
var a = $("input[name=a]:checked").val(),
|
||||
b = $("input[name=b]:checked").val(),
|
||||
hash = 'D'+a+','+b;
|
||||
$('form#diffform').submit(function() {
|
||||
var a = $('input[name="a"]:checked').val(),
|
||||
b = $('input[name="b"]:checked').val(),
|
||||
hash = 'D' + a + ',' + b;
|
||||
$.get("{% url "snippet_diff" %}", {
|
||||
a: a,
|
||||
b: b
|
||||
|
@ -110,26 +110,26 @@ $(document).ready(function(){
|
|||
var curLine = document.location.hash,
|
||||
hashlist;
|
||||
|
||||
if(curLine.substring(0,2) == '#D'){
|
||||
if (curLine.substring(0, 2) === '#D'){
|
||||
hashlist = curLine.substring(2).split(',');
|
||||
if (hashlist.length == 2) {
|
||||
console.log(hashlist);
|
||||
$('form#diffform input[name=a][value='+hashlist[0]+']').attr('checked', true);
|
||||
$('form#diffform input[name=b][value='+hashlist[1]+']').attr('checked', true);
|
||||
$('form#diffform input[name="a"][value="'+hashlist[0]+'"]').attr('checked', true);
|
||||
$('form#diffform input[name="b"][value="'+hashlist[1]+'"]').attr('checked', true);
|
||||
$('#snippet-diff').slideDown('fast');
|
||||
$('#snippet-diff form').submit();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Line Highlighting
|
||||
*/
|
||||
* Line Highlighting
|
||||
*/
|
||||
var curLine = document.location.hash,
|
||||
hashlist;
|
||||
|
||||
if(curLine.substring(0,2) == '#L'){
|
||||
if (curLine.substring(0, 2) == '#L'){
|
||||
hashlist = curLine.substring(2).split(',');
|
||||
if (hashlist.length > 0 && hashlist[0] !== "") {
|
||||
if (hashlist.length > 0 && hashlist[0] !== '') {
|
||||
$.each(hashlist, function(index, elem){
|
||||
$('.linenums li#' + elem).addClass('marked');
|
||||
});
|
||||
|
@ -147,7 +147,7 @@ $(document).ready(function(){
|
|||
}
|
||||
|
||||
$('.linenums li.marked').each(function (index, elem) {
|
||||
if (hash !== "L") hash += ',';
|
||||
if (hash !== 'L') hash += ',';
|
||||
hash += $(elem).attr('id');
|
||||
});
|
||||
|
||||
|
|
|
@ -40,6 +40,6 @@
|
|||
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
|
||||
</div>
|
||||
{% endif %}
|
||||
<input tabindex="0" type="submit"class="btn btn-primary" value="{% trans "Paste it" %}"/>
|
||||
<input tabindex="0" type="submit"class="btn btn-primary" value="{% trans "Paste it" %}">
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
</a>
|
||||
</h4>
|
||||
{% include "dpaste/snippet_pre.html" %}
|
||||
{% if not forloop.last %}<hr/>{% endif %}
|
||||
{% if not forloop.last %}<hr>{% endif %}
|
||||
{% empty %}
|
||||
<p>{% trans "No snippets saved. Either all your snippets are expired or your cookie has changed." %}</p>
|
||||
{% endfor %}
|
||||
|
|
Loading…
Reference in a new issue