Browse Source

Init git repo

master
Skylar Ittner 1 year ago
commit
76b216f85b
  1. 7
      .gitignore
  2. 37
      config.xml
  3. 23
      hooks/README.md
  4. 269
      nbproject/build.xml
  5. 3
      nbproject/configs/android.properties
  6. 3
      nbproject/configs/android_1.properties
  7. 5
      nbproject/configs/ios.properties
  8. 5
      nbproject/configs/ios_1.properties
  9. 48
      nbproject/plugins.properties
  10. 7
      nbproject/project.properties
  11. 9
      nbproject/project.xml
  12. 34
      package.json
  13. 11
      scripts/generate_credits.sh
  14. 5
      scripts/npm_prepare.sh
  15. 79
      scripts/remove_bloat.sh
  16. 7
      scripts/www_npm_install.sh
  17. 93
      www/assets/css/app.css
  18. 16
      www/assets/css/backdrop.css
  19. 16
      www/assets/css/oled.css
  20. 79
      www/assets/css/tablet.css
  21. 42
      www/assets/css/web-barcode.css
  22. 60
      www/assets/fonts/roboto/Roboto.css
  23. BIN
      www/assets/fonts/roboto/Roboto_400.woff
  24. BIN
      www/assets/fonts/roboto/Roboto_400.woff2
  25. BIN
      www/assets/fonts/roboto/Roboto_400i.woff
  26. BIN
      www/assets/fonts/roboto/Roboto_400i.woff2
  27. BIN
      www/assets/fonts/roboto/Roboto_500.woff
  28. BIN
      www/assets/fonts/roboto/Roboto_500.woff2
  29. BIN
      www/assets/fonts/roboto/Roboto_500i.woff
  30. BIN
      www/assets/fonts/roboto/Roboto_500i.woff2
  31. BIN
      www/assets/fonts/roboto/Roboto_700.woff
  32. BIN
      www/assets/fonts/roboto/Roboto_700.woff2
  33. BIN
      www/assets/fonts/roboto/Roboto_700i.woff
  34. BIN
      www/assets/fonts/roboto/Roboto_700i.woff2
  35. 31
      www/assets/iframeloading.html
  36. 152
      www/assets/js/autofill.js
  37. 27
      www/assets/js/discover.js
  38. 191
      www/assets/js/location.js
  39. 37
      www/assets/js/login.js
  40. 162
      www/assets/js/main.js
  41. 91
      www/assets/js/map.js
  42. 119
      www/assets/js/map_leaflet.js
  43. 142
      www/assets/js/map_mapbox.js
  44. 166
      www/assets/js/platform.js
  45. 142
      www/assets/js/settings.js
  46. 58
      www/assets/js/storage.js
  47. 111
      www/assets/js/sync.js
  48. 275
      www/assets/js/util.js
  49. 53
      www/index.html
  50. 57
      www/manifest.json
  51. 18
      www/package.json
  52. 5387
      www/pages/credits.html
  53. 112
      www/pages/credits.template.html
  54. 69
      www/pages/discover.html
  55. 24
      www/pages/login.html
  56. 17
      www/pages/profile.html
  57. 113
      www/pages/settings.html
  58. 17
      www/pages/welcome.html
  59. 245
      www/routes.js
  60. 42
      www/settings.js

7
.gitignore

@ -0,0 +1,7 @@
node_modules/
www/node_modules/
platforms
nbproject/private
plugins
*yarn-error.log
*npm-debug.log

37
config.xml

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" id="vote.lecte.Lecte" version="1.0.0">
<name>Lecte</name>
<description>
Community voting and reputation app.
</description>
<author email="dev@netsyms.com" href="https://netsyms.com">
Netsyms Technologies
</author>
<content src="index.html"/>
<plugin name="cordova-plugin-whitelist" spec="1"/>
<access origin="*"/>
<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
<allow-intent href="tel:*"/>
<allow-intent href="sms:*"/>
<allow-intent href="mailto:*"/>
<allow-intent href="geo:*"/>
<access launch-external="yes" origin="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
<preference name="HeaderColor" value="#4CAF50" />
<resource-file src="/res/android/drawable/ic_launcher_background.xml" target="/app/src/main/res/drawable/ic_launcher_background.xml" />
<resource-file src="/res/android/drawable/ic_launcher_foreground.xml" target="/app/src/main/res/drawable/ic_launcher_foreground.xml" />
<resource-file src="res/android/mipmap-anydpi-v26/ic_launcher.xml" target="app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml" />
<icon background="res/android/drawable/ic_launcher_background.xml" density="mdpi" foreground="res/android/drawable/ic_launcher_foreground.xml" src="res/android/mipmap-mdpi/ic_launcher.png" />
<icon background="res/android/drawable/ic_launcher_background.xml" density="hdpi" foreground="res/android/drawable/ic_launcher_foreground.xml" src="res/android/mipmap-hdpi/ic_launcher.png" />
<icon background="res/android/drawable/ic_launcher_background.xml" density="xhdpi" foreground="res/android/drawable/ic_launcher_foreground.xml" src="res/android/mipmap-xhdpi/ic_launcher.png" />
<icon background="res/android/drawable/ic_launcher_background.xml" density="xxhdpi" foreground="res/android/drawable/ic_launcher_foreground.xml" src="res/android/mipmap-xxhdpi/ic_launcher.png" />
<icon background="res/android/drawable/ic_launcher_background.xml" density="xxxhdpi" foreground="res/android/drawable/ic_launcher_foreground.xml" src="res/android/mipmap-xxxhdpi/ic_launcher.png" />
</platform>
<platform name="ios">
<allow-intent href="itms:*"/>
<allow-intent href="itms-apps:*"/>
</platform>
<hook src="scripts/npm_prepare.sh" type="before_prepare" />
</widget>

23
hooks/README.md

