~widelands-dev/widelands-website/update_beautifulsoup4

« back to all changes in this revision

Viewing changes to templates/wlmaps/index.html

  • Committer: Shevonar
  • Date: 2012-04-24 21:14:22 UTC
  • mto: This revision was merged to the branch mainline in revision 330.
  • Revision ID: infomh@anmaruco.de-20120424211422-d80y5yd8x9q9gzpx
Maps modul reworked and adjusted to new style.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
{% endcomment %}
5
5
 
6
6
{% load custom_date %}
7
 
 
8
 
{% block extra_head %}
9
 
<link rel="stylesheet" type="text/css" media="all" href="{{ MEDIA_URL }}css/modal_windows.css" />
10
 
{{ block.super }}
11
 
 
12
 
{% endblock %}
13
 
 
14
 
{% block title %}{{ block.super }}{% endblock %}
 
7
{% load wlprofile %}
 
8
{% load wlmaps_extra %}
 
9
{% load pybb_extras %}
15
10
 
16
11
{% block content %}
17
 
<script src="{{ MEDIA_URL}}/js/jqModal.js" type="text/javascript"></script>
18
 
<script type="text/javascript">
19
 
$().ready(function() {
20
 
  $('#upload_map_dialog')
21
 
    .jqDrag('.jqDrag')
22
 
    .jqm({
23
 
      trigger:'#umdTrigger',
24
 
      overlay: 50,
25
 
      overlayClass: 'modalOverlay',
26
 
      onShow: function(h) {
27
 
          /* calculate correct position on screen */
28
 
          o = h.w 
29
 
          if(o.css("top") == "0px") {
30
 
              cw = document.body.clientWidth;
31
 
              ch = document.body.clientHeight;
32
 
 
33
 
              top = document.body.scrollTop + (ch-o.height())/2;
34
 
              left = (cw-o.width())/2;
35
 
 
36
 
              o.css("top",top+"px").css("left",left+"px");
37
 
          }
38
 
          /* callback executed when a trigger click. Show notice */
39
 
          o.css('opacity',1).slideDown(); 
40
 
      },
41
 
      });
42
 
});
43
 
</script>    
44
 
 
45
 
<div id="map_list">
46
 
    <div align="right">
47
 
        <a href="#" id="umdTrigger">Upload a new map</a>
48
 
    </div>
49
 
 
50
 
    <h1>Widelands maps</h1>
51
 
    
52
 
    <table cellspacing="1" width="100%">
53
 
        <tr align="center">
54
 
            <th width="">&nbsp;</th>
55
 
            <th width="" nowrap="nowrap" align="left">Name</th>
56
 
            <th width="" nowrap="nowrap">Author</th>
57
 
            <th width="" nowrap="nowrap">Max Players</th>
58
 
            <th width="" nowrap="nowrap">Size</th>
59
 
            <th width="" nowrap="nowrap">World</th>
60
 
            <th width="" nowrap="nowrap">Uploaded</th>
61
 
            <th width="" nowrap="nowrap">Downloaded</th>
62
 
            <th width="" nowrap="nowrap">Details</th>
63
 
        </tr>
64
 
 
65
 
        {% for o in object_list %}
66
 
        <tr class="{% cycle "odd" "even" %}">
67
 
            <td><a href="{{ o.get_absolute_url }}"><img src="{{ MEDIA_URL }}{{ o.minimap.url }}" alt="{{ o.name }}"/></a></td>
68
 
            <td><a href="{{ o.get_absolute_url }}">{{ o.name }}</a></td>
69
 
            <td>{{ o.author }}</td>
70
 
            <td>{{ o.nr_players }}</td>
71
 
            <td>{{ o.w }} x {{ o.h }}</td>
72
 
            <td>{{ o.world_name|title }}</td>
73
 
            <td>At {{ o.pub_date|custom_date:user }} by {{ o.uploader.username }}</td>
74
 
            <td>{{ o.nr_downloads }} times</td>
75
 
            <td>
76
 
               <p><a href="{{ o.get_absolute_url }}">Details</a></p>
77
 
               <p><a href="{% url wlmaps_download o.slug %}">Direct Download</a></p>
78
 
            </td>
79
 
        </tr>
80
 
        {% endfor %}
81
 
    </table>
82
 
 
83
 
</div>
84
 
 
85
 
<!-- Modal upload box -->
86
 
<div id="upload_map_dialog" class="jqmDialog">
87
 
    <img src="{{ MEDIA_URL }}/img/close_icon.png" alt="close" class="jqmClose" />
88
 
 
89
 
    <div class="box_title jqDrag">
90
 
        <h3 class="box_title">Upload a new map</h3>
91
 
    </div>
92
 
 
93
 
    <div class="box_content">
94
 
        <form class="upload_form" enctype="multipart/form-data" action="{% url wlmaps_upload %}" method="post">{% csrf_token %}
95
 
            <label for="id_mapfile">Select map:</label>
96
 
            <input type="file" id="id_mapfile" name="mapfile"/><br />
97
 
            <label for="id_comment">Upload comment:</label><br />
98
 
            <textarea id="id_comment" rows="10" name="comment" style="width: 100%"></textarea>
99
 
            <br/>
100
 
 
101
 
            <!--<input class="upload_button" type="button" value="Upload" />-->
102
 
            <input type="submit" value="Upload" />
103
 
            <input class="cancel_button" type="button" value="Cancel" />
104
 
        </form>
105
 
 
106
 
        <div class="progress_indicator"></div>
107
 
    </div>
108
 
 
109
 
</div>
110
 
 
111
 
<script type="text/javascript">
112
 
