show warning if unable to conenct to lsd

This commit is contained in:
j 2013-11-03 15:35:05 +01:00
parent 6013154708
commit fd7d603934
3 changed files with 129 additions and 84 deletions

1
.gitignore vendored
View file

@ -3,3 +3,4 @@
MANIFEST MANIFEST
build build
db.sqlite db.sqlite
secret.txt

14
README Normal file
View file

@ -0,0 +1,14 @@
LSD example site
REQUIREMENTS
you have to install
Django
pip install Django
django_lsd
pip install git+https://git.0x2620.org/django_lsd.git#egg=django_lsd
CLINETS
and users will need to run lsd, more on that at
https://git.0x2620.org/?p=lsd.git

View file

@ -1,5 +1,6 @@
Ox.load('UI', function() { Ox.load('UI', function() {
var current, var lsdURL = 'http://127.0.0.1:15550',
current,
columns = [ columns = [
{ {
id: 'state', id: 'state',
@ -73,8 +74,15 @@ Ox.load('UI', function() {
url: '/api/' url: '/api/'
}).bindEvent({ }).bindEvent({
load: function(data) { load: function(data) {
Ox.get(lsdURL + '/api/', function(result) {
!result ? warningDialog() : load(data);
});
}
});
function load(data) {
window.app.local = Ox.API({ window.app.local = Ox.API({
url: 'http://127.0.0.1:15550/api/' url: lsdURL + '/api/'
}, function() { }, function() {
if (!data.user) { if (!data.user) {
signupDialog(); signupDialog();
@ -86,7 +94,7 @@ Ox.load('UI', function() {
app.local.config({}); app.local.config({});
app.$player = $('<audio>'); app.$player = $('<audio>');
app.play = function(id) { app.play = function(id) {
var url = 'http://127.0.0.1:15550/get/' + id; var url = lsdURL + '/get/' + id;
app.$player.attr('src', url); app.$player.attr('src', url);
app.$player[0].play(); app.$player[0].play();
current = id; current = id;
@ -138,7 +146,6 @@ Ox.load('UI', function() {
}); });
}); });
} }
});
function signupDialog() { function signupDialog() {
var $form, var $form,
@ -160,7 +167,7 @@ Ox.load('UI', function() {
username: values.username, username: values.username,
password: values.password, password: values.password,
url: document.location.origin + '/api/', url: document.location.origin + '/api/',
extensions: ['ogg', 'mp3'] extensions: ['ogg', 'oga', 'mp3']
}, function() { }, function() {
document.location.reload(); document.location.reload();
}); });
@ -174,6 +181,9 @@ Ox.load('UI', function() {
], ],
closeButton: true, closeButton: true,
content: Ox.Element() content: Ox.Element()
.css({
padding: '48px'
})
.append( .append(
$form = Ox.Form({ $form = Ox.Form({
items: [ items: [
@ -200,4 +210,24 @@ Ox.load('UI', function() {
width: 432 width: 432
}).open(); }).open();
} }
function warningDialog() {
var $dialog = Ox.Dialog({
buttons: [
],
closeButton: false,
content: Ox.Element()
.css({
padding: '48px'
})
.append(
'Could not connect to LSD on <a href="' + lsdURL + '">'+lsdURL+'</a><br>'
+ 'Please start or install <a href="https://git.0x2620.org/?p=lsd.git">LSD</a>'
),
height: 192,
removeOnClose: true,
title: 'LSD Not Running',
width: 432
}).open();
}
}); });