@ -0,0 +1,23 @@
<!--
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
-->
# Cordova Hooks
Cordova Hooks represent special scripts which could be added by application and plugin developers or even by your own build system to customize cordova commands. See Hooks Guide for more details: http://cordova.apache.org/docs/en/edge/guide_appdev_hooks_index.md.html#Hooks%20Guide.

269
nbproject/build.xml

@ -0,0 +1,269 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Generated file; DO NOT EDIT.
-->
<project name="Lecte" basedir="..">
<property file="nbproject/configs/${config}.properties" />
<scriptdef name="checkVersion" language="javascript">
<attribute name="first" />
<attribute name="property" />
<![CDATA[
var first = attributes.get("first");
if (first >= "3.0.0") {
project.setProperty(attributes.get("property"), true);
}
]]>
</scriptdef>
<scriptdef name="forDevice" language="javascript">
<![CDATA[
var dev = project.getProperty("device");
if (dev == "device") {
project.setProperty("build.for.device", true);
}
]]>
</scriptdef>
<target name="check-cordova-project">
<condition property="cordova.project">
<or>
<available file=".cordova"/>
<available file="hooks"/>
</or>
</condition>
</target>
<target name="upgrade-to-cordova-project" depends="check-cordova-project,check-cordova-version" unless="cordova.project">
<echo level="info" message="${cordova.command} -d create ${java.io.tmpdir}/nb_temp_project com.coolappz.${project.name} ${project.name}" />
<delete dir="${java.io.tmpdir}/nb_temp_project"/>
<exec executable="${cordova.command}" resolveexecutable="true" searchpath="true" failonerror="true" >
<env key="${cordova.path.key}" path="${cordova.path.value}:${android.sdk.home}/tools:${android.sdk.home}/platform-tools:${jdk.home}/bin:${ant.home}/bin:${jdk.home}/bin"/>
<env key="JAVA_HOME" path="${jdk.home}"/>
<arg value="-d"/>
<arg value="create"/>
<arg value="${java.io.tmpdir}/nb_temp_project"/>
<arg value="com.coolappz.${project.name}"/>
<arg value="${project.name}" />
</exec>
<copy todir="." overwrite="true" failonerror="false">
<fileset dir="${java.io.tmpdir}/nb_temp_project"/>
</copy>
<delete dir="${java.io.tmpdir}/nb_temp_project"/>
<delete dir="www"/>
<copy todir="www" failonerror="false" quiet="true" >
<fileset dir="${site.root}"/>
</copy>
</target>
<target name="create-hello-world" depends="check-cordova-version">
<echo level="info" message="${cordova.command} -d create www_nb_temp com.coolappz.${project.name} ${project.name}" />
<exec executable="${cordova.command}" resolveexecutable="true" searchpath="true" failonerror="true">
<env key="${cordova.path.key}" path="${cordova.path.value}:${android.sdk.home}/tools:${android.sdk.home}/platform-tools:${jdk.home}/bin:${ant.home}/bin:${jdk.home}/bin"/>
<env key="JAVA_HOME" path="${jdk.home}"/>
<arg value="-d"/>
<arg value="create"/>
<arg value="www_nb_temp"/>
<arg value="com.coolappz.${project.name}"/>
<arg value="${project.name}" />
</exec>
<delete dir="www"/>
<mkdir dir="www"/>
<move file="www_nb_temp/www" tofile="www"/>
<delete dir="www_nb_temp"/>
<delete file="www/config.xml"/>
</target>
<taskdef
classname="org.netbeans.modules.cordova.updatetask.ReadConfigTask"
classpath="${update.task.jar}"
name="readconfig"/>
<taskdef
classname="org.netbeans.modules.cordova.updatetask.PluginTask"
classpath="${update.task.jar}"
name="plugintask"/>
<target name="check-cordova-version">
<property environment="env"/>
<checkVersion first="${cordova.version}" property="cordova.ver.3"/>
<fail message="Cordova version 3 or greater required." unless="cordova.ver.3"/>
<readconfig/>
<forDevice/>
</target>
<target name="check-android-template">
<available file="platforms/android" property="android.generated.exists"/>
</target>
<target name="check-ios-template">
<available file="platforms/ios" property="ios.generated.exists"/>
</target>
<target name="create-android" depends="check-android-template,check-cordova-version,upgrade-to-cordova-project" unless="android.generated.exists">
<echo level="info" message="${cordova.command} -d platform add android"/>
<exec executable="${cordova.command}" resolveexecutable="true" searchpath="true" failonerror="true">
<env key="${cordova.path.key}" path="${cordova.path.value}:${android.sdk.home}/tools:${android.sdk.home}/platform-tools:${jdk.home}/bin:${ant.home}/bin:${jdk.home}/bin"/>
<env key="JAVA_HOME" path="${jdk.home}"/>
<arg value="-d"/>
<arg value="platform"/>
<arg value="add"/>
<arg value="android"/>
</exec>
</target>
<target name="create-ios" depends="check-ios-template,check-cordova-version,upgrade-to-cordova-project" unless="ios.generated.exists">
<echo level="info" message="${cordova.command} -d platform add ios"/>
<exec executable="${cordova.command}" resolveexecutable="true" searchpath="true" dir="." failonerror="true">
<env key="${cordova.path.key}" path="${cordova.path.value}:${android.sdk.home}/tools:${android.sdk.home}/platform-tools:${jdk.home}/bin:${ant.home}/bin:${jdk.home}/bin"/>
<env key="JAVA_HOME" path="${jdk.home}"/>
<arg value="-d"/>
<arg value="platform"/>
<arg value="add"/>
<arg value="ios"/>
</exec>
</target>
<target name="rebuild-ios" depends="clean-ios,build-ios"/>
<target name="build-ios" depends="create-ios,update-plugins,update-ios,build-ios-xcodebuild,build-ios-ipa"/>
<target name="build-ios-xcodebuild">
<property name="path" location="platforms/ios/build"/>
<exec executable="xcodebuild" dir="platforms/ios" failonerror="true">
<arg value="-project"/>
<arg value="${project.name}.xcodeproj"/>
<arg value="ARCHS=${ios.build.arch}"/>
<arg value="-target"/>
<arg value="${project.name}"/>
<arg value="-configuration"/>
<arg value="Release"/>
<arg value="-sdk"/>
<arg value="${ios.build.sdk}" />
<arg value="build"/>
<arg value="CONFIGURATION_BUILD_DIR=${path}"/>
</exec>
</target>
<target name="build-ios-ipa" if="build.for.device">
<exec executable="xcrun" dir="platforms/ios/build" failonerror="true">
<env key="CODESIGN_ALLOCATE" value="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate" />
<arg value="-sdk"/>
<arg value="${ios.build.sdk}" />
<arg value="PackageApplication"/>
<arg value="-v"/>
<arg value="${project.name}.app"/>
<arg value="-o"/>
<arg value="${basedir}/platforms/ios/build/${project.name}.ipa"/>
<arg value="--sign"/>
<arg value="${ios.certificate.name}"/>
<arg value="--embed"/>
<arg value="${ios.provisioning.profile}"/>
</exec>
<available file="${basedir}/platforms/ios/build/${project.name}.ipa" property="ipa.found"/>
<fail unless="ipa.found" message="PackageApplication failed."/>
</target>
<target name="sim-ios" depends="build-ios,ios-run-device,ios-run-simulator">
</target>
<target name="ios-run-device" if="build.for.device">
<echo>
Install "${basedir}/platforms/ios/build/${project.name}.ipa" through iTunes and run it.
</echo>
<exec executable="open" failonerror="true">
<arg value="${basedir}/platforms/ios/build/${project.name}.ipa"/>
</exec>
</target>
<target name="ios-run-simulator" unless="build.for.device">
<exec executable="killall" dir="platforms/ios/build">
<arg value="launchd_sim"/>
</exec>
<exec executable="${ios.sim.exec}" dir="platforms/ios/build">
<arg line="launch ${project.name}.app ${ios.device.args} --exit"/>
</exec>
</target>
<target name="update-plugins">
<plugintask/>
</target>
<target name="update-android">
<echo level="info" message="${cordova.command} prepare android"/>
<exec executable="${cordova.command}" resolveexecutable="true" searchpath="true" failonerror="true">
<env key="${cordova.path.key}" path="${cordova.path.value}:${android.sdk.home}/tools:${android.sdk.home}/platform-tools:${jdk.home}/bin:${ant.home}/bin:${jdk.home}/bin"/>
<env key="JAVA_HOME" path="${jdk.home}"/>
<arg value="prepare"/>
<arg value="android"/>
</exec>
</target>
<target name="update-ios">
<echo level="info" message="${cordova.command} prepare ios"/>
<exec executable="${cordova.command}" resolveexecutable="true" searchpath="true" failonerror="true">
<env key="${cordova.path.key}" path="${cordova.path.value}:${android.sdk.home}/tools:${android.sdk.home}/platform-tools:${jdk.home}/bin:${ant.home}/bin:${jdk.home}/bin"/>
<env key="JAVA_HOME" path="${jdk.home}"/>
<arg value="prepare"/>
<arg value="ios"/>
</exec>
</target>
<target name="rebuild-android" depends="clean-android,build-android"/>
<target name="build-android" depends="create-android,update-plugins">
<echo level="info" message="${cordova.command} -d build android"/>
<exec executable="${cordova.command}" resolveexecutable="true" searchpath="true" failonerror="true">
<env key="${cordova.path.key}" path="${cordova.path.value}:${android.sdk.home}/tools:${android.sdk.home}/platform-tools:${jdk.home}/bin:${ant.home}/bin:${jdk.home}/bin"/>
<env key="JAVA_HOME" path="${jdk.home}"/>
<arg value="-d"/>
<arg value="build"/>
<arg value="android"/>
</exec>
</target>
<target name="sim-android" depends="create-android,update-plugins">
<echo level="info" message="${cordova.command} -d ${android.target.device.arg} android"/>
<exec executable="${cordova.command}" resolveexecutable="true" searchpath="true" failonerror="true">
<env key="${cordova.path.key}" path="${cordova.path.value}:${android.sdk.home}/tools:${android.sdk.home}/platform-tools:${jdk.home}/bin:${ant.home}/bin:${jdk.home}/bin"/>
<env key="JAVA_HOME" path="${jdk.home}"/>
<arg value="-d"/>
<arg value="${android.target.device.arg}"/>
<arg value="android"/>
</exec>
</target>
<target name="clean-android" depends="check-android-template" if="android.generated.exists">
<exec executable="./gradlew" dir="platforms/android">
<arg value="clean" />
</exec>
</target>
<target name="clean-ios" depends="check-ios-template" if="ios.generated.exists">
<exec executable="platforms/ios/cordova/clean" />
</target>
</project>

