Remove some spot.js dependencies
This commit is contained in:
@@ -78,7 +78,7 @@ export default {
|
|||||||
return {page: sPage, items: asHash};
|
return {page: sPage, items: asHash};
|
||||||
},
|
},
|
||||||
setHash(sPage = '', asItems = []) {
|
setHash(sPage = '', asItems = []) {
|
||||||
if(typeof asItems == 'string') asItems = [asItems];
|
if(typeof asItems == 'string' && asItems != '') asItems = [asItems];
|
||||||
const sItems = (asItems.length > 0)?(this.spot.consts.hash_sep + asItems.join(this.spot.consts.hash_sep)):'';
|
const sItems = (asItems.length > 0)?(this.spot.consts.hash_sep + asItems.join(this.spot.consts.hash_sep)):'';
|
||||||
window.location.hash = '#' + sPage + sItems;
|
window.location.hash = '#' + sPage + sItems;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,15 +162,15 @@ export default {
|
|||||||
resizeDuration: 400,
|
resizeDuration: 400,
|
||||||
hasVideo: true,
|
hasVideo: true,
|
||||||
onMediaChange: (oMedia) => {
|
onMediaChange: (oMedia) => {
|
||||||
this.spot.updateHash('media', oMedia.id);
|
this.$parent.hash.items = [this.currProject.codename, 'media', oMedia.id];
|
||||||
if(oMedia.set == 'post-medias') this.goToPost({type: 'media', id: oMedia.id});
|
if(oMedia.set == 'post-medias') this.goToPost({type: 'media', id: oMedia.id});
|
||||||
},
|
},
|
||||||
onClosing: () => {this.spot.flushHash();}
|
onClosing: () => {this.$parent.hash.items = [this.$parent.hash.items[0]];}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async initFeed() {
|
async initFeed() {
|
||||||
//Simplebar event
|
//Simplebar event
|
||||||
this.$refs.feedSimpleBar.scrollElement.addEventListener('scroll', this.onFeedScroll);
|
this.$refs.feedSimpleBar?.scrollElement.addEventListener('scroll', this.onFeedScroll);
|
||||||
|
|
||||||
//Mobile Touchscreen Events
|
//Mobile Touchscreen Events
|
||||||
//TODO
|
//TODO
|
||||||
@@ -622,7 +622,7 @@ export default {
|
|||||||
- parseFloat(getComputedStyle(this.$refs.feedSimpleBar.$el).paddingTop)
|
- parseFloat(getComputedStyle(this.$refs.feedSimpleBar.$el).paddingTop)
|
||||||
);
|
);
|
||||||
|
|
||||||
//this.spot.flushHash(['post', 'message']);
|
//this.$parent.hash.items = [this.$parent.hash.items[0]];
|
||||||
|
|
||||||
return oRef;
|
return oRef;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,9 +50,8 @@
|
|||||||
displayedId() {
|
displayedId() {
|
||||||
return this.options.displayed_id?(this.spot.lang('counter', this.options.displayed_id)):'';
|
return this.options.displayed_id?(this.spot.lang('counter', this.options.displayed_id)):'';
|
||||||
},
|
},
|
||||||
hash() {
|
anchorLink() {
|
||||||
let asHash = this.spot.getHash();
|
return '#'+[this.hash.page, this.hash.items[0], this.options.type, this.options.id].join(this.spot.consts.hash_sep);
|
||||||
return '#'+[asHash.page, asHash.items[0], this.options.type, this.options.id].join(this.spot.consts.hash_sep);
|
|
||||||
},
|
},
|
||||||
modeHisto() {
|
modeHisto() {
|
||||||
return (this.project.currProject.mode == this.spot.consts.modes.histo);
|
return (this.project.currProject.mode == this.spot.consts.modes.histo);
|
||||||
@@ -69,10 +68,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
inject: ['spot', 'project', 'user', 'map'],
|
inject: ['spot', 'project', 'user', 'map', 'hash'],
|
||||||
methods: {
|
methods: {
|
||||||
copyAnchor() {
|
copyAnchor() {
|
||||||
copyTextToClipboard(this.spot.consts.server+this.spot.hash());
|
copyTextToClipboard(this.spot.consts.server+this.anchorLink);
|
||||||
this.anchorTitle = this.spot.lang('link_copied');
|
this.anchorTitle = this.spot.lang('link_copied');
|
||||||
this.anchorIcon = 'copied';
|
this.anchorIcon = 'copied';
|
||||||
setTimeout(()=>{ //TODO animation
|
setTimeout(()=>{ //TODO animation
|
||||||
@@ -141,7 +140,7 @@
|
|||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="index">
|
<div class="index">
|
||||||
<spotIcon :icon="subType" :text="displayedId" />
|
<spotIcon :icon="subType" :text="displayedId" />
|
||||||
<a v-if="anchorVisible" class="link desktop" @click="copyAnchor" ref="anchor" :href="hash" :title="anchorTitle">
|
<a v-if="anchorVisible" class="link desktop" @click="copyAnchor" ref="anchor" :href="anchorLink" :title="anchorTitle">
|
||||||
<spotIcon :icon="anchorIcon" />
|
<spotIcon :icon="anchorIcon" />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ export default class Spot {
|
|||||||
this.consts.hash_sep = '-';
|
this.consts.hash_sep = '-';
|
||||||
this.consts.title = 'Spotty';
|
this.consts.title = 'Spotty';
|
||||||
this.consts.default_page = 'project';
|
this.consts.default_page = 'project';
|
||||||
this.consts.timezone = Intl.DateTimeFormat().resolvedOptions().timeZone || this.consts.default_timezone;
|
//this.consts.timezone = Intl.DateTimeFormat().resolvedOptions().timeZone || this.consts.default_timezone;
|
||||||
|
|
||||||
this.pages = {};
|
this.pages = {};
|
||||||
|
|
||||||
//Variables & constants from php
|
//Variables & constants from php
|
||||||
this.vars('tmp', 'object');
|
this.vars('tmp', 'object');
|
||||||
this.vars('page', 'string');
|
this.vars('page', 'string');
|
||||||
$.each(asGlobals.vars, (sKey, oValue) => {this.vars(sKey, oValue)});
|
Object.entries(asGlobals.vars).forEach(([sKey, oValue]) => {this.vars(sKey, oValue);});
|
||||||
|
|
||||||
//page elem
|
//page elem
|
||||||
this.elem = {};
|
this.elem = {};
|
||||||
@@ -20,6 +20,7 @@ export default class Spot {
|
|||||||
|
|
||||||
/* Initialization */
|
/* Initialization */
|
||||||
|
|
||||||
|
/*
|
||||||
init() {
|
init() {
|
||||||
this.elem.container = $('#container');
|
this.elem.container = $('#container');
|
||||||
this.elem.main = $('#main');
|
this.elem.main = $('#main');
|
||||||
@@ -35,6 +36,7 @@ export default class Spot {
|
|||||||
.on('hashchange', () => {this.onHashChange();})
|
.on('hashchange', () => {this.onHashChange();})
|
||||||
.trigger('hashchange');
|
.trigger('hashchange');
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/* Variable Management */
|
/* Variable Management */
|
||||||
|
|
||||||
@@ -56,6 +58,7 @@ export default class Spot {
|
|||||||
|
|
||||||
/* Interface with server */
|
/* Interface with server */
|
||||||
|
|
||||||
|
/*
|
||||||
get(sAction, fOnSuccess, oVars, fOnError, fonProgress) {
|
get(sAction, fOnSuccess, oVars, fOnError, fonProgress) {
|
||||||
oVars = oVars || {};
|
oVars = oVars || {};
|
||||||
fOnError = fOnError || function(sError) {console.log(sError);};
|
fOnError = fOnError || function(sError) {console.log(sError);};
|
||||||
@@ -82,6 +85,7 @@ export default class Spot {
|
|||||||
fOnError(textStatus+' '+errorThrown);
|
fOnError(textStatus+' '+errorThrown);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
async get2(sAction, oVars, bLoading) {
|
async get2(sAction, oVars, bLoading) {
|
||||||
oVars = oVars || {};
|
oVars = oVars || {};
|
||||||
@@ -89,11 +93,8 @@ export default class Spot {
|
|||||||
oVars['t'] = this.consts.timezone;
|
oVars['t'] = this.consts.timezone;
|
||||||
bLoading = true;
|
bLoading = true;
|
||||||
|
|
||||||
let oUrl = new URL(this.consts.server+this.consts.process_page);
|
|
||||||
oUrl.search = new URLSearchParams(oVars).toString();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let oUrl = new URL(this.consts.server+this.consts.process_page);
|
let oUrl = new URL(this.consts.process_page, this.consts.server);
|
||||||
oUrl.search = new URLSearchParams(oVars).toString();
|
oUrl.search = new URLSearchParams(oVars).toString();
|
||||||
const oRequest = await fetch(oUrl, {method: 'GET', /*body: JSON.stringify(oVars),*/ headers: {"Content-Type": "application/json"}});
|
const oRequest = await fetch(oUrl, {method: 'GET', /*body: JSON.stringify(oVars),*/ headers: {"Content-Type": "application/json"}});
|
||||||
if(!oRequest.ok) {
|
if(!oRequest.ok) {
|
||||||
@@ -103,10 +104,12 @@ export default class Spot {
|
|||||||
else {
|
else {
|
||||||
let oResponse = await oRequest.json();
|
let oResponse = await oRequest.json();
|
||||||
bLoading = false;
|
bLoading = false;
|
||||||
if(oResponse.desc.substr(0, this.consts.lang_prefix.length)==this.consts.lang_prefix) oResponse.desc = this.lang(oData.desc.substr(this.consts.lang_prefix.length));
|
if(oResponse.desc.substr(0, this.consts.lang_prefix.length)==this.consts.lang_prefix) {
|
||||||
|
oResponse.desc = this.lang(oResponse.desc.substr(this.consts.lang_prefix.length));
|
||||||
|
}
|
||||||
|
|
||||||
if(oResponse.result == this.consts.error) return Promise.reject(oResponse.desc);
|
if(oResponse.result == this.consts.error) return Promise.reject(oResponse.desc);
|
||||||
else return Promise.resolve(oResponse.data, oResponse.desc);
|
else return oResponse.data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(oError) {
|
catch(oError) {
|
||||||
@@ -135,11 +138,13 @@ export default class Spot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isMobile() {
|
isMobile() {
|
||||||
return $('#mobile').is(':visible');
|
const mobileElem = document.getElementById('mobile');
|
||||||
|
return !!mobileElem && getComputedStyle(mobileElem).display !== 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Page Switch - Trigger & Event catching */
|
/* Page Switch - Trigger & Event catching */
|
||||||
|
|
||||||
|
/*
|
||||||
onHashChange() {
|
onHashChange() {
|
||||||
var asHash = this.getHash();
|
var asHash = this.getHash();
|
||||||
if(asHash.hash !='' && asHash.page != '') this.switchPage(asHash); //page switching
|
if(asHash.hash !='' && asHash.page != '') this.switchPage(asHash); //page switching
|
||||||
@@ -186,6 +191,7 @@ export default class Spot {
|
|||||||
var asHash = this.getHash();
|
var asHash = this.getHash();
|
||||||
if(asHash.items.length > 1 && (asTypes.length == 0 || asTypes.indexOf(asHash.items[1]) != -1)) this.setHash(asHash.page, [asHash.items[0]]);
|
if(asHash.items.length > 1 && (asTypes.length == 0 || asTypes.indexOf(asHash.items[1]) != -1)) this.setHash(asHash.page, [asHash.items[0]]);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/* Page Events */
|
/* Page Events */
|
||||||
|
|
||||||
@@ -224,6 +230,7 @@ export default class Spot {
|
|||||||
|
|
||||||
/* Page Switch - DOM Replacement */
|
/* Page Switch - DOM Replacement */
|
||||||
|
|
||||||
|
/*
|
||||||
getActionLink(sAction, oVars) {
|
getActionLink(sAction, oVars) {
|
||||||
if(!oVars) oVars = {};
|
if(!oVars) oVars = {};
|
||||||
let sVars = '';
|
let sVars = '';
|
||||||
@@ -232,11 +239,13 @@ export default class Spot {
|
|||||||
|
|
||||||
return this.consts.process_page+'?a='+sAction+sVars;
|
return this.consts.process_page+'?a='+sAction+sVars;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
addPage(sPage, oPage) {
|
addPage(sPage, oPage) {
|
||||||
this.pages[sPage] = oPage;
|
this.pages[sPage] = oPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
switchPage(asHash) {
|
switchPage(asHash) {
|
||||||
var sPageName = asHash.page;
|
var sPageName = asHash.page;
|
||||||
var bSamePage = (this.vars('page') == sPageName);
|
var bSamePage = (this.vars('page') == sPageName);
|
||||||
@@ -278,6 +287,7 @@ export default class Spot {
|
|||||||
var $FadeInElem = bFirstPage?this.elem.container:this.elem.main;
|
var $FadeInElem = bFirstPage?this.elem.container:this.elem.main;
|
||||||
$FadeInElem.hide().fadeTo('slow', 1);
|
$FadeInElem.hide().fadeTo('slow', 1);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
setPageTitle(sTitle) {
|
setPageTitle(sTitle) {
|
||||||
document.title = this.consts.title+' - '+sTitle;
|
document.title = this.consts.title+' - '+sTitle;
|
||||||
|
|||||||
Reference in New Issue
Block a user