Skip to content

Commit

Permalink
Merge pull request #6 from Surfoo/develop
Browse files Browse the repository at this point in the history
Merge develop -> master
  • Loading branch information
Surfoo authored Jun 18, 2017
2 parents 42b64d1 + 349de19 commit f182fbd
Show file tree
Hide file tree
Showing 343 changed files with 3,488 additions and 202,006 deletions.
15 changes: 13 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@
*.swp
*.sublime-project
*.sublime-workspace
.php_cs.cache
TODO
!app/tmp/.gitkeep
!app/logs/.gitkeep
!app/cache/.gitkeep
app/tmp
app/logs
app/cache
app/config.php
node_modules
!web/roadbook/.gitkeep
!web/roadbook/pdf/.gitkeep
web/roadbook/*.*
web/roadbook/pdf/*.*
!web/assets/.gitkeep
web/assets
web/roadbook
web/roadbook/pdf
vendor
samples
49 changes: 49 additions & 0 deletions app/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
label {
font-weight: normal;
}

.checkbox, .radio {
display: inline-block;
}

#faq dd {
margin-bottom: 0.6em;
}

#actions {
width: 210mm;
margin: auto;
}

#tinymce {
margin-top: 1em;
width: 210mm;
margin: 1em auto;
}

footer li {
list-style-type: none;
display: inline;
margin-right: 2em;
}

.hello-user {
color: white;
}

.hello-user img {
border-radius: 50%;
}

.close, .close:hover {
opacity: 1;
}

.tabbable ul {
margin-bottom: 15px;
}

.mce-throbber {
background-position: center 80px !important;
}

176 changes: 84 additions & 92 deletions web/js/georoadbook.js → app/app.js
Original file line number Diff line number Diff line change
@@ -1,120 +1,101 @@
/* jshint esversion: 6 */
/* global $:true */