3
nbproject/configs/android.properties

@ -0,0 +1,3 @@
device=emulator
display.name=Android Emulator
type=android

3
nbproject/configs/android_1.properties

@ -0,0 +1,3 @@
device=device
display.name=Android Device
type=android

5
nbproject/configs/ios.properties

@ -0,0 +1,5 @@
device=emulator
display.name=iPhone Simulator
ios.build.arch=i386
ios.build.sdk=
type=ios

5
nbproject/configs/ios_1.properties

@ -0,0 +1,5 @@
device=device
display.name=iPhone Device
ios.build.arch=armv7 armv7s
ios.build.sdk=
type=ios

48
nbproject/plugins.properties

@ -0,0 +1,48 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# This is a list of plugins installed in your project
# You can delete or add new plugins
#
# Format is following:
# id.of.plugin=url_of_repository
#
# Corresponding "id.of.plugin" can be found in the plugin's plugin.xml file:
# <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="foo.bar.plugin" version="0.0.1">
#
# This list contains all core cordova plugins.
#
# For more information about plugins see http://cordova.apache.org/blog/releases/2013/07/23/cordova-3.html
#
cordova-plugin-device=https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
cordova-plugin-network-information=https://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information.git
cordova-plugin-battery-status=https://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status.git
cordova-plugin-device-motion=https://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion.git
cordova-plugin-device-orientation=https://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation.git
cordova-plugin-geolocation=https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git
cordova-plugin-camera=https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git
cordova-plugin-media-capture=https://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture.git
cordova-plugin-media=https://git-wip-us.apache.org/repos/asf/cordova-plugin-media.git
cordova-plugin-file=https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git
cordova-plugin-file-transfer=https://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer.git
cordova-plugin-dialogs=https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
cordova-plugin-vibration=https://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration.git
cordova-plugin-contacts=https://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts.git
cordova-plugin-globalization=https://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization.git
cordova-plugin-splashscreen=https://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen.git
cordova-plugin-console=https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git

