267 lines
7.7 KiB
HTML
267 lines
7.7 KiB
HTML
<!DOCTYPE HTML>
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>Qgelm - Terminal</title>
|
|
<meta name="author" content="qgelm.de"/>
|
|
<meta name="Description" content="Login Terminal"/>
|
|
<meta http-equiv="Access-Control-Allow-Origin" content="*">
|
|
<link rel="sitemap" type="application/xml" title="Sitemap" href=""/>
|
|
<link rel="shortcut icon" href="favicon.ico"/>
|
|
<script src="./js/jquery-1.7.1.min.js"></script>
|
|
<script src="./js/jquery.mousewheel-min.js"></script>
|
|
<script src="./js/jquery.terminal-min.js"></script>
|
|
<link href="./css/jquery.terminal.css" rel="stylesheet"/>
|
|
</head>
|
|
<body>
|
|
|
|
<script>
|
|
|
|
|
|
function doAjax(url, callback) {
|
|
// call YQL
|
|
$.getJSON("http://query.yahooapis.com/v1/public/yql?"+
|
|
"q=select%20*%20from%20html%20where%20url%3D%22"+
|
|
encodeURIComponent(url)+
|
|
"%22&format=xml'&callback=?",
|
|
// this function gets the data from the successful
|
|
// JSON-P call
|
|
function(data){
|
|
// if there is data, filter it and render it out
|
|
if(data.results[0]){
|
|
var data = data.results[0];
|
|
//$.terminal.active().echo(filterData(data));
|
|
callback(filterData(data));
|
|
// otherwise tell the world that something went wrong
|
|
} else {
|
|
var errormsg = "ERROR loading "+url;
|
|
$.terminal.active().echo(errormsg);
|
|
}
|
|
});
|
|
}
|
|
// filter out some nasties
|
|
function filterData(data){
|
|
data = data.replace(/<?\/body[^>]*>/g,'');
|
|
data = data.replace(/[\r|\n]+/g,'');
|
|
data = data.replace(/<--[\S\s]*?-->/g,'');
|
|
data = data.replace(/<noscript[^>]*>[\S\s]*?<\/noscript>/g,'');
|
|
data = data.replace(/<script[^>]*>[\S\s]*?<\/script>/g,'');
|
|
data = data.replace(/<script.*\/>/,'');
|
|
return data;
|
|
}
|
|
|
|
function loadHeise() {
|
|
heise = new Array();
|
|
//q="http://heise.de.feedsportal.com/c/35207/f/653902/index.rss";
|
|
doAjax("http://www.heise.de/newsticker/heise-top-atom.xml", function(data) {
|
|
var $xml = $(data);
|
|
//var term = $.terminal.active();
|
|
//term.echo(data);
|
|
$xml.find("entry").each(function() {
|
|
var $this = $(this);
|
|
item = {
|
|
title: $this.find("title").text(),
|
|
link: $this.find("link").text(),
|
|
description: $this.find("summary").text(),
|
|
published: new Date($this.find("published").text()),
|
|
updated: new Date($this.find("updated").text()),
|
|
author: $this.find("author").text()
|
|
}
|
|
heise[heise.length] = item;
|
|
});
|
|
});
|
|
}
|
|
|
|
function showDate(d, tag) {
|
|
var yyyy = d.getFullYear();
|
|
var mm = 1+d.getMonth();
|
|
var dd = d.getDate();
|
|
var q = "http://www.eucharistiefeier.de/lk/api.php?format=xml&jahr="+yyyy+"&monat="+mm+"&tag="+dd;
|
|
doAjax(q, function(data) {
|
|
var term = $.terminal.active();
|
|
var celeb = $(data).find("celebration");
|
|
//term.echo("DEBUG "+data);
|
|
term.echo(tag+": "+celeb.attr("wtag")+", "+celeb.attr("datum")+ " ("+celeb.attr("rang")+" "+celeb.attr("farbe")+" "+celeb.attr("grad")+")");
|
|
term.echo(" "+celeb.attr("tl"));
|
|
term.echo(" Evangelium "+celeb.attr("ev"));
|
|
term.echo(" Lesung(en) "+celeb.attr("l1")+" / "+celeb.attr("l2"));
|
|
term.echo(" Antwortpsalm "+celeb.attr("ap"));
|
|
});
|
|
}
|
|
|
|
function printNewsItem(item) {
|
|
var term = $.terminal.active();
|
|
term.echo(item.title);
|
|
term.echo("--------------------------");
|
|
term.echo(item.description);
|
|
term.echo(" ("+item.updated.toString()+")");
|
|
term.echo("");
|
|
}
|
|
|
|
function openURL(url) {
|
|
window.open (url,'_blank',false);
|
|
}
|
|
|
|
function gotoURL(url) {
|
|
window.open (url,'_self',false);
|
|
}
|
|
|
|
function date2ddmmyyy(dt) {
|
|
return dt.getDate()+'-'+dt.getMonth()+'-'+dt.getFullYear();
|
|
}
|
|
|
|
jQuery(document).ready(function($) {
|
|
|
|
var id = 1;
|
|
loadHeise();
|
|
|
|
dpbx_uid = '';
|
|
if (localStorage.getItem('__dpbx_uid')) {
|
|
dpbx_uid = localStorage.getItem('__dpbx_uid');
|
|
} else {
|
|
dpbx_uid = '';
|
|
}
|
|
|
|
$('body').terminal( {
|
|
|
|
echo: function(arg1) {
|
|
this.echo(arg1);
|
|
},
|
|
|
|
reset: function() {
|
|
window.open ('/','_self',false);
|
|
},
|
|
|
|
goto: function(where) {
|
|
if (localStorage.getItem(where)) {
|
|
gotoURL(localStorage.getItem(where));
|
|
} else {
|
|
gotoURL('http://'+where+'.qgelm.de');
|
|
}
|
|
},
|
|
|
|
open: function(where) {
|
|
if (localStorage.getItem(where)) {
|
|
openURL(localStorage.getItem(where));
|
|
} else {
|
|
openURL('http://'+where+'.qgelm.de');
|
|
}
|
|
},
|
|
|
|
wiki: function(arg1) {
|
|
gotoURL('http://de.wikipedia.org/wiki/'+arg1);
|
|
},
|
|
|
|
dropbox: {
|
|
user: function(id) {
|
|
localStorage.setItem('__dpbx_uid', id);
|
|
dpbx_uid = id;
|
|
},
|
|
dir: function(where) {
|
|
var df = "";
|
|
if (where=='.') {
|
|
df = '';
|
|
} else {
|
|
df = where;
|
|
}
|
|
//"https://dl.dropboxusercontent.com/u/<uid>/xxx.html"
|
|
doAjax("", function(data) {
|
|
var $xml = $(data);
|
|
//var term = $.terminal.active();
|
|
//term.echo(data);
|
|
$xml.find("entry").each(function() {
|
|
var $this = $(this);
|
|
item = {
|
|
title: $this.find("title").text(),
|
|
updated: new Date($this.find("updated").text()),
|
|
}
|
|
//
|
|
});
|
|
});
|
|
},
|
|
open: function(where) {
|
|
openURL('https://dl.dropboxusercontent.com/u/'+dpbx_uid+'/'+where);
|
|
},
|
|
goto: function(where) {
|
|
gotoURL('https://dl.dropboxusercontent.com/u/'+dpbx_uid+'/'+where);
|
|
},
|
|
help: function () {
|
|
this.echo("load from 'Public' Dropbox folder, available commands:");
|
|
this.echo(" 'user', 'open'/'goto'");
|
|
}
|
|
},
|
|
|
|
|
|
|
|
calc: {
|
|
add: function(a, b) {
|
|
this.echo(a+b);
|
|
},
|
|
sub: function(a, b) {
|
|
this.echo(a-b);
|
|
}
|
|
},
|
|
|
|
date: function () {
|
|
var d = new Date();
|
|
this.echo(d.toString());
|
|
},
|
|
heute: function () {
|
|
var d = new Date();
|
|
showDate(d, "Heute");
|
|
},
|
|
morgen: function () {
|
|
var d = new Date();
|
|
d.setDate(d.getDate() + 1);
|
|
showDate(d, "Morgen");
|
|
},
|
|
|
|
|
|
news: {
|
|
all: function() {
|
|
for (i = heise.length-1; i>=0; i--) {
|
|
printNewsItem(heise[i]);
|
|
}
|
|
},
|
|
today: function() {
|
|
var tdy = date2ddmmyyy(new Date());
|
|
for (i = heise.length-1; i>=0; i--) {
|
|
item = heise[i];
|
|
if (date2ddmmyyy(item.updated) == tdy) {
|
|
printNewsItem(heise[i]);
|
|
}
|
|
}
|
|
},
|
|
update: function() {
|
|
loadHeise();
|
|
},
|
|
help: function () {
|
|
this.echo("load news from heise.de rss feed, available commands:");
|
|
this.echo(" 'update', 'all', 'today'");
|
|
}
|
|
},
|
|
|
|
set: function(name, content) {
|
|
localStorage.setItem(name, content);
|
|
},
|
|
get: function(name) {
|
|
this.echo(localStorage.getItem(name));
|
|
},
|
|
|
|
help: function () {
|
|
this.echo("there is no help, just type one of the commands:");
|
|
this.echo(" 'set', 'get', 'date', 'news', 'goto'/'open',...");
|
|
}
|
|
}
|
|
, {
|
|
greetings: "Qgelm - Console",
|
|
onBlur: function() {
|
|
// prevent loosing focus
|
|
return false;
|
|
}
|
|
});
|
|
});
|
|
|
|
</script>
|
|
</body>
|