Initial import of arsnova-legacy-js

This project holds an WAR overlay for the legacy ARSnova 1.x
based on Sencha and PHP.
parents
.project
.classpath
.settings/*
target/*
<project name="ARSnova" default="run">
<property name="lib.dir" value="lib" />
<property name="sencha.dir" value="${lib.dir}/sencha1.1.1" />
<target name="min:js">
<chmod file="${sencha.dir}/jsbuilder/jsdb/linux/jsdb" perm="+x" />
<exec executable="sh" dir="${sencha.dir}/jsbuilder" failonerror="true">
<arg value="JSBuilder.sh" />
<arg value="-p ../ARSnovaCombined.jsb3" />
<arg value="-d ../" />
<arg value="-v" />
</exec>
</target>
<target name="min:css">
<java jar="${sencha.dir}/jsbuilder/ycompressor/ycompressor.jar" fork="true" failonerror="true" output="resources/css/arsnova_min.css">
<arg value="resources/css/arsnova_new.css" />
</java>
</target>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.thm.arsnova</groupId>
<artifactId>arsnova-legacy-js</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
</project>
\ No newline at end of file
Instruktionen für ARSnova
1. CouchDB installieren.
2. In der Apache-Konfiguration einen ProxyPass einrichten:
ProxyPass /couchdb http://localhost:5984
3. Die Datenbank inkl. aller Views für ARSnova anlegen lassen:
http://localhost/arsnova/couchdb_views/update.php
4. ARSnova über localhost/arsnova/developer.html aufrufen
5. Für die Produktion (ars.thm.de macht dies automatisch):
- arsnova_min.css (minifiziert) erzeugen.
- arsnovaCombined.js erzeugen. Beachte hierzu: lib/sencha1.1.1/ARSnovaCombinedHowTo
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>
arsnova-legacy-js
</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
\ No newline at end of file
/*--------------------------------------------------------------------------+
This file is part of ARSnova.
app.js
- Beschreibung: Einstiegsseite für ARSnova.
- Version: 1.0, 01/05/12
- Autor(en): Christian Thomas Weber <christian.t.weber@gmail.com>
+---------------------------------------------------------------------------+
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or any later version.
+---------------------------------------------------------------------------+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------*/
Ext.regApplication({
name: "ARSnova",
/* const */
WEBAPP : 'webapp',
NATIVE : 'native',
APP_URL : window.location.origin + window.location.pathname,
WEBSERVICE_URL : "app/webservices/",
LOGIN_GUEST : "0",
LOGIN_THM : "1",
LOGIN_OPENID : "2",
LOGIN_TWITTER : "3",
LOGIN_FACEBOOK : "4",
LOGIN_GOOGLE : "5",
USER_ROLE_STUDENT: "0",
USER_ROLE_SPEAKER: "1",
CANTEEN_LOCATION: "THM Mensa Gießen",
CANTEEN_DAY : "26.03.2012",
glossOnIcon: false,
icon: 'resources/images/ARSnova_Grafiken/01_AppIcon_114x114px.png',
/* items */
mainTabPanel: null,
tabPanel : null,
loginPanel : null,
loadingMask : null,
taskManager : null,
previousActiveItem: null,
/* infos */
loginMode : null, /* ARSnova.LOGIN_GUEST, ... */
appStatus : null, /* ARSnova.WEBAPP || ARSnova.NATIVE */
isSessionOwner : false, /* boolean */
loggedIn : false, /* boolean */
userRole : null, /* ARSnova.USER_ROLE_STUDENT || ARSnova.USER_ROLE_SPEAKER */
isNative : function () { return this.appStatus === this.NATIVE; },
isWebApp : function () { return this.appStatus === this.WEBAPP; },
/* models */
answerModel : null,
feedbackModel : null,
foodVoteModel : null,
loggedInModel : null,
questionModel : null,
sessionModel : null,
statisticModel : null,
userRankingModel: null,
/* other*/
cardSwitchDuration: 500,
/* tasks */
/**
* delete feedbacks that can be removed
*/
cleanFeedbackVotes: {
name: 'looking for feedbacks that have to be remove',
run: function(){
restProxy.cleanSessionFeedback();
},
interval: 60000 //60 seconds
},
/**
* update every x seconds the user timestamp
* important for all "who is online"-requests
*/
loggedInTask: {
name: 'save that user is logged in',
run: function(){
restProxy.loggedInTask();
},
interval: 60000 //60 seconds
},
/**
* This is called automatically when the page loads. Here we set up the main component on the page
*/
launch: function(){
if (!this.checkWebKit()) return;
if (!this.checkLocalStorage()) return;
this.checkEstudyURL();
this.setupAppStatus();
taskManager = new Ext.util.TaskRunner();
this.initModels();
this.mainTabPanel = new ARSnova.views.MainTabPanel();
this.checkPreviousLogin();
this.checkFullscreen();
},
setupAppStatus: function() {
this.appStatus = (navigator.device == null) ? this.WEBAPP : this.NATIVE;
},
/**
* initialize models
*/
initModels: function(){
this.answerModel = new ARSnova.models.Answer();
this.feedbackModel = new ARSnova.models.Feedback();
this.foodVoteModel = new ARSnova.models.FoodVote();
this.loggedInModel = new ARSnova.models.LoggedIn();
this.questionModel = new ARSnova.models.Question();
this.sessionModel = new ARSnova.models.Session();
this.statisticModel = new ARSnova.models.Statistic();
this.userRankingModel = new ARSnova.models.UserRanking();
},
/**
* check browser-engine
*/
checkWebKit: function() {
var result = /AppleWebKit\/([\d.]+)/.exec(navigator.userAgent);
if (!result) {
alert(Messages.SUPPORTED_BROWSERES);
return false;
} else {
return true;
}
},
/**
* Detect: If the application is not run in full screen mode on an apple
* device, notify user how to add app to home screen for full screen mode.
*/
checkFullscreen: function(){
if (localStorage.getItem('html5 info read') == null){
if (!this.popup){
this.popup = new ARSnova.views.CheckFullscreenPanel();
}
this.popup.show('fade');
}
},
/**
* after user has logged in
* start some tasks and show the correct homepage to user
*/
afterLogin: function(){
taskManager.start(ARSnova.loggedInTask);
taskManager.start(ARSnova.mainTabPanel.tabPanel.canteenTabPanel.statisticPanel.updateCanteenBadgeIconTask);
ARSnova.mainTabPanel.tabPanel.setActiveItem(ARSnova.mainTabPanel.tabPanel.homeTabPanel, 'slide');
var hTP = ARSnova.mainTabPanel.tabPanel.homeTabPanel;
switch (ARSnova.userRole) {
case ARSnova.USER_ROLE_STUDENT:
hTP.homePanel.checkLogin();
hTP.setActiveItem(hTP.homePanel);
break;
case ARSnova.USER_ROLE_SPEAKER:
hTP.setActiveItem(hTP.mySessionsPanel);
hTP.mySessionsPanel.fireEvent('activate');
break;
default:
break;
};
},
/**
* returns true if user is logged in a session
*/
checkSessionLogin: function(){
if(localStorage.getItem('sessionId') == undefined || localStorage.getItem('sessionId') == "")
return false;
else
return true;
},
getGetVariable: function(variable){
HTTP_GET_VARS = new Array();
strGET = document.location.search.substr(1,document.location.search.length);
if(strGET != ''){
gArr = strGET.split('&');
for(i = 0; i < gArr.length; ++i){
v = '';
vArr = gArr[i].split('=');
if(vArr.length > 1){
v = vArr[1];
}
HTTP_GET_VARS[unescape(vArr[0])] = unescape(v);
}
}
if(!HTTP_GET_VARS[variable]){
return 'undefined';
} else {
return HTTP_GET_VARS[variable];
}
},
checkPreviousLogin: function(){
if (localStorage.getItem('role') == null || localStorage.getItem('loginMode') == null || localStorage.getItem('login') == null) return false;
ARSnova.loggedIn = true;
ARSnova.loginMode = localStorage.getItem('loginMode');
ARSnova.userRole = localStorage.getItem('role');
ARSnova.setWindowTitle();
ARSnova.afterLogin();
},
setWindowTitle: function(){
switch (ARSnova.userRole) {
case ARSnova.USER_ROLE_SPEAKER:
window.document.title = "ARSnova: Dozent/in";
break;
case ARSnova.USER_ROLE_STUDENT:
window.document.title = "ARSnova: Zuhörer/in";
break;
default:
window.document.title = "ARSnova";
break;
}
},
/**
* Wrapper for an invidivudal LoadMask
*/
showLoadMask: function(message){
this.loadingMask = new Ext.LoadMask(Ext.getBody(), {
msg: message || ""
});
this.loadingMask.show();
setTimeout("ARSnova.hideLoadMask()", 5000); // hide this mask after 5 seconds automatically
},
/**
* Wrapper for an invidivudal LoadMask
*/
hideLoadMask: function(){
if(this.loadingMask){
clearTimeout("ARSnova.hideLoadMask()", 5000);
this.loadingMask.hide();
this.loadingMask.destroy();
}
},
/**
* clear local storage
*/
cleanLocalStorage: function(){
localStorage.clear();
},
/**
* check if string is valid json
*/
isJsonString: function(str){
try {
JSON.parse(str);
} catch (e){
return false;
}
return true;
},
/**
* for correct protocol, if arsnova is called inside estudy
*/
checkEstudyURL: function(){
if (window.location.host.indexOf("estudy") != -1 && window.location.protocol == "http:"){
window.location = "https://" + window.location.hostname + "/arsnova";
}
},
/**
* make localStorage ready
*/
checkLocalStorage: function(){
// try {
if (localStorage.getItem('lastVisitedSessions') == null){
localStorage.setItem('lastVisitedSessions', "[]");
}
if (localStorage.getItem('questionIds') == null){
localStorage.setItem('questionIds', "[]");
}
if (localStorage.getItem('loggedIn') == null){
localStorage.setItem('loggedIn', "[]");
}
localStorage.setItem('sessionId', "");
if (localStorage.getItem('user has voted'))
localStorage.removeItem('user has voted');
// } catch (e) {
// if (e.name == "QUOTA_EXCEEDED_ERR") {
// console.log("Quota_Exceeded_Error");
// Ext.Msg.alert("Hinweis", "Ihr Browser meldet einen Fehler: <br>\"Quota_Exceeded_Error\"<br> ARSnova kann nicht ausgeführt werden.");
// Ext.Msg.doComponentLayout();
// return false;
// }
// }
return true;
},
initFoodStore: function(){
var foodStore = Ext.getStore("Food");
if(ARSnova.config.menu1 != null && ARSnova.config.menu1 != "")
foodStore.add({
name: ARSnova.config.menu1,
value: 0
});
if(ARSnova.config.menu2 != null && ARSnova.config.menu2 != "")
foodStore.add({
name: ARSnova.config.menu2,
value: 0
});
if(ARSnova.config.menu3 != null && ARSnova.config.menu3 != "")
foodStore.add({
name: ARSnova.config.menu3,
value: 0
});
if(ARSnova.config.menu4 != null && ARSnova.config.menu4 != "")
foodStore.add({
name: ARSnova.config.menu4,
value: 0
});
if(ARSnova.config.menu5 != null && ARSnova.config.menu5 != "")
foodStore.add({
name: ARSnova.config.menu5,
value: 0
});
},
formatSessionID: function(sessionID){
var tmp = [];
for(var i = 0; i < sessionID.length; i++){
if(i % 2){
tmp.push(sessionID.substr(i - 1, 2));
}
}
if(tmp.length * 2 < sessionID.length) tmp.push(sessionID[tmp.length * 2])
return tmp.join(" ");
},
saveLastVisitedSession: function(sessionObj){
//save session as one of five lastVisitedSessions in localStorage
var sessions = Ext.decode(localStorage.getItem('lastVisitedSessions'));
var alreadyCreated = false;
for ( var i = 0; i < sessions.length; i++){
var session = sessions[i];
if (sessionObj._id == session._id){
alreadyCreated = i;
break;
}
}
if (sessions.length == 5){
if (alreadyCreated !== false){
sessions.splice(alreadyCreated, 1);
} else {
sessions.pop();
}
sessions.unshift(sessionObj);
} else {
if (alreadyCreated !== false){
sessions.splice(alreadyCreated, 1);
}
sessions.unshift(sessionObj);
}
localStorage.setItem('lastVisitedSessions', Ext.encode(sessions));
},
removeVisitedSession: function(sessionId){
var sessions = Ext.decode(localStorage.getItem('lastVisitedSessions'));
for ( var i = 0; i < sessions.length; i++){
var session = sessions[i];
if (sessionId == session._id){
sessions.splice(i, 1);
}
}
localStorage.setItem('lastVisitedSessions', Ext.encode(sessions));
}
});
function clone(obj) {
// Handle the 3 simple types, and null or undefined
if (null == obj || "object" != typeof obj) return obj;
// Handle Date
if (obj instanceof Date) {
var copy = new Date();
copy.setTime(obj.getTime());
return copy;
}
// Handle Array
if (obj instanceof Array) {
var copy = [];
for (var i = 0; i < obj.length; ++i) {
copy[i] = clone(obj[i]);
}
return copy;
}
// Handle Object
if (obj instanceof Object) {
var copy = {};
for (var attr in obj) {
if (obj.hasOwnProperty(attr)) copy[attr] = clone(obj[attr]);
}
return copy;
}
throw new Error("Unable to copy obj! Its type isn't supported.");
};
\ No newline at end of file
/*--------------------------------------------------------------------------+
This file is part of ARSnova.
app/controllers/archive.js
- Beschreibung: Archive-Controller
- Version: 1.0, 01/05/12
- Autor(en): Christian Thomas Weber <christian.t.weber@gmail.com>
+---------------------------------------------------------------------------+
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or any later version.
+---------------------------------------------------------------------------+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------*/
Ext.regController("archive", {
index: function(options){
ARSnova.mainTabPanel.tabPanel.setActiveItem(ARSnova.mainTabPanel.tabPanel.archiveTabPanel, {
type: 'slide',
});
},
showArchive: function(options){
var aTP = ARSnova.mainTabPanel.tabPanel.archiveTabPanel;
aTP.questionPanel.courseId = options.courseId;
aTP.setActiveItem(aTP.questionPanel, {
type: 'slide',
});
},
});
\ No newline at end of file
/*--------------------------------------------------------------------------+
This file is part of ARSnova.
app/controllers/auth.js
- Beschreibung: Auth-Controller
- Version: 1.0, 01/05/12
- Autor(en): Christian Thomas Weber <christian.t.weber@gmail.com>
+---------------------------------------------------------------------------+
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or any later version.
+---------------------------------------------------------------------------+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+--------------------------------------------------------------------------*/
Ext.regController("auth", {
qr: function(options) {
ARSnova.loggedIn = true;
if (localStorage.getItem('login') === null) {
localStorage.setItem('login', ARSnova.models.Auth.generateGuestName());
}
ARSnova.userRole = ARSnova.USER_ROLE_STUDENT;
localStorage.setItem('role', ARSnova.userRole);
ARSnova.loginMode = ARSnova.LOGIN_GUEST;
localStorage.setItem('loginMode', ARSnova.loginMode);
ARSnova.afterLogin();
window.location = window.location.pathname + "#";
Ext.dispatch({controller:'sessions', action:'login', keyword: options.sessionid});
},
roleSelect: function(options){
ARSnova.userRole = options.mode;
localStorage.setItem('role', options.mode);
ARSnova.setWindowTitle();
ARSnova.mainTabPanel.tabPanel.setActiveItem(ARSnova.mainTabPanel.tabPanel.loginPanel, 'slide');
},