7
nbproject/project.properties

@ -0,0 +1,7 @@
auxiliary.org-netbeans-modules-cordova.cordova_5f_build_5f_script_5f_version=52
auxiliary.org-netbeans-modules-cordova.phonegap=true
file.reference.Lecte-test=test
file.reference.Lecte-www=www
files.encoding=UTF-8
site.root.folder=${file.reference.Lecte-www}
test.folder=${file.reference.Lecte-test}

9
nbproject/project.xml

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.web.clientproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/clientside-project/1">
<name>Lecte</name>
</data>
</configuration>
</project>

34
package.json

@ -0,0 +1,34 @@
{
"name": "vote.lecte.lecte",
"displayName": "Lecte",
"version": "1.0.0",
"description": "",
"main": "www/index.html",
"window": {
"icon": "res/logo.png",
"id": "vote.lecte.Lecte_window_main_00001",
"frame": true
},
"user_agent": "Mozilla/5.0 (%osinfo) %name/%ver NW.js/%nwver WebKit/%webkit_ver Chromium/%chromium_ver",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"ecosystem:cordova"
],
"author": "Netsyms Technologies",
"license": "MPL-2.0",
"dependencies": {
"cordova-android": "^8.1.0"
},
"cordova": {
"plugins": {
"cordova-plugin-geolocation": {},
"cordova-plugin-inappbrowser": {},
"cordova-plugin-whitelist": {},
"cordova-plugin-device": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-headercolor": {}
}
}
}

11
scripts/generate_credits.sh

@ -0,0 +1,11 @@
#!/bin/bash
echo "Generating credits files..."
cd www
yarn licenses generate-disclaimer > ../license-credits.md
cd ..
yarn licenses generate-disclaimer >> license-credits.md
cp www/pages/credits.template.html www/pages/credits.html
sed -e "/{{credits}}/r license-credits.md" -e "/{{credits}}/d" -i www/pages/credits.html

5
scripts/npm_prepare.sh

@ -0,0 +1,5 @@
#!/bin/sh
./scripts/www_npm_install.sh
./scripts/generate_credits.sh
./scripts/remove_bloat.sh

79
scripts/remove_bloat.sh

@ -0,0 +1,79 @@
#!/bin/bash
# This script removes some stuff in `www/node_modules` that the app doesn't need to run.
# It removes about 6MB from the build size.
echo "Removing bloat in node_modules..."
pwd
cd www/node_modules
rm -rf {ansicolors,buffer-from,cardinal,concat-stream,core-util-is,csscolorparser}
rm -rf {dom7,earcut,esprima,geojson-vt,gl-matrix,grid-index,ieee754,inherits,isarray}
rm -rf {kdbush,leaflet-geometryutil,@mapbox,minimist,murmurhash-js}
rm -rf {path-to-regexp,pbf,potpack,process-nextick-args}
rm -rf {protocol-buffers-schema,quickselect,readable-stream,redeyed,resolve-protobuf-schema}
rm -rf {rw,safe-buffer,sharkdown,split,ssr-window,string_decoder,supercluster}
rm -rf {template7,text-encoding,through,tinyqueue,ts-custom-error,typedarray}
rm -rf {util-deprecate,vt-pbf,wgs84}
# Make npm stop complaining that these don't exist by actually removing them
rm -rf .bin/*
cd bwip-js
rm -rf {bin,examples,src,barcode.ps,demo.html,stb_truetype.h}
rm -rf dist/bwip-js.js
rm -rf dist/node-bwipjs.js
cd ..
cd @fortawesome/fontawesome-free
rm -rf {js,less,metadata,scss,sprites,svgs}
find css -type f -not -name 'all.min.css' -delete
cd ../..
cd framework7
rm -rf components
rm -rf lazy-components
rm -rf less
rm -rf modules
rm -rf utils
rm -f framework7.*
rm -f framework7-lite.*
find css -type f -not -name 'framework7.bundle.min.css' -delete
find js -type f -not -name 'framework7.bundle.min.js' -delete
cd ..
cd jquery
rm -rf src
rm -rf external
find dist -type f -not -name 'jquery.min.js' -delete
cd ..
cd leaflet
rm -rf {CHANGELOG.md,src}
find dist -type f -not -name 'leaflet.css' -not -name 'leaflet.js' -delete
cd ..
cd leaflet.locatecontrol
rm -rf {CHANGELOG.md,README.md,src}
find dist -type f -not -name 'L.Control.Locate.min.css' -not -name 'L.Control.Locate.min.js' -delete
cd ..
cd leaflet.markercluster
rm -rf {build,example,spec,src,CHANGELOG.md}
find dist -type f -not -name 'leaflet.markercluster.js' -not -name 'MarkerCluster.css' -not -name 'MarkerCluster.Default.css' -delete
cd ..
cd material-design-icons
# Remove everything except the icon font and license, but also exclude the
# current and parent folder (. , ..) so rm won't complain about refusing
# to delete the whole filesystem
find . -maxdepth 1 -not -name '.' -not -name 'LICENSE' -not -name 'iconfont' -exec rm -rf {} \;
cd ..
cd mapbox-gl
rm -rf {build,flow-typed,src}
find dist -type f -not -name 'mapbox-gl.css' -not -name 'mapbox-gl.js' -delete
rm -rf dist/style-spec
cd ..
echo "Cleanup finished"

7
scripts/www_npm_install.sh

@ -0,0 +1,7 @@
#!/bin/bash
echo "Installing node modules in www/..."
cd www
npm install
cd ..

93
www/assets/css/app.css

@ -0,0 +1,93 @@
/*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/*
Framework7 and FontAwesome both have a .fab class
*/
.fafab {
font-family: "Font Awesome 5 Brands";
}
.fab {
-webkit-text-size-adjust: 100%;
-webkit-font-smoothing: antialiased;
font-family: var(--f7-font-family);
font-size: var(--f7-font-size);
line-height: var(--f7-line-height);
}
.page-content-fab-pad {
padding-bottom: var(--f7-fab-size);
}
.navbar, .item-link .item-title, .item-media, .item-divider, .item-label, .fab, .button, .noselect {
user-select: none;
}
.navbar-inner {
-webkit-app-region: drag;
}
.navbar-inner > * {
-webkit-app-region: no-drag;
}
/*
* Material icons are too big and disrupt the flow of text
*/
.block .material-icons {
font-size: var(--f7-block-font-size);
}
.material-icons.material-icons-24px {
font-size: 24px;
}
.material-icons-intext .material-icons {
font-size: var(--f7-block-font-size);
}
#mapbox {
width: 100%;
height: 100%;
background-color: #e8e5d8;
}
#mapbox .user-marker {
width: 25px;
height: 25px;
background-image: url(../images/user.png);
background-size: contain;
}
/* Allow tapping/clicking on package markers
* when the location dot is overlapping them
*/
#mapbox .mapboxgl-user-location-dot {
pointer-events: none;
}
.no-animation * {
-webkit-transition: 10ms !important;
-moz-transition: 10ms !important;
-o-transition: 10ms !important;
-ms-transition: 10ms !important;
transition: 10ms !important;
}
/*
Allow easily changing help text to reflect finger/mouse usage.
*/
.clicktext {
display: none;
}
@media (pointer:fine) {
.taptext {
display: none;
}
.clicktext {
display: initial;
}
}

