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
build
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() {
var current,
var lsdURL = 'http://127.0.0.1:15550',
current,
columns = [
{
id: 'state',
@ -73,8 +74,15 @@ Ox.load('UI', function() {
url: '/api/'
}).bindEvent({
load: function(data) {
Ox.get(lsdURL + '/api/', function(result) {
!result ? warningDialog() : load(data);
});
}
});
function load(data) {
window.app.local = Ox.API({
url: 'http://127.0.0.1:15550/api/'
url: lsdURL + '/api/'
}, function() {
if (!data.user) {
signupDialog();
@ -86,7 +94,7 @@ Ox.load('UI', function() {
app.local.config({});
app.$player = $('<audio>');
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[0].play();
current = id;
@ -138,7 +146,6 @@ Ox.load('UI', function() {
});
});
}
});
function signupDialog() {
var $form,
@ -160,7 +167,7 @@ Ox.load('UI', function() {
username: values.username,
password: values.password,
url: document.location.origin + '/api/',
extensions: ['ogg', 'mp3']
extensions: ['ogg', 'oga', 'mp3']
}, function() {
document.location.reload();
});
@ -174,6 +181,9 @@ Ox.load('UI', function() {
],
closeButton: true,
content: Ox.Element()
.css({
padding: '48px'
})
.append(
$form = Ox.Form({
items: [
@ -200,4 +210,24 @@ Ox.load('UI', function() {
width: 432
}).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();
}
});