this.autorun(() => { if (settings.ready()) { const foundSettings = ReactivityProvider.findOne(ReactivityProvider.types.Settings); if (foundSettings && foundSettings.showLiveChat && !initializedLiveChat) { initializedLiveChat = true; LiveChat.prepare(window, window.nudgespot || []); window.nudgespot.init('748ae792d632f6c5e14ad610e53ef745'); } SessionManager.set(SessionManager.strSessionApplicationLanguage, foundSettings.language || 'en'); TAPi18n.setLanguage(SessionManager.get(SessionManager.strSessionApplicationLanguage)); } });
const applyLanguage = (language = 'en') => { language = filterLanguage(language); if (!availableLanguages[language]) { language = language.split('-').shift(); } if (!language) { return; } document.documentElement.classList[isRtl(language) ? 'add' : 'remove']('rtl'); TAPi18n.setLanguage(language); loadMomentLocale(language).then((locale) => moment.locale(locale), (error) => console.error(error)); };
Meteor.startup(() => { TAPi18n.setLanguage(getUserLanguage()) T9n.setLanguage(getUserLanguage()) // Runs whenever language is changed Tracker.autorun(function () { const language = TAPi18n.getLanguage() // Change html attribute $('html').attr('lang', language) // Change moment.js locale moment.locale(language) }) })
setUiLanguage = function(lang) { Session.set('showLoadingIndicator', true); TAPi18n.setLanguage(lang) .done(function() { T9n.setLanguage(lang); prefClientLanguage.set(lang); Session.set('showLoadingIndicator', false); }) .fail(function(errorMessage) { // Handle the situation console.log(errorMessage); }); };
Meteor.startup(() => { // Only show the connection error box if it has been 5 seconds since // the app started setTimeout(() => { // FIXME: // Launch screen handle created in lib/router.js // dataReadyHold.release(); // Show the connection error box showConnectionIssue.set(true); }, CONNECTION_ISSUE_TIMEOUT); TAPi18n.setLanguage('fr') .done(function () { Session.set("selectedLanguage", 'fr'); }) .fail(function (error_message) { console.log(error_message); T9n.setLanguage('fr'); moment.locale('fr'); }); });
import { TAPi18n } from 'meteor/tap:i18n'; import { sAlert } from 'meteor/juliancwirko:s-alert'; import '../common/useraccounts-configuration.js'; //import '../common/admin-configuration.js'; import './routes.js'; TAPi18n.setLanguage("fr"); sAlert.config({ effect: '', position: 'top-right', timeout: 4000, html: false, onRouteclose: true, stack: true, offset: 0, beep: false, });
Meteor.startup(function () { if (Meteor.isClient) { if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/serviceWorker.js').then().catch(error => console.log(error)); } Session.set("loading_language", true); TAPi18n.setLanguage(getUserLanguage()).then(function () { Session.set("loading_language", false); window.cookieconsent_options = { "message": TAPi18n.__("global.cookie_consent.message"), "dismiss": TAPi18n.__("global.cookie_consent.dismiss"), "learnMore": TAPi18n.__("global.cookie_consent.learn_more"), "link": "dataprivacy", "theme": "dark-floating" }; $.getScript("//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/1.0.10/cookieconsent.min.js"); }); navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate; $(function() { FastClick.attach(document.body); }); document.onkeyup = function (event) { if (event.keyCode === 9) { $(".focused").removeClass("focused"); if ($(document.activeElement).prop("tagName") !== "BODY") { $(document.activeElement).addClass("focused"); } $('.removeQuestion').css("height", "initial"); if ($(document.activeElement).hasClass("questionIcon")) { $(document.activeElement).find(".removeQuestion").css("height", "44px"); } $('.smallGlyphicon').removeClass("smallGlyphicon"); if ($(document.activeElement).hasClass("button-markdown")) { $(document.activeElement).find(".glyphicon").addClass("smallGlyphicon"); } calculateTitelHeight(); calculateFooterFontSize(); } }; $(document).on("keyup", ".focused", function () { if (event.keyCode === 13) { $(".focused").click(); } }); document.onmousedown = function () { $(".focused").removeClass("focused"); $('.removeQuestion').css("height", "initial"); $('.smallGlyphicon').removeClass("smallGlyphicon"); calculateTitelHeight(); }; if (location.origin.indexOf("staging.arsnova.click") > -1 || location.origin.indexOf("localhost") > -1) { // Enable Debug object Debug = { addMembers: function (amount) { if (amount > 50) { throw new Error("Only 50 Members may be added per command call"); } const hashtag = Router.current().params.quizName; if (!Session.get("questionGroup") || !localData.containsHashtag(hashtag)) { throw new Error("Unsupported Operation: Invalid credentials"); } const debugMemberCount = MemberListCollection.find({hashtag: hashtag, nick: {$regex: "debug_user_*", $options: "i"}}).count(); const selectedNicks = SessionConfigurationCollection.findOne().nicks.selectedValues; for (let i = 1; i < amount + 1; i++) { if (MemberListCollection.find().fetch().length === selectedNicks.length) { return; } let nickname = ""; if (selectedNicks.length > 0) { do { nickname = selectedNicks[randomIntFromInterval(0, selectedNicks.length - 1)]; } while (MemberListCollection.findOne({nick: nickname})); } else { nickname = "debug_user_" + (i + debugMemberCount); } const bgColor = nicknameLib.rgbToHex(nicknameLib.getRandomInt(0, 255), nicknameLib.getRandomInt(0, 255), nicknameLib.getRandomInt(0, 255)); Meteor.call('MemberListCollection.addLearner', { hashtag: hashtag, nick: nickname, isDummyUser: true, privateKey: localData.getPrivateKey(), backgroundColor: bgColor, foregroundColor: nicknameLib.transformForegroundColor(nicknameLib.hexToRgb(bgColor)) }); } }, removeMembers: function () { if (!Session.get("questionGroup") || !localData.containsHashtag(Session.get("questionGroup").getHashtag())) { throw new Error("Unsupported Operation: Invalid credentials"); } Meteor.call("MemberListCollection.removeDebugUsersFromSession", Router.current().params.quizName); } }; } /* Triggers the session cleanup if the user closes the tab or the browser * @see http://stackoverflow.com/a/26275621 */ const confirmLeave = function () { if (typeof Router.current().params.quizName !== "undefined" && !localData.containsHashtag(Router.current().params.quizName)) { new Splashscreen({ autostart: true, templateName: "exitSessionSplashscreen", closeOnButton: '#closeDialogButton, #exitSessionButton, .splashscreen-container-close>.glyphicon-remove', onRendered: function (instance) { instance.templateSelector.find('#exitSessionButton').on('click', function () { cleanUp(); }); } }); return ""; } return null; }; $(window).on('mouseover', (function () { window.onbeforeunload = null; })); $(window).on('mouseout', (function () { window.onbeforeunload = confirmLeave; })); let prevKey = ""; $(document).keydown(function (e) { if (e.key.toUpperCase() == "W" && prevKey == "CONTROL") { window.onbeforeunload = confirmLeave; } else if (e.key.toUpperCase() == "F4" && (prevKey == "ALT" || prevKey == "CONTROL")) { window.onbeforeunload = confirmLeave; } prevKey = e.key.toUpperCase(); }); } });
Meteor.startup(function () { if (Meteor.isCordova) { window.alert = navigator.notification.alert; window.confirm = navigator.notification.confirm; } Session.setDefault('geolocate', true); Session.setDefault('radius', 25000); Session.setDefault('GPSstart', false); if(Meteor._localStorage.getItem('radius')){ Session.set('radius', parseInt(Meteor._localStorage.getItem('radius'))); } if(Meteor._localStorage.getItem('geolocate')){ Session.set('geolocate', JSON.parse(Meteor._localStorage.getItem('geolocate'))); } let language = window.navigator.userLanguage || window.navigator.language; if (language.indexOf('-') !== -1) language = language.split('-')[0]; if (language.indexOf('_') !== -1) language = language.split('_')[0]; ////console.log(language); //alert('language: ' + language + '\n'); Helpers.setLanguage(language); TAPi18n.setLanguage(language) .done(function () { //Session.set("showLoadingIndicator", false); }) .fail(function (error_message) { //console.log(error_message); }); SchemasEventsRest.i18n("schemas.eventsrest"); SchemasFollowRest.i18n("schemas.followrest"); SchemasInviteAttendeesEventRest.i18n("schemas.followrest"); SchemasNewsRest.i18n("schemas.news"); Template.registerHelper('distance',function (coordinates) { let geo = Location.getReactivePosition(); if(geo && geo.latitude){ let rmetre=geolib.getDistance( {latitude: parseFloat(coordinates.latitude), longitude: parseFloat(coordinates.longitude)}, {latitude: parseFloat(geo.latitude), longitude: parseFloat(geo.longitude)}); if(rmetre>1000){ let rkm=rmetre/1000; return rkm+' km'; }else{ return rmetre+' m'; } }else{ return false; } }); Template.registerHelper('equals', function(v1, v2) { return (v1 === v2); } ); Template.registerHelper('langChoix', function() { return Helpers.language(); } ); Template.registerHelper('diffInText', function(start, end) { let a = moment(start); let b = moment(end); let diffInMs = b.diff(a); // 86400000 milliseconds let diffInDays = b.diff(a, 'days'); // 1 day let diffInDayText=moment.duration(diffInMs).humanize(); return diffInDayText; } ); Template.registerHelper('isCordova', function() { return Meteor.isCordova; } ); Template.registerHelper('imageDoc', function(id) { if(id){ //console.log(id); return Documents.findOne({ id : id,doctype :'image'}); }else{ return this && this._id && this._id._str && Documents.findOne({ id : this._id._str,doctype :'image'}); } } ); Template.registerHelper("currentFieldValue", function (fieldName) { return AutoForm.getFieldValue(fieldName) || false; }); Template.registerHelper("urlImageCommunecter", function () { return Meteor.settings.public.urlimage; }); Template.registerHelper("SchemasFollowRest", SchemasFollowRest); Template.registerHelper("SchemasInviteAttendeesEventRest", SchemasInviteAttendeesEventRest); Template.registerHelper("SchemasNewsRest", SchemasNewsRest); Template.registerHelper("SchemasEventsRest", SchemasEventsRest); let success = function (state) { if(state === 'Enabled') { //console.log("GPS Is Enabled"); Session.set('GPSstart', true); Location.locate(function(pos){ Session.set('geo',pos); //console.log(pos); }, function(err){ //console.log(err.message); Session.set('GPSstart', false); Session.set('geo',null); Session.set('geoError',err.message); }); }else if(state==="Disabled"){ //console.log("GPS Is Disabled"); Session.set('GPSstart', false); Session.set('geo',null); Session.set('geoError','GPS Is Disabled'); }else if(state=='NotDetermined' || state=='Restricted'){ //console.log("Never asked user for auhtorization"); Session.set('GPSstart', false); Session.set('geo',null); Session.set('geoError','Never asked user for auhtorization'); }else if(state==='Denied'){ //console.log("Asked User for authorization but they denied"); Session.set('GPSstart', false); Session.set('geo',null); Session.set('geoError','Asked User for authorization but they denied'); } } let failure = function () { //console.log("Failed to get the GPS State"); Session.set('geoError','Failed to get the GPS State'); Session.set('GPSstart', false); } Location.getGPSState(success, failure, { dialog: false }); });
}, }) Template.app_content.helpers({ connected() { if (showConnectionIssue.get()) { return Meteor.status().connected; } return true; }, }); Template.app_nav.events({ 'click .js-select-lang'(event, instance) { const lang = event.target.id; TAPi18n.setLanguage(lang) .done(function () { Session.set("selectedLanguage", lang); T9n.setLanguage(lang); moment.locale(lang); }) .fail(function (error_message) { console.log(error_message); }); }, 'click .login-out'(event) { event.preventDefault(); Meteor.logout(); FlowRouter.go('/'); },