16
www/assets/css/backdrop.css

@ -0,0 +1,16 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/*
We want the backdrops to be there so there aren't accidental touches,
but we don't want them to obscure anything.
*/
.actions-backdrop.backdrop-in, .custom-modal-backdrop.backdrop-in,
.dialog-backdrop.backdrop-in, .popover-backdrop.backdrop-in,
.popup-backdrop.backdrop-in, .preloader-backdrop.backdrop-in,
.sheet-backdrop.backdrop-in {
opacity: 0;
}

16
www/assets/css/oled.css

@ -0,0 +1,16 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/*
* Color adjustments for better OLED performance
*/
:root #app.theme-dark {
--f7-page-bg-color: #020202;
--f7-list-bg-color: #020202;
--f7-popover-bg-color: #020202;
--f7-sheet-bg-color: #020202;
}

79
www/assets/css/tablet.css

@ -0,0 +1,79 @@
/*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/*
Created on : Apr 3, 2020, 11:55:50 AM
Author : Skylar Ittner
*/
.only-tablet {
display: none;
}
@media all and (min-width: 768px) {
.only-tablet {
display: inherit;
}
.no-tablet {
display: none;
}
.page.tabbed .tabbar {
/* Remove tab switcher at bottom of page */
display: none;
height: 0;
}
.page.tabbed .tabs {
/* Put tabs next to each other */
display: flex;
}
.page.tabbed .tabs .tab {
/* un-hide "non-active" tabs */
display: block;
/* Make FABs stay where they should */
position: relative;
}
.page.tabbed .tabs .tab.tab-67 {
width: 66.67% !important;
}
.page.tabbed .tabs .tab.tab-33 {
width: 33.33% !important;
}
.page.tabbed .page-content {
padding-top: 0;
padding-bottom: 0;
}
.elevation-tablet {
/* .elevation-3 */
box-shadow: var(--f7-elevation-3)!important;
}
.page.tabbed .tabs .tab:not(:first-child) {
/*box-shadow: inset 5px 0 9px -5px rgba(0,0,0,0.3);*/
border-left: 1px solid rgba(0,0,0,0.1);
}
.page.tabbed .fab {
margin-bottom: 0;
}
.sheet-backdrop.backdrop-in {
visibility: hidden;
}
.padding-bottom-tablet {
padding-bottom: 3rem !important;
}
#mapbox {
height: calc(100% - var(--f7-navbar-height));
}
}
@media all and (min-width: 768px) and (min-height: 700px) {
.margin-top-tablet {
margin-top: 1rem;
}
}

42
www/assets/css/web-barcode.css

