change themes to nederburg
This commit is contained in:
59
public/js/audio.js
Normal file
59
public/js/audio.js
Normal file
@@ -0,0 +1,59 @@
|
||||
(function(){
|
||||
var waves = new SineWaves({
|
||||
el: document.getElementById('waves'),
|
||||
speed: 5,
|
||||
rotate: 0,
|
||||
ease: 'SineInOut',
|
||||
wavesWidth: '75%',
|
||||
waves: [
|
||||
{
|
||||
timeModifier: 4,
|
||||
lineWidth: 1,
|
||||
amplitude: -20,
|
||||
wavelength: 20
|
||||
},
|
||||
{
|
||||
timeModifier: 2,
|
||||
lineWidth: 1,
|
||||
amplitude: -10,
|
||||
wavelength: 27,
|
||||
},
|
||||
{
|
||||
timeModifier: 1,
|
||||
lineWidth: 1,
|
||||
amplitude: -27,
|
||||
wavelength: 27,
|
||||
},
|
||||
{
|
||||
timeModifier: 3,
|
||||
lineWidth: 1,
|
||||
amplitude: 36,
|
||||
wavelength: 36
|
||||
},
|
||||
{
|
||||
timeModifier: 0.5,
|
||||
lineWidth: 1,
|
||||
amplitude: -50,
|
||||
wavelength: 50
|
||||
},
|
||||
{
|
||||
timeModifier: 1.3,
|
||||
lineWidth: 1,
|
||||
amplitude: -36,
|
||||
wavelength: 36
|
||||
}
|
||||
],
|
||||
initialize: function (){},
|
||||
resizeEvent: function() {
|
||||
var gradient = this.ctx.createLinearGradient(0, 0, this.width, 0);
|
||||
gradient.addColorStop(0,"rgba(0, 0, 255, 0)");
|
||||
gradient.addColorStop(0.5,"rgba(255, 0, 0, 0.75)");
|
||||
gradient.addColorStop(1,"rgba(0, 255, 0, 0");
|
||||
var index = -1;
|
||||
var length = this.waves.length;
|
||||
while(++index < length){
|
||||
this.waves[index].strokeStyle = gradient;
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
||||
140
public/js/autosize.min.js
vendored
Normal file
140
public/js/autosize.min.js
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
! function(e, t) {
|
||||
if ("function" == typeof define && define.amd) define(["exports", "module"], t);
|
||||
else if ("undefined" != typeof exports && "undefined" != typeof module) t(exports, module);
|
||||
else {
|
||||
var n = {
|
||||
exports: {}
|
||||
};
|
||||
t(n.exports, n), e.autosize = n.exports
|
||||
}
|
||||
}(this, function(e, t) {
|
||||
"use strict";
|
||||
|
||||
function n(e) {
|
||||
function t() {
|
||||
var t = window.getComputedStyle(e, null);
|
||||
"vertical" === t.resize ? e.style.resize = "none" : "both" === t.resize && (e.style.resize = "horizontal"), s = "content-box" === t.boxSizing ? -(parseFloat(t.paddingTop) + parseFloat(t.paddingBottom)) : parseFloat(t.borderTopWidth) + parseFloat(t.borderBottomWidth), isNaN(s) && (s = 0), l()
|
||||
}
|
||||
|
||||
function n(t) {
|
||||
var n = e.style.width;
|
||||
e.style.width = "0px", e.offsetWidth, e.style.width = n, e.style.overflowY = t
|
||||
}
|
||||
|
||||
function o(e) {
|
||||
for (var t = []; e && e.parentNode && e.parentNode instanceof Element;) e.parentNode.scrollTop && t.push({
|
||||
node: e.parentNode,
|
||||
scrollTop: e.parentNode.scrollTop
|
||||
}), e = e.parentNode;
|
||||
return t
|
||||
}
|
||||
|
||||
function r() {
|
||||
var t = e.style.height,
|
||||
n = o(e),
|
||||
r = document.documentElement && document.documentElement.scrollTop;
|
||||
e.style.height = "";
|
||||
var i = e.scrollHeight + s;
|
||||
return 0 === e.scrollHeight ? void(e.style.height = t) : (e.style.height = i + "px", u = e.clientWidth, n.forEach(function(e) {
|
||||
e.node.scrollTop = e.scrollTop
|
||||
}), void(r && (document.documentElement.scrollTop = r)))
|
||||
}
|
||||
|
||||
function l() {
|
||||
r();
|
||||
var t = Math.round(parseFloat(e.style.height)),
|
||||
o = window.getComputedStyle(e, null),
|
||||
i = "content-box" === o.boxSizing ? Math.round(parseFloat(o.height)) : e.offsetHeight;
|
||||
if (i !== t ? "hidden" === o.overflowY && (n("scroll"), r(), i = "content-box" === o.boxSizing ? Math.round(parseFloat(window.getComputedStyle(e, null).height)) : e.offsetHeight) : "hidden" !== o.overflowY && (n("hidden"), r(), i = "content-box" === o.boxSizing ? Math.round(parseFloat(window.getComputedStyle(e, null).height)) : e.offsetHeight), a !== i) {
|
||||
a = i;
|
||||
var l = d("autosize:resized");
|
||||
try {
|
||||
e.dispatchEvent(l)
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
if (e && e.nodeName && "TEXTAREA" === e.nodeName && !i.has(e)) {
|
||||
var s = null,
|
||||
u = e.clientWidth,
|
||||
a = null,
|
||||
c = function() {
|
||||
e.clientWidth !== u && l()
|
||||
},
|
||||
p = function(t) {
|
||||
window.removeEventListener("resize", c, !1), e.removeEventListener("input", l, !1), e.removeEventListener("keyup", l, !1), e.removeEventListener("autosize:destroy", p, !1), e.removeEventListener("autosize:update", l, !1), Object.keys(t).forEach(function(n) {
|
||||
e.style[n] = t[n]
|
||||
}), i.delete(e)
|
||||
}.bind(e, {
|
||||
height: e.style.height,
|
||||
resize: e.style.resize,
|
||||
overflowY: e.style.overflowY,
|
||||
overflowX: e.style.overflowX,
|
||||
wordWrap: e.style.wordWrap
|
||||
});
|
||||
e.addEventListener("autosize:destroy", p, !1), "onpropertychange" in e && "oninput" in e && e.addEventListener("keyup", l, !1), window.addEventListener("resize", c, !1), e.addEventListener("input", l, !1), e.addEventListener("autosize:update", l, !1), e.style.overflowX = "hidden", e.style.wordWrap = "break-word", i.set(e, {
|
||||
destroy: p,
|
||||
update: l
|
||||
}), t()
|
||||
}
|
||||
}
|
||||
|
||||
function o(e) {
|
||||
var t = i.get(e);
|
||||
t && t.destroy()
|
||||
}
|
||||
|
||||
function r(e) {
|
||||
var t = i.get(e);
|
||||
t && t.update()
|
||||
}
|
||||
var i = "function" == typeof Map ? new Map : function() {
|
||||
var e = [],
|
||||
t = [];
|
||||
return {
|
||||
has: function(t) {
|
||||
return e.indexOf(t) > -1
|
||||
},
|
||||
get: function(n) {
|
||||
return t[e.indexOf(n)]
|
||||
},
|
||||
set: function(n, o) {
|
||||
e.indexOf(n) === -1 && (e.push(n), t.push(o))
|
||||
},
|
||||
delete: function(n) {
|
||||
var o = e.indexOf(n);
|
||||
o > -1 && (e.splice(o, 1), t.splice(o, 1))
|
||||
}
|
||||
}
|
||||
}(),
|
||||
d = function(e) {
|
||||
return new Event(e, {
|
||||
bubbles: !0
|
||||
})
|
||||
};
|
||||
try {
|
||||
new Event("test")
|
||||
} catch (e) {
|
||||
d = function(e) {
|
||||
var t = document.createEvent("Event");
|
||||
return t.initEvent(e, !0, !1), t
|
||||
}
|
||||
}
|
||||
var l = null;
|
||||
"undefined" == typeof window || "function" != typeof window.getComputedStyle ? (l = function(e) {
|
||||
return e
|
||||
}, l.destroy = function(e) {
|
||||
return e
|
||||
}, l.update = function(e) {
|
||||
return e
|
||||
}) : (l = function(e, t) {
|
||||
return e && Array.prototype.forEach.call(e.length ? e : [e], function(e) {
|
||||
return n(e, t)
|
||||
}), e
|
||||
}, l.destroy = function(e) {
|
||||
return e && Array.prototype.forEach.call(e.length ? e : [e], o), e
|
||||
}, l.update = function(e) {
|
||||
return e && Array.prototype.forEach.call(e.length ? e : [e], r), e
|
||||
}), t.exports = l
|
||||
});
|
||||
|
||||
autosize(document.querySelector('textarea'));
|
||||
37
public/js/backToTop.js
Normal file
37
public/js/backToTop.js
Normal file
@@ -0,0 +1,37 @@
|
||||
$(function(){
|
||||
// browser window scroll (in pixels) after which the "back to top" link is shown
|
||||
var offset = 300,
|
||||
//browser window scroll (in pixels) after which the "back to top" link opacity is reduced
|
||||
offset_opacity = 1200,
|
||||
//duration of the top scrolling animation (in ms)
|
||||
scroll_top_duration = 700,
|
||||
//grab the "back to top" link
|
||||
$backToTop = $('#back-to-top');
|
||||
$shareNav = $('#share-nav');
|
||||
|
||||
//hide or show the "back to top" link
|
||||
$(window).scroll(function(){
|
||||
if ($(this).scrollTop() > offset) {
|
||||
$backToTop.fadeIn();
|
||||
$shareNav.fadeIn();
|
||||
} else {
|
||||
$backToTop.fadeOut();
|
||||
$backToTop.removeClass('btt-fade-out');
|
||||
$shareNav.fadeOut();
|
||||
}
|
||||
|
||||
if($(this).scrollTop() > offset_opacity) {
|
||||
$backToTop.addClass('btt-fade-out');
|
||||
}
|
||||
});
|
||||
|
||||
//smooth scroll to top
|
||||
$backToTop.on('click', function(event){
|
||||
event.preventDefault();
|
||||
$('body,html').animate({
|
||||
scrollTop: 0 ,
|
||||
}, scroll_top_duration
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
62
public/js/bg.js
Normal file
62
public/js/bg.js
Normal file
@@ -0,0 +1,62 @@
|
||||
var dreamBGGradients = [
|
||||
[],
|
||||
// From https://uigradients.com
|
||||
['#bdc3c7', '#2c3e50'], // Grade Grey
|
||||
['#ee9ca7', '#ffdde1'], // Piggy Pink
|
||||
['#1c92d2', '#f2fcfe'], // Telegram
|
||||
// Custom
|
||||
['#acb6e5'] // Lan
|
||||
]
|
||||
|
||||
var dreamBody = $('body')
|
||||
var dreamFront = $('.flip-container .front')
|
||||
var dreamBack = $('.flip-container .back')
|
||||
|
||||
var dreamPrevBgIndex = 0
|
||||
var dreamBodyBgSwitch = []
|
||||
var dreamBodyBgSwitchIndex = 0
|
||||
|
||||
var dreamBg = dreamBGGradients[getRandomInt(0, dreamBGGradients.length)]
|
||||
dreamBodyBgSwitch.push(dreamBg)
|
||||
setBackground(dreamFront, dreamBg)
|
||||
|
||||
setBackground(dreamBody, dreamBg)
|
||||
|
||||
dreamBg = dreamBGGradients[getRandomInt(0, dreamBGGradients.length)]
|
||||
dreamBodyBgSwitch.push(dreamBg)
|
||||
setBackground(dreamBack, dreamBg)
|
||||
|
||||
function connect(arr) {
|
||||
var str = ''
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
if (i !== arr.length - 1) {
|
||||
str += arr[i] + ', '
|
||||
} else {
|
||||
str += arr[i]
|
||||
}
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
||||
function getRandomInt(min, max) {
|
||||
min = Math.ceil(min)
|
||||
max = Math.floor(max)
|
||||
var random
|
||||
while (1) {
|
||||
random = Math.floor(Math.random() * (max - min)) + min
|
||||
if (random !== dreamPrevBgIndex) {
|
||||
dreamPrevBgIndex = random
|
||||
break
|
||||
}
|
||||
}
|
||||
return random
|
||||
}
|
||||
|
||||
function setBackground(target, gradient) {
|
||||
target.css({
|
||||
background: gradient[0]
|
||||
})
|
||||
target.css({
|
||||
background: 'linear-gradient(to right, ' + connect(gradient) + ')'
|
||||
})
|
||||
}
|
||||
5
public/js/core.min.js
vendored
Normal file
5
public/js/core.min.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
function cardPressed(){this.classList.add('card-hover');}
|
||||
function cardReleased(){this.classList.remove('card-hover');}
|
||||
function hamburgerMenuPressed(){if(this.parentNode.classList.contains('hamburger-menu-open')){document.body.classList.remove('no-scroll');this.parentNode.classList.remove('hamburger-menu-open')
|
||||
this.setAttribute('aria-expanded',"false");document.body.style.paddingRight=0+"px";}else{document.body.style.paddingRight=window.innerWidth-document.documentElement.clientWidth+"px";document.body.classList.add('no-scroll');this.parentNode.classList.add('hamburger-menu-open')
|
||||
this.setAttribute('aria-expanded',"true");}}
|
||||
87
public/js/fitvids.js
Normal file
87
public/js/fitvids.js
Normal file
@@ -0,0 +1,87 @@
|
||||
/*jshint browser:true */
|
||||
/*!
|
||||
* FitVids 1.1
|
||||
*
|
||||
* Copyright 2013, Chris Coyier - http://css-tricks.com + Dave Rupert - http://daverupert.com
|
||||
* Credit to Thierry Koblentz - http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/
|
||||
* Released under the WTFPL license - http://sam.zoy.org/wtfpl/
|
||||
*
|
||||
*/
|
||||
|
||||
;(function( $ ){
|
||||
|
||||
'use strict';
|
||||
|
||||
$.fn.fitVids = function( options ) {
|
||||
var settings = {
|
||||
customSelector: null,
|
||||
ignore: null
|
||||
};
|
||||
|
||||
if(!document.getElementById('fit-vids-style')) {
|
||||
// appendStyles: https://github.com/toddmotto/fluidvids/blob/master/dist/fluidvids.js
|
||||
var head = document.head || document.getElementsByTagName('head')[0];
|
||||
var css = '.fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}';
|
||||
var div = document.createElement("div");
|
||||
div.innerHTML = '<p>x</p><style id="fit-vids-style">' + css + '</style>';
|
||||
head.appendChild(div.childNodes[1]);
|
||||
}
|
||||
|
||||
if ( options ) {
|
||||
$.extend( settings, options );
|
||||
}
|
||||
|
||||
return this.each(function(){
|
||||
var selectors = [
|
||||
'iframe[src*="player.vimeo.com"]',
|
||||
'iframe[src*="youtube.com"]',
|
||||
'iframe[src*="youtube-nocookie.com"]',
|
||||
'iframe[src*="kickstarter.com"][src*="video.html"]',
|
||||
'object',
|
||||
'embed'
|
||||
];
|
||||
|
||||
if (settings.customSelector) {
|
||||
selectors.push(settings.customSelector);
|
||||
}
|
||||
|
||||
var ignoreList = '.fitvidsignore';
|
||||
|
||||
if(settings.ignore) {
|
||||
ignoreList = ignoreList + ', ' + settings.ignore;
|
||||
}
|
||||
|
||||
var $allVideos = $(this).find(selectors.join(','));
|
||||
$allVideos = $allVideos.not('object object'); // SwfObj conflict patch
|
||||
$allVideos = $allVideos.not(ignoreList); // Disable FitVids on this video.
|
||||
|
||||
$allVideos.each(function(){
|
||||
var $this = $(this);
|
||||
if($this.parents(ignoreList).length > 0) {
|
||||
return; // Disable FitVids on this video.
|
||||
}
|
||||
if (this.tagName.toLowerCase() === 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; }
|
||||
if ((!$this.css('height') && !$this.css('width')) && (isNaN($this.attr('height')) || isNaN($this.attr('width'))))
|
||||
{
|
||||
$this.attr('height', 9);
|
||||
$this.attr('width', 16);
|
||||
}
|
||||
var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr('height') && !isNaN(parseInt($this.attr('height'), 10))) ) ? parseInt($this.attr('height'), 10) : $this.height(),
|
||||
width = !isNaN(parseInt($this.attr('width'), 10)) ? parseInt($this.attr('width'), 10) : $this.width(),
|
||||
aspectRatio = height / width;
|
||||
if(!$this.attr('name')){
|
||||
var videoName = 'fitvid' + $.fn.fitVids._count;
|
||||
$this.attr('name', videoName);
|
||||
$.fn.fitVids._count++;
|
||||
}
|
||||
$this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+'%');
|
||||
$this.removeAttr('height').removeAttr('width');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// Internal counter for unique video names.
|
||||
$.fn.fitVids._count = 0;
|
||||
|
||||
// Works with either jQuery or Zepto
|
||||
})( window.jQuery || window.Zepto );
|
||||
6
public/js/html2canvas.min.js
vendored
Normal file
6
public/js/html2canvas.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
578
public/js/index.js
Normal file
578
public/js/index.js
Normal file
@@ -0,0 +1,578 @@
|
||||
(function fileClosure(){
|
||||
// everything in this file should be declared within this closure (function).
|
||||
|
||||
// global variables
|
||||
let hidden;
|
||||
hidden = 'hidden';
|
||||
|
||||
const doc = document.documentElement;
|
||||
const staticman = Object.create(null);
|
||||
const translations = {
|
||||
success: {
|
||||
title: 'Review submitted',
|
||||
text: 'Thanks for your review! It will be shown on the site once it has been approved.',
|
||||
close: 'Close'
|
||||
},
|
||||
error: {
|
||||
title: 'Error',
|
||||
text: 'Sorry, there was an error with the submission!',
|
||||
close: 'Close'
|
||||
},
|
||||
discard: {
|
||||
title: 'Discard Comment',
|
||||
button: 'discard'
|
||||
},
|
||||
submit: 'Submit',
|
||||
submitted: 'Submitted'
|
||||
};
|
||||
|
||||
function isObj(obj) {
|
||||
return (obj && typeof obj === 'object' && obj !== null) ? true : false;
|
||||
}
|
||||
|
||||
function createEl(element = 'div') {
|
||||
return document.createElement(element);
|
||||
}
|
||||
|
||||
function elem(selector, parent = document){
|
||||
let elem = parent.querySelector(selector);
|
||||
return elem != false ? elem : false;
|
||||
}
|
||||
|
||||
function elems(selector, parent = document) {
|
||||
let elems = parent.querySelectorAll(selector);
|
||||
return elems.length ? elems : false;
|
||||
}
|
||||
|
||||
function pushClass(el, targetClass) {
|
||||
if (isObj(el) && targetClass) {
|
||||
elClass = el.classList;
|
||||
elClass.contains(targetClass) ? false : elClass.add(targetClass);
|
||||
}
|
||||
}
|
||||
|
||||
function deleteClass(el, targetClass) {
|
||||
if (isObj(el) && targetClass) {
|
||||
elClass = el.classList;
|
||||
elClass.contains(targetClass) ? elClass.remove(targetClass) : false;
|
||||
}
|
||||
}
|
||||
|
||||
function modifyClass(el, targetClass) {
|
||||
if (isObj(el) && targetClass) {
|
||||
elClass = el.classList;
|
||||
elClass.contains(targetClass) ? elClass.remove(targetClass) : elClass.add(targetClass);
|
||||
}
|
||||
}
|
||||
|
||||
function containsClass(el, targetClass) {
|
||||
if (isObj(el) && targetClass && el !== document ) {
|
||||
return el.classList.contains(targetClass) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
function isChild(node, parentClass) {
|
||||
let objectsAreValid = isObj(node) && parentClass && typeof parentClass == 'string';
|
||||
return (objectsAreValid && node.closest(parentClass)) ? true : false;
|
||||
}
|
||||
|
||||
function elemAttribute(elem, attr, value = null) {
|
||||
if (value) {
|
||||
elem.setAttribute(attr, value);
|
||||
} else {
|
||||
value = elem.getAttribute(attr);
|
||||
return value ? value : false;
|
||||
}
|
||||
}
|
||||
|
||||
function deleteChars(str, subs) {
|
||||
let newStr = str;
|
||||
if (Array.isArray(subs)) {
|
||||
for (let i = 0; i < subs.length; i++) {
|
||||
newStr = newStr.replace(subs[i], '');
|
||||
}
|
||||
} else {
|
||||
newStr = newStr.replace(subs, '');
|
||||
}
|
||||
return newStr;
|
||||
}
|
||||
|
||||
function isBlank(str) {
|
||||
return (!str || str.trim().length === 0);
|
||||
}
|
||||
|
||||
(function updateDate() {
|
||||
var date = new Date();
|
||||
var year = date.getFullYear();
|
||||
elem('.year').innerHTML = year;
|
||||
})();
|
||||
|
||||
(function() {
|
||||
let bar = 'nav_bar-wrap';
|
||||
let navBar = elem(`.${bar}`);
|
||||
let nav = elem('.nav-body');
|
||||
let open = 'nav-open';
|
||||
let exit = 'nav-exit';
|
||||
let drop = 'nav-drop';
|
||||
let pop = 'nav-pop';
|
||||
let navDrop = elem(`.${drop}`);
|
||||
|
||||
function toggleMenu(){
|
||||
let menuOpen, menuPulled, status;
|
||||
modifyClass(navDrop, pop);
|
||||
modifyClass(navBar, hidden);
|
||||
menuOpen = containsClass(nav, open);
|
||||
menuPulled = containsClass(nav, exit);
|
||||
|
||||
status = menuOpen || menuPulled ? true : false;
|
||||
|
||||
status ? modifyClass(nav, exit) : modifyClass(nav, open);
|
||||
status ? modifyClass(nav, open) : modifyClass(nav, exit);
|
||||
}
|
||||
|
||||
navBar.addEventListener('click', function() {
|
||||
toggleMenu();
|
||||
});
|
||||
elem('.nav-close').addEventListener('click', function() {
|
||||
toggleMenu();
|
||||
});
|
||||
|
||||
elem('.nav-drop').addEventListener('click', function(e) {
|
||||
e.target === this ? toggleMenu() : false;
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
function convertToUnderScoreCase(str) {
|
||||
let char, newChar, newStr;
|
||||
newStr = '';
|
||||
if (typeof str == 'string') {
|
||||
for (let x = 0; x < str.length; x++) {
|
||||
char = str.charAt(x);
|
||||
if (char.match(/^[A-Z]*$/)) {
|
||||
char = char.toLowerCase();
|
||||
newChar = `_${char}`
|
||||
newStr += newChar;
|
||||
} else {
|
||||
newStr += char;
|
||||
}
|
||||
}
|
||||
return newStr;
|
||||
}
|
||||
}
|
||||
|
||||
function createModal(children, parent) {
|
||||
let body, modal, title;
|
||||
|
||||
modal = createEl();
|
||||
pushClass(modal, 'modal');
|
||||
body = createEl();
|
||||
pushClass(body, 'modal_inner');
|
||||
title = createEl('h3');
|
||||
pushClass(title, 'modal_title');
|
||||
body.appendChild(title);
|
||||
// add html specific to modal
|
||||
if (isObj(children)) {
|
||||
if (Array.isArray(children)) {
|
||||
children.map(function(child){
|
||||
body.appendChild(child);
|
||||
});
|
||||
} else {
|
||||
body.appendChild(children);
|
||||
}
|
||||
}
|
||||
modal.appendChild(body);
|
||||
parent.append(modal);
|
||||
pushClass(doc, 'modal_show');
|
||||
}
|
||||
|
||||
function fillModal(obj) {
|
||||
let el, targetClass, modal;
|
||||
modal = elem('.modal');
|
||||
const entries = Object.entries(obj)
|
||||
for (const [element, content] of entries) {
|
||||
targetClass = `.${convertToUnderScoreCase(element)}`;
|
||||
el = elem(targetClass, modal);
|
||||
el.innerHTML = content;
|
||||
}
|
||||
}
|
||||
|
||||
(function comments(){
|
||||
let comments, form, replyNotice, open;
|
||||
|
||||
comments = elem('.comments');
|
||||
form = elem('.form');
|
||||
button = elem('.form_toggle');
|
||||
replyNotice = elem('.reply_notice')
|
||||
open = 'form_open';
|
||||
|
||||
let successOutput, errorOutput;
|
||||
|
||||
successOutput = {
|
||||
modalTitle: translations.success.title,
|
||||
modalText: translations.success.text,
|
||||
modalClose: translations.success.close
|
||||
};
|
||||
errorOutput = {
|
||||
modalTitle: translations.error.title,
|
||||
modalText: translations.error.text,
|
||||
modalClose: translations.error.close
|
||||
};
|
||||
|
||||
function feedbackModal() {
|
||||
let body, button, children;
|
||||
body = createEl();
|
||||
pushClass(body, 'modal_text');
|
||||
button = createEl();
|
||||
pushClass(button, 'btn');
|
||||
pushClass(button, 'modal_close');
|
||||
children = [
|
||||
body,
|
||||
button
|
||||
];
|
||||
return children;
|
||||
}
|
||||
|
||||
function confirmModal() {
|
||||
// confirm if you want to exit form
|
||||
let group, button, cancel;
|
||||
group = createEl();
|
||||
pushClass(group, 'btn_group');
|
||||
button = createEl();
|
||||
pushClass(button, 'btn');
|
||||
pushClass(button, 'modal_close')
|
||||
pushClass(button, 'form_close')
|
||||
cancel = createEl();
|
||||
pushClass(cancel, 'modal_close')
|
||||
pushClass(cancel, 'btn_close');
|
||||
pushClass(cancel, 'icon');
|
||||
group.appendChild(button);
|
||||
group.appendChild(cancel);
|
||||
return group;
|
||||
}
|
||||
|
||||
function handleForm(form) {
|
||||
|
||||
function formValues() {
|
||||
// returns an object with form field values
|
||||
let deadWeight, fields, fieldAreas, obj;
|
||||
fieldAreas = elems('.form_input', form);
|
||||
fields = Array.from(fieldAreas);
|
||||
obj = Object.create(null);
|
||||
deadWeight = ['fields', 'options', '[' , ']', 'undefined'];
|
||||
|
||||
fields.map(function(field) {
|
||||
let key, value;
|
||||
key = deleteChars(field.name, deadWeight);
|
||||
key = convertToUnderScoreCase(key);
|
||||
value = field.value;
|
||||
obj[key] = value;
|
||||
});
|
||||
return obj;
|
||||
}
|
||||
|
||||
(function submitForm() {
|
||||
form.addEventListener('submit', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
let fields, recaptchaResponse, submit, url;
|
||||
url = [endpoint, 'v3/entry', gitProvider, username, repository, branch, 'comments'].join('/');
|
||||
fields = formValues();
|
||||
submit = elem('.form_submit', form);
|
||||
recaptchaResponse = elem('[name="g-recaptcha-response"]', form);
|
||||
|
||||
submit.value = translations.submitted;
|
||||
|
||||
function formActions(info) {
|
||||
showModal(info);
|
||||
submit.value = translations.submit;
|
||||
}
|
||||
|
||||
let data = {
|
||||
fields: {
|
||||
name: fields.name,
|
||||
email: fields.email,
|
||||
comment: fields.comment,
|
||||
replyID: fields.reply_id,
|
||||
replyName: fields.reply_name,
|
||||
replyThread: fields.reply_thread
|
||||
},
|
||||
options: {
|
||||
slug: fields.slug
|
||||
}
|
||||
};
|
||||
|
||||
if (staticman.secret){
|
||||
data.options.reCaptcha = {};
|
||||
data.options.reCaptcha.siteKey = staticman.siteKey;
|
||||
data.options.reCaptcha.secret = staticman.secret;
|
||||
data["g-recaptcha-response"] = recaptchaResponse.value;
|
||||
}
|
||||
|
||||
fetch(url, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(data),
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
}).then(function(res) {
|
||||
if(res.ok) {
|
||||
formActions(successOutput);
|
||||
} else {
|
||||
formActions(errorOutput);
|
||||
}
|
||||
}).catch(function(error) {
|
||||
formActions(errorOutput);
|
||||
console.error('Error:', error);
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
||||
function getHiddenFields() {
|
||||
let reply_id, reply_name, reply_thread, reply_to, obj;
|
||||
|
||||
reply_id = elem('.reply_id', form);
|
||||
reply_name = elem('.reply_name', form);
|
||||
reply_thread = elem('.reply_thread', form);
|
||||
reply_to = elem('.reply_to', form);
|
||||
|
||||
obj = {
|
||||
id: reply_id,
|
||||
name: reply_name,
|
||||
thread: reply_thread,
|
||||
to: reply_to
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
function setReplyValues(trigger) {
|
||||
let comment, id, name, thread;
|
||||
|
||||
let reply_fields = getHiddenFields();
|
||||
|
||||
comment = trigger.parentNode;
|
||||
id = comment.id;
|
||||
name = elem('.comment_name_span', comment);
|
||||
thread = elem('.comment_thread', comment);
|
||||
reply_fields.thread.value = thread.textContent;
|
||||
reply_fields.id.value = id;
|
||||
reply_fields.name.value = name.textContent;
|
||||
reply_fields.to.textContent = name.textContent;
|
||||
}
|
||||
|
||||
function resetReplyValues() {
|
||||
let reply_fields;
|
||||
reply_fields = getHiddenFields();
|
||||
const values = Object.entries(reply_fields);
|
||||
for (const [key, element] of values) {
|
||||
if (key == 'to') {
|
||||
element.textContent = '';
|
||||
} else {
|
||||
element.value = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function toggleForm(action = true) {
|
||||
let reply_to, toggle_btn;
|
||||
action = action ? pushClass : deleteClass;
|
||||
toggle_btn = elem('.form_toggle');
|
||||
action(form, open);
|
||||
action(toggle_btn, hidden);
|
||||
reply_to = getHiddenFields().to.textContent;
|
||||
isBlank(reply_to) ? pushClass(replyNotice, hidden) : deleteClass(replyNotice, hidden) ;
|
||||
}
|
||||
|
||||
comments.addEventListener('click', function (event){
|
||||
let confirm, fields, modal, target, obj, formIsEmpty, hiddenValuesEmpty;
|
||||
|
||||
// buttons
|
||||
let isFormCloseBtn, isFormToggleBtn, isModalCloseBtn, isResetFormBtn, isReplyBt;
|
||||
|
||||
target = event.target;
|
||||
fields = formValues();
|
||||
formIsEmpty = isBlank(fields.name) && isBlank(fields.comment) && isBlank(fields.email) ? true : false;
|
||||
hiddenValuesEmpty = isBlank(fields.reply_id) ? true : false;
|
||||
|
||||
isFormCloseBtn = containsClass(target, 'form_close');
|
||||
isFormToggleBtn = containsClass(target, 'form_toggle');
|
||||
isModalCloseBtn = containsClass(target, 'modal_close');
|
||||
isResetFormBtn = containsClass(target, 'form_reset');
|
||||
isReplyBtn = containsClass(target, 'reply_btn');
|
||||
|
||||
isReplyBtn ? setReplyValues(target) : false;
|
||||
isReplyBtn || isFormToggleBtn ? toggleForm() : false;
|
||||
isFormCloseBtn ? toggleForm(false) : false;
|
||||
|
||||
if (isFormCloseBtn) {
|
||||
form.reset();
|
||||
}
|
||||
|
||||
if (isResetFormBtn) {
|
||||
if (formIsEmpty) {
|
||||
hiddenValuesEmpty ? false : resetReplyValues();
|
||||
toggleForm(false);
|
||||
} else {
|
||||
obj = {
|
||||
modalTitle: translations.discard.title,
|
||||
modalClose: translations.discard.button
|
||||
}
|
||||
confirm = confirmModal();
|
||||
createModal(confirm, comments);
|
||||
fillModal(obj);
|
||||
}
|
||||
}
|
||||
|
||||
if (isModalCloseBtn) {
|
||||
modal = target.closest('.modal');
|
||||
modal.remove();
|
||||
deleteClass(doc, 'modal_show');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
form ? handleForm(form) : false;
|
||||
|
||||
function showModal(obj) {
|
||||
let feedbackBody;
|
||||
feedback = feedbackModal();
|
||||
createModal(feedback, comments);
|
||||
fillModal(obj);
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
(function makeExternalLinks(){
|
||||
let links = elems('a');
|
||||
if(links) {
|
||||
Array.from(links).forEach(function(link){
|
||||
let target, rel, blank, noopener, attr1, attr2, url, isExternal;
|
||||
url = elemAttribute(link, 'href');
|
||||
isExternal = (url && typeof url == 'string' && url.startsWith('http')) && !containsClass(link, 'nav_item') && !isChild(link, '.post_item') && !isChild(link, '.pager') ? true : false;
|
||||
if(isExternal) {
|
||||
target = 'target';
|
||||
rel = 'rel';
|
||||
blank = '_blank';
|
||||
noopener = 'noopener';
|
||||
attr1 = elemAttribute(link, target);
|
||||
attr2 = elemAttribute(link, noopener);
|
||||
|
||||
attr1 ? false : elemAttribute(link, target, blank);
|
||||
attr2 ? false : elemAttribute(link, rel, noopener);
|
||||
}
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
||||
let headingNodes = [], results, link, icon, current, id,
|
||||
tags = ['h2', 'h3', 'h4', 'h5', 'h6'];
|
||||
|
||||
current = document.URL;
|
||||
|
||||
tags.forEach(function(tag){
|
||||
results = document.getElementsByTagName(tag);
|
||||
Array.prototype.push.apply(headingNodes, results);
|
||||
});
|
||||
|
||||
headingNodes.forEach(function(node){
|
||||
link = createEl('a');
|
||||
icon = createEl('img');
|
||||
icon.src = 'https://h.cowbay.org/images/icons/link.svg';
|
||||
link.className = 'link';
|
||||
link.appendChild(icon);
|
||||
id = node.getAttribute('id');
|
||||
if(id) {
|
||||
link.href = `${current}#${id}`;
|
||||
node.appendChild(link);
|
||||
pushClass(node, 'link_owner');
|
||||
}
|
||||
});
|
||||
|
||||
const copyToClipboard = str => {
|
||||
let copy, selection, selected;
|
||||
copy = createEl('textarea');
|
||||
copy.value = str;
|
||||
copy.setAttribute('readonly', '');
|
||||
copy.style.position = 'absolute';
|
||||
copy.style.left = '-9999px';
|
||||
selection = document.getSelection();
|
||||
doc.appendChild(copy);
|
||||
// check if there is any selected content
|
||||
selected = selection.rangeCount > 0 ? selection.getRangeAt(0) : false;
|
||||
copy.select();
|
||||
document.execCommand('copy');
|
||||
doc.removeChild(copy);
|
||||
if (selected) { // if a selection existed before copying
|
||||
selection.removeAllRanges(); // unselect existing selection
|
||||
selection.addRange(selected); // restore the original selection
|
||||
}
|
||||
}
|
||||
|
||||
(function copyHeadingLink() {
|
||||
let deeplink, deeplinks, newLink, parent, target;
|
||||
deeplink = 'link';
|
||||
deeplinks = elems(`.${deeplink}`);
|
||||
if(deeplinks) {
|
||||
document.addEventListener('click', function(event)
|
||||
{
|
||||
target = event.target;
|
||||
parent = target.parentNode;
|
||||
if (target && containsClass(target, deeplink) || containsClass(parent, deeplink)) {
|
||||
event.preventDefault();
|
||||
newLink = target.href != undefined ? target.href : target.parentNode.href;
|
||||
copyToClipboard(newLink);
|
||||
}
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
||||
(function copyLinkToShare() {
|
||||
let copy, copied, excerpt, isCopyIcon, isInExcerpt, link, page, postCopy, postLink, target;
|
||||
copy = 'copy';
|
||||
copied = 'copy_done';
|
||||
excerpt = 'excerpt';
|
||||
postCopy = 'post_copy';
|
||||
postLink = 'post_card';
|
||||
|
||||
doc.addEventListener('click', function(event) {
|
||||
target = event.target;
|
||||
isCopyIcon = containsClass(target, copy);
|
||||
isInExcerpt = containsClass(target, postCopy);
|
||||
if (isCopyIcon) {
|
||||
if (isInExcerpt) {
|
||||
link = target.closest(`.${excerpt}`).previousElementSibling;
|
||||
link = containsClass(link, postLink)? elemAttribute(link, 'href') : false;
|
||||
} else {
|
||||
link = window.location.href;
|
||||
}
|
||||
if(link) {
|
||||
copyToClipboard(link);
|
||||
pushClass(target, copied);
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
(function hideAside(){
|
||||
let aside, title, posts;
|
||||
aside = elem('.aside');
|
||||
title = aside ? aside.previousElementSibling : null;
|
||||
if(aside && title.nodeName.toLowerCase() === 'h3') {
|
||||
posts = Array.from(aside.children);
|
||||
posts.length < 1 ? title.remove() : false;
|
||||
}
|
||||
})();
|
||||
|
||||
(function goBack() {
|
||||
let backBtn = elem('.btn_back');
|
||||
let history = window.history;
|
||||
if (backBtn) {
|
||||
backBtn.addEventListener('click', function(){
|
||||
history.back();
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
||||
// add new code above this line
|
||||
})();
|
||||
6
public/js/jquery.min.js
vendored
Normal file
6
public/js/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
public/js/jquerymigrate.js
vendored
Normal file
2
public/js/jquerymigrate.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -1,57 +1,144 @@
|
||||
// smooth-scroll
|
||||
$.smoothScroll({
|
||||
//滑动到的位置的偏移量
|
||||
offset: 0,
|
||||
//滑动的方向,可取 'top' 或 'left'
|
||||
direction: 'top',
|
||||
// 只有当你想重写默认行为的时候才会用到
|
||||
scrollTarget: null,
|
||||
// 滑动开始前的回调函数。`this` 代表正在被滚动的元素
|
||||
beforeScroll: function () { },
|
||||
//滑动完成后的回调函数。 `this` 代表触发滑动的元素
|
||||
afterScroll: function () { },
|
||||
//缓动效果
|
||||
easing: 'swing',
|
||||
//滑动的速度
|
||||
speed: 700,
|
||||
// "自动" 加速的系数
|
||||
autoCoefficent: 2
|
||||
});
|
||||
|
||||
|
||||
// Bind the hashchange event listener
|
||||
$(window).bind('hashchange', function (event) {
|
||||
$.smoothScroll({
|
||||
// Replace '#/' with '#' to go to the correct target
|
||||
offset: $("body").attr("data-offset")? -$("body").attr("data-offset"):0 ,
|
||||
// offset: -30,
|
||||
scrollTarget: decodeURI(location.hash.replace(/^\#\/?/, '#'))
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
// $(".smooth-scroll").on('click', "a", function() {
|
||||
$('a[href*="#"]')
|
||||
.bind('click', function (event) {
|
||||
// Remove '#' from the hash.
|
||||
var hash = this.hash.replace(/^#/, '')
|
||||
if (this.pathname === location.pathname && hash) {
|
||||
event.preventDefault();
|
||||
// Change '#' (removed above) to '#/' so it doesn't jump without the smooth scrolling
|
||||
location.hash = '#/' + hash;
|
||||
}
|
||||
});
|
||||
|
||||
// Trigger hashchange event on page load if there is a hash in the URL.
|
||||
if (location.hash) {
|
||||
$(window).trigger('hashchange');
|
||||
}
|
||||
|
||||
// // $('[data-spy="scroll"]').each(function () {
|
||||
// // var $spy = $(this).scrollspy('refresh')
|
||||
// // })
|
||||
|
||||
// $('[data-spy="scroll"]').on('activate.bs.scrollspy', function () {
|
||||
// // do something…
|
||||
// var offset = $('[data-spy="scroll"]').attr("data-offset")
|
||||
// })
|
||||
/*
|
||||
Future Imperfect by HTML5 UP
|
||||
html5up.net | @n33co
|
||||
Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
|
||||
skel.breakpoints({
|
||||
xlarge: '(max-width: 1680px)',
|
||||
large: '(max-width: 1280px)',
|
||||
medium: '(max-width: 980px)',
|
||||
small: '(max-width: 736px)',
|
||||
xsmall: '(max-width: 480px)'
|
||||
});
|
||||
|
||||
$(function() {
|
||||
|
||||
var $window = $(window),
|
||||
$body = $('body'),
|
||||
$menu = $('#menu'),
|
||||
$shareMenu = $('#share-menu'),
|
||||
$sidebar = $('#sidebar'),
|
||||
$main = $('#main');
|
||||
|
||||
// TODO: Fix this, or implement lazy load.
|
||||
// Disable animations/transitions until the page has loaded.
|
||||
// $body.addClass('is-loading');
|
||||
|
||||
// $window.on('load', function() {
|
||||
// window.setTimeout(function() {
|
||||
// $body.removeClass('is-loading');
|
||||
// }, 100);
|
||||
// });
|
||||
|
||||
// Fix: Placeholder polyfill.
|
||||
$('form').placeholder();
|
||||
|
||||
// Prioritize "important" elements on medium.
|
||||
skel.on('+medium -medium', function() {
|
||||
$.prioritize(
|
||||
'.important\\28 medium\\29',
|
||||
skel.breakpoint('medium').active
|
||||
);
|
||||
});
|
||||
|
||||
// IE<=9: Reverse order of main and sidebar.
|
||||
if (skel.vars.IEVersion <= 9)
|
||||
$main.insertAfter($sidebar);
|
||||
|
||||
$menu.appendTo($body);
|
||||
$shareMenu.appendTo($body);
|
||||
|
||||
$menu.panel({
|
||||
delay: 500,
|
||||
hideOnClick: true,
|
||||
hideOnEscape: true,
|
||||
hideOnSwipe: true,
|
||||
resetScroll: true,
|
||||
resetForms: true,
|
||||
side: 'right',
|
||||
target: $body,
|
||||
visibleClass: 'is-menu-visible'
|
||||
});
|
||||
|
||||
$shareMenu.panel({
|
||||
delay: 500,
|
||||
hideOnClick: true,
|
||||
hideOnEscape: true,
|
||||
hideOnSwipe: true,
|
||||
resetScroll: true,
|
||||
resetForms: true,
|
||||
side: 'right',
|
||||
target: $body,
|
||||
visibleClass: 'is-share-visible'
|
||||
});
|
||||
|
||||
// Menu.
|
||||
/*$menu
|
||||
.appendTo($body)
|
||||
.panel({
|
||||
delay: 500,
|
||||
hideOnClick: true,
|
||||
hideOnSwipe: true,
|
||||
resetScroll: true,
|
||||
resetForms: true,
|
||||
side: 'right',
|
||||
target: $body,
|
||||
visibleClass: 'is-menu-visible'
|
||||
});*/
|
||||
|
||||
// Search (header).
|
||||
var $search = $('#search'),
|
||||
$search_input = $search.find('input');
|
||||
|
||||
$body
|
||||
.on('click', '[href="#search"]', function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
// Not visible?
|
||||
if (!$search.hasClass('visible')) {
|
||||
|
||||
// Reset form.
|
||||
$search[0].reset();
|
||||
|
||||
// Show.
|
||||
$search.addClass('visible');
|
||||
|
||||
// Focus input.
|
||||
$search_input.focus();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$search_input
|
||||
.on('keydown', function(event) {
|
||||
|
||||
if (event.keyCode == 27)
|
||||
$search_input.blur();
|
||||
|
||||
})
|
||||
.on('blur', function() {
|
||||
window.setTimeout(function() {
|
||||
$search.removeClass('visible');
|
||||
}, 100);
|
||||
});
|
||||
|
||||
// Intro.
|
||||
var $intro = $('#intro');
|
||||
|
||||
// Move to main on <=large, back to sidebar on >large.
|
||||
skel
|
||||
.on('+medium', function() {
|
||||
$intro.prependTo($main);
|
||||
})
|
||||
.on('-medium', function() {
|
||||
$intro.prependTo($sidebar);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
||||
13
public/js/menu.js
Normal file
13
public/js/menu.js
Normal file
@@ -0,0 +1,13 @@
|
||||
const toggle = document.getElementById('toggle');
|
||||
const menu = document.getElementById('menu');
|
||||
|
||||
function toggleMenu() {
|
||||
menu.classList.toggle('main-nav__list--active');
|
||||
this.classList.toggle('main-nav__btn--active');
|
||||
this.setAttribute(
|
||||
'aria-expanded',
|
||||
this.getAttribute('aria-expanded') === 'true' ? 'false' : 'true'
|
||||
);
|
||||
}
|
||||
|
||||
toggle.addEventListener('click', toggleMenu, false);
|
||||
1
public/js/production.min.js
vendored
Normal file
1
public/js/production.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/js/script-pcw6v3xilnxydl1vddzazdverrnn9ctynvnxgwho987mfyqkuylcb1nlt.min.js
vendored
Normal file
1
public/js/script-pcw6v3xilnxydl1vddzazdverrnn9ctynvnxgwho987mfyqkuylcb1nlt.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
public/js/script.min.js
vendored
Normal file
2
public/js/script.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
(function($){'use strict';$(window).on('load',function(){$('.preloader').fadeOut(300);});$('.navigation').headroom();$('[data-background]').each(function(){$(this).css({'background-image':'url('+$(this).data('background')+')'});});$('.featured-post-slider').slick({dots:false,speed:300,autoplay:true,arrows:false,slidesToShow:4,slidesToScroll:1,responsive:[{breakpoint:1024,settings:{slidesToShow:2}},{breakpoint:600,settings:{slidesToShow:2}},{breakpoint:480,settings:{slidesToShow:1}}]});setTimeout(function(){$('.masonry-container').masonry({itemSelector:'.masonry-container > div',columnWidth:1});},500);if(($('#instafeed').length)!==0){var userId=$('#instafeed').attr('data-userId');var accessToken=$('#instafeed').attr('data-accessToken');var userFeed=new Instafeed({get:'user',userId:userId,resolution:'low_resolution',accessToken:accessToken,template:'<div class="instagram-post"><img class="img-fluid w-100" src="{{image}}" alt="instagram-image"><ul class="list-inline text-center"><li class="list-inline-item"><a href="{{link}}" target="_blank" class="text-white"><i class="ti-heart mr-2"></i>{{likes}}</a></li><li class="list-inline-item"><a href="{{link}}" target="_blank" class="text-white"><i class="ti-comments mr-2"></i>{{comments}}</a></li></ul></div>'});userFeed.run();}
|
||||
setTimeout(function(){$('.instagram-slider').slick({dots:false,speed:300,autoplay:true,arrows:false,slidesToShow:6,slidesToScroll:1,responsive:[{breakpoint:1024,settings:{slidesToShow:4}},{breakpoint:600,settings:{slidesToShow:3}},{breakpoint:480,settings:{slidesToShow:2}}]});},1000);$('article').each(function(){let _this=$(this);_this.readingTime({readingTimeTarget:_this.find('.eta'),remotePath:_this.attr('data-file'),remoteTarget:_this.attr('data-target')});});})(jQuery);
|
||||
11
public/js/semantic.min.js
vendored
Normal file
11
public/js/semantic.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
10
public/js/sine-waves.min.js
vendored
Normal file
10
public/js/sine-waves.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
126
public/js/site.js
Normal file
126
public/js/site.js
Normal file
@@ -0,0 +1,126 @@
|
||||
var SemanticUIColors = [
|
||||
'red',
|
||||
'orange',
|
||||
'yellow',
|
||||
'olive',
|
||||
'green',
|
||||
'teal',
|
||||
'blue',
|
||||
'violet',
|
||||
'purple',
|
||||
'pink',
|
||||
'brown'
|
||||
]
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.dream-flip-toggle').click(function() {
|
||||
var c = $('.flip-container')
|
||||
|
||||
if (dreamBodyBgSwitchIndex === 0) {
|
||||
c.css('overflow', 'hidden')
|
||||
setBackground(dreamBody, dreamBodyBgSwitch[1])
|
||||
dreamBodyBgSwitchIndex = 1
|
||||
$('.flipper .front .ui.menu').css('overflow-x', '')
|
||||
} else {
|
||||
c.removeAttr('style')
|
||||
setBackground(dreamBody, dreamBodyBgSwitch[0])
|
||||
dreamBodyBgSwitchIndex = 0
|
||||
$('.flipper .front .ui.menu').css('overflow-x', 'auto')
|
||||
}
|
||||
|
||||
c.toggleClass('flip-it')
|
||||
})
|
||||
|
||||
var postList = $('.post-list')
|
||||
var pMaxHeight = $(window).height() - $('.ui.menu').outerHeight(true)
|
||||
postList.css('max-height', pMaxHeight)
|
||||
|
||||
$('.ui.cards .image')
|
||||
.dimmer({
|
||||
opacity: 0.6,
|
||||
closable: false
|
||||
})
|
||||
.dimmer('show')
|
||||
|
||||
$('.ui.accordion').accordion()
|
||||
|
||||
$('#tag-category-pop').click(function() {
|
||||
var dt = $('.dream-header-tags.dream-tags')
|
||||
var dc = $('.dream-categories')
|
||||
var dtDisplay = dt.css('display')
|
||||
var dcDisplay = dc.css('display')
|
||||
if (dtDisplay === 'none') {
|
||||
dt.css('display', 'block')
|
||||
dc.css('display', 'block')
|
||||
} else {
|
||||
dt.css('display', 'none')
|
||||
dc.css('display', 'none')
|
||||
}
|
||||
})
|
||||
|
||||
setSemanticUIColor()
|
||||
})
|
||||
|
||||
function randomInt(min, max) {
|
||||
min = Math.ceil(min)
|
||||
max = Math.floor(max)
|
||||
random = Math.floor(Math.random() * (max - min)) + min
|
||||
return random
|
||||
}
|
||||
|
||||
function setSemanticUIColor() {
|
||||
var tagsParent = $('.dream-tags')
|
||||
tagsParent.children().map(function() {
|
||||
$(this).addClass(SemanticUIColors[randomInt(0, SemanticUIColors.length)])
|
||||
})
|
||||
}
|
||||
|
||||
function savePostAsImg() {
|
||||
var postList = $('.post-list')
|
||||
var useWidth = postList.prop('scrollWidth')
|
||||
var useHeight = postList.prop('scrollHeight')
|
||||
var removedHeight = $('.post-list .post-disqus-area').prop('scrollHeight')
|
||||
|
||||
var canvas = document.createElement('canvas')
|
||||
var width = useWidth
|
||||
var height = useHeight - removedHeight
|
||||
var scale = 2
|
||||
canvas.width = width * scale
|
||||
canvas.height = height * scale
|
||||
canvas.getContext('2d').scale(scale, scale)
|
||||
|
||||
html2canvas(document.querySelector('.post-single-main'), {
|
||||
canvas: canvas,
|
||||
width: width,
|
||||
height: height,
|
||||
scale: scale,
|
||||
useCORS: true
|
||||
}).then(function(canvas) {
|
||||
var ctx = canvas.getContext('2d')
|
||||
|
||||
ctx.mozImageSmoothingEnabled = false
|
||||
ctx.webkitImageSmoothingEnabled = false
|
||||
ctx.msImageSmoothingEnabled = false
|
||||
ctx.imageSmoothingEnabled = false
|
||||
|
||||
var data = canvas.toDataURL('image/png')
|
||||
|
||||
var link = document.createElement('a')
|
||||
link.href = URL.createObjectURL(dataURLtoBlob(data))
|
||||
link.download = 'screenshot.png'
|
||||
link.click()
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
function dataURLtoBlob(dataurl) {
|
||||
var arr = dataurl.split(','),
|
||||
mime = arr[0].match(/:(.*?);/)[1],
|
||||
bstr = atob(arr[1]),
|
||||
n = bstr.length,
|
||||
u8arr = new Uint8Array(n)
|
||||
while (n--) {
|
||||
u8arr[n] = bstr.charCodeAt(n)
|
||||
}
|
||||
return new Blob([u8arr], { type: mime })
|
||||
}
|
||||
54
public/js/timeago.js
Normal file
54
public/js/timeago.js
Normal file
@@ -0,0 +1,54 @@
|
||||
function calculateTimeSince(num){
|
||||
const currentTime = Math.floor(Date.now()/1000);
|
||||
const timestamp = parseInt(num);
|
||||
const timeSince = currentTime - timestamp;
|
||||
|
||||
var timeAgo;
|
||||
var timeTag;
|
||||
var minute = 60;
|
||||
var hour = 3600;
|
||||
var day = 86400;
|
||||
var week = 604800;
|
||||
var month = 2.628e+6;
|
||||
var year = 3.154e+7;
|
||||
|
||||
if (timeSince < minute ) {
|
||||
timeAgo = 1;
|
||||
timeTag = timeAgo < 2 ? 'MIN' : 'MINS';
|
||||
} else if (timeSince > minute && timeSince < hour ) {
|
||||
timeAgo = Math.ceil(timeSince / minute);
|
||||
timeTag = timeAgo < 2 ? 'MIN' : 'MINS';
|
||||
} else if (timeSince > hour && timeSince < day ) {
|
||||
timeAgo = Math.floor(timeSince / hour);
|
||||
timeTag = timeAgo < 2 ? 'HR' : 'HRS';
|
||||
} else if (timeSince > day && timeSince < week) {
|
||||
timeAgo = Math.floor(timeSince / day);
|
||||
timeTag = timeAgo < 2 ? 'DAY' : 'DAYS';
|
||||
} else if (timeSince > week && timeSince < month) {
|
||||
timeAgo = Math.floor(timeSince / week);
|
||||
timeTag = timeAgo < 2 ? 'WK' : 'WKS';
|
||||
} else if (timeSince > month && timeSince < year) {
|
||||
timeAgo = Math.floor(timeSince / month);
|
||||
timeTag = timeAgo < 2 ? 'MONTH' : 'MONTHS';
|
||||
} else if (timeSince > year) {
|
||||
timeAgo = Math.floor(timeSince / year);
|
||||
timeTag = timeAgo < 2 ? 'YR' : 'YRS';
|
||||
}
|
||||
|
||||
return `${timeAgo} ${timeTag} AGO`;
|
||||
}
|
||||
|
||||
function populateCommentsTime(nodes) {
|
||||
if (nodes) {
|
||||
nodes.forEach(function(node) {
|
||||
let durationTime = node.dataset.time;
|
||||
let durationSeconds = Math.ceil(Date.parse(durationTime) / 1000) ;
|
||||
let durationSince = calculateTimeSince(durationSeconds);
|
||||
node.innerHTML = `${durationSince}`;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const durations = document.querySelectorAll('.comment_heading');
|
||||
|
||||
populateCommentsTime(durations);
|
||||
619
public/js/util.js
Normal file
619
public/js/util.js
Normal file
@@ -0,0 +1,619 @@
|
||||
(function($) {
|
||||
|
||||
/**
|
||||
* Generate an indented list of links from a nav. Meant for use with panel().
|
||||
* @return {jQuery} jQuery object.
|
||||
*/
|
||||
$.fn.navList = function() {
|
||||
|
||||
var $this = $(this);
|
||||
$a = $this.find('a'),
|
||||
b = [];
|
||||
|
||||
$a.each(function() {
|
||||
|
||||
var $this = $(this),
|
||||
indent = Math.max(0, $this.parents('li').length - 1),
|
||||
href = $this.attr('href'),
|
||||
target = $this.attr('target');
|
||||
|
||||
b.push(
|
||||
'<a ' +
|
||||
'class="link depth-' + indent + '"' +
|
||||
( (typeof target !== 'undefined' && target != '') ? ' target="' + target + '"' : '') +
|
||||
( (typeof href !== 'undefined' && href != '') ? ' href="' + href + '"' : '') +
|
||||
'>' +
|
||||
'<span class="indent-' + indent + '"></span>' +
|
||||
$this.text() +
|
||||
'</a>'
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
return b.join('');
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Panel-ify an element.
|
||||
* @param {object} userConfig User config.
|
||||
* @return {jQuery} jQuery object.
|
||||
*/
|
||||
$.fn.panel = function(userConfig) {
|
||||
|
||||
// No elements?
|
||||
if (this.length == 0)
|
||||
return $this;
|
||||
|
||||
// Multiple elements?
|
||||
if (this.length > 1) {
|
||||
|
||||
for (var i=0; i < this.length; i++)
|
||||
$(this[i]).panel(userConfig);
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
// Vars.
|
||||
var $this = $(this),
|
||||
$body = $('body'),
|
||||
$window = $(window),
|
||||
id = $this.attr('id'),
|
||||
config;
|
||||
|
||||
// Config.
|
||||
config = $.extend({
|
||||
|
||||
// Delay.
|
||||
delay: 0,
|
||||
|
||||
// Hide panel on link click.
|
||||
hideOnClick: false,
|
||||
|
||||
// Hide panel on escape keypress.
|
||||
hideOnEscape: false,
|
||||
|
||||
// Hide panel on swipe.
|
||||
hideOnSwipe: false,
|
||||
|
||||
// Reset scroll position on hide.
|
||||
resetScroll: false,
|
||||
|
||||
// Reset forms on hide.
|
||||
resetForms: false,
|
||||
|
||||
// Side of viewport the panel will appear.
|
||||
side: null,
|
||||
|
||||
// Target element for "class".
|
||||
target: $this,
|
||||
|
||||
// Class to toggle.
|
||||
visibleClass: 'visible'
|
||||
|
||||
}, userConfig);
|
||||
|
||||
// Expand "target" if it's not a jQuery object already.
|
||||
if (typeof config.target != 'jQuery')
|
||||
config.target = $(config.target);
|
||||
|
||||
// Panel.
|
||||
|
||||
// Methods.
|
||||
$this._hide = function(event) {
|
||||
|
||||
// Already hidden? Bail.
|
||||
if (!config.target.hasClass(config.visibleClass))
|
||||
return;
|
||||
|
||||
// If an event was provided, cancel it.
|
||||
if (event) {
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
}
|
||||
|
||||
// Hide.
|
||||
config.target.removeClass(config.visibleClass);
|
||||
|
||||
// Post-hide stuff.
|
||||
window.setTimeout(function() {
|
||||
|
||||
// Reset scroll position.
|
||||
if (config.resetScroll)
|
||||
$this.scrollTop(0);
|
||||
|
||||
// Reset forms.
|
||||
if (config.resetForms)
|
||||
$this.find('form').each(function() {
|
||||
this.reset();
|
||||
});
|
||||
|
||||
}, config.delay);
|
||||
|
||||
};
|
||||
|
||||
// Vendor fixes.
|
||||
$this
|
||||
.css('-ms-overflow-style', '-ms-autohiding-scrollbar')
|
||||
.css('-webkit-overflow-scrolling', 'touch');
|
||||
|
||||
// Hide on click.
|
||||
if (config.hideOnClick) {
|
||||
|
||||
$this.find('a')
|
||||
.css('-webkit-tap-highlight-color', 'rgba(0,0,0,0)');
|
||||
|
||||
$this
|
||||
.on('click', 'a', function(event) {
|
||||
|
||||
var $a = $(this),
|
||||
href = $a.attr('href'),
|
||||
target = $a.attr('target');
|
||||
|
||||
if (!href || href == '#' || href == '' || href == '#' + id)
|
||||
return;
|
||||
|
||||
// Cancel original event.
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
// Hide panel.
|
||||
$this._hide();
|
||||
|
||||
// Redirect to href.
|
||||
//window.setTimeout(function() {
|
||||
|
||||
if (target == '_blank')
|
||||
window.open(href);
|
||||
else
|
||||
window.location.href = href;
|
||||
|
||||
//}, config.delay + 10);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Event: Touch stuff.
|
||||
$this.on('touchstart', function(event) {
|
||||
|
||||
$this.touchPosX = event.originalEvent.touches[0].pageX;
|
||||
$this.touchPosY = event.originalEvent.touches[0].pageY;
|
||||
|
||||
})
|
||||
|
||||
$this.on('touchmove', function(event) {
|
||||
|
||||
if ($this.touchPosX === null
|
||||
|| $this.touchPosY === null)
|
||||
return;
|
||||
|
||||
var diffX = $this.touchPosX - event.originalEvent.touches[0].pageX,
|
||||
diffY = $this.touchPosY - event.originalEvent.touches[0].pageY,
|
||||
th = $this.outerHeight(),
|
||||
ts = ($this.get(0).scrollHeight - $this.scrollTop());
|
||||
|
||||
// Hide on swipe?
|
||||
if (config.hideOnSwipe) {
|
||||
|
||||
var result = false,
|
||||
boundary = 20,
|
||||
delta = 50;
|
||||
|
||||
switch (config.side) {
|
||||
|
||||
case 'left':
|
||||
result = (diffY < boundary && diffY > (-1 * boundary)) && (diffX > delta);
|
||||
break;
|
||||
|
||||
case 'right':
|
||||
result = (diffY < boundary && diffY > (-1 * boundary)) && (diffX < (-1 * delta));
|
||||
break;
|
||||
|
||||
case 'top':
|
||||
result = (diffX < boundary && diffX > (-1 * boundary)) && (diffY > delta);
|
||||
break;
|
||||
|
||||
case 'bottom':
|
||||
result = (diffX < boundary && diffX > (-1 * boundary)) && (diffY < (-1 * delta));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (result) {
|
||||
|
||||
$this.touchPosX = null;
|
||||
$this.touchPosY = null;
|
||||
$this._hide();
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Prevent vertical scrolling past the top or bottom.
|
||||
if (($this.scrollTop() < 0 && diffY < 0)
|
||||
|| (ts > (th - 2) && ts < (th + 2) && diffY > 0)) {
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Event: Prevent certain events inside the panel from bubbling.
|
||||
$this.on('click touchend touchstart touchmove', function(event) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
// Event: Hide panel if a child anchor tag pointing to its ID is clicked.
|
||||
$this.on('click', 'a[href="#' + id + '"]', function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
config.target.removeClass(config.visibleClass);
|
||||
|
||||
});
|
||||
|
||||
// Body.
|
||||
|
||||
// Event: Hide panel on body click/tap.
|
||||
$body.on('click touchend', function(event) {
|
||||
$this._hide(event);
|
||||
});
|
||||
|
||||
// Event: Toggle.
|
||||
$body.on('click', 'a[href="#' + id + '"]', function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
config.target.toggleClass(config.visibleClass);
|
||||
|
||||
});
|
||||
|
||||
// Window.
|
||||
|
||||
// Event: Hide on ESC.
|
||||
if (config.hideOnEscape)
|
||||
$window.on('keydown', function(event) {
|
||||
|
||||
if (event.keyCode == 27)
|
||||
$this._hide(event);
|
||||
|
||||
});
|
||||
|
||||
return $this;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Apply "placeholder" attribute polyfill to one or more forms.
|
||||
* @return {jQuery} jQuery object.
|
||||
*/
|
||||
$.fn.placeholder = function() {
|
||||
|
||||
// Browser natively supports placeholders? Bail.
|
||||
if (typeof (document.createElement('input')).placeholder != 'undefined')
|
||||
return $(this);
|
||||
|
||||
// No elements?
|
||||
if (this.length == 0)
|
||||
return $this;
|
||||
|
||||
// Multiple elements?
|
||||
if (this.length > 1) {
|
||||
|
||||
for (var i=0; i < this.length; i++)
|
||||
$(this[i]).placeholder();
|
||||
|
||||
return $this;
|
||||
|
||||
}
|
||||
|
||||
// Vars.
|
||||
var $this = $(this);
|
||||
|
||||
// Text, TextArea.
|
||||
$this.find('input[type=text],textarea')
|
||||
.each(function() {
|
||||
|
||||
var i = $(this);
|
||||
|
||||
if (i.val() == ''
|
||||
|| i.val() == i.attr('placeholder'))
|
||||
i
|
||||
.addClass('polyfill-placeholder')
|
||||
.val(i.attr('placeholder'));
|
||||
|
||||
})
|
||||
.on('blur', function() {
|
||||
|
||||
var i = $(this);
|
||||
|
||||
if (i.attr('name').match(/-polyfill-field$/))
|
||||
return;
|
||||
|
||||
if (i.val() == '')
|
||||
i
|
||||
.addClass('polyfill-placeholder')
|
||||
.val(i.attr('placeholder'));
|
||||
|
||||
})
|
||||
.on('focus', function() {
|
||||
|
||||
var i = $(this);
|
||||
|
||||
if (i.attr('name').match(/-polyfill-field$/))
|
||||
return;
|
||||
|
||||
if (i.val() == i.attr('placeholder'))
|
||||
i
|
||||
.removeClass('polyfill-placeholder')
|
||||
.val('');
|
||||
|
||||
});
|
||||
|
||||
// Password.
|
||||
$this.find('input[type=password]')
|
||||
.each(function() {
|
||||
|
||||
var i = $(this);
|
||||
var x = $(
|
||||
$('<div>')
|
||||
.append(i.clone())
|
||||
.remove()
|
||||
.html()
|
||||
.replace(/type="password"/i, 'type="text"')
|
||||
.replace(/type=password/i, 'type=text')
|
||||
);
|
||||
|
||||
if (i.attr('id') != '')
|
||||
x.attr('id', i.attr('id') + '-polyfill-field');
|
||||
|
||||
if (i.attr('name') != '')
|
||||
x.attr('name', i.attr('name') + '-polyfill-field');
|
||||
|
||||
x.addClass('polyfill-placeholder')
|
||||
.val(x.attr('placeholder')).insertAfter(i);
|
||||
|
||||
if (i.val() == '')
|
||||
i.hide();
|
||||
else
|
||||
x.hide();
|
||||
|
||||
i
|
||||
.on('blur', function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var x = i.parent().find('input[name=' + i.attr('name') + '-polyfill-field]');
|
||||
|
||||
if (i.val() == '') {
|
||||
|
||||
i.hide();
|
||||
x.show();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
x
|
||||
.on('focus', function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var i = x.parent().find('input[name=' + x.attr('name').replace('-polyfill-field', '') + ']');
|
||||
|
||||
x.hide();
|
||||
|
||||
i
|
||||
.show()
|
||||
.focus();
|
||||
|
||||
})
|
||||
.on('keypress', function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
x.val('');
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Events.
|
||||
$this
|
||||
.on('submit', function() {
|
||||
|
||||
$this.find('input[type=text],input[type=password],textarea')
|
||||
.each(function(event) {
|
||||
|
||||
var i = $(this);
|
||||
|
||||
if (i.attr('name').match(/-polyfill-field$/))
|
||||
i.attr('name', '');
|
||||
|
||||
if (i.val() == i.attr('placeholder')) {
|
||||
|
||||
i.removeClass('polyfill-placeholder');
|
||||
i.val('');
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
})
|
||||
.on('reset', function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
$this.find('select')
|
||||
.val($('option:first').val());
|
||||
|
||||
$this.find('input,textarea')
|
||||
.each(function() {
|
||||
|
||||
var i = $(this),
|
||||
x;
|
||||
|
||||
i.removeClass('polyfill-placeholder');
|
||||
|
||||
switch (this.type) {
|
||||
|
||||
case 'submit':
|
||||
case 'reset':
|
||||
break;
|
||||
|
||||
case 'password':
|
||||
i.val(i.attr('defaultValue'));
|
||||
|
||||
x = i.parent().find('input[name=' + i.attr('name') + '-polyfill-field]');
|
||||
|
||||
if (i.val() == '') {
|
||||
i.hide();
|
||||
x.show();
|
||||
}
|
||||
else {
|
||||
i.show();
|
||||
x.hide();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'checkbox':
|
||||
case 'radio':
|
||||
i.attr('checked', i.attr('defaultValue'));
|
||||
break;
|
||||
|
||||
case 'text':
|
||||
case 'textarea':
|
||||
i.val(i.attr('defaultValue'));
|
||||
|
||||
if (i.val() == '') {
|
||||
i.addClass('polyfill-placeholder');
|
||||
i.val(i.attr('placeholder'));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
i.val(i.attr('defaultValue'));
|
||||
break;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
return $this;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Moves elements to/from the first positions of their respective parents.
|
||||
* @param {jQuery} $elements Elements (or selector) to move.
|
||||
* @param {bool} condition If true, moves elements to the top. Otherwise, moves elements back to their original locations.
|
||||
*/
|
||||
$.prioritize = function($elements, condition) {
|
||||
|
||||
var key = '__prioritize';
|
||||
|
||||
// Expand $elements if it's not already a jQuery object.
|
||||
if (typeof $elements != 'jQuery')
|
||||
$elements = $($elements);
|
||||
|
||||
// Step through elements.
|
||||
$elements.each(function() {
|
||||
|
||||
var $e = $(this), $p,
|
||||
$parent = $e.parent();
|
||||
|
||||
// No parent? Bail.
|
||||
if ($parent.length == 0)
|
||||
return;
|
||||
|
||||
// Not moved? Move it.
|
||||
if (!$e.data(key)) {
|
||||
|
||||
// Condition is false? Bail.
|
||||
if (!condition)
|
||||
return;
|
||||
|
||||
// Get placeholder (which will serve as our point of reference for when this element needs to move back).
|
||||
$p = $e.prev();
|
||||
|
||||
// Couldn't find anything? Means this element's already at the top, so bail.
|
||||
if ($p.length == 0)
|
||||
return;
|
||||
|
||||
// Move element to top of parent.
|
||||
$e.prependTo($parent);
|
||||
|
||||
// Mark element as moved.
|
||||
$e.data(key, $p);
|
||||
|
||||
}
|
||||
|
||||
// Moved already?
|
||||
else {
|
||||
|
||||
// Condition is true? Bail.
|
||||
if (condition)
|
||||
return;
|
||||
|
||||
$p = $e.data(key);
|
||||
|
||||
// Move element back to its original location (using our placeholder).
|
||||
$e.insertAfter($p);
|
||||
|
||||
// Unmark element as moved.
|
||||
$e.removeData(key);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
$('table tr td:first-child').on('click touch', function() {
|
||||
$(this).parent().toggleClass('active');
|
||||
$(this).parent().siblings().removeClass('active');
|
||||
})
|
||||
|
||||
var tables = document.getElementsByTagName('table');
|
||||
for (i = 0; i < tables.length; i++) {
|
||||
var headers = tables[i].getElementsByTagName('th'),
|
||||
rows = tables[i].getElementsByTagName('tr'),
|
||||
header = [];
|
||||
for (h = 0; h < headers.length; h++) {
|
||||
header.push(headers[h].textContent);
|
||||
}
|
||||
for (r = 0; r < rows.length; r++) {
|
||||
var cells = rows[r].getElementsByTagName('td');
|
||||
for (c = 0; c < cells.length; c++) {
|
||||
if (cells[c].getAttribute('data-header') == undefined && header[c] !== undefined) {
|
||||
cells[c].setAttribute('data-header', header[c]);
|
||||
}
|
||||
if (cells[c].innerHTML.trim() == 'Yes') {
|
||||
cells[c].innerHTML = '<i class="fa fa-check" aria-hidden="true" style="color:green"></i>';
|
||||
}
|
||||
if (cells[c].innerHTML.trim() == 'Free') {
|
||||
cells[c].innerHTML = '<i class="fa fa-check" aria-hidden="true" style="color:green"></i>';
|
||||
}
|
||||
if (cells[c].innerHTML.trim() == 'No') {
|
||||
cells[c].innerHTML = '<i class="fa fa-times" aria-hidden="true" style="color:red"></i>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
434
public/js/w3.js
Normal file
434
public/js/w3.js
Normal file
@@ -0,0 +1,434 @@
|
||||
/* W3.JS 1.03 December 2017 by w3schools.com */
|
||||
"use strict";
|
||||
var w3 = {};
|
||||
w3.hide = function (sel) {
|
||||
w3.hideElements(w3.getElements(sel));
|
||||
};
|
||||
w3.hideElements = function (elements) {
|
||||
var i, l = elements.length;
|
||||
for (i = 0; i < l; i++) {
|
||||
w3.hideElement(elements[i]);
|
||||
}
|
||||
};
|
||||
w3.hideElement = function (element) {
|
||||
w3.styleElement(element, "display", "none");
|
||||
};
|
||||
w3.show = function (sel, a) {
|
||||
var elements = w3.getElements(sel);
|
||||
if (a) {w3.hideElements(elements);}
|
||||
w3.showElements(elements);
|
||||
};
|
||||
w3.showElements = function (elements) {
|
||||
var i, l = elements.length;
|
||||
for (i = 0; i < l; i++) {
|
||||
w3.showElement(elements[i]);
|
||||
}
|
||||
};
|
||||
w3.showElement = function (element) {
|
||||
w3.styleElement(element, "display", "block");
|
||||
};
|
||||
w3.addStyle = function (sel, prop, val) {
|
||||
w3.styleElements(w3.getElements(sel), prop, val);
|
||||
};
|
||||
w3.styleElements = function (elements, prop, val) {
|
||||
var i, l = elements.length;
|
||||
for (i = 0; i < l; i++) {
|
||||
w3.styleElement(elements[i], prop, val);
|
||||
}
|
||||
};
|
||||
w3.styleElement = function (element, prop, val) {
|
||||
element.style.setProperty(prop, val);
|
||||
};
|
||||
w3.toggleShow = function (sel) {
|
||||
var i, x = w3.getElements(sel), l = x.length;
|
||||
for (i = 0; i < l; i++) {
|
||||
if (x[i].style.display == "none") {
|
||||
w3.styleElement(x[i], "display", "block");
|
||||
} else {
|
||||
w3.styleElement(x[i], "display", "none");
|
||||
}
|
||||
}
|
||||
};
|
||||
w3.addClass = function (sel, name) {
|
||||
w3.addClassElements(w3.getElements(sel), name);
|
||||
};
|
||||
w3.addClassElements = function (elements, name) {
|
||||
var i, l = elements.length;
|
||||
for (i = 0; i < l; i++) {
|
||||
w3.addClassElement(elements[i], name);
|
||||
}
|
||||
};
|
||||
w3.addClassElement = function (element, name) {
|
||||
var i, arr1, arr2;
|
||||
arr1 = element.className.split(" ");
|
||||
arr2 = name.split(" ");
|
||||
for (i = 0; i < arr2.length; i++) {
|
||||
if (arr1.indexOf(arr2[i]) == -1) {element.className += " " + arr2[i];}
|
||||
}
|
||||
};
|
||||
w3.removeClass = function (sel, name) {
|
||||
w3.removeClassElements(w3.getElements(sel), name);
|
||||
};
|
||||
w3.removeClassElements = function (elements, name) {
|
||||
var i, l = elements.length, arr1, arr2, j;
|
||||
for (i = 0; i < l; i++) {
|
||||
w3.removeClassElement(elements[i], name);
|
||||
}
|
||||
};
|
||||
w3.removeClassElement = function (element, name) {
|
||||
var i, arr1, arr2;
|
||||
arr1 = element.className.split(" ");
|
||||
arr2 = name.split(" ");
|
||||
for (i = 0; i < arr2.length; i++) {
|
||||
while (arr1.indexOf(arr2[i]) > -1) {
|
||||
arr1.splice(arr1.indexOf(arr2[i]), 1);
|
||||
}
|
||||
}
|
||||
element.className = arr1.join(" ");
|
||||
};
|
||||
w3.toggleClass = function (sel, c1, c2) {
|
||||
w3.toggleClassElements(w3.getElements(sel), c1, c2);
|
||||
};
|
||||
w3.toggleClassElements = function (elements, c1, c2) {
|
||||
var i, l = elements.length;
|
||||
for (i = 0; i < l; i++) {
|
||||
w3.toggleClassElement(elements[i], c1, c2);
|
||||
}
|
||||
};
|
||||
w3.toggleClassElement = function (element, c1, c2) {
|
||||
var t1, t2, t1Arr, t2Arr, j, arr, allPresent;
|
||||
t1 = (c1 || "");
|
||||
t2 = (c2 || "");
|
||||
t1Arr = t1.split(" ");
|
||||
t2Arr = t2.split(" ");
|
||||
arr = element.className.split(" ");
|
||||
if (t2Arr.length == 0) {
|
||||
allPresent = true;
|
||||
for (j = 0; j < t1Arr.length; j++) {
|
||||
if (arr.indexOf(t1Arr[j]) == -1) {allPresent = false;}
|
||||
}
|
||||
if (allPresent) {
|
||||
w3.removeClassElement(element, t1);
|
||||
} else {
|
||||
w3.addClassElement(element, t1);
|
||||
}
|
||||
} else {
|
||||
allPresent = true;
|
||||
for (j = 0; j < t1Arr.length; j++) {
|
||||
if (arr.indexOf(t1Arr[j]) == -1) {allPresent = false;}
|
||||
}
|
||||
if (allPresent) {
|
||||
w3.removeClassElement(element, t1);
|
||||
w3.addClassElement(element, t2);
|
||||
} else {
|
||||
w3.removeClassElement(element, t2);
|
||||
w3.addClassElement(element, t1);
|
||||
}
|
||||
}
|
||||
};
|
||||
w3.getElements = function (id) {
|
||||
if (typeof id == "object") {
|
||||
return [id];
|
||||
} else {
|
||||
return document.querySelectorAll(id);
|
||||
}
|
||||
};
|
||||
w3.filterHTML = function(id, sel, filter) {
|
||||
var a, b, c, i, ii, iii, hit;
|
||||
a = w3.getElements(id);
|
||||
for (i = 0; i < a.length; i++) {
|
||||
b = w3.getElements(sel);
|
||||
for (ii = 0; ii < b.length; ii++) {
|
||||
hit = 0;
|
||||
if (b[ii].innerHTML.toUpperCase().indexOf(filter.toUpperCase()) > -1) {
|
||||
hit = 1;
|
||||
}
|
||||
c = b[ii].getElementsByTagName("*");
|
||||
for (iii = 0; iii < c.length; iii++) {
|
||||
if (c[iii].innerHTML.toUpperCase().indexOf(filter.toUpperCase()) > -1) {
|
||||
hit = 1;
|
||||
}
|
||||
}
|
||||
if (hit == 1) {
|
||||
b[ii].style.display = "";
|
||||
} else {
|
||||
b[ii].style.display = "none";
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
w3.sortHTML = function(id, sel, sortvalue) {
|
||||
var a, b, i, ii, y, bytt, v1, v2, cc, j;
|
||||
a = w3.getElements(id);
|
||||
for (i = 0; i < a.length; i++) {
|
||||
for (j = 0; j < 2; j++) {
|
||||
cc = 0;
|
||||
y = 1;
|
||||
while (y == 1) {
|
||||
y = 0;
|
||||
b = a[i].querySelectorAll(sel);
|
||||
for (ii = 0; ii < (b.length - 1); ii++) {
|
||||
bytt = 0;
|
||||
if (sortvalue) {
|
||||
v1 = b[ii].querySelector(sortvalue).innerHTML.toLowerCase();
|
||||
v2 = b[ii + 1].querySelector(sortvalue).innerHTML.toLowerCase();
|
||||
} else {
|
||||
v1 = b[ii].innerHTML.toLowerCase();
|
||||
v2 = b[ii + 1].innerHTML.toLowerCase();
|
||||
}
|
||||
if ((j == 0 && (v1 > v2)) || (j == 1 && (v1 < v2))) {
|
||||
bytt = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bytt == 1) {
|
||||
b[ii].parentNode.insertBefore(b[ii + 1], b[ii]);
|
||||
y = 1;
|
||||
cc++;
|
||||
}
|
||||
}
|
||||
if (cc > 0) {break;}
|
||||
}
|
||||
}
|
||||
};
|
||||
w3.sortHTMLbyNumber = function(id, sel, sortvalue) {
|
||||
var a, b, i, ii, y, bytt, v1, v2, cc, j;
|
||||
a = w3.getElements(id);
|
||||
for (i = 0; i < a.length; i++) {
|
||||
for (j = 0; j < 2; j++) {
|
||||
cc = 0;
|
||||
y = 1;
|
||||
while (y == 1) {
|
||||
y = 0;
|
||||
b = a[i].querySelectorAll(sel);
|
||||
for (ii = 0; ii < (b.length - 1); ii++) {
|
||||
bytt = 0;
|
||||
if (sortvalue) {
|
||||
v1 = b[ii].querySelector(sortvalue).innerHTML.toLowerCase();
|
||||
v2 = b[ii + 1].querySelector(sortvalue).innerHTML.toLowerCase();
|
||||
} else {
|
||||
v1 = b[ii].innerHTML.toLowerCase();
|
||||
v2 = b[ii + 1].innerHTML.toLowerCase();
|
||||
}
|
||||
var i1 = parseInt(v1, 10);
|
||||
var i2 = parseInt(v2, 10);
|
||||
if ((j == 0 && (i1 > i2)) || (j == 1 && (i1 < i2))) {
|
||||
bytt = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bytt == 1) {
|
||||
b[ii].parentNode.insertBefore(b[ii + 1], b[ii]);
|
||||
y = 1;
|
||||
cc++;
|
||||
}
|
||||
}
|
||||
if (cc > 0) {break;}
|
||||
}
|
||||
}
|
||||
};
|
||||
w3.slideshow = function (sel, ms, func) {
|
||||
var i, ss, x = w3.getElements(sel), l = x.length;
|
||||
ss = {};
|
||||
ss.current = 1;
|
||||
ss.x = x;
|
||||
ss.ondisplaychange = func;
|
||||
if (!isNaN(ms) || ms == 0) {
|
||||
ss.milliseconds = ms;
|
||||
} else {
|
||||
ss.milliseconds = 1000;
|
||||
}
|
||||
ss.start = function() {
|
||||
ss.display(ss.current)
|
||||
if (ss.ondisplaychange) {ss.ondisplaychange();}
|
||||
if (ss.milliseconds > 0) {
|
||||
window.clearTimeout(ss.timeout);
|
||||
ss.timeout = window.setTimeout(ss.next, ss.milliseconds);
|
||||
}
|
||||
};
|
||||
ss.next = function() {
|
||||
ss.current += 1;
|
||||
if (ss.current > ss.x.length) {ss.current = 1;}
|
||||
ss.start();
|
||||
};
|
||||
ss.previous = function() {
|
||||
ss.current -= 1;
|
||||
if (ss.current < 1) {ss.current = ss.x.length;}
|
||||
ss.start();
|
||||
};
|
||||
ss.display = function (n) {
|
||||
w3.styleElements(ss.x, "display", "none");
|
||||
w3.styleElement(ss.x[n - 1], "display", "block");
|
||||
}
|
||||
ss.start();
|
||||
return ss;
|
||||
};
|
||||
w3.includeHTML = function(cb) {
|
||||
var z, i, elmnt, file, xhttp;
|
||||
z = document.getElementsByTagName("*");
|
||||
for (i = 0; i < z.length; i++) {
|
||||
elmnt = z[i];
|
||||
file = elmnt.getAttribute("w3-include-html");
|
||||
if (file) {
|
||||
xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = function() {
|
||||
if (this.readyState == 4) {
|
||||
if (this.status == 200) {elmnt.innerHTML = this.responseText;}
|
||||
if (this.status == 404) {elmnt.innerHTML = "Page not found.";}
|
||||
elmnt.removeAttribute("w3-include-html");
|
||||
w3.includeHTML(cb);
|
||||
}
|
||||
}
|
||||
xhttp.open("GET", file, true);
|
||||
xhttp.send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (cb) cb();
|
||||
};
|
||||
w3.getHttpData = function (file, func) {
|
||||
w3.http(file, function () {
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
func(this.responseText);
|
||||
}
|
||||
});
|
||||
};
|
||||
w3.getHttpObject = function (file, func) {
|
||||
w3.http(file, function () {
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
func(JSON.parse(this.responseText));
|
||||
}
|
||||
});
|
||||
};
|
||||
w3.displayHttp = function (id, file) {
|
||||
w3.http(file, function () {
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
w3.displayObject(id, JSON.parse(this.responseText));
|
||||
}
|
||||
});
|
||||
};
|
||||
w3.http = function (target, readyfunc, xml, method) {
|
||||
var httpObj;
|
||||
if (!method) {method = "GET"; }
|
||||
if (window.XMLHttpRequest) {
|
||||
httpObj = new XMLHttpRequest();
|
||||
} else if (window.ActiveXObject) {
|
||||
httpObj = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
}
|
||||
if (httpObj) {
|
||||
if (readyfunc) {httpObj.onreadystatechange = readyfunc;}
|
||||
httpObj.open(method, target, true);
|
||||
httpObj.send(xml);
|
||||
}
|
||||
};
|
||||
w3.getElementsByAttribute = function (x, att) {
|
||||
var arr = [], arrCount = -1, i, l, y = x.getElementsByTagName("*"), z = att.toUpperCase();
|
||||
l = y.length;
|
||||
for (i = -1; i < l; i += 1) {
|
||||
if (i == -1) {y[i] = x;}
|
||||
if (y[i].getAttribute(z) !== null) {arrCount += 1; arr[arrCount] = y[i];}
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
w3.dataObject = {},
|
||||
w3.displayObject = function (id, data) {
|
||||
var htmlObj, htmlTemplate, html, arr = [], a, l, rowClone, x, j, i, ii, cc, repeat, repeatObj, repeatX = "";
|
||||
htmlObj = document.getElementById(id);
|
||||
htmlTemplate = init_template(id, htmlObj);
|
||||
html = htmlTemplate.cloneNode(true);
|
||||
arr = w3.getElementsByAttribute(html, "w3-repeat");
|
||||
l = arr.length;
|
||||
for (j = (l - 1); j >= 0; j -= 1) {
|
||||
cc = arr[j].getAttribute("w3-repeat").split(" ");
|
||||
if (cc.length == 1) {
|
||||
repeat = cc[0];
|
||||
} else {
|
||||
repeatX = cc[0];
|
||||
repeat = cc[2];
|
||||
}
|
||||
arr[j].removeAttribute("w3-repeat");
|
||||
repeatObj = data[repeat];
|
||||
if (repeatObj && typeof repeatObj == "object" && repeatObj.length != "undefined") {
|
||||
i = 0;
|
||||
for (x in repeatObj) {
|
||||
i += 1;
|
||||
rowClone = arr[j];
|
||||
rowClone = w3_replace_curly(rowClone, "element", repeatX, repeatObj[x]);
|
||||
a = rowClone.attributes;
|
||||
for (ii = 0; ii < a.length; ii += 1) {
|
||||
a[ii].value = w3_replace_curly(a[ii], "attribute", repeatX, repeatObj[x]).value;
|
||||
}
|
||||
(i === repeatObj.length) ? arr[j].parentNode.replaceChild(rowClone, arr[j]) : arr[j].parentNode.insertBefore(rowClone, arr[j]);
|
||||
}
|
||||
} else {
|
||||
console.log("w3-repeat must be an array. " + repeat + " is not an array.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
html = w3_replace_curly(html, "element");
|
||||
htmlObj.parentNode.replaceChild(html, htmlObj);
|
||||
function init_template(id, obj) {
|
||||
var template;
|
||||
template = obj.cloneNode(true);
|
||||
if (w3.dataObject.hasOwnProperty(id)) {return w3.dataObject[id];}
|
||||
w3.dataObject[id] = template;
|
||||
return template;
|
||||
}
|
||||
function w3_replace_curly(elmnt, typ, repeatX, x) {
|
||||
var value, rowClone, pos1, pos2, originalHTML, lookFor, lookForARR = [], i, cc, r;
|
||||
rowClone = elmnt.cloneNode(true);
|
||||
pos1 = 0;
|
||||
while (pos1 > -1) {
|
||||
originalHTML = (typ == "attribute") ? rowClone.value : rowClone.innerHTML;
|
||||
pos1 = originalHTML.indexOf("{{", pos1);
|
||||
if (pos1 === -1) {break;}
|
||||
pos2 = originalHTML.indexOf("}}", pos1 + 1);
|
||||
lookFor = originalHTML.substring(pos1 + 2, pos2);
|
||||
lookForARR = lookFor.split("||");
|
||||
value = undefined;
|
||||
for (i = 0; i < lookForARR.length; i += 1) {
|
||||
lookForARR[i] = lookForARR[i].replace(/^\s+|\s+$/gm, ''); //trim
|
||||
if (x) {value = x[lookForARR[i]];}
|
||||
if (value == undefined && data) {value = data[lookForARR[i]];}
|
||||
if (value == undefined) {
|
||||
cc = lookForARR[i].split(".");
|
||||
if (cc[0] == repeatX) {value = x[cc[1]]; }
|
||||
}
|
||||
if (value == undefined) {
|
||||
if (lookForARR[i] == repeatX) {value = x;}
|
||||
}
|
||||
if (value == undefined) {
|
||||
if (lookForARR[i].substr(0, 1) == '"') {
|
||||
value = lookForARR[i].replace(/"/g, "");
|
||||
} else if (lookForARR[i].substr(0,1) == "'") {
|
||||
value = lookForARR[i].replace(/'/g, "");
|
||||
}
|
||||
}
|
||||
if (value != undefined) {break;}
|
||||
}
|
||||
if (value != undefined) {
|
||||
r = "{{" + lookFor + "}}";
|
||||
if (typ == "attribute") {
|
||||
rowClone.value = rowClone.value.replace(r, value);
|
||||
} else {
|
||||
w3_replace_html(rowClone, r, value);
|
||||
}
|
||||
}
|
||||
pos1 = pos1 + 1;
|
||||
}
|
||||
return rowClone;
|
||||
}
|
||||
function w3_replace_html(a, r, result) {
|
||||
var b, l, i, a, x, j;
|
||||
if (a.hasAttributes()) {
|
||||
b = a.attributes;
|
||||
l = b.length;
|
||||
for (i = 0; i < l; i += 1) {
|
||||
if (b[i].value.indexOf(r) > -1) {b[i].value = b[i].value.replace(r, result);}
|
||||
}
|
||||
}
|
||||
x = a.getElementsByTagName("*");
|
||||
l = x.length;
|
||||
a.innerHTML = a.innerHTML.replace(r, result);
|
||||
}
|
||||
};
|
||||
1
public/js/w3codecolor-min.js
vendored
Normal file
1
public/js/w3codecolor-min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
644
public/js/w3codecolor.js
Normal file
644
public/js/w3codecolor.js
Normal file
@@ -0,0 +1,644 @@
|
||||
/* w3codecolor ver 1.31 by w3schools.com */
|
||||
/* add bash script color by jesselau.com*/
|
||||
function w3CodeColor() {
|
||||
var x, i, j, k, l, modes = ["html", "js", "java", "css", "sql", "python", "bash", "go"];
|
||||
if (!document.getElementsByClassName) {return;}
|
||||
k = modes.length;
|
||||
for (j = 0; j < k; j++) {
|
||||
x = document.getElementsByClassName(modes[j] + "High");
|
||||
l = x.length;
|
||||
for (i = 0; i < l; i++) {
|
||||
x[i].innerHTML = w3CodeColorize(x[i].innerHTML, modes[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
function w3CodeColorize(x, lang) {
|
||||
var tagcolor = "mediumblue";
|
||||
var tagnamecolor = "brown";
|
||||
var attributecolor = "red";
|
||||
var attributevaluecolor = "mediumblue";
|
||||
var commentcolor = "green";
|
||||
var cssselectorcolor = "brown";
|
||||
var csspropertycolor = "red";
|
||||
var csspropertyvaluecolor = "mediumblue";
|
||||
var cssdelimitercolor = "black";
|
||||
var cssimportantcolor = "red";
|
||||
var jscolor = "black";
|
||||
var jskeywordcolor = "mediumblue";
|
||||
var jsstringcolor = "brown";
|
||||
var jsnumbercolor = "red";
|
||||
var jspropertycolor = "black";
|
||||
var javacolor = "black";
|
||||
var javakeywordcolor = "mediumblue";
|
||||
var javastringcolor = "brown";
|
||||
var javanumbercolor = "red";
|
||||
var javapropertycolor = "black";
|
||||
var phptagcolor = "red";
|
||||
var phpcolor = "black";
|
||||
var phpkeywordcolor = "mediumblue";
|
||||
var phpglobalcolor = "goldenrod";
|
||||
var phpstringcolor = "brown";
|
||||
var phpnumbercolor = "red";
|
||||
var pythoncolor = "black";
|
||||
var pythonkeywordcolor = "mediumblue";
|
||||
var pythonstringcolor = "brown";
|
||||
var pythonnumbercolor = "red";
|
||||
var angularstatementcolor = "red";
|
||||
var sqlcolor = "black";
|
||||
var sqlkeywordcolor = "mediumblue";
|
||||
var sqlstringcolor = "brown";
|
||||
var sqlnumbercolor = "";
|
||||
var bashcolor = "black";
|
||||
var bashkeywordcolor = "mediumblue";
|
||||
var bashstringcolor = "brown";
|
||||
var bashnumbercolor = "red";
|
||||
var gocolor = "black";
|
||||
var gokeywordcolor = "mediumblue";
|
||||
var gostringcolor = "brown";
|
||||
var gonumbercolor = "red";
|
||||
if (!lang) {lang = "html"; }
|
||||
if (lang == "html") {return htmlMode(x);}
|
||||
if (lang == "css") {return cssMode(x);}
|
||||
if (lang == "js") {return jsMode(x);}
|
||||
if (lang == "java") {return javaMode(x);}
|
||||
if (lang == "php") {return phpMode(x);}
|
||||
if (lang == "sql") {return sqlMode(x);}
|
||||
if (lang == "python") {return pythonMode(x);}
|
||||
if (lang == "bash") {return bashMode(x);}
|
||||
if (lang == "go") {return goMode(x);}
|
||||
return x;
|
||||
function extract(str, start, end, func, repl) {
|
||||
var s, e, d = "", a = [];
|
||||
while (str.search(start) > -1) {
|
||||
s = str.search(start);
|
||||
e = str.indexOf(end, s);
|
||||
if (e == -1) {e = str.length;}
|
||||
if (repl) {
|
||||
a.push(func(str.substring(s, e + (end.length))));
|
||||
str = str.substring(0, s) + repl + str.substr(e + (end.length));
|
||||
} else {
|
||||
d += str.substring(0, s);
|
||||
d += func(str.substring(s, e + (end.length)));
|
||||
str = str.substr(e + (end.length));
|
||||
}
|
||||
}
|
||||
this.rest = d + str;
|
||||
this.arr = a;
|
||||
}
|
||||
function htmlMode(txt) {
|
||||
var rest = txt, done = "", php, comment, angular, startpos, endpos, note, i;
|
||||
php = new extract(rest, "<\\?php", "?>", phpMode, "W3PHPPOS");
|
||||
rest = php.rest;
|
||||
comment = new extract(rest, "<!--", "-->", commentMode, "W3HTMLCOMMENTPOS");
|
||||
rest = comment.rest;
|
||||
while (rest.indexOf("<") > -1) {
|
||||
note = "";
|
||||
startpos = rest.indexOf("<");
|
||||
if (rest.substr(startpos, 9).toUpperCase() == "<STYLE") {note = "css";}
|
||||
if (rest.substr(startpos, 10).toUpperCase() == "<SCRIPT") {note = "javascript";}
|
||||
endpos = rest.indexOf(">", startpos);
|
||||
if (endpos == -1) {endpos = rest.length;}
|
||||
done += rest.substring(0, startpos);
|
||||
done += tagMode(rest.substring(startpos, endpos + 4));
|
||||
rest = rest.substr(endpos + 4);
|
||||
if (note == "css") {
|
||||
endpos = rest.indexOf("</style>");
|
||||
if (endpos > -1) {
|
||||
done += cssMode(rest.substring(0, endpos));
|
||||
rest = rest.substr(endpos);
|
||||
}
|
||||
}
|
||||
if (note == "javascript") {
|
||||
endpos = rest.indexOf("</script>");
|
||||
if (endpos > -1) {
|
||||
done += jsMode(rest.substring(0, endpos));
|
||||
rest = rest.substr(endpos);
|
||||
}
|
||||
}
|
||||
}
|
||||
rest = done + rest;
|
||||
angular = new extract(rest, "{{", "}}", angularMode);
|
||||
rest = angular.rest;
|
||||
for (i = 0; i < comment.arr.length; i++) {
|
||||
rest = rest.replace("W3HTMLCOMMENTPOS", comment.arr[i]);
|
||||
}
|
||||
for (i = 0; i < php.arr.length; i++) {
|
||||
rest = rest.replace("W3PHPPOS", php.arr[i]);
|
||||
}
|
||||
return rest;
|
||||
}
|
||||
function tagMode(txt) {
|
||||
var rest = txt, done = "", startpos, endpos, result;
|
||||
while (rest.search(/(\s|<br>)/) > -1) {
|
||||
startpos = rest.search(/(\s|<br>)/);
|
||||
endpos = rest.indexOf(">");
|
||||
if (endpos == -1) {endpos = rest.length;}
|
||||
done += rest.substring(0, startpos);
|
||||
done += attributeMode(rest.substring(startpos, endpos));
|
||||
rest = rest.substr(endpos);
|
||||
}
|
||||
result = done + rest;
|
||||
result = "<span style=color:" + tagcolor + "><</span>" + result.substring(4);
|
||||
if (result.substr(result.length - 4, 4) == ">") {
|
||||
result = result.substring(0, result.length - 4) + "<span style=color:" + tagcolor + ">></span>";
|
||||
}
|
||||
return "<span style=color:" + tagnamecolor + ">" + result + "</span>";
|
||||
}
|
||||
function attributeMode(txt) {
|
||||
var rest = txt, done = "", startpos, endpos, singlefnuttpos, doublefnuttpos, spacepos;
|
||||
while (rest.indexOf("=") > -1) {
|
||||
endpos = -1;
|
||||
startpos = rest.indexOf("=");
|
||||
singlefnuttpos = rest.indexOf("'", startpos);
|
||||
doublefnuttpos = rest.indexOf('"', startpos);
|
||||
spacepos = rest.indexOf(" ", startpos + 2);
|
||||
if (spacepos > -1 && (spacepos < singlefnuttpos || singlefnuttpos == -1) && (spacepos < doublefnuttpos || doublefnuttpos == -1)) {
|
||||
endpos = rest.indexOf(" ", startpos);
|
||||
} else if (doublefnuttpos > -1 && (doublefnuttpos < singlefnuttpos || singlefnuttpos == -1) && (doublefnuttpos < spacepos || spacepos == -1)) {
|
||||
endpos = rest.indexOf('"', rest.indexOf('"', startpos) + 1);
|
||||
} else if (singlefnuttpos > -1 && (singlefnuttpos < doublefnuttpos || doublefnuttpos == -1) && (singlefnuttpos < spacepos || spacepos == -1)) {
|
||||
endpos = rest.indexOf("'", rest.indexOf("'", startpos) + 1);
|
||||
}
|
||||
if (!endpos || endpos == -1 || endpos < startpos) {endpos = rest.length;}
|
||||
done += rest.substring(0, startpos);
|
||||
done += attributeValueMode(rest.substring(startpos, endpos + 1));
|
||||
rest = rest.substr(endpos + 1);
|
||||
}
|
||||
return "<span style=color:" + attributecolor + ">" + done + rest + "</span>";
|
||||
}
|
||||
function attributeValueMode(txt) {
|
||||
return "<span style=color:" + attributevaluecolor + ">" + txt + "</span>";
|
||||
}
|
||||
function angularMode(txt) {
|
||||
return "<span style=color:" + angularstatementcolor + ">" + txt + "</span>";
|
||||
}
|
||||
function commentMode(txt) {
|
||||
return "<span style=color:" + commentcolor + ">" + txt + "</span>";
|
||||
}
|
||||
function cssMode(txt) {
|
||||
var rest = txt, done = "", s, e, comment, i, midz, c, cc;
|
||||
comment = new extract(rest, /\/\*/, "*/", commentMode, "W3CSSCOMMENTPOS");
|
||||
rest = comment.rest;
|
||||
while (rest.search("{") > -1) {
|
||||
s = rest.search("{");
|
||||
midz = rest.substr(s + 1);
|
||||
cc = 1;
|
||||
c = 0;
|
||||
for (i = 0; i < midz.length; i++) {
|
||||
if (midz.substr(i, 1) == "{") {cc++; c++}
|
||||
if (midz.substr(i, 1) == "}") {cc--;}
|
||||
if (cc == 0) {break;}
|
||||
}
|
||||
if (cc != 0) {c = 0;}
|
||||
e = s;
|
||||
for (i = 0; i <= c; i++) {
|
||||
e = rest.indexOf("}", e + 1);
|
||||
}
|
||||
if (e == -1) {e = rest.length;}
|
||||
done += rest.substring(0, s + 1);
|
||||
done += cssPropertyMode(rest.substring(s + 1, e));
|
||||
rest = rest.substr(e);
|
||||
}
|
||||
rest = done + rest;
|
||||
rest = rest.replace(/{/g, "<span style=color:" + cssdelimitercolor + ">{</span>");
|
||||
rest = rest.replace(/}/g, "<span style=color:" + cssdelimitercolor + ">}</span>");
|
||||
for (i = 0; i < comment.arr.length; i++) {
|
||||
rest = rest.replace("W3CSSCOMMENTPOS", comment.arr[i]);
|
||||
}
|
||||
return "<span style=color:" + cssselectorcolor + ">" + rest + "</span>";
|
||||
}
|
||||
function cssPropertyMode(txt) {
|
||||
var rest = txt, done = "", s, e, n, loop;
|
||||
if (rest.indexOf("{") > -1 ) { return cssMode(rest); }
|
||||
while (rest.search(":") > -1) {
|
||||
s = rest.search(":");
|
||||
loop = true;
|
||||
n = s;
|
||||
while (loop == true) {
|
||||
loop = false;
|
||||
e = rest.indexOf(";", n);
|
||||
if (rest.substring(e - 5, e + 1) == " ") {
|
||||
loop = true;
|
||||
n = e + 1;
|
||||
}
|
||||
}
|
||||
if (e == -1) {e = rest.length;}
|
||||
done += rest.substring(0, s);
|
||||
done += cssPropertyValueMode(rest.substring(s, e + 1));
|
||||
rest = rest.substr(e + 1);
|
||||
}
|
||||
return "<span style=color:" + csspropertycolor + ">" + done + rest + "</span>";
|
||||
}
|
||||
function cssPropertyValueMode(txt) {
|
||||
var rest = txt, done = "", s;
|
||||
rest = "<span style=color:" + cssdelimitercolor + ">:</span>" + rest.substring(1);
|
||||
while (rest.search(/!important/i) > -1) {
|
||||
s = rest.search(/!important/i);
|
||||
done += rest.substring(0, s);
|
||||
done += cssImportantMode(rest.substring(s, s + 10));
|
||||
rest = rest.substr(s + 10);
|
||||
}
|
||||
result = done + rest;
|
||||
if (result.substr(result.length - 1, 1) == ";" && result.substr(result.length - 6, 6) != " " && result.substr(result.length - 4, 4) != "<" && result.substr(result.length - 4, 4) != ">" && result.substr(result.length - 5, 5) != "&") {
|
||||
result = result.substring(0, result.length - 1) + "<span style=color:" + cssdelimitercolor + ">;</span>";
|
||||
}
|
||||
return "<span style=color:" + csspropertyvaluecolor + ">" + result + "</span>";
|
||||
}
|
||||
function cssImportantMode(txt) {
|
||||
return "<span style=color:" + cssimportantcolor + ";font-weight:bold;>" + txt + "</span>";
|
||||
}
|
||||
function jsMode(txt) {
|
||||
var rest = txt, done = "", esc = [], i, cc, tt = "", sfnuttpos, dfnuttpos, compos, comlinepos, keywordpos, numpos, mypos, dotpos, y;
|
||||
for (i = 0; i < rest.length; i++) {
|
||||
cc = rest.substr(i, 1);
|
||||
if (cc == "\\") {
|
||||
esc.push(rest.substr(i, 2));
|
||||
cc = "W3JSESCAPE";
|
||||
i++;
|
||||
}
|
||||
tt += cc;
|
||||
}
|
||||
rest = tt;
|
||||
y = 1;
|
||||
while (y == 1) {
|
||||
sfnuttpos = getPos(rest, "'", "'", jsStringMode);
|
||||
dfnuttpos = getPos(rest, '"', '"', jsStringMode);
|
||||
compos = getPos(rest, /\/\*/, "*/", commentMode);
|
||||
comlinepos = getPos(rest, /\/\//, "<br>", commentMode);
|
||||
numpos = getNumPos(rest, jsNumberMode);
|
||||
keywordpos = getKeywordPos("js", rest, jsKeywordMode);
|
||||
dotpos = getDotPos(rest, jsPropertyMode);
|
||||
if (Math.max(numpos[0], sfnuttpos[0], dfnuttpos[0], compos[0], comlinepos[0], keywordpos[0], dotpos[0]) == -1) {break;}
|
||||
mypos = getMinPos(numpos, sfnuttpos, dfnuttpos, compos, comlinepos, keywordpos, dotpos);
|
||||
if (mypos[0] == -1) {break;}
|
||||
if (mypos[0] > -1) {
|
||||
done += rest.substring(0, mypos[0]);
|
||||
done += mypos[2](rest.substring(mypos[0], mypos[1]));
|
||||
rest = rest.substr(mypos[1]);
|
||||
}
|
||||
}
|
||||
rest = done + rest;
|
||||
for (i = 0; i < esc.length; i++) {
|
||||
rest = rest.replace("W3JSESCAPE", esc[i]);
|
||||
}
|
||||
return "<span style=color:" + jscolor + ">" + rest + "</span>";
|
||||
}
|
||||
function jsStringMode(txt) {
|
||||
return "<span style=color:" + jsstringcolor + ">" + txt + "</span>";
|
||||
}
|
||||
function jsKeywordMode(txt) {
|
||||
return "<span style=color:" + jskeywordcolor + ">" + txt + "</span>";
|
||||
}
|
||||
function jsNumberMode(txt) {
|
||||
return "<span style=color:" + jsnumbercolor + ">" + txt + "</span>";
|
||||
}
|
||||
function jsPropertyMode(txt) {
|
||||
return "<span style=color:" + jspropertycolor + ">" + txt + "</span>";
|
||||
}
|
||||
function getDotPos(txt, func) {
|
||||
var x, i, j, s, e, arr = [".","<", " ", ";", "(", "+", ")", "[", "]", ",", "&", ":", "{", "}", "/" ,"-", "*", "|", "%"];
|
||||
s = txt.indexOf(".");
|
||||
if (s > -1) {
|
||||
x = txt.substr(s + 1);
|
||||
for (j = 0; j < x.length; j++) {
|
||||
cc = x[j];
|
||||
for (i = 0; i < arr.length; i++) {
|
||||
if (cc.indexOf(arr[i]) > -1) {
|
||||
e = j;
|
||||
return [s + 1, e + s + 1, func];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return [-1, -1, func];
|
||||
}
|
||||
function getMinPos() {
|
||||
var i, arr = [];
|
||||
for (i = 0; i < arguments.length; i++) {
|
||||
if (arguments[i][0] > -1) {
|
||||
if (arr.length == 0 || arguments[i][0] < arr[0]) {arr = arguments[i];}
|
||||
}
|
||||
}
|
||||
if (arr.length == 0) {arr = arguments[i];}
|
||||
return arr;
|
||||
}
|
||||
function javaMode(txt) {
|
||||
var rest = txt, done = "", esc = [], i, cc, tt = "", sfnuttpos, dfnuttpos, compos, comlinepos, keywordpos, numpos, mypos, dotpos, y;
|
||||
for (i = 0; i < rest.length; i++) {
|
||||
cc = rest.substr(i, 1);
|
||||
if (cc == "\\") {
|
||||
esc.push(rest.substr(i, 2));
|
||||
cc = "W3JSESCAPE";
|
||||
i++;
|
||||
}
|
||||
tt += cc;
|
||||
}
|
||||
rest = tt;
|
||||
y = 1;
|
||||
while (y == 1) {
|
||||
sfnuttpos = getPos(rest, "'", "'", javaStringMode);
|
||||
dfnuttpos = getPos(rest, '"', '"', javaStringMode);
|
||||
compos = getPos(rest, /\/\*/, "*/", commentMode);
|
||||
comlinepos = getPos(rest, /\/\//, "<br>", commentMode);
|
||||
numpos = getNumPos(rest, javaNumberMode);
|
||||
keywordpos = getKeywordPos("java", rest, javaKeywordMode);
|
||||
dotpos = getDotPos(rest, javaPropertyMode);
|
||||
if (Math.max(numpos[0], sfnuttpos[0], dfnuttpos[0], compos[0], comlinepos[0], keywordpos[0], dotpos[0]) == -1) {break;}
|
||||
mypos = getMinPos(numpos, sfnuttpos, dfnuttpos, compos, comlinepos, keywordpos, dotpos);
|
||||
if (mypos[0] == -1) {break;}
|
||||
if (mypos[0] > -1) {
|
||||
done += rest.substring(0, mypos[0]);
|
||||
done += mypos[2](rest.substring(mypos[0], mypos[1]));
|
||||
rest = rest.substr(mypos[1]);
|
||||
}
|
||||
}
|
||||
rest = done + rest;
|
||||
for (i = 0; i < esc.length; i++) {
|
||||
rest = rest.replace("W3JSESCAPE", esc[i]);
|
||||
}
|
||||
return "<span style=color:" + javacolor + ">" + rest + "</span>";
|
||||
}
|
||||
function javaStringMode(txt) {
|
||||
return "<span style=color:" + javastringcolor + ">" + txt + "</span>";
|
||||
}
|
||||
function javaKeywordMode(txt) {
|
||||
return "<span style=color:" + javakeywordcolor + ">" + txt + "</span>";
|
||||
}
|
||||
function javaNumberMode(txt) {
|
||||
return "<span style=color:" + javanumbercolor + ">" + txt + "</span>";
|
||||
}
|
||||
function javaPropertyMode(txt) {
|
||||
return "<span style=color:" + javapropertycolor + ">" + txt + "</span>";
|
||||
}
|
||||
function sqlMode(txt) {
|
||||
var rest = txt, y, done = "", sfnuttpos, dfnuttpos, compos, comlinepos, keywordpos, numpos, mypos;
|
||||
y = 1;
|
||||
while (y == 1) {
|
||||
sfnuttpos = getPos(rest, "'", "'", sqlStringMode);
|
||||
dfnuttpos = getPos(rest, '"', '"', sqlStringMode);
|
||||
compos = getPos(rest, /\/\*/, "*/", commentMode);
|
||||
comlinepos = getPos(rest, /--/, "<br>", commentMode);
|
||||
numpos = getNumPos(rest, sqlNumberMode);
|
||||
keywordpos = getKeywordPos("sql", rest, sqlKeywordMode);
|
||||
if (Math.max(numpos[0], sfnuttpos[0], dfnuttpos[0], compos[0], comlinepos[0], keywordpos[0]) == -1) {break;}
|
||||
mypos = getMinPos(numpos, sfnuttpos, dfnuttpos, compos, comlinepos, keywordpos);
|
||||
if (mypos[0] == -1) {break;}
|
||||
if (mypos[0] > -1) {
|
||||
done += rest.substring(0, mypos[0]);
|
||||
done += mypos[2](rest.substring(mypos[0], mypos[1]));
|
||||
rest = rest.substr(mypos[1]);
|
||||
}
|
||||
}
|
||||
rest = done + rest;
|
||||
return "<span style=color:" + sqlcolor + ">" + rest + "</span>";
|
||||
}
|
||||
function sqlStringMode(txt) {
|
||||
return "<span style=color:" + sqlstringcolor + ">" + txt + "</span>";
|
||||
}
|
||||
function sqlKeywordMode(txt) {
|
||||
return "<span style=color:" + sqlkeywordcolor + ">" + txt + "</span>";
|
||||
}
|
||||
function sqlNumberMode(txt) {
|
||||
return "<span style=color:" + sqlnumbercolor + ">" + txt + "</span>";
|
||||
}
|
||||
function phpMode(txt) {
|
||||
var rest = txt, done = "", sfnuttpos, dfnuttpos, compos, comlinepos, comhashpos, keywordpos, mypos, y;
|
||||
y = 1;
|
||||
while (y == 1) {
|
||||
sfnuttpos = getPos(rest, "'", "'", phpStringMode);
|
||||
dfnuttpos = getPos(rest, '"', '"', phpStringMode);
|
||||
compos = getPos(rest, /\/\*/, "*/", commentMode);
|
||||
comlinepos = getPos(rest, /\/\//, "<br>", commentMode);
|
||||
comhashpos = getPos(rest, "#", "<br>", commentMode);
|
||||
numpos = getNumPos(rest, phpNumberMode);
|
||||
keywordpos = getKeywordPos("php", rest, phpKeywordMode);
|
||||
if (Math.max(numpos[0], sfnuttpos[0], dfnuttpos[0], compos[0], comlinepos[0], comhashpos[0], keywordpos[0]) == -1) {break;}
|
||||
mypos = getMinPos(numpos, sfnuttpos, dfnuttpos, compos, comlinepos, comhashpos, keywordpos);
|
||||
if (mypos[0] == -1) {break;}
|
||||
if (mypos[0] > -1) {
|
||||
done += rest.substring(0, mypos[0]);
|
||||
done += mypos[2](rest.substring(mypos[0], mypos[1]));
|
||||
rest = rest.substr(mypos[1]);
|
||||
}
|
||||
}
|
||||
rest = done + rest;
|
||||
rest = "<span style=color:" + phptagcolor + "><" + rest.substr(4, 4) + "</span>" + rest.substring(8);
|
||||
if (rest.substr(rest.length - 5, 5) == "?>") {
|
||||
rest = rest.substring(0, rest.length - 5) + "<span style=color:" + phptagcolor + ">?></span>";
|
||||
}
|
||||
return "<span style=color:" + phpcolor + ">" + rest + "</span>";
|
||||
}
|
||||
function phpStringMode(txt) {
|
||||
return "<span style=color:" + phpstringcolor + ">" + txt + "</span>";
|
||||
}
|
||||
function phpNumberMode(txt) {
|
||||
return "<span style=color:" + phpnumbercolor + ">" + txt + "</span>";
|
||||
}
|
||||
function phpKeywordMode(txt) {
|
||||
var glb = ["$GLOBALS","$_SERVER","$_REQUEST","$_POST","$_GET","$_FILES","$_ENV","$_COOKIE","$_SESSION"];
|
||||
if (glb.indexOf(txt.toUpperCase()) > -1) {
|
||||
if (glb.indexOf(txt) > -1) {
|
||||
return "<span style=color:" + phpglobalcolor + ">" + txt + "</span>";
|
||||
} else {
|
||||
return txt;
|
||||
}
|
||||
} else {
|
||||
return "<span style=color:" + phpkeywordcolor + ">" + txt + "</span>";
|
||||
}
|
||||
}
|
||||
function pythonMode(txt) {
|
||||
var rest = txt, done = "", sfnuttpos, dfnuttpos, compos, comlinepos, comhashpos, keywordpos, mypos, y;
|
||||
y = 1;
|
||||
while (y == 1) {
|
||||
sfnuttpos = getPos(rest, "'", "'", pythonStringMode);
|
||||
dfnuttpos = getPos(rest, '"', '"', pythonStringMode);
|
||||
compos = getPos(rest, /\/\*/, "*/", commentMode);
|
||||
comlinepos = getPos(rest, /\/\//, "<br>", commentMode);
|
||||
comhashpos = getPos(rest, "#", "<br>", commentMode);
|
||||
numpos = getNumPos(rest, pythonNumberMode);
|
||||
keywordpos = getKeywordPos("python", rest, pythonKeywordMode);
|
||||
if (Math.max(numpos[0], sfnuttpos[0], dfnuttpos[0], compos[0], comlinepos[0], comhashpos[0], keywordpos[0]) == -1) {break;}
|
||||
mypos = getMinPos(numpos, sfnuttpos, dfnuttpos, compos, comlinepos, comhashpos, keywordpos);
|
||||
if (mypos[0] == -1) {break;}
|
||||
if (mypos[0] > -1) {
|
||||
done += rest.substring(0, mypos[0]);
|
||||
done += mypos[2](rest.substring(mypos[0], mypos[1]));
|
||||
rest = rest.substr(mypos[1]);
|
||||
}
|
||||
}
|
||||
rest = done + rest;
|
||||
return "<span style=color:" + pythoncolor + ">" + rest + "</span>";
|
||||
}
|
||||
function pythonStringMode(txt) {
|
||||
return "<span style=color:" + pythonstringcolor + ">" + txt + "</span>";
|
||||
}
|
||||
function pythonNumberMode(txt) {
|
||||
return "<span style=color:" + pythonnumbercolor + ">" + txt + "</span>";
|
||||
}
|
||||
function pythonKeywordMode(txt) {
|
||||
return "<span style=color:" + pythonkeywordcolor + ">" + txt + "</span>";
|
||||
}
|
||||
function bashMode(txt) {
|
||||
var rest = txt, done = "", sfnuttpos, dfnuttpos, compos, comlinepos, comhashpos, keywordpos, mypos, y;
|
||||
y = 1;
|
||||
while (y == 1) {
|
||||
sfnuttpos = getPos(rest, "'", "'", bashStringMode);
|
||||
dfnuttpos = getPos(rest, '"', '"', bashStringMode);
|
||||
compos = getPos(rest, /\/\*/, "*/", commentMode);
|
||||
comlinepos = getPos(rest, /\/\//, "<br>", commentMode);
|
||||
comhashpos = getPos(rest, "#", "<br>", commentMode);
|
||||
numpos = getNumPos(rest, bashNumberMode);
|
||||
keywordpos = getKeywordPos("bash", rest, bashKeywordMode);
|
||||
if (Math.max(numpos[0], sfnuttpos[0], dfnuttpos[0], compos[0], comlinepos[0], comhashpos[0], keywordpos[0]) == -1) {break;}
|
||||
mypos = getMinPos(numpos, sfnuttpos, dfnuttpos, compos, comlinepos, comhashpos, keywordpos);
|
||||
if (mypos[0] == -1) {break;}
|
||||
if (mypos[0] > -1) {
|
||||
done += rest.substring(0, mypos[0]);
|
||||
done += mypos[2](rest.substring(mypos[0], mypos[1]));
|
||||
rest = rest.substr(mypos[1]);
|
||||
}
|
||||
}
|
||||
rest = done + rest;
|
||||
return "<span style=color:" + bashcolor + ">" + rest + "</span>";
|
||||
}
|
||||
function bashStringMode(txt) {
|
||||
return "<span style=color:" + bashstringcolor + ">" + txt + "</span>";
|
||||
}
|
||||
function bashNumberMode(txt) {
|
||||
return "<span style=color:" + bashnumbercolor + ">" + txt + "</span>";
|
||||
}
|
||||
function bashKeywordMode(txt) {
|
||||
return "<span style=color:" + bashkeywordcolor + ">" + txt + "</span>";
|
||||
}
|
||||
|
||||
function goMode(txt) {
|
||||
var rest = txt, done = "", sfnuttpos, dfnuttpos, compos, comlinepos, comhashpos, keywordpos, mypos, y;
|
||||
y = 1;
|
||||
while (y == 1) {
|
||||
sfnuttpos = getPos(rest, "'", "'", goStringMode);
|
||||
dfnuttpos = getPos(rest, '"', '"', goStringMode);
|
||||
compos = getPos(rest, /\/\*/, "*/", commentMode);
|
||||
comlinepos = getPos(rest, /\/\//, "<br>", commentMode);
|
||||
comhashpos = getPos(rest, "#", "<br>", commentMode);
|
||||
numpos = getNumPos(rest, goNumberMode);
|
||||
keywordpos = getKeywordPos("go", rest, goKeywordMode);
|
||||
if (Math.max(numpos[0], sfnuttpos[0], dfnuttpos[0], compos[0], comlinepos[0], comhashpos[0], keywordpos[0]) == -1) {break;}
|
||||
mypos = getMinPos(numpos, sfnuttpos, dfnuttpos, compos, comlinepos, comhashpos, keywordpos);
|
||||
if (mypos[0] == -1) {break;}
|
||||
if (mypos[0] > -1) {
|
||||
done += rest.substring(0, mypos[0]);
|
||||
done += mypos[2](rest.substring(mypos[0], mypos[1]));
|
||||
rest = rest.substr(mypos[1]);
|
||||
}
|
||||
}
|
||||
rest = done + rest;
|
||||
return "<span style=color:" + gocolor + ">" + rest + "</span>";
|
||||
}
|
||||
function goStringMode(txt) {
|
||||
return "<span style=color:" + gostringcolor + ">" + txt + "</span>";
|
||||
}
|
||||
function goNumberMode(txt) {
|
||||
return "<span style=color:" + gonumbercolor + ">" + txt + "</span>";
|
||||
}
|
||||
function goKeywordMode(txt) {
|
||||
return "<span style=color:" + gokeywordcolor + ">" + txt + "</span>";
|
||||
}
|
||||
function getKeywordPos(typ, txt, func) {
|
||||
var words, i, pos, rpos = -1, rpos2 = -1, patt;
|
||||
if (typ == "js") {
|
||||
words = ["abstract","arguments","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete",
|
||||
"do","double","else","enum","eval","event","export","extends","false","final","finally","float","for","function","goto","if","implements","import",
|
||||
"in","instanceof","int","interface","let","long","NaN","native","new","null","package","private","protected","public","return","short","static",
|
||||
"super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield"];
|
||||
} else if (typ == "java") {
|
||||
words = ["abstract","arguments","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete",
|
||||
"do","double","else","enum","eval","event","export","extends","false","final","finally","float","for","function","goto","if","implements","import",
|
||||
"in","instanceof","int","interface","let","long","NaN","native","new","null","package","private","protected","public","return","short","static",
|
||||
"super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield",
|
||||
"String"];
|
||||
} else if (typ == "php") {
|
||||
words = ["$GLOBALS","$_SERVER","$_REQUEST","$_POST","$_GET","$_FILES","$_ENV","$_COOKIE","$_SESSION",
|
||||
"__halt_compiler","abstract","and","array","as","break","callable","case","catch","class","clone","const","continue","declare","default",
|
||||
"die","do","echo","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","eval","exit","extends","final","for",
|
||||
"foreach","function","global","goto","if","implements","include","include_once","instanceof","insteadof","interface","isset","list","namespace","new",
|
||||
"or","print","private","protected","public","require","require_once","return","static","switch","throw","trait","try","unset","use","var","while","xor"];
|
||||
} else if (typ == "sql") {
|
||||
words = ["ADD","EXTERNAL","PROCEDURE","ALL","FETCH","PUBLIC","ALTER","FILE","RAISERROR","AND","FILLFACTOR","READ","ANY","READTEXT","AS","FOREIGN",
|
||||
"RECONFIGURE","ASC","FREETEXT","REFERENCES","AUTHORIZATION","FREETEXTTABLE","REPLICATION","BACKUP","FROM","RESTORE","BEGIN","FULL","RESTRICT","BETWEEN",
|
||||
"FUNCTION","RETURN","BREAK","GOTO","REVERT","BROWSE","GRANT","REVOKE","BULK","GROUP","RIGHT","BY","HAVING","ROLLBACK","CASCADE","HOLDLOCK","ROWCOUNT",
|
||||
"CASE","IDENTITY","ROWGUIDCOL","CHECK","IDENTITY_INSERT","RULE","CHECKPOINT","IDENTITYCOL","SAVE","CLOSE","IF","SCHEMA","CLUSTERED","IN",
|
||||
"SECURITYAUDIT","COALESCE","INDEX","SELECT","COLLATE","INNER","SEMANTICKEYPHRASETABLE","COLUMN","INSERT","SEMANTICSIMILARITYDETAILSTABLE","COMMIT",
|
||||
"INTERSECT","SEMANTICSIMILARITYTABLE","COMPUTE","INTO","SESSION_USER","CONSTRAINT","IS","SET","CONTAINS","JOIN","SETUSER","CONTAINSTABLE","KEY",
|
||||
"SHUTDOWN","CONTINUE","KILL","SOME","CONVERT","LEFT","STATISTICS","CREATE","LIKE","SYSTEM_USER","CROSS","LINENO","TABLE","CURRENT","LOAD","TABLESAMPLE",
|
||||
"CURRENT_DATE","MERGE","TEXTSIZE","CURRENT_TIME","NATIONAL","THEN","CURRENT_TIMESTAMP","NOCHECK","TO","CURRENT_USER","NONCLUSTERED","TOP","CURSOR",
|
||||
"NOT","TRAN","DATABASE","NULL","TRANSACTION","DBCC","NULLIF","TRIGGER","DEALLOCATE","OF","TRUNCATE","DECLARE","OFF","TRY_CONVERT","DEFAULT","OFFSETS",
|
||||
"TSEQUAL","DELETE","ON","UNION","DENY","OPEN","UNIQUE","DESC","OPENDATASOURCE","UNPIVOT","DISK","OPENQUERY","UPDATE","DISTINCT","OPENROWSET",
|
||||
"UPDATETEXT","DISTRIBUTED","OPENXML","USE","DOUBLE","OPTION","USER","DROP","OR","VALUES","DUMP","ORDER","VARYING","ELSE","OUTER","VIEW","END",
|
||||
"OVER","WAITFOR","ERRLVL","PERCENT","WHEN","ESCAPE","PIVOT","WHERE","EXCEPT","PLAN","WHILE","EXEC","PRECISION","WITH","EXECUTE","PRIMARY",
|
||||
"WITHIN GROUP","EXISTS","PRINT","WRITETEXT","EXIT","PROC","LIMIT","MODIFY","COUNT","REPLACE"];
|
||||
} else if (typ == "python") {
|
||||
words = ["as", "assert", "break", "class", "continue", "def", "del", "elif", "else", "except", "finally", "for", "from", "global", "if", "import",
|
||||
"lambda", "pass", "raise", "return", "try", "while", "with", "yield", "in", "abs", "all", "any", "bin", "bool", "bytearray", "callable", "chr",
|
||||
"classmethod", "compile", "complex", "delattr", "dict", "dir", "divmod", "enumerate", "eval", "filter", "float", "format", "frozenset", "getattr",
|
||||
"globals", "hasattr", "hash", "help", "hex", "id", "input", "int", "isinstance", "issubclass", "iter", "len", "list", "locals", "map", "max",
|
||||
"memoryview", "min", "next", "object", "oct", "open", "ord", "pow", "print", "property", "range", "repr", "reversed", "round", "set", "setattr", "slice",
|
||||
"sorted", "staticmethod", "str", "sum", "super", "tuple", "type", "vars", "zip", "__import__", "NotImplemented", "Ellipsis", "__debug__"];
|
||||
} else if (typ == "bash") {
|
||||
words = ["sudo", "git", "hugo", "cd", "rm", "mkdir", "delete", "find", "ssh", "scp", "nano", "server", "root", "nginx", "rsync", "bash",
|
||||
"chmod", "echo", "print", "apt-get", "ls", "which", "touch", "python", "go", "php", "chown", "du", "dhclient", "journalctl", "systemctl", "service", "tar",
|
||||
"zip", "unzip", "cp", "mv", "curl", "wget", "dpkg", "pip", "install", "pip3", "mysql"];
|
||||
} else if (typ == "go") {
|
||||
words = ["package", "import", "var", "const", "defer", "go", "goto", "return", "break", "continue", "fallthrough", "if", "else", "switch", "select", "case",
|
||||
"default", "for", "range", "chan", "map", "bool", "string", "error", "int", "int8", "int16", "int32", "int64", "rune", "byte", "uint", "uint8",
|
||||
"uint16", "uint32", "uint64", "uintptr", "float32", "float64", "complex64", "complex128", "append", "cap", "close", "complex", "copy", "delete",
|
||||
"imag", "len", "make", "new", "panic", "print", "println", "real", "recover", "true", "false", "nil", "iota","func"];
|
||||
}
|
||||
for (i = 0; i < words.length; i++) {
|
||||
if (typ == "php" || typ == "sql") {
|
||||
pos = txt.toLowerCase().indexOf(words[i].toLowerCase());
|
||||
} else {
|
||||
pos = txt.indexOf(words[i]);
|
||||
}
|
||||
if (pos > -1) {
|
||||
patt = /\W/g;
|
||||
if (txt.substr(pos + words[i].length,1).match(patt) && txt.substr(pos - 1,1).match(patt)) {
|
||||
if (pos > -1 && (rpos == -1 || pos < rpos)) {
|
||||
rpos = pos;
|
||||
rpos2 = rpos + words[i].length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return [rpos, rpos2, func];
|
||||
}
|
||||
function getPos(txt, start, end, func) {
|
||||
var s, e;
|
||||
s = txt.search(start);
|
||||
e = txt.indexOf(end, s + (end.length));
|
||||
if (e == -1) {e = txt.length;}
|
||||
return [s, e + (end.length), func];
|
||||
}
|
||||
function getNumPos(txt, func) {
|
||||
var arr = ["<br>", " ", ";", "(", "+", ")", "[", "]", ",", "&", ":", "{", "}", "/" ,"-", "*", "|", "%", "="], i, j, c, startpos = 0, endpos, word;
|
||||
for (i = 0; i < txt.length; i++) {
|
||||
for (j = 0; j < arr.length; j++) {
|
||||
c = txt.substr(i, arr[j].length);
|
||||
if (c == arr[j]) {
|
||||
if (c == "-" && (txt.substr(i - 1, 1) == "e" || txt.substr(i - 1, 1) == "E")) {
|
||||
continue;
|
||||
}
|
||||
endpos = i;
|
||||
if (startpos < endpos) {
|
||||
word = txt.substring(startpos, endpos);
|
||||
if (!isNaN(word)) {return [startpos, endpos, func];}
|
||||
}
|
||||
i += arr[j].length;
|
||||
startpos = i;
|
||||
i -= 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return [-1, -1, func];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user