Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
Bugfix: then torrent_content_hash is not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
adw0rd committed Jun 1, 2013
1 parent 7fe8de9 commit fe6fa86
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 42 deletions.
44 changes: 23 additions & 21 deletions torrent_stream/templates/torrent_stream/button.html
@@ -1,22 +1,24 @@
{% load i18n static %}
{% with 'torrent_stream_button_'|add:torrent_content_hash as transport_id %}
{% trans "Watch online" as watch_online_translated %}
<a href="#" id="{{ transport_id }}">
<img src="{% static "torrent_stream/play_icon_small.png" %}"
alt="{{ watch_online_translated }}" title="{{ watch_online_translated }}"
style="float:left" />
<span style="padding-left:2px">{{ watch_online_translated }}</span>
</a>
<div style="clear:both"></div>
<script type="text/javascript">
var torrent_stream_config = {
'transport_id': '{{ transport_id }}',
'torrent_stream_js': '{% url torrent_stream_js torrent_content_hash %}',
'box_width': parseInt('{{ TORRENT_STREAM_PLAYER.width }}'),
'box_height': parseInt('{{ TORRENT_STREAM_PLAYER.height }}'),
'ajax_loader': '{% static "torrent_stream/ajax-loader.gif" %}',
'close_player_confirm': '{% trans "Are you sure you want to close the player?" %}'
}
</script>
<script type="text/javascript" src="{% static "torrent_stream/button.js" %}"></script>
{% endwith %}
{% if torrent_content_hash %}
{% with 'torrent_stream_button_'|add:torrent_content_hash as transport_id %}
{% trans "Watch online" as watch_online_translated %}
<a href="#" id="{{ transport_id }}">
<img src="{% static "torrent_stream/play_icon_small.png" %}"
alt="{{ watch_online_translated }}" title="{{ watch_online_translated }}"
style="float:left" />
<span style="padding-left:2px">{{ watch_online_translated }}</span>
</a>
<div style="clear:both"></div>
<script type="text/javascript">
var torrent_stream_config = {
'transport_id': '{{ transport_id }}',
'torrent_stream_js': '{% url torrent_stream_js torrent_content_hash %}',
'box_width': parseInt('{{ TORRENT_STREAM_PLAYER.width }}'),
'box_height': parseInt('{{ TORRENT_STREAM_PLAYER.height }}'),
'ajax_loader': '{% static "torrent_stream/ajax-loader.gif" %}',
'close_player_confirm': '{% trans "Are you sure you want to close the player?" %}'
}
</script>
<script type="text/javascript" src="{% static "torrent_stream/button.js" %}"></script>
{% endwith %}
{% endif %}
44 changes: 23 additions & 21 deletions torrent_stream/templates/torrent_stream/player.html
@@ -1,21 +1,23 @@
{% with 'torrent_stream_transport_'|add:torrent_content_hash as transport_id %}
<div id="{{ transport_id }}"></div>
<script type="text/javascript">
(function() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "{% url torrent_stream_js torrent_content_hash %}";
script.async = true;
var transport = document.getElementById('{{ transport_id }}');
transport.appendChild(script);
var player = document.createElement("div");
player.style.cssText = 'width:{{ TORRENT_STREAM_PLAYER.width }};'+
'height:{{ TORRENT_STREAM_PLAYER.height }};' +
'overflow:hidden';
transport.appendChild(player);
script.addEventListener('load', function () {
tsplayer(player, {width: "{{ TORRENT_STREAM_PLAYER.width }}", height: "{{ TORRENT_STREAM_PLAYER.height }}"});
});
})();
</script>
{% endwith %}
{% if torrent_content_hash %}
{% with 'torrent_stream_transport_'|add:torrent_content_hash as transport_id %}
<div id="{{ transport_id }}"></div>
<script type="text/javascript">
(function() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "{% url torrent_stream_js torrent_content_hash %}";
script.async = true;
var transport = document.getElementById('{{ transport_id }}');
transport.appendChild(script);
var player = document.createElement("div");
player.style.cssText = 'width:{{ TORRENT_STREAM_PLAYER.width }};'+
'height:{{ TORRENT_STREAM_PLAYER.height }};' +
'overflow:hidden';
transport.appendChild(player);
script.addEventListener('load', function () {
tsplayer(player, {width: "{{ TORRENT_STREAM_PLAYER.width }}", height: "{{ TORRENT_STREAM_PLAYER.height }}"});
});
})();
</script>
{% endwith %}
{% endif %}

0 comments on commit fe6fa86

Please sign in to comment.