$(function() {
113
 
    /* Bind cancel button */
114
 
    $('.upload_form .cancel_button').click( function() {
115
 
        $('#upload_map_dialog').jqmHide();
116
 
    });
117
 
 
118
 
    /* On submit, create a hidden iframe, use this as target for
119
 
       our submit, extract the result and then delete it */
120
 
    jQuery(".upload_form").submit( function(data) {
121
 
            var submittingForm = jQuery( this );
122
 
            var frameName = ("upload"+(new Date()).getTime());
123
 
            var uploadFrame = jQuery("<iframe name=\""+frameName+"\" />");
124
 
 
125
 
            // Disable the submit and cancel until a unsuccesfull reply 
126
 
            // was returned
127
 
            $(".upload_form input[type='submit']").attr("disabled","disabled")
128
 
            $(".upload_form input[type='button']").attr("disabled","disabled")
129
 
            
130
 
            o = $('#upload_map_dialog .progress_indicator')
131
 
            o.html("<h3>Uploading...</h3> <div>Uploading your map. Please wait...</div>");
132
 
            uploadFrame.css("display", "none");
133
 
            uploadFrame.load(function(data){
134
 
                // get the result
135
 
                fbody = jQuery(window.frames[ frameName ].document.getElementsByTagName( "body" )[ 0 ]);
136
 
                
137
 
                // Safari does beautification of the returned text (with pre tags)
138
 
                // so we extract the data using a regular expression
139
 
                json_data = eval('(' +  /\{.*\}/.exec(fbody.html())[0] + ')') ;
140
 
                
141
 
                //submit is complete here, check the result
142
 
                o = $('#upload_map_dialog .progress_indicator')
143
 
                if(json_data["success_code"] == 0) {
144
 
                o.html('<h3>Success!</h3><br /> Your map has been added! Will reload page in 5s');
145
 
                setTimeout(function(){
146
 
                    $('#upload_map_dialog').jqmHide();
147
 
                    window.location.reload(); 
148
 
                },500);
149
 
                
150
 
                } else {
151
 
                o.html('<h3>An error occured:</h3><br /> <div class="errormessage">' + json_data["success_code"] + ': ' + json_data["error_msg"] + '</div>');
152
 
                
153
 
                // Enable the submit and cancel because the user might want to 
154
 
                // try it again
155
 
                $(".upload_form input[type='submit']").removeAttr("disabled")
156
 
                $(".upload_form input[type='button']").removeAttr("disabled")
157
 
                }
158
 
                
159
 
                // make sure the iframe is removed again
160
 
                setTimeout(function(){
161
 
                    uploadFrame.remove();},100);
162
 
 
163
 
                return false;
164
 
                });
165
 
            jQuery('body:first').append(uploadFrame);
166
 
            
167
 
            submittingForm.attr('target', frameName);
168
 
        });
169
 
});
170
 
</script>
171
 
 
172
 
 
 
12
{% if user.is_authenticated %}
 
13
<a href="{% url wlmaps_upload %}" class="posRight invertedColor">Upload a new map</a>
 
14
{% endif %}
 
15
<h1>Maps</h1>
 
16
<div class="blogEntry">
 
17
        {% pybb_pagination _('Maps') %}
 
18
        <br /><br />
 
19
        <table class="forum">
 
20
                {% for map in maps %}
 
21
                <tr class="{% cycle "odd" "even" %}">
 
22
                        <td><a href="{{ map.get_absolute_url }}"><img class="minimap" src="{{ MEDIA_URL }}{{ map.minimap.url }}" alt="{{ map.name }}" /></a></td>
 
23
                        <td>
 
24
                                <h3><a class="invertedColor" href="{{ map.get_absolute_url }}">{{ map.name }}</a></h3>
 
25
                                <table>
 
26
                                        <tr>
 
27
                                                <td class="prop">Author:</td><td>{{ map.author }}</td>
 
28
                                                <td class="spacer"></td>
 
29
                                                <td class="prop">Dimensions:</td><td>{{ map.w }} x {{ map.h }}</td>
 
30
                                        </tr>
 
31
                                        <tr>
 
32
                                                <td class="prop">World:</td><td>{{ map.world_name|title }}</td>
 
33
                                                <td class="spacer"></td>
 
34
                                                <td class="prop">Max. Players:</td><td>{{ map.nr_players }}</td>
 
35
                                        </tr>
 
36
                                        <tr>
 
37
                                                <td class="prop">Rating:</td>
 
38
                                                <td colspan="4">{{ map.rating|average_rating }} ({{ map.rating.votes }} Votes)</td>
 
39
                                        </tr>
 
40
                                        <tr>
 
41
                                                <td class="prop">Upload:</td>
 
42
                                                <td colspan="4">by {{ map.uploader|user_link }} at {{ map.pub_date|custom_date:user }}</td>
 
43
                                        </tr>
 
44
                                        <tr>
 
45
                                                <td class="prop">Downloads:</td><td>{{ map.nr_downloads }}</td>
 
46
                                                <td class="spacer"></td>
 
47
                                                <td colspan="2">
 
48
                                                        <button onclick="window.location.href='{% url wlmaps_download map.slug %}';">
 
49
                                                                <img src="{{MEDIA_URL}}/img/download.png" alt ="" class="middle" />
 
50
                                                                <span class="middle">Direct Download</span>
 
51
                                                        </button>
 
52
                                                </td>
 
53
                                        </tr>
 
54
                                </table>
 
55
                        </td>
 
56
                </tr>
 
57
                {% endfor %}
 
58
        </table>
 
59
        <br />
 
60
        {% pybb_pagination _('Maps') %}
 
61
        <br />
 
62
</div>
173
63
{% endblock %}