@ -0,0 +1,42 @@
/*
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#web-barcode-ui {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 999999;
display: block;
background: rgba(0,0,0,0.75);
}
#web-barcode-ui.hidden {
display: none;
}
#web-barcode-ui video#barcode-viewer {
max-width: calc(100% - 2em);
max-height: calc(100% - 2em);
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border-radius: 1em;
}
#web-barcode-ui .text {
position: absolute;
left: 0;
bottom: 0;
width: 100vw;
padding: 1em 5px 1em 5px;
color: white;
text-align: center;
background: rgba(0,0,0,0.5);
}

60
www/assets/fonts/roboto/Roboto.css

@ -0,0 +1,60 @@
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 400;
src:
local('Roboto'),
local('Roboto-Regular'),
url('Roboto_400.woff') format('woff'),
url('Roboto_400.woff2') format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: italic;
font-weight: 400;
src:
local('Roboto Italic'),
local('Roboto-Italic'),
url('Roboto_400i.woff') format('woff'),
url('Roboto_400i.woff2') format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 500;
src:
local('Roboto Medium'),
local('Roboto-Medium'),
url('Roboto_500.woff') format('woff'),
url('Roboto_500.woff2') format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: italic;
font-weight: 500;
src:
local('Roboto Medium Italic'),
local('Roboto-MediumItalic'),
url('Roboto_500i.woff') format('woff'),
url('Roboto_500i.woff2') format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 700;
src:
local('Roboto Bold'),
local('Roboto-Bold'),
url('Roboto_700.woff') format('woff'),
url('Roboto_700.woff2') format('woff2');
}
@font-face {
font-family: 'Roboto';
font-style: italic;
font-weight: 700;
src:
local('Roboto Bold Italic'),
local('Roboto-BoldItalic'),
url('Roboto_700i.woff') format('woff'),
url('Roboto_700i.woff2') format('woff2');
}

BIN
www/assets/fonts/roboto/Roboto_400.woff

BIN
www/assets/fonts/roboto/Roboto_400.woff2

BIN
www/assets/fonts/roboto/Roboto_400i.woff

BIN
www/assets/fonts/roboto/Roboto_400i.woff2

BIN
www/assets/fonts/roboto/Roboto_500.woff

BIN
www/assets/fonts/roboto/Roboto_500.woff2

BIN
www/assets/fonts/roboto/Roboto_500i.woff

BIN
www/assets/fonts/roboto/Roboto_500i.woff2

BIN
www/assets/fonts/roboto/Roboto_700.woff

BIN
www/assets/fonts/roboto/Roboto_700.woff2

BIN
www/assets/fonts/roboto/Roboto_700i.woff

BIN
www/assets/fonts/roboto/Roboto_700i.woff2

31
www/assets/iframeloading.html

@ -0,0 +1,31 @@
<!DOCTYPE html>
<!--
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
<html>
<head>
<title>Loading</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
*,html,body {
background-color: #fff;
font-family: Roboto, Ubuntu, sans-serif;
text-align: center;
}
div {
margin-top: 1rem;
}
</style>
</head>
<body>
<div>Loading...</div>
<script src="../settings.js"></script>
<script>
window.location.href = SETTINGS.loginurl;
</script>
</body>
</html>

152
www/assets/js/autofill.js

@ -0,0 +1,152 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
var autofillDB = {};
var autofillStreetDB = [];
if (getStorage("autofill_db") != null) {
autofillDB = JSON.parse(getStorage("autofill_db"));
}
if (getStorage("autofill_streetdb") != null) {
autofillStreetDB = JSON.parse(getStorage("autofill_streetdb"));
}
function addressToNumberAndStreet(address) {
var number = "";
var street = "";
var addressRegex = RegExp("^[0-9]+ .+$");
if (addressRegex.test(address)) {
number = address.split(" ", 2)[0];
street = address.substring(address.indexOf(' ') + 1);
}
return [number, street];
}
function addAutofillEntry(address) {
var [number, street] = addressToNumberAndStreet(address);
if (number == "" || street == "") {
return;
}
if (typeof autofillDB[number] == 'undefined') {
autofillDB[number] = [
[street, 1]
];
} else {
var found = false;
for (var i = 0; i < autofillDB[number].length; i++) {
if (autofillDB[number][i][0] == street) {
autofillDB[number][i][1]++;
found = true;
break;
}
}
if (!found) {
autofillDB[number].push([street, 1]);
}
}
setStorage("autofill_db", JSON.stringify(autofillDB));
var found = false;
for (var i = 0; i < autofillStreetDB.length; i++) {
if (autofillStreetDB[i][0] == street) {
autofillStreetDB[i][1]++;
found = true;
break;
}
}
if (!found) {
autofillStreetDB.push([street, 1]);
}
setStorage("autofill_streetdb", JSON.stringify(autofillStreetDB));
}
function searchAutofill(q, number) {
var byNumber = [];
if (typeof number != 'undefined') {
byNumber = searchAutofillByNumber(number, q);
}
var byStreet = [];
if (q.length > 0) {
byStreet = searchAutofillByStreet(q);
}
return byNumber.concat(byStreet.filter((item) => byNumber.indexOf(item) < 0));
}
function searchAutofillByNumber(number, q) {
if (typeof autofillDB[number] == 'undefined') {
return [];
}
var sorted = autofillDB[number].sort(function (a, b) {
return b[1] - a[1];
});
var query = false;
if (typeof q != 'undefined' && q != "") {
query = true;
}
var streets = [];
for (var i = 0; i < sorted.length; i++) {
// if there's no search query OR if the query matches the current item
if (!query || (query && sorted[i][0].toLowerCase().includes(q))) {
streets.push(sorted[i][0]);
}
}
return streets;
}
function searchAutofillByStreet(q) {
var streets = [];
var sortedDB = autofillStreetDB.sort(function (a, b) {
return b[1] - a[1];
});
//console.log(sortedDB);
q = q.toLowerCase();
for (var i = 0; i < sortedDB.length; i++) {
//console.log(sortedDB[i][0].toLowerCase().indexOf(q));
if (sortedDB[i][0].toLowerCase().includes(q)) {
streets.push(sortedDB[i][0]);
}
}
return streets;
}
function setupStreetAutofill(streetBox, numberBox) {
app.autocomplete.create({
inputEl: streetBox,
openIn: 'dropdown',
/* If we set valueProperty to "id" then input value on select will be set according to this property */
valueProperty: 'name', //object's "value" property name
textProperty: 'name', //object's "text" property name
limit: 10, //limit to 10 results
typeahead: true,
dropdownPlaceholderText: '',
source: function (query, render) {
var streets = searchAutofill(query, $(numberBox).val());
render(streets);
}
});
}

