Skip to content

Commit

Permalink
iframe game view
Browse files Browse the repository at this point in the history
  • Loading branch information
climu committed Jul 11, 2023
1 parent a1c86d4 commit 999f094
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 2 deletions.
43 changes: 43 additions & 0 deletions league/templates/league/iframe/archives_games.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{% extends "iframe.html" %}
{% load league_tags wgo_tags l10n i18n static %}

{% block title %}Archives - Games {% if sgf %}- {{sgf.black.username}} vs {{sgf.white.username}} {%endif %}{% endblock %}
{% block extra_head_js %}
<script type="text/javascript">
function load_game(sgf_id) {
$.ajax({
type: "GET",
url: "/league/game/json/" + sgf_id,
dataType: "json",
success: processData,
error: function(){ alert("failed"); }
});

function processData(data) {
document.getElementById("game_infos").innerHTML = data.game_infos;
var elem = document.getElementById("player");
var player = new WGo.BasicPlayer(elem, {
sgf: data.sgf,
});
window.history.pushState('page2', 'Title', data.permalink);
document.getElementById("game-header").innerText = ' - ' + data.white + ' vs ' + data.black;
document.title ='Archives - Games - '+ data.white + ' vs ' + data.black + ' - Open Study Room';
$("[data-toggle=tooltip]").tooltip();
};

return false;
};
</script>
{% endblock %}

{% block content %}
{% include "league/includes/game_table_view.html" %}
{% endblock %}

{% block extra_css %}
<link rel="stylesheet" href="{% static 'css/league.css' %}"/>
<link rel="stylesheet" href="{% static 'league/css/archives_games.css' %}"/>
{% endblock %}
{% block extra_js %}
{% include "league/includes/sgrfs_datatable.html" with sgfs_data_json=sgfs_data_json %}
{% endblock %}
40 changes: 40 additions & 0 deletions league/templates/league/iframe/games.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{% extends "iframe.html" %}
{% load tz static league_tags wgo_tags bootstrap3 l10n i18n%}

{% block extra_head_js %}
<script type="text/javascript">
function load_game(sgf_id) {
$.ajax({
type: "GET",
url: "/league/game/json/" + sgf_id,
dataType: "json",
success: processData,
error: function(){ alert("failed"); }
});

function processData(data)
{
document.getElementById("game_infos").innerHTML= data.game_infos ;
var elem = document.getElementById("player");
var player = new WGo.BasicPlayer(elem, {
sgf: data.sgf
});
window.history.pushState('page2', 'Title', data.permalink);
document.getElementById("game_infos").innerHTML = data.game_infos ;
document.getElementById("game-header").innerHTML= ' - ' + data.white + ' vs ' + data.black;
document.title = data.white + ' vs ' + data.black + ' - Open Study Room';
$("[data-toggle=tooltip]").tooltip();

};
return false;};
</script>
{% endblock %}
{% block content %}

{% include "league/includes/game_table_view.html" with event=event %}
{% endblock %}

{% block extra_js %}
{% get_current_language as LANGUAGE_CODE %}
{% include "league/includes/sgrfs_datatable.html" with sgfs_data_json=sgfs_data_json %}
{% endblock %}
9 changes: 7 additions & 2 deletions league/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,16 +277,21 @@ def list_games(request, event_id=None, sgf_id=None):
context.update({'sgf': sgf})

if event_id is None:
template = loader.get_template('league/archives_games.html')
template_path = 'league/archives_games.html'

else:
event = get_object_or_404(LeagueEvent, pk=event_id)
template = loader.get_template('league/games.html')
template_path = 'league/games.html'
context.update({
'event': event,
'can_join': event.can_join(request.user),
'can_quit': event.can_quit(request.user),
})
if request.GET.get('iframe'):
template_path = template_path.replace('league', 'league/iframe')

template = loader.get_template(template_path)

return HttpResponse(template.render(context, request))


Expand Down
4 changes: 4 additions & 0 deletions openstudyroom/static/css/openstudyroom.css
Original file line number Diff line number Diff line change
Expand Up @@ -367,4 +367,8 @@ height: auto;
}
.slider {
margin-top: 5em;
}

body.iframe{
padding: 0 !important;
}
92 changes: 92 additions & 0 deletions openstudyroom/templates/iframe.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{% load static wagtailuserbar compress puput_tags %}
{% load menu_tags osr_tags tz calendar_tags%}
{% load bootstrap3 %}
{% load i18n %}


<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- image for socials -->
<link href="https://fonts.googleapis.com/css?family=Raleway:400,500" rel="stylesheet">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->

{% if not debug %}
<!-- Google Analytics -->
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-106566532-1', 'auto');
ga('send', 'pageview');
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
<!-- End Google Analytics -->
{% endif %}

<title>
{% block title %}
{% endblock %}
</title>


{# Global stylesheets #}
{% bootstrap_css %}

{% compress css %}
<link rel="stylesheet" type="text/css" href="{% static 'css/openstudyroom.css' %}">
<link type="text/css" href="{%static 'wgo/wgo.player.css' %}" rel="stylesheet" />

{% endcompress %}

<link href='https://fonts.googleapis.com/css?family=Roboto:400,300,300italic,100italic,100,400italic,500,500italic,700,900,700italic,900italic' rel='stylesheet' type='text/css'>
<script src="https://kit.fontawesome.com/0fe78b4c78.js" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
{% block extra_css %}
{# Override this in templates to add extra stylesheets #}
{% endblock %}

{% block extra_head_js %}
{# Override this in templates to add extra stylesheets #}
{% endblock %}
</head>

<body class="iframe">

<header>
{% block extra-header %}{% endblock %}
</header>

{% block content%}
{% endblock %}

{% block main %}{% endblock %}

{% get_current_timezone as TIME_ZONE %}
{% get_current_language as LANGUAGE_CODE %}


{# Global javascript #}
{% bootstrap_javascript %}
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment-with-locales.min.js"></script>
<script type="text/javascript" src="{% static 'js/openstudyroom.js' %}"></script>
<script type="text/javascript" src="{%static 'wgo/wgo.min.js'%}"></script>
<script type="text/javascript" src="{%static 'wgo/wgo.player.min.js'%}"></script>
<script type="text/javascript">$("[data-toggle=tooltip]").tooltip();</script>
<script>
moment.locale('{{LANGUAGE_CODE}}');
gmt($('.rich-text'),'{{TIME_ZONE}}','{% tz_offset %}')
</script>
{% block extra_js %}
{# Override this in templates to add extra javascript #}
{% endblock %}

{# for machina templates we needs a js block #}
{% block js %}
{% endblock %}
</body>
</html>

0 comments on commit 999f094

Please sign in to comment.