fixed script loading, every module can have one js function which is called when all js is loaded.
This commit is contained in:
parent
eeebbb84e0
commit
2bc1a48b9b
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* jQuery on document ready */
|
||||
$(document).ready(function() {
|
||||
|
||||
$("#submitButton").click(function(){
|
||||
$.get('./api.php?call=account&action=login&username='+$('#username').val()+'&password_sha='+$.sha1($('#password').val())+'&password_md5='+hex_md5($('#password').val()), function (data) {
|
||||
if(data === 1){
|
||||
$("#loginStatusMsg").html('Login successful!!');
|
||||
} else {
|
||||
$("#loginStatusMsg").html('Wrong username or password!');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
@ -1,4 +1,4 @@
|
||||
$(document).ready(function() {
|
||||
function init__SYSTEM_SAI_saimod_sys_login() {
|
||||
//jqBootstrapValidation
|
||||
$("#login_form input").not("[type=submit]").jqBootstrapValidation({
|
||||
preventSubmit: true,
|
||||
@ -31,4 +31,4 @@ $(document).ready(function() {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@ -39,6 +39,9 @@ class default_page extends \SYSTEM\PAGE\Page {
|
||||
'<script src="'.\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'page/default_page/js/libs/bootstrap.min.js').'" type="text/javascript"></script>'.
|
||||
'<script src="'.\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'page/default_page/js/loadcssjs.js').'" type="text/javascript"></script>'.
|
||||
'<script src="'.\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'page/default_page/js/index.js').'" type="text/javascript"></script>';
|
||||
'<script src="https://www.google.com/jsapi" type="text/javascript"></script>'.
|
||||
'<script src="https://maps.google.com/maps/api/js?v=3&sensor=false" type="text/javascript"></script>'.
|
||||
'<script type="text/javascript">google.load("visualization", "1", {packages:["corechart"]});</script>';
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@ -1,41 +0,0 @@
|
||||
|
||||
var baseURL = "http://www.da-sense.de";
|
||||
var endpoint = "api.php";
|
||||
var url = baseURL + "/" + endpoint;
|
||||
|
||||
/** jQuery on document ready */
|
||||
function init(){
|
||||
|
||||
// initialize content
|
||||
loadContent('overview_request');
|
||||
|
||||
/**
|
||||
* generic navigation control
|
||||
*/
|
||||
$('div.main div#div-nav ul.nav li a').click(function () {
|
||||
var id = $(this).attr("id");
|
||||
if(id !== undefined){
|
||||
console.log("Action: "+id);
|
||||
|
||||
$('div.main div#div-nav ul.nav li').each(function(){
|
||||
$(this).removeClass('active');
|
||||
});
|
||||
$(this).parent().addClass('active');
|
||||
loadContent(id);
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Load content
|
||||
* @param {type} id
|
||||
* @returns {undefined} */
|
||||
function loadContent(id){
|
||||
var splitID = id.split("_");
|
||||
if(splitID.length > 1){
|
||||
var folder = splitID[0];
|
||||
var file = splitID[1] + ".html";
|
||||
$('div#div-content').load('dasense/page/default_developer/modules/apireference/'+folder+'/'+file);
|
||||
}
|
||||
}
|
||||
@ -1,315 +0,0 @@
|
||||
|
||||
var service_url = "http://www.da-sense.de/productive/analysis.php";
|
||||
|
||||
var map;
|
||||
|
||||
var latlng;
|
||||
var radius; // [meters]
|
||||
var active = true;
|
||||
|
||||
var currentAngle;
|
||||
var resizeMarker;
|
||||
var marker;
|
||||
var circle;
|
||||
|
||||
var storedBonusAreas = [];
|
||||
|
||||
var myOptions;
|
||||
var storedCircleOptions;
|
||||
var circleOptions;
|
||||
|
||||
/** jQuery on document ready */
|
||||
function init() {
|
||||
$('#datepicker').datepicker({
|
||||
format: 'dd-mm-yyyy',
|
||||
weekStart: 1
|
||||
});
|
||||
$('#timepicker').timepicker();
|
||||
|
||||
latlng = new google.maps.LatLng(49.87367, 8.65105);
|
||||
radius = 500;
|
||||
|
||||
// map initialization
|
||||
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
|
||||
|
||||
circleOptions = {
|
||||
strokeColor: "#61ade7",
|
||||
strokeOpacity: 0.6,
|
||||
strokeWeight: 1,
|
||||
fillColor: "#61ade7",
|
||||
fillOpacity: 0.45,
|
||||
map: map,
|
||||
center: latlng ,
|
||||
radius: radius,
|
||||
clickable:false
|
||||
};
|
||||
|
||||
storedCircleOptions = {
|
||||
strokeColor: "#00ff00",
|
||||
strokeOpacity: 0.6,
|
||||
strokeWeight: 1,
|
||||
fillColor: "#00ff00",
|
||||
fillOpacity: 0.2,
|
||||
map: map,
|
||||
center: latlng ,
|
||||
radius: radius,
|
||||
clickable:true
|
||||
};
|
||||
|
||||
myOptions = {
|
||||
zoom: 15,
|
||||
maxZoom:18,
|
||||
minZoom:7,
|
||||
center: latlng,
|
||||
mapTypeId: google.maps.MapTypeId.ROADMAP
|
||||
};
|
||||
|
||||
updateAddress();
|
||||
updateRadius();
|
||||
updateExploration();
|
||||
reload();
|
||||
|
||||
// set google maps marker
|
||||
marker = new google.maps.Marker({
|
||||
position: latlng,
|
||||
map: map,
|
||||
title: 'Center point of bonus area',
|
||||
icon: new google.maps.MarkerImage("dasense/page/default_developer/img/geo_point.png",new google.maps.Size(16,16),new google.maps.Point(0,0),new google.maps.Point(8,8)),
|
||||
cursor: "move",
|
||||
draggable: true
|
||||
});
|
||||
|
||||
google.maps.event.addListener(marker, 'dragstart', function(e) {
|
||||
currentAngle = GEO_FUNCTIONS.getAngle(e.latLng, resizeMarker.getPosition());
|
||||
});
|
||||
|
||||
google.maps.event.addListener(marker, 'drag', function(e) {
|
||||
dragCenterPoint(e);
|
||||
});
|
||||
|
||||
google.maps.event.addListener(marker, 'dragend', function(e) {
|
||||
dragCenterPoint(e);
|
||||
//fitZoom();
|
||||
map.setCenter(latlng);
|
||||
|
||||
updateAddress();
|
||||
updateExploration();
|
||||
});
|
||||
|
||||
google.maps.event.addListener(map, 'rightclick', function(e) {
|
||||
dragCenterPoint(e)
|
||||
marker.setPosition(latlng);
|
||||
});
|
||||
|
||||
// set google maps overlay: circle with specified radius and 'geopoint-marker' as centerpoint
|
||||
var resMarkPos = GEO_FUNCTIONS.getDestination(latlng, radius, 0.25*Math.PI);
|
||||
resizeMarker = new google.maps.Marker({
|
||||
position: resMarkPos,
|
||||
map: map,
|
||||
title: "Radius resizer",
|
||||
icon: new google.maps.MarkerImage("dasense/page/default_developer/img/geo_resize.png",new google.maps.Size(10,10),new google.maps.Point(0,0),new google.maps.Point(5,5)),
|
||||
cursor: "move",
|
||||
draggable: true
|
||||
});
|
||||
|
||||
circle = new google.maps.Circle(circleOptions);
|
||||
|
||||
google.maps.event.addListener(resizeMarker, 'dragend', function(e) {
|
||||
var dist = GEO_FUNCTIONS.getDistance(e.latLng, latlng);
|
||||
circle.setOptions({radius: dist});
|
||||
radius = dist;
|
||||
fitZoom();
|
||||
|
||||
updateRadius();
|
||||
updateExploration();
|
||||
});
|
||||
|
||||
google.maps.event.addListener(resizeMarker, 'drag', function(e) {
|
||||
var dist = GEO_FUNCTIONS.getDistance(e.latLng, latlng);
|
||||
radius = dist;
|
||||
|
||||
updateRadius();
|
||||
circle.setOptions({radius: dist});
|
||||
});
|
||||
|
||||
fitZoom();
|
||||
|
||||
// send button
|
||||
/* $('#submit_icon').click(function () {
|
||||
cleanErrorFields();
|
||||
|
||||
// simple validation of input fields
|
||||
var label = $('#field_label').val();
|
||||
var multiplier = $('#field_multiplier').val();
|
||||
var timeSlot = $('#field_timeSlot').val();
|
||||
var password = $('#field_password').val();
|
||||
|
||||
var valid_label = validate(label,true,255,'string');
|
||||
if(valid_label === false) {
|
||||
$('#field_error_label').html("Check label field: string (max 255 chars)");
|
||||
return;
|
||||
}
|
||||
|
||||
var valid_multiplier = validate(multiplier,true,255,'real');
|
||||
if(valid_multiplier === false){
|
||||
$('#field_error_multiplier').html("Check multiplier field: double");
|
||||
return;
|
||||
}
|
||||
|
||||
var valid_timeSlot = validate(timeSlot,true,255,'int');
|
||||
if(valid_timeSlot === false){
|
||||
$('#field_error_timeSlot').html("Check time slot field: int [seconds]");
|
||||
return;
|
||||
}
|
||||
|
||||
var valid_password = validate(password,true,45,'string');
|
||||
if(valid_password === false){
|
||||
$('#field_error_password').html("Check password field: string [max 45 chars]");
|
||||
return;
|
||||
}
|
||||
|
||||
var formatted_address = $('#field_address').html();
|
||||
|
||||
$(this).addClass('loader');
|
||||
marker.setMap(null);
|
||||
resizeMarker.setMap(null);
|
||||
circle.setOptions({fillOpacity: 0.3, fillColor: '#ff0000', strokeColor: '#ff0000'});
|
||||
|
||||
var json = '{"geo":{"lat":'+latlng.lat()+',"lng":'+latlng.lng()+',"radius":'+radius+',"faddress":"'+encodeURI(JSON.stringify(formatted_address))+'"},"starttime":'+new Date().getTime()+',"slot":'+timeSlot*1000+',"multiplier":'+multiplier+',"label":"'+encodeURI(JSON.stringify(label))+'"}';
|
||||
|
||||
// service call
|
||||
$.post(service_url,
|
||||
{
|
||||
ctrl: 'barea',
|
||||
mthd: 'insert',
|
||||
pswd: password,
|
||||
json: json
|
||||
},
|
||||
function(data,textStatus,jqXHR) {
|
||||
$('#submit_icon').removeClass('loader');
|
||||
|
||||
// service call response
|
||||
if(data['result']['status'] != null && data['result']['status'].toLowerCase() == 'ok'){
|
||||
$('#submit_icon').addClass('clean').html('Bonus area has been pushed to all registered devices.<br>Thank you for using this nice service :-)');
|
||||
circle.setOptions(storedCircleOptions);
|
||||
circle.setOptions({radius: radius, center: latlng});
|
||||
}else if(data['result']['status'] != null){
|
||||
marker.setMap(map);
|
||||
resizeMarker.setMap(map);
|
||||
circle.setOptions(circleOptions);
|
||||
circle.setOptions({radius: radius, center: latlng});
|
||||
$('#field_password').val('');
|
||||
$('#field_error_password').html("Wrong service password");
|
||||
}
|
||||
|
||||
})
|
||||
.error(function() { alert("An unexpected error occurred, please try again later !"); });
|
||||
|
||||
});
|
||||
|
||||
// clean all error fields
|
||||
function cleanErrorFields(){
|
||||
$('#field_error_label').html("<br>");
|
||||
$('#field_error_multiplier').html("<br>");
|
||||
$('#field_error_timeSlot').html("<br>");
|
||||
$('#field_error_password').html("<br>");
|
||||
}
|
||||
|
||||
// fit button
|
||||
$('#fit_icon').click(function(){
|
||||
fitZoom();
|
||||
});
|
||||
|
||||
// get all bonus areas
|
||||
$('#ref_all').click(function(){
|
||||
active = false;
|
||||
$(this).addClass('active');
|
||||
$('#ref_active').removeClass('active');
|
||||
|
||||
reload();
|
||||
});
|
||||
|
||||
// get all active bonus areas
|
||||
$('#ref_active').click(function(){
|
||||
active = true;
|
||||
$(this).addClass('active');
|
||||
$('#ref_all').removeClass('active');
|
||||
|
||||
reload();
|
||||
});*/
|
||||
|
||||
};
|
||||
|
||||
|
||||
function updateAddress(){
|
||||
$('#field_coords').html("("+latlng.lat() +", " + latlng.lng()+")");
|
||||
new google.maps.Geocoder().geocode({'latLng': latlng, 'language': 'de_DE'}, function(results, status) {
|
||||
if (status === google.maps.GeocoderStatus.OK) {
|
||||
$('#field_address').html(results[0]['formatted_address']);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateRadius(){
|
||||
$('#field_radius').html(radius.toFixed(2)+" m");
|
||||
}
|
||||
|
||||
function updateExploration(){
|
||||
/*$.getJSON(service_url+'?ctrl=data&mthd=explore&coord='+latlng.lat()+','+latlng.lng()+'&'+'radius='+radius , function(data) {
|
||||
if(data.result.length > 0){
|
||||
$("#field_exploration").html(Number((1-Number(data.result[0].explore))* 100).toFixed(2) + " %");
|
||||
}
|
||||
});*/
|
||||
}
|
||||
|
||||
function dragCenterPoint(e){
|
||||
var curPos = e.latLng;
|
||||
circle.setOptions({center: curPos});
|
||||
latlng = curPos;
|
||||
resizeMarker.setPosition(GEO_FUNCTIONS.getDestination(curPos, radius, currentAngle));
|
||||
$('#field_coords').html("("+latlng.lat() +", " + latlng.lng()+")");
|
||||
}
|
||||
|
||||
function fitZoom(){
|
||||
map.fitBounds(
|
||||
new google.maps.LatLngBounds(
|
||||
GEO_FUNCTIONS.getDestination(latlng, 2.5*radius, 1.25*Math.PI),
|
||||
GEO_FUNCTIONS.getDestination(latlng, 2.5*radius, 0.25*Math.PI)));
|
||||
}
|
||||
|
||||
// reload markers
|
||||
function reload(){
|
||||
clearOverlays();
|
||||
getStoredBonusAreas();
|
||||
}
|
||||
|
||||
// Removes the overlays from the map, but keeps them in the array
|
||||
function clearOverlays() {
|
||||
if (storedBonusAreas) {
|
||||
for (i in storedBonusAreas) {
|
||||
storedBonusAreas[i].setMap(null);
|
||||
}
|
||||
}
|
||||
storedBonusAreas = [];
|
||||
}
|
||||
|
||||
function getStoredBonusAreas(){
|
||||
storedBonusAreas = [];
|
||||
|
||||
// service call
|
||||
/* $.getJSON(service_url,
|
||||
{
|
||||
ctrl: 'barea',
|
||||
mthd: ((active == true)?'getallactive':'getall')
|
||||
},
|
||||
function(data,textStatus,jqXHR) {
|
||||
// >> creat circles + storedCircleOptions + tooltip (!!! replace radius + center !!!)
|
||||
var i=0;
|
||||
$.each(data['result'], function(key, value) {
|
||||
var sCircle = new google.maps.Circle(storedCircleOptions);
|
||||
sCircle.setOptions({radius: value['radius'], center: new google.maps.LatLng(value['lat'],value['lng'])});
|
||||
storedBonusAreas[i++] = sCircle;
|
||||
});
|
||||
})
|
||||
.error(function() { alert("An unexpected error occurred, please try again later !"); });*/
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
function init(){
|
||||
// initialize content
|
||||
loadContent('server_architecture');
|
||||
|
||||
/**
|
||||
* generic navigation control
|
||||
*/
|
||||
$('div.main div#div-nav ul.nav li a').click(function () {
|
||||
var id = $(this).attr("id");
|
||||
if(id !== undefined){
|
||||
console.log("Action: "+id);
|
||||
|
||||
$('div.main div#div-nav ul.nav li').each(function(){
|
||||
$(this).removeClass('active');
|
||||
});
|
||||
$(this).parent().addClass('active');
|
||||
loadContent(id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Load content
|
||||
* @param {type} id
|
||||
* @returns {undefined} */
|
||||
function loadContent(id){
|
||||
var splitID = id.split("_");
|
||||
if(splitID.length > 1){
|
||||
var folder = splitID[0];
|
||||
var file = splitID[1] + ".html";
|
||||
$('div#div-content').load('dasense/page/default_developer/modules/documentation/'+folder+'/'+file);
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,7 @@
|
||||
|
||||
var last_id = '';
|
||||
var scripts_loaded = 0;
|
||||
var scripts_req = 0;
|
||||
/** jQuery on document ready */
|
||||
$(document).ready(function() {
|
||||
|
||||
@ -22,22 +25,41 @@ $(document).ready(function() {
|
||||
$('.brand').click(function(){
|
||||
location.reload();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function loadModuleContent(id){
|
||||
$('div#content-wrapper').load('./?action=developer&sai_mod='+id, function(){});
|
||||
last_id = id;
|
||||
$('div#content-wrapper').load('./?action=developer&sai_mod='+id, function(){
|
||||
$.getJSON('./?action=developer&sai_mod='+id+'&css=1', function (data) {
|
||||
if(data){
|
||||
for(var i=0; i < data['result'].length; i++){
|
||||
loadCSS(data['result'][i]);}
|
||||
}
|
||||
});
|
||||
|
||||
$.getJSON('./?action=developer&sai_mod='+id+'&js=1', function (data) {
|
||||
if(data){
|
||||
scripts_req = data['result'].length;
|
||||
for(var i=0; i < data['result'].length; i++){
|
||||
loadJS(unescape(data['result'][i]));}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$.getJSON('./?action=developer&sai_mod='+id+'&css=1', function (data) {
|
||||
if(data){
|
||||
for(var i=0; i < data['result'].length; i++){
|
||||
loadCSS(data['result'][i]);}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function script_loaded(){
|
||||
scripts_loaded += 1;
|
||||
|
||||
$.getJSON('./?action=developer&sai_mod='+id+'&js=1', function (data) {
|
||||
if(data){
|
||||
for(var i=0; i < data['result'].length; i++){
|
||||
loadJS(unescape(data['result'][i]));}
|
||||
}
|
||||
});
|
||||
if(scripts_loaded >= scripts_req){
|
||||
scripts_loaded = 0;
|
||||
func = 'init_'+last_id;
|
||||
//func = jssrc.substring(jssrc.lastIndexOf('/')+1);
|
||||
func = func.replace(/\./g,'_');
|
||||
if(typeof window[func] === 'function') {
|
||||
window[func]();
|
||||
console.log(func+' called');}
|
||||
}
|
||||
}
|
||||
@ -1,18 +1,19 @@
|
||||
function loadJS(jssrc) {
|
||||
if(jssrc){
|
||||
var snode = document.createElement('script');
|
||||
snode.setAttribute('type','text/javascript');
|
||||
snode.setAttribute('src',jssrc);
|
||||
document.getElementsByTagName('head')[0].appendChild(snode);
|
||||
$.getScript(jssrc).done(function(script, textStatus) {
|
||||
console.log('Script: '+jssrc+' - '+textStatus );
|
||||
script_loaded();
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function loadCSS(csssrc) {
|
||||
if(csssrc){
|
||||
function loadCSS(csssrc) {
|
||||
if(csssrc){
|
||||
var snode = document.createElement('link');
|
||||
snode.setAttribute('type','text/css');
|
||||
snode.setAttribute('rel', 'stylesheet');
|
||||
snode.setAttribute('href',csssrc);
|
||||
document.getElementsByTagName('head')[0].appendChild(snode);
|
||||
console.log('Css: '+csssrc+' loaded.');
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
function init(){
|
||||
|
||||
}
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
|
||||
/** jQuery on document ready */
|
||||
function init(){
|
||||
|
||||
selectUsers();
|
||||
|
||||
$('#select-to').change(function(e){
|
||||
$('#select-to option:selected').each(function(){
|
||||
switch($(this).val()){
|
||||
case 'users': selectUsers(); break;
|
||||
case 'os': selectOS(); break;
|
||||
default: selectAll(); break;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
function selectUsers(){
|
||||
$('#element-os').hide();
|
||||
$('#element-users').show();
|
||||
// @todo: create table dynamically
|
||||
}
|
||||
|
||||
function selectOS(){
|
||||
$('#element-os').show();
|
||||
$('#element-users').hide();
|
||||
}
|
||||
|
||||
function selectAll(){
|
||||
$('#element-os').hide();
|
||||
$('#element-users').hide();
|
||||
}
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
|
||||
/** jQuery on document ready */
|
||||
function init(){
|
||||
|
||||
// initialize content
|
||||
loadContent('import');
|
||||
|
||||
/**
|
||||
* generic navigation control
|
||||
*/
|
||||
$('div.main div.tabbable ul.nav li a').click(function () {
|
||||
var id = $(this).parent().attr("id");
|
||||
if(id !== undefined){
|
||||
console.log("Action: "+id);
|
||||
|
||||
$('div.main div.tabbable ul.nav li').each(function(){
|
||||
$(this).removeClass('active');
|
||||
});
|
||||
$(this).parent().addClass('active');
|
||||
loadContent(id);
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Load content
|
||||
* @param {type} id
|
||||
* @returns {undefined} */
|
||||
function loadContent(id){
|
||||
$('div.tab-content').load('dasense/page/default_developer/modules/texthandler/'+id+'.html');
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user