27
www/assets/js/discover.js

@ -0,0 +1,27 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
function setTabSwipable() {
var page = $(".page[data-name=discover]");
// If the page has grown larger, refresh to disable swiping tabs
if (page.width() >= 768 && $(".tabs-swipeable-wrap")[0]) {
router.refreshPage();
} else if (page.width() < 768 && !$(".tabs-swipeable-wrap")[0]) {
router.refreshPage();
}
}
$(window).on('resize', setTabSwipable);
setTabSwipable();
// Adjust the map when opening its tab
$(".view-main").on("click", ".tab-link#map-tab-link", function () {
var center = map.getCenter();
map.resize();
map.setCenter(center);
});

191
www/assets/js/location.js

@ -0,0 +1,191 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
var lastGpsUpdateTimestamp = 0;
var userPosition = {
coords: {
latitude: 0.0,
longitude: 0.0,
accuracy: 999999
},
updated: 0
};
// Preload last known location while GPS warms up
if (getStorage("user_latitude") != null && getStorage("user_longitude") != null) {
userPosition.coords.latitude = getStorage("user_latitude");
userPosition.coords.longitude = getStorage("user_longitude");
}
// Request the user's IP geolocation as a poor substitute for an actual location
// Should improve UX for weather tool at least
$.ajax({
url: SETTINGS.geoipapi,
dataType: 'json',
timeout: 10 * 1000,
success: function (resp) {
if (resp.status == "OK" && userPosition.coords.accuracy > 99999) {
userPosition.coords.latitude = resp.location.latitude;
userPosition.coords.longitude = resp.location.longitude;
userPosition.coords.accuracy = 99999;
userPosition.updated = time();
}
}
});
var geoerrorcount = 0;
var mapLocationControlStarted = false;
if ("geolocation" in navigator) {
navigator.geolocation.watchPosition(function (position) {
userPosition.coords = position.coords;
userPosition.updated = time();
setStorage("user_latitude", userPosition.coords.latitude);
setStorage("user_longitude", userPosition.coords.longitude);
if (mapLocationControlStarted) {
// Don't send location at an interval less than one minute
var currentTimestamp = Math.floor(Date.now() / 1000);
if (lastGpsUpdateTimestamp < (currentTimestamp - 60)) {
lastGpsUpdateTimestamp = currentTimestamp;
// TODO: check if user logged in, and if so send approx. location
// to allow discovery
}
} else {
if (map != null) {
map.startLocateControl();
mapLocationControlStarted = true;
}
}
}, function (err) {
if (typeof error == "function") {
error(err.message);
}
}, {
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0
});
} else {
geoerrorcount++;
console.log("Warn", "Geolocation error #" + geoerrorcount + ": ", error);
// Stop showing error toasts if they're happening a lot
if (geoerrorcount <= 3) {
app.toast.show({
text: '<i class="fas fa-compass"></i> ' + error,
position: "bottom",
destroyOnClose: true,
closeTimeout: 1000 * 3
});
}
}
/**
* Calculate distance between two GPS points using Vincenty Formula.
*
* From Aman Singh https://stackoverflow.com/q/30536869
*
* @param {type} lat1
* @param {type} lon1
* @param {type} lat2
* @param {type} lon2
* @returns {Number} distance in meters
*/
function getDistance(lat1, lon1, lat2, lon2) {
var toRad = function (value) {
return value * Math.PI / 180;
}
var a = 6378137, b = 6356752.314245, f = 1 / 298.257223563;
var L = toRad(lon2 - lon1);
var U1 = Math.atan((1 - f) * Math.tan(toRad(lat1)));
var U2 = Math.atan((1 - f) * Math.tan(toRad(lat2)));
var sinU1 = Math.sin(U1), cosU1 = Math.cos(U1);
var sinU2 = Math.sin(U2), cosU2 = Math.cos(U2);
var lambda = L, lambdaP, iterLimit = 100;
do
{
var sinLambda = Math.sin(lambda), cosLambda = Math.cos(lambda);
var sinSigma = Math.sqrt((cosU2 * sinLambda) * (cosU2 * sinLambda) + (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda) * (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda));
if (sinSigma == 0)
return 0;
var cosSigma = sinU1 * sinU2 + cosU1 * cosU2 * cosLambda;
var sigma = Math.atan2(sinSigma, cosSigma);
var sinAlpha = cosU1 * cosU2 * sinLambda / sinSigma;
var cosSqAlpha = 1 - sinAlpha * sinAlpha;
var cos2SigmaM = cosSigma - 2 * sinU1 * sinU2 / cosSqAlpha;
if (isNaN(cos2SigmaM))
cos2SigmaM = 0;
var C = f / 16 * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha));
lambdaP = lambda;
lambda = L + (1 - C) * f * sinAlpha * (sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
} while (Math.abs(lambda - lambdaP) > 1e-12 && --iterLimit > 0);
if (iterLimit == 0)
return NaN
var uSq = cosSqAlpha * (a * a - b * b) / (b * b);
var A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
var B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
var deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) - B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM)));
var s = b * A * (sigma - deltaSigma);
return s;
}
/**
* Return a formatted string with units corresponding to a number of meters.
* Respects user "units" setting ("metric" or "imperial").
* @param number meters
* @param bool space Add a space between number and units. Default true.
* @returns string "1000 ft", "2 mi", "3 km",
*/
function getDisplayDistance(meters, space) {
if (typeof space == 'undefined') {
space = true;
}
var units = getStorage("units");
if (units == null) {
units = "metric";
}
var number = Math.round(meters);
var label = "m";
if (units == "imperial") {
// Convert to feet
number = Math.round(number * 3.28084);
label = "ft";
if (number >= 1320) { // 0.25 miles
number = (number / 5280);
if (number < 10) {
number = number.toFixed(2);
} else {
number = Math.round(number);
}
label = "mi";
}
} else {
if (number >= 1000) {
number = (number / 1000);
if (number < 16) {
number = number.toFixed(1);
} else {
number = Math.round(number);
}
label = "km";
}
}
if (space) {
return number + " " + label;
}
return number + "" + label;
}

