Compare commits

..

No commits in common. "9ce027285cf62c184332038e9ca543867b0f990b" and "fe8008c5b535166cbbb91a8772a52cea02b6e551" have entirely different histories.

3 changed files with 138 additions and 135 deletions

164
.jshintrc
View file

@ -1,74 +1,93 @@
{ {
"maxerr": 50, // JSHint Default Configuration File (as on JSHint website)
"bitwise": true, // See http://jshint.com/docs/ for more details
"camelcase": false,
"curly": false, "maxerr" : 50, // {int} Maximum error before stopping
"eqeqeq": true,
"forin": true, // Enforcing
"freeze": true, "bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
"immed": false, "camelcase" : false, // true: Identifiers must be in camelCase
"latedef": true, "curly" : false, // true: Require {} for every new block or scope
"newcap": true, "eqeqeq" : true, // true: Require triple equals (===) for comparison
"noarg": true, "forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
"noempty": true, "freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc.
"nonbsp": true, "immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
"nonew": false, "latedef" : true, // true: Require variables/functions to be defined before being used
"plusplus": false, "newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()`
"quotmark": true, "noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
"undef": true, "noempty" : true, // true: Prohibit use of empty blocks
"unused": true, "nonbsp" : true, // true: Prohibit `non-breaking whitespace` characters.
"strict": true, "nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment)
"maxparams": false, "plusplus" : false, // true: Prohibit use of `++` and `--`
"maxdepth": false, "quotmark" : true, // Quotation mark consistency:
"maxstatements": false, // false : do nothing (default)
"maxcomplexity": false, // true : ensure whatever is used is consistent
"maxlen": false, // "single" : require single quotes
"varstmt": false, // "double" : require double quotes
"asi": false, "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
"boss": false, "unused" : true, // Unused variables:
"debug": false, // true : all variables, last function parameter
"eqnull": false, // "vars" : all variables only
"esversion": 9, // "strict" : all variables, all function parameters
"moz": false, "strict" : true, // true: Requires all functions run in ES5 Strict Mode
"evil": false, "maxparams" : false, // {int} Max number of formal params allowed per function
"expr": false, "maxdepth" : false, // {int} Max depth of nested blocks (within functions)
"funcscope": false, "maxstatements" : false, // {int} Max number statements per function
"globalstrict": false, "maxcomplexity" : false, // {int} Max cyclomatic complexity per function
"iterator": false, "maxlen" : false, // {int} Max number of characters per line
"lastsemic": false, "varstmt" : false, // true: Disallow any var statements. Only `let` and `const` are allowed.
"laxbreak": false,
"laxcomma": false, // Relaxing
"loopfunc": false, "asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
"multistr": false, "boss" : false, // true: Tolerate assignments where comparisons would be expected
"noyield": false, "debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
"notypeof": false, "eqnull" : false, // true: Tolerate use of `== null`
"proto": false, "esversion" : 9, // {int} Specify the ECMAScript version to which the code must adhere.
"scripturl": false, "moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features)
"shadow": false, // (ex: `for each`, multiple try/catch, function expression…)
"sub": false, "evil" : false, // true: Tolerate use of `eval` and `new Function()`
"supernew": false, "expr" : false, // true: Tolerate `ExpressionStatement` as Programs
"validthis": false, "funcscope" : false, // true: Tolerate defining variables inside control statements
"browser": true, "globalstrict" : false, // true: Allow global "use strict" (also enables 'strict')
"browserify": false, "iterator" : false, // true: Tolerate using the `__iterator__` property
"couch": false, "lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
"devel": true, "laxbreak" : false, // true: Tolerate possibly unsafe line breakings
"dojo": false, "laxcomma" : false, // true: Tolerate comma-first style coding
"jasmine": false, "loopfunc" : false, // true: Tolerate functions being defined in loops
"jquery": true, "multistr" : false, // true: Tolerate multi-line strings
"mocha": true, "noyield" : false, // true: Tolerate generator functions with no yield statement in them.
"mootools": false, "notypeof" : false, // true: Tolerate invalid typeof operator values
"node": false, "proto" : false, // true: Tolerate using the `__proto__` property
"nonstandard": false, "scripturl" : false, // true: Tolerate script-targeted URLs
"phantom": false, "shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
"prototypejs": false, "sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
"qunit": false, "supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;`
"rhino": false, "validthis" : false, // true: Tolerate using this in a non-constructor function
"shelljs": false,
"typed": false, // Environments
"worker": false, "browser" : true, // Web Browser (window, document, etc)
"wsh": false, "browserify" : false, // Browserify (node.js code in the browser)
"yui": false, "couch" : false, // CouchDB
"globals": { "devel" : true, // Development/debugging (alert, confirm, etc)
"dojo" : false, // Dojo Toolkit
"jasmine" : false, // Jasmine
"jquery" : true, // jQuery
"mocha" : true, // Mocha
"mootools" : false, // MooTools
"node" : false, // Node.js
"nonstandard" : false, // Widely adopted globals (escape, unescape, etc)
"phantom" : false, // PhantomJS
"prototypejs" : false, // Prototype and Scriptaculous
"qunit" : false, // QUnit
"rhino" : false, // Rhino
"shelljs" : false, // ShellJS
"typed" : false, // Globals for typed array constructions
"worker" : false, // Web Workers
"wsh" : false, // Windows Scripting Host
"yui" : false, // Yahoo User Interface
// Custom globals
"globals" : { // additional predefined global variables
"debugOn": true, "debugOn": true,
"hippie": true, "hippie": true,
"viewHover": true, "viewHover": true,
@ -76,10 +95,9 @@
"TimeDisplay": true, "TimeDisplay": true,
"DateDisplay": true, "DateDisplay": true,
"checkButtonAndTarget": true, "checkButtonAndTarget": true,
"getClosestEdgeToElement": true, "getClosestEdge": true,
"getClosestEdgeToMouse": true,
"centerElementUnderCursor": true, "centerElementUnderCursor": true,
"setAttributesAccordingToPosition": true, "setAttributesAccordingToPosition": true,
"HippieTaskBar": true "HippieTaskBar": true
} }
} }