(function() {
'use strict';

$('#spoilers4gpx').click(function(event) {
event.preventDefault();
window.open(this.href);
});

/**** Upload *****/
var content_gpx = null;

$('#btn_geocaching').click(function() {
window.location = '/login';
});

$('#hint').change(function() {
if ($('#hint').is(':checked')) {
$('#hint_options').show();
} else {
$('#hint_options').hide();
}
$('#hint_options').toggleClass('hidden');
});

$('#sort').change(function() {
if ($('#sort').is(':checked')) {
$('#sort_options').show();
} else {
$('#sort_options').hide();
}
$('#sort_options').toggleClass('hidden');
});

$('.option-help').tooltip({
placement: 'right'
});

// file selection
if (window.File && window.FileList && window.FileReader) {

$('#gpx').change(function(e) {

// fetch FileList object
var files = e.target.files || e.dataTransfer.files;

// process all File objects
for (var i = 0, f; f = files[i]; i++) {
if (f.size > 8 * 1024 * 1024) {
$('#error').html('<p>"' + f.name + '" is too big, 8Mo Max.<p>').show();
return false;
}
ParseFile(f);
}
});
} else {
$('#error').html('<p>Your browser doesn\'t support some features. Please, upgrade it.<br /> ' +
'If you are using Internet Explorer 9, you must install the version 10 at least.</p>').show();
}

// output file information

function ParseFile(file) {
var reader = new FileReader();
var fileinfo = [{
'name': file.name,
'size': file.size
}];
var reader = new FileReader(),
parser, doc, fileinfo = [{
'name': file.name,
'size': file.size
}];

reader.onload = function(e) {
if (window.DOMParser) {
parser = new DOMParser();
doc = parser.parseFromString(e.target.result, 'text/xml');
} else {
doc = new ActiveXObject('Microsoft.XMLDOM');
doc.async = 'false';
doc.loadXML(e.target.result);
}
if (window.DOMParser) {
parser = new DOMParser();
doc = parser.parseFromString(e.target.result, 'text/xml');
} else {
doc = new ActiveXObject('Microsoft.XMLDOM');
doc.async = 'false';
doc.loadXML(e.target.result);
}

doc = parser.parseFromString(e.target.result, 'application/xml');
if (!doc || doc.documentElement.tagName != 'gpx') {
content_gpx = null;
$('#error').html('<p>"' + fileinfo[0]['name'] + '" in an invalid file.<p>').show().delay(3000).fadeOut();
return false;
}
content_gpx = e.target.result;
},
reader.readAsText(file, 'UTF-8');
doc = parser.parseFromString(e.target.result, 'application/xml');
if (!doc || doc.documentElement.tagName != 'gpx') {
content_gpx = null;
$('#error').html('<p>"' + fileinfo[0].name + '" in an invalid file.<p>').show().delay(3000).fadeOut();
return false;
}
content_gpx = e.target.result;
},
/*jshint -W030 */
reader.readAsText(file, 'UTF-8');
}

$('input[type="submit"]').click(function() {
if (!content_gpx) {
$('#error').html('<p>GPX file is missing.</p>').show().delay(3000).fadeOut();
$('#error').html('').addClass('hidden');

if ((!content_gpx && $('#pocket_list').attr('selected', 'selected').val() === 'undefined') || (!content_gpx && $('#pocket_list').attr('selected', 'selected').val() === '')) {
$('#error').html('<p>A GPX file or a Pocket Query is missing.</p>').toggleClass('hidden');
return false;
}

var btn = $(this);
btn.button('loading');

$.ajax({
url: "upload.php",
url: "/upload",
type: "POST",
data: {
gpx: content_gpx,
locale: $('#locale').attr('selected', 'selected').val(),
toc: !! $('input[name="toc"]:checked').val(),
note: !! $('input[name="note"]:checked').val(),
short_desc: !! $('input[name="short_desc"]:checked').val(),
long_desc: !! $('input[name="long_desc"]:checked').val(),
hint: !! $('input[name="hint"]:checked').val(),
hint_encrypted: !! parseInt($('input[name="hint_encrypted"]:checked').val()),
waypoints: !! $('input[name="waypoints"]:checked').val(),
spoilers: !! $('input[name="spoilers"]:checked').val(),
logs: !! $('input[name="logs"]:checked').val(),
toc: !!$('input[name="toc"]:checked').val(),
note: !!$('input[name="note"]:checked').val(),
short_desc: !!$('input[name="short_desc"]:checked').val(),
long_desc: !!$('input[name="long_desc"]:checked').val(),
hint: !!$('input[name="hint"]:checked').val(),
hint_encrypted: !!parseInt($('input[name="hint_encrypted"]:checked').val()),
waypoints: !!$('input[name="waypoints"]:checked').val(),
spoilers: !!$('input[name="spoilers"]:checked').val(),
logs: !!$('input[name="logs"]:checked').val(),
sort_by: $('input[name="sort_by"]:checked').val(),
pagebreak: !! $('input[name="pagebreak"]:checked').val(),
images: !! $('input[name="images"]:checked').val()
pagebreak: !!$('input[name="pagebreak"]:checked').val(),
images: !!$('input[name="images"]:checked').val(),
pocket_guid: $('#pocket_list').attr('selected', 'selected').val()
},
success: function(data) {
if (!data || data === "" || typeof data !== 'object') {
return
return;
}
if (data && !data.success) {
$('#error').html('<p>' + data.message + '</p>').show();
btn.button('reset');
return
return;
}
$(location).attr('href', data.redirect);
},
Expand All @@ -134,7 +115,6 @@
tinymce.init({
selector: "#editable",
language: language,
height: "297mm",
plugins: [
"advlist autolink link image lists charmap hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime nonbreaking",
Expand Down Expand Up @@ -170,23 +150,13 @@
ed.setProgressState(1);

$.ajax({
url: "/delete.php",
url: "/delete",
type: "POST",
datatype: 'json',
data: {
id: roadbook_id
},
success: function(data) {
ed.setProgressState(0);

if (!data || data === "" || typeof data !== 'object') {
return;
}
if (data && data.success) {
$(location).attr('href', '../?deleted');
} else {
return;
}
success: function(url) {
location.href = url;
},
failure: function() {
ed.setProgressState(0);
Expand Down Expand Up @@ -246,7 +216,7 @@
var ed = tinyMCE.get('editable');
ed.setProgressState(1);
$.ajax({
url: "/save.php",
url: "/save",
type: "POST",
datatype: 'json',
data: {
Expand Down Expand Up @@ -274,6 +244,7 @@
var _ajax = function(real_export) {
var ed = tinyMCE.get('editable');
ed.setProgressState(1);
real_export = +real_export;

$('#btn_save').addClass('disabled');
$('#btn_export').addClass('disabled');
Expand All @@ -282,7 +253,7 @@
$('#btn_delete').addClass('disabled');

$.ajax({
url: "/export.php",
url: "/export",
type: "POST",
data: {
real_export: real_export,
Expand All @@ -295,10 +266,10 @@
'margin-bottom': document.forms[0].margin_bottom.value,
'header-align': document.forms[0].header_align.value,
'header-text': document.forms[0].header_text.value,
'header-pagination': !! $('input[name="header_pagination"]:checked').val(),
'header-pagination': !!$('input[name="header_pagination"]:checked').val(),
'footer-align': document.forms[0].footer_align.value,
'footer-text': document.forms[0].footer_text.value,
'footer-pagination': !! $('input[name="footer_pagination"]:checked').val(),
'footer-pagination': !!$('input[name="footer_pagination"]:checked').val(),
},

success: function(data) {
Expand Down Expand Up @@ -326,7 +297,7 @@
if (data && data.success) {
ed.setProgressState(0);
$('#dl_pdf').show();
$('#download_link').html(data.link + ' (' + data.size + 'Mo)');
$('#download_link').html(data.link + ' (' + data.size + 'Mb)');
$('#ui_exported').modal('show');
} else {
alert('Conversion failed :-(\nMessage:\n' + data.error);
Expand All @@ -349,4 +320,25 @@
});
};

}())
// init
if (typeof $("#gpx").fileinput === 'function') {
$("#gpx")
.fileinput({
'browseLabel': 'GPX file',
'showPreview': true,
'showUpload': false,
'maxFileCount': 1,
'autoReplace': true,
'maxFileSize': 8192,
'allowedFileExtensions': ['gpx']
})
.on('change', function(e) {
// fetch FileList object
var files = e.target.files || e.dataTransfer.files;
if (typeof files[0] === 'undefined') {
return false;
}
ParseFile(files[0]);
});
}
}());
Loading

0 comments on commit f182fbd

Please sign in to comment.