37
www/assets/js/login.js

@ -0,0 +1,37 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
$(window).on("message", function (e) {
var data = e.originalEvent.data;
var parts = data.split("&");
var u = "";
var p = "";
for (var i = 0; i < parts.length; i++) {
if (parts[i].startsWith("user:")) {
u = parts[i].replace("user:", "");
} else if (parts[i].startsWith("password:")) {
p = parts[i].replace("password:", "");
}
}
if (u != "" && p != "") {
setStorage("username", u);
setStorage("password", p);
// Reset last change so we won't overwrite server settings
setStorage("lastchange", 0, true);
app.toast.show({
text: "You are now logged in!",
position: "bottom",
destroyOnClose: true,
closeTimeout: 1000 * 3
});
restartApplication();
} else {
app.dialog.alert("There was a problem. Try again later.", "Error");
}
});

162
www/assets/js/main.js

@ -0,0 +1,162 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var $$ = Dom7;
// Detect platform and run platform-specific setup code
// for Cordova, NW.js, or the browser
initPlatform();
var app = new Framework7({
root: "#app",
name: "Lecte",
id: "vote.lecte.Lecte",
theme: "md",
card: {
swipeToClose: false
},
popup: {
backdrop: true
},
popover: {
backdrop: true
},
init: true,
initOnDeviceReady: false,
routes: routes
});
var mainView = app.views.create('.view-main', {
url: "/",
animate: true
});
var router = mainView.router;
function restartApplication() {
window.location = "index.html";
}
router.on("pageInit", function (pagedata) {
pagedata.$el.find('script').each(function (el) {
if ($$(this).attr('src')) {
var s = document.createElement('script');
s.src = $$(this).attr('src');
$$('head').append(s);
} else {
eval($$(this).text());
}
});
// Stop text selection from popping a system toolbar even after changing pages
if (window.getSelection) {
window.getSelection().removeAllRanges();
} else if (document.selection) {
document.selection.empty();
}
});
/**
* Perform back button behavior.
* Call this function whenever the equivalent to the Android back button is pressed.
* @returns {undefined}
*/
function handleBackButton() {
// Close map sheet if it's open
if ($(".sheet-modal").hasClass("modal-in")) {
app.sheet.close();
} else if ($(".searchbar-enabled")[0]) {
app.searchbar.disable();
} else if (scanningBarcode) {
return;
} else {
router.back({force: true, ignoreCache: true});
}
// Stop text selection from popping a system toolbar even after changing pages
if (window.getSelection) {
window.getSelection().removeAllRanges();
} else if (document.selection) {
document.selection.empty();
}
}
$(document).keyup(function (e) {
if (e.key === "Escape" || e.keyCode == 27) {
handleBackButton();
}
});
router.on("routeChange", function (newRoute) {
console.log("Info", "Navigating to ", newRoute.path);
});
function setAppTheme(theme) {
if (theme == "light") {
$("#app").removeClass("theme-dark");
if (platform_type == "cordova" && cordova.platformId == 'android' && typeof StatusBar !== 'undefined') {
StatusBar.styleDefault();
StatusBar.backgroundColorByHexString("#E0E0E0");
}
} else if (theme == "dark") {
$("#app").addClass("theme-dark");
if (platform_type == "cordova" && cordova.platformId == 'android' && typeof StatusBar !== 'undefined') {
StatusBar.styleLightContent();
StatusBar.backgroundColorByHexString("#000000");
}
}
}
function applyColorTheme() {
if (getStorage("apptheme") == "dark") {
setAppTheme("dark");
} else if (getStorage("apptheme") == "light") {
setAppTheme("light");
} else {
// automatic theme, default light
if (typeof Framework7.device.prefersColorScheme() !== 'undefined' && Framework7.device.prefersColorScheme() == "dark") {
setAppTheme("dark");
} else {
setAppTheme("light");
}
}
}
/**
* Turn animations on or off.
* @param {boolean} on true for on, false for off.
* @returns {undefined}
*/
function toggleAnimations(on) {
if (on) {
$("#app").removeClass("no-animation");
} else {
$("#app").addClass("no-animation");
}
mainView.params.animate = on;
}
/**
* Turn animations on or off while considering user preferences.
* @param boolean enabled true to enable, false to disable, undefined to use animation=on/off setting.
* @returns {undefined}
*/
function setAnimations(enabled) {
if (getStorage("animation") == null) {
setStorage("animation", "auto");
}
if (typeof enabled !== "undefined") {
toggleAnimations(enabled == true);
return;
}
if (getStorage("animation") == "off") {
toggleAnimations(false);
} else if (getStorage("animation") == "on") {
toggleAnimations(true);
}
}
applyColorTheme();
setAnimations();
router.navigate("/discover");

91
www/assets/js/map.js

@ -0,0 +1,91 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
var map = null;
var maptype = "mapbox";
function createMap() {
if (getStorage("maptype") == null) {
setStorage("maptype", "mapbox");
}
maptype = getStorage("maptype");
if (maptype == "mapbox") {
if (mapboxgl.supported()) {
map = mapboxMap();
} else {
console.log("Warn", "mapbox-gl not supported, falling back to Leaflet");
maptype = "leaflet";
map = leafletMap();
}
} else {
map = leafletMap();
}
map.updateUserLayer();
}
/**
* Destroy and re-create the map.
* @returns {undefined}
*/
function reloadMap() {
try {
if (map != null && typeof map != 'undefined') {
var mapcenter = map.getCenter();
var mapzoom = map.getZoom();
if (map.maptype == "mapbox") {
var mapbearing = map.getBearing();
var mappitch = map.getPitch();
}