View file

@ -1,5 +1,5 @@
// TODO: Inhalte angleichen nach Zusammenfassung von app.js und function.js. // TODO: Inhalte angleichen nach Zusammenfassung von app.js und function.js.
// Benennung und Beschreibungen verbessern. // Bennung und Beschreibungen verbessern.
// This is called everytime // This is called everytime
function setup() { function setup() {
@ -56,7 +56,7 @@ function HippieScroll($tp, $dn) {
}); });
$dn.click(function (event) { $dn.click(function (event) {
event.preventDefault(); event.preventDefault();
const pos = Math.max(hippie.screen.dh, hippie.body.h) - hippie.screen.vh; var pos = Math.max(hippie.screen.dh, hippie.body.h) - hippie.screen.vh;
$('html').scrollTop(pos); $('html').scrollTop(pos);
// document.documentElement.scrollTop = pos; // document.documentElement.scrollTop = pos;
console.info('Scrolled down to', pos); console.info('Scrolled down to', pos);
@ -91,7 +91,7 @@ function HippieMeta($ma, $pp) {
let metaOn = false; let metaOn = false;
$ma.click(function () { $ma.click(function () {
const $wrap, $pop; var $wrap, $pop;
// if (metaOn !== true) { // if (metaOn !== true) {
if (!metaOn) { if (!metaOn) {
@ -162,25 +162,23 @@ function HippieMeta($ma, $pp) {
// Sets the href attribute to mailto: with given information // Sets the href attribute to mailto: with given information
function composeMail(tag, name, prov, suffix, text, topic) { function composeMail(tag, name, prov, suffix, text, topic) {
'use strict'; let trigger = tag.indexOf(".");
let trigger = tag.indexOf('.');
let mailString = name + '@' + prov + '.' + suffix; let mailString = name + '@' + prov + '.' + suffix;
let textString = mailString.replace(/@/g, '(at)'); let textString = mailString.replace(/@/g, "(at)");
let descString = 'Nachricht an ' + mailString; let descString = "Nachricht an " + mailString;
if (!text) { if (!text) {
text = mailString; text = mailString;
} else if (text === 'at') { } else if (text === "at") {
text = textString; text = textString;
} else if (text === 'to') { } else if (text === "to") {
text = descString; text = descString;
} }
if (topic) { if (topic) {
topic = '?subject=' + topic; topic = "?subject=" + topic;
} else { } else {
topic = ''; topic = "";
} }
if (trigger === -1) { if (trigger === -1) {
@ -188,7 +186,7 @@ function composeMail(tag, name, prov, suffix, text, topic) {
const elContent = el.innerHTML; const elContent = el.innerHTML;
el.innerHTML = elContent + text; el.innerHTML = elContent + text;
el.setAttribute('href', 'mailto:' + mailString + topic); el.setAttribute("href", "mailto:" + mailString + topic);
} else { } else {
const els = document.getElementsByClassName(tag.slice(1)); const els = document.getElementsByClassName(tag.slice(1));
@ -196,7 +194,7 @@ function composeMail(tag, name, prov, suffix, text, topic) {
const elContent = el.innerHTML; const elContent = el.innerHTML;
el.innerHTML = elContent + text; el.innerHTML = elContent + text;
el.setAttribute('href', 'mailto:' + mailString + topic); el.setAttribute("href", "mailto:" + mailString + topic);
} }
} }
} }
@ -348,40 +346,21 @@ function checkButtonAndTarget(event, element, button = 0) {
); );
} }
function getClosestEdgeToElement(element) { function getClosestEdge(element) {
'use strict';
const rect = element.getBoundingClientRect(); const rect = element.getBoundingClientRect();
const windowWidth = window.innerWidth;
const windowHeight = window.innerHeight;
const distances = { const distances = {
top: rect.top, top: rect.top,
right: window.innerWidth - rect.right, right: windowWidth - rect.right,
bottom: window.innerHeight - rect.bottom, bottom: windowHeight - rect.bottom,
left: rect.left left: rect.left
}; };
return Object.keys(distances).reduce((a, b) => distances[a] < distances[b] ? a : b); return Object.keys(distances).reduce((a, b) => distances[a] < distances[b] ? a : b);
} }
function getClosestEdgeToMouse(event) {
'use strict';
const mouseX = event.clientX;
const mouseY = event.clientY;
const distances = {
left: mouseX,
right: window.innerWidth - mouseX,
top: mouseY,
bottom: window.innerHeight - mouseY
};
return Object.keys(distances).reduce((a, b) =>
distances[a] < distances[b] ? a : b
);
}
function centerElementUnderCursor(event, element) { function centerElementUnderCursor(event, element) {
'use strict';
const offsetX = element.getBoundingClientRect().width / 2; const offsetX = element.getBoundingClientRect().width / 2;
const offsetY = element.getBoundingClientRect().height / 2; const offsetY = element.getBoundingClientRect().height / 2;
const x = event.clientX - offsetX; const x = event.clientX - offsetX;
@ -392,8 +371,6 @@ function centerElementUnderCursor(event, element) {
} }
function setAttributesAccordingToPosition(element, position, attributes) { function setAttributesAccordingToPosition(element, position, attributes) {
'use strict';
element.classList.remove(...Object.values(attributes).map(pos => pos.className)); element.classList.remove(...Object.values(attributes).map(pos => pos.className));
Object.keys(attributes[position].styles).forEach(key => { Object.keys(attributes[position].styles).forEach(key => {
element.style[key] = ''; element.style[key] = '';
@ -463,15 +440,17 @@ Clock.prototype.formatDigits = function (val) {
return val; return val;
}; };
var floor = Math.floor;
function ongoing() { function ongoing() {
var now = new Date(); var now = new Date();
var w = Math.floor(now.getDay()); var w = Math.floor(now.getDay());
var D = ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag']; var D = new Array("Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag");
var DNumb = Math.floor(now.getDate()); var DNumb = Math.floor(now.getDate());
var MNumb = Math.floor(now.getMonth()); var MNumb = Math.floor(now.getMonth());
var M = ['Januar', 'Februar', 'M&auml;rz', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'MaiOktober', 'November', 'Dezember']; var M = new Array("Januar", "Februar", "M&auml;rz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember");
var y = Math.floor(now.getYear()); var y = Math.floor(now.getYear());
if (y < 999) y += 1900; if (y < 999) y += 1900;
@ -522,22 +501,23 @@ function ongoing() {
var moonPosX = 0; var moonPosX = 0;
var moonPosY = 0; var moonPosY = 0;
var sun = $('#sun').css({ var sun = $("#sun").css({
'left': (s / 60) * travelWidth, "left": (s / 60) * travelWidth,
'top': (m / 60) * travelHeight "top": (m / 60) * travelHeight
}); });
$('#day').text(D[w]); $("#day").text(D[w]);
$('#dayNumb').text(DNumb); $("#dayNumb").text(DNumb);
$('#month').text(M[MNumb]); $("#month").text(M[MNumb]);
$('#year').text(y); $("#year").text(y);
$('#time').text('' + zeroFill(h, 2) + ':' + zeroFill(m, 2) + ':' + zeroFill(s, 2)); $("#time").text('' + zeroFill(h, 2) + ':' + zeroFill(m, 2) + ':' + zeroFill(s, 2));
$("#julian").text(jd.toFixed(6));
//$("#star").text(stH + ':' + stM + ':' + stS);
$("#star").text(stH + ':' + stM);
$("#star1").text(stGMT);
$("#star2").text(stGMT2);
$('#julian').text(jd.toFixed(6));
//$('#star').text(stH + ':' + stM + ':' + stS);
$('#star').text(stH + ':' + stM);
$('#star1').text(stGMT);
$('#star2').text(stGMT2);
} }
function zeroFill(number, width) { function zeroFill(number, width) {
@ -545,7 +525,7 @@ function zeroFill(number, width) {
if (width > 0) { if (width > 0) {
return new Array(width + (/\./.test(number) ? 2 : 1)).join('0') + number; return new Array(width + (/\./.test(number) ? 2 : 1)).join('0') + number;
} }
return number + ''; // always return a string return number + ""; // always return a string
} }
//Länge der Balken im Diagram berechnen //Länge der Balken im Diagram berechnen
@ -565,7 +545,7 @@ String.prototype.transform = function () {
} }
//Array Element erweitern //Array Element erweitern
Array.prototype.arrayAdd = function () { Array.prototype.arrayAdd = function () {
return eval(this.join('+')); return eval(this.join("+"));
} }
//Speicherplatz in Prozent berechnen //Speicherplatz in Prozent berechnen

View file

@ -8,7 +8,6 @@ class HippieTaskBar {
// TODO: Erweitern auf allgemeine Möglichkeiten und dann aus JSON-Datei laden // TODO: Erweitern auf allgemeine Möglichkeiten und dann aus JSON-Datei laden
this.options = options || { this.options = options || {
direction: 0, direction: 0,
position: 'bottom',
date: { date: {
year: 'numeric', year: 'numeric',
month: '2-digit', month: '2-digit',
@ -31,7 +30,7 @@ class HippieTaskBar {
this.element.querySelector('.clock').appendChild(dateElement); this.element.querySelector('.clock').appendChild(dateElement);
this.date = new DateDisplay(dateElement, this.options.date); this.date = new DateDisplay(dateElement, this.options.date);
this.setOptions(this.options.position); this.setOptions('bottom');
} }
onMouseDown(event) { onMouseDown(event) {
@ -50,7 +49,9 @@ class HippieTaskBar {
onMouseMove(event) { onMouseMove(event) {
if (this.isDragging) { if (this.isDragging) {
this.options.position = getClosestEdgeToMouse(event); if (!this.isDragging) return;
const closestEdge = getClosestEdge(this.placeholder);
const borderRadius = '4px'; const borderRadius = '4px';
const attributes = { const attributes = {
top: { top: {
@ -111,7 +112,7 @@ class HippieTaskBar {
} }
}; };
setAttributesAccordingToPosition(this.placeholder, this.options.position, attributes); setAttributesAccordingToPosition(this.placeholder, closestEdge, attributes);
centerElementUnderCursor(event, this.placeholder); centerElementUnderCursor(event, this.placeholder);
} }
} }
@ -120,6 +121,7 @@ class HippieTaskBar {
if (event.target === this.placeholder) { if (event.target === this.placeholder) {
console.debug('Drag mode disabled'); console.debug('Drag mode disabled');
if (!this.isDragging) return;
this.isDragging = false; this.isDragging = false;
this.snapToEdges(); this.snapToEdges();
@ -137,8 +139,11 @@ class HippieTaskBar {
this.element.style.display = ''; this.element.style.display = '';
} }
// TODO: Prüfung auf Ziel auslagern und schon bei Mausbewegung verfügbar machen
snapToEdges() { snapToEdges() {
this.setOptions(this.options.position); const closestEdge = getClosestEdge(this.placeholder);
this.setOptions(closestEdge);
this.date.changeFormat(this.options.date, this.options.direction); this.date.changeFormat(this.options.date, this.options.direction);
} }