Problems in changing countdown - javascript

I want to change time to 28th May, but I am not getting how to do that.
! function(a) {
"use strict";
"function" == typeof define && define.amd ? define(["jquery"], a) : a(jQuery)
}(function(a) {
"use strict";
function b(a) {
if (a instanceof Date) return a;
if (String(a).match(g)) return String(a).match(/^[0-9]*$/) && (a = Number(a)), String(a).match(/\-/) && (a = String(a).replace(/\-/g, "/")), new Date(a);
throw new Error("Couldn't cast `" + a + "` to a date object.")
}
function c(a) {
var b = a.toString().replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
return new RegExp(b)
}
function d(a) {
return function(b) {
var d = b.match(/%(-|!)?[A-Z]{1}(:[^;]+;)?/gi);
if (d)
for (var f = 0, g = d.length; g > f; ++f) {
var h = d[f].match(/%(-|!)?([a-zA-Z]{1})(:[^;]+;)?/),
j = c(h[0]),
k = h[1] || "",
l = h[3] || "",
m = null;
h = h[2], i.hasOwnProperty(h) && (m = i[h], m = Number(a[m])), null !== m && ("!" === k && (m = e(l, m)), "" === k && 10 > m && (m = "0" + m.toString()), b = b.replace(j, m.toString()))
}
return b = b.replace(/%%/, "%")
}
}
function e(a, b) {
var c = "s",
d = "";
return a && (a = a.replace(/(:|;|\s)/gi, "").split(/\,/), 1 === a.length ? c = a[0] : (d = a[0], c = a[1])), 1 === Math.abs(b) ? d : c
}
var f = [],
g = [],
h = {
precision: 100,
elapse: !1
};
g.push(/^[0-9]*$/.source), g.push(/([0-9]{1,2}\/){2}[0-9]{4}( [0-9]{1,2}(:[0-9]{2}){2})?/.source), g.push(/[0-9]{4}([\/\-][0-9]{1,2}){2}( [0-9]{1,2}(:[0-9]{2}){2})?/.source), g = new RegExp(g.join("|"));
var i = {
Y: "years",
m: "months",
n: "daysToMonth",
w: "weeks",
d: "daysToWeek",
D: "totalDays",
H: "hours",
M: "minutes",
S: "seconds"
},
j = function(b, c, d) {
this.el = b, this.$el = a(b), this.interval = null, this.offset = {}, this.options = a.extend({}, h), this.instanceNumber = f.length, f.push(this), this.$el.data("countdown-instance", this.instanceNumber), d && ("function" == typeof d ? (this.$el.on("update.countdown", d), this.$el.on("stoped.countdown", d), this.$el.on("finish.countdown", d)) : this.options = a.extend({}, h, d)), this.setFinalDate(c), this.start()
};
a.extend(j.prototype, {
start: function() {
null !== this.interval && clearInterval(this.interval);
var a = this;
this.update(), this.interval = setInterval(function() {
a.update.call(a)
}, this.options.precision)
},
stop: function() {
clearInterval(this.interval), this.interval = null, this.dispatchEvent("stoped")
},
toggle: function() {
this.interval ? this.stop() : this.start()
},
pause: function() {
this.stop()
},
resume: function() {
this.start()
},
remove: function() {
this.stop.call(this), f[this.instanceNumber] = null, delete this.$el.data().countdownInstance
},
setFinalDate: function(a) {
this.finalDate = b(a)
},
update: function() {
if (0 === this.$el.closest("html").length) return void this.remove();
var b, c = void 0 !== a._data(this.el, "events"),
d = new Date;
b = this.finalDate.getTime() - d.getTime(), b = Math.ceil(b / 1e3), b = !this.options.elapse && 0 > b ? 0 : Math.abs(b), this.totalSecsLeft !== b && c && (this.totalSecsLeft = b, this.elapsed = d >= this.finalDate, this.offset = {
seconds: this.totalSecsLeft % 60,
minutes: Math.floor(this.totalSecsLeft / 60) % 60,
hours: Math.floor(this.totalSecsLeft / 60 / 60) % 24,
days: Math.floor(this.totalSecsLeft / 60 / 60 / 24) % 7,
daysToWeek: Math.floor(this.totalSecsLeft / 60 / 60 / 24) % 7,
daysToMonth: Math.floor(this.totalSecsLeft / 60 / 60 / 24 % 30.4368),
totalDays: Math.floor(this.totalSecsLeft / 60 / 60 / 24),
weeks: Math.floor(this.totalSecsLeft / 60 / 60 / 24 / 7),
months: Math.floor(this.totalSecsLeft / 60 / 60 / 24 / 30.4368),
years: Math.abs(this.finalDate.getFullYear() - d.getFullYear())
}, this.options.elapse || 0 !== this.totalSecsLeft ? this.dispatchEvent("update") : (this.stop(), this.dispatchEvent("finish")))
},
dispatchEvent: function(b) {
var c = a.Event(b + ".countdown");
c.finalDate = this.finalDate, c.elapsed = this.elapsed, c.offset = a.extend({}, this.offset), c.strftime = d(this.offset), this.$el.trigger(c)
}
}), a.fn.countdown = function() {
var b = Array.prototype.slice.call(arguments, 0);
return this.each(function() {
var c = a(this).data("countdown-instance");
if (void 0 !== c) {
var d = f[c],
e = b[0];
j.prototype.hasOwnProperty(e) ? d[e].apply(d, b.slice(1)) : null === String(e).match(/^[$A-Z_][0-9A-Z_$]*$/i) ? (d.setFinalDate.call(d, e), d.start()) : a.error("Method %s does not exist on jQuery.countdown".replace(/\%s/gi, e))
} else new j(this, b[0], b[1])
})
}
});

Instead of posting some library's code, read the docs. It's all in there!
$('#myCountDown').countdown('2017/05/28', function(event) {
$(this).html(event.strftime('%w weeks %d days %H:%M:%S'));
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.countdown/2.2.0/jquery.countdown.min.js"></script>
<div id="myCountDown"></div>

Related

Stopping skew of the object while using camera.lookat() in three.js

I have made this short code to move a object randomly on the screen. I used camera.lookat(). But while using it I observed that when the model/object moves to the sides of the screen, in order to look at the camera it changes its shape a little. In a way one can say that it skews a little.
I wanted to used camera.lookat() without this skewing of the object. I have been trying for a while now but couldn't figure out a way to do it. Can anyone help me out here please. Here is my code:
EDIT
while running code snippet here you may find a error footer here. It's because of unavailability of tween.js cdn. Wait for some time after clicking on "run snippet" here and you will see a tower moving here and there.
My JS:
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0xff0000, .5);
document.body.appendChild(renderer.domElement);
var light1 = new THREE.AmbientLight(0xffffff);
light1.position.set(0, -70, 100).normalize();
scene.add(light1);
var light2 = new THREE.AmbientLight(0xffffff);
light2.position.set(0, 70, 100).normalize();
scene.add(light2);
camera.position.z = 20;
var loader = new THREE.GLTFLoader();
loader.crossOrigin = true;
loader.load('https://docs.mapbox.com/mapbox-gl-js/assets/34M_17/34M_17.gltf', function(gltf) {
cube = gltf.scene;
// gltf.scene.position.y -= 15;
// gltf.scene.position.x -= 24;
// gltf.scene.lookAt(camera.position);
gltf.scene.position.set(-40, 0, -3.75);
gltf.scene.scale.set(0.4, 0.4, 0.4);
// gltf.scene.rotation.y += 0.6;
// gltf.scene.rotation.z -= 0.3;
scene.add(gltf.scene);
renderer.render(scene, camera);
maketween();
});
//// Setup the animation loop.
function animate(time) {
requestAnimationFrame(animate);
TWEEN.update(time);
renderer.render(scene, camera);
}
requestAnimationFrame(animate);
function maketween() {
var randomX = Math.floor(Math.random() * 57) - 28;
var randomY = Math.floor(Math.random() * 23) - 10;
var tween = new TWEEN.Tween({
x: cube.position.x,
y: cube.position.y,
z: cube.position.z
}) // Create a new tween that modifies 'coords'.
.to({
x: randomX,
y: randomY,
z: 0
}, 1000) // Move to (300, 200) in 1 second.
.easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
.repeat(0)
.onUpdate(function(object) {
// console.log("tween",randomX,randomY,object.x);
if (object.x == randomX || object.x == 0) {
var randomX = Math.floor(Math.random() * 57) - 28;
var randomY = Math.floor(Math.random() * 23) - 10;
// console.log("*",randomX,randomY);
} else {
cube.position.x = object.x;
cube.position.y = object.y;
}
cube.lookAt(camera.position);
}).onComplete(() => {
// console.log("tween stopped");
maketween();
});
tween.chain(tween);
tween.start();
}
//BELOW THIS POINT IS TWEEN.JS (NOT MY CODE)
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.TWEEN = factory());
}(this, (function () { 'use strict';
var version = '18.4.2';
/**
* Tween.js - Licensed under the MIT license
* https://github.com/tweenjs/tween.js
* ----------------------------------------------
*
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.
* Thank you all, you're awesome!
*/
var _Group = function () {
this._tweens = {};
this._tweensAddedDuringUpdate = {};
};
_Group.prototype = {
getAll: function () {
return Object.keys(this._tweens).map(function (tweenId) {
return this._tweens[tweenId];
}.bind(this));
},
removeAll: function () {
this._tweens = {};
},
add: function (tween) {
this._tweens[tween.getId()] = tween;
this._tweensAddedDuringUpdate[tween.getId()] = tween;
},
remove: function (tween) {
delete this._tweens[tween.getId()];
delete this._tweensAddedDuringUpdate[tween.getId()];
},
update: function (time, preserve) {
var tweenIds = Object.keys(this._tweens);
if (tweenIds.length === 0) {
return false;
}
time = time !== undefined ? time : TWEEN.now();
// Tweens are updated in "batches". If you add a new tween during an
// update, then the new tween will be updated in the next batch.
// If you remove a tween during an update, it may or may not be updated.
// However, if the removed tween was added during the current batch,
// then it will not be updated.
while (tweenIds.length > 0) {
this._tweensAddedDuringUpdate = {};
for (var i = 0; i < tweenIds.length; i++) {
var tween = this._tweens[tweenIds[i]];
if (tween && tween.update(time) === false) {
tween._isPlaying = false;
if (!preserve) {
delete this._tweens[tweenIds[i]];
}
}
}
tweenIds = Object.keys(this._tweensAddedDuringUpdate);
}
return true;
}
};
var TWEEN = new _Group();
TWEEN.Group = _Group;
TWEEN._nextId = 0;
TWEEN.nextId = function () {
return TWEEN._nextId++;
};
// Include a performance.now polyfill.
// In node.js, use process.hrtime.
if (typeof (self) === 'undefined' && typeof (process) !== 'undefined' && process.hrtime) {
TWEEN.now = function () {
var time = process.hrtime();
// Convert [seconds, nanoseconds] to milliseconds.
return time[0] * 1000 + time[1] / 1000000;
};
}
// In a browser, use self.performance.now if it is available.
else if (typeof (self) !== 'undefined' &&
self.performance !== undefined &&
self.performance.now !== undefined) {
// This must be bound, because directly assigning this function
// leads to an invocation exception in Chrome.
TWEEN.now = self.performance.now.bind(self.performance);
}
// Use Date.now if it is available.
else if (Date.now !== undefined) {
TWEEN.now = Date.now;
}
// Otherwise, use 'new Date().getTime()'.
else {
TWEEN.now = function () {
return new Date().getTime();
};
}
TWEEN.Tween = function (object, group) {
this._isPaused = false;
this._pauseStart = null;
this._object = object;
this._valuesStart = {};
this._valuesEnd = {};
this._valuesStartRepeat = {};
this._duration = 1000;
this._repeat = 0;
this._repeatDelayTime = undefined;
this._yoyo = false;
this._isPlaying = false;
this._reversed = false;
this._delayTime = 0;
this._startTime = null;
this._easingFunction = TWEEN.Easing.Linear.None;
this._interpolationFunction = TWEEN.Interpolation.Linear;
this._chainedTweens = [];
this._onStartCallback = null;
this._onStartCallbackFired = false;
this._onUpdateCallback = null;
this._onRepeatCallback = null;
this._onCompleteCallback = null;
this._onStopCallback = null;
this._group = group || TWEEN;
this._id = TWEEN.nextId();
};
TWEEN.Tween.prototype = {
getId: function () {
return this._id;
},
isPlaying: function () {
return this._isPlaying;
},
isPaused: function () {
return this._isPaused;
},
to: function (properties, duration) {
this._valuesEnd = Object.create(properties);
if (duration !== undefined) {
this._duration = duration;
}
return this;
},
duration: function duration(d) {
this._duration = d;
return this;
},
start: function (time) {
this._group.add(this);
this._isPlaying = true;
this._isPaused = false;
this._onStartCallbackFired = false;
this._startTime = time !== undefined ? typeof time === 'string' ? TWEEN.now() + parseFloat(time) : time : TWEEN.now();
this._startTime += this._delayTime;
for (var property in this._valuesEnd) {
// Check if an Array was provided as property value
if (this._valuesEnd[property] instanceof Array) {
if (this._valuesEnd[property].length === 0) {
continue;
}
// Create a local copy of the Array with the start value at the front
this._valuesEnd[property] = [this._object[property]].concat(this._valuesEnd[property]);
}
// If `to()` specifies a property that doesn't exist in the source object,
// we should not set that property in the object
if (this._object[property] === undefined) {
continue;
}
// Save the starting value, but only once.
if (typeof(this._valuesStart[property]) === 'undefined') {
this._valuesStart[property] = this._object[property];
}
if ((this._valuesStart[property] instanceof Array) === false) {
this._valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings
}
this._valuesStartRepeat[property] = this._valuesStart[property] || 0;
}
return this;
},
stop: function () {
if (!this._isPlaying) {
return this;
}
this._group.remove(this);
this._isPlaying = false;
this._isPaused = false;
if (this._onStopCallback !== null) {
this._onStopCallback(this._object);
}
this.stopChainedTweens();
return this;
},
end: function () {
this.update(Infinity);
return this;
},
pause: function(time) {
if (this._isPaused || !this._isPlaying) {
return this;
}
this._isPaused = true;
this._pauseStart = time === undefined ? TWEEN.now() : time;
this._group.remove(this);
return this;
},
resume: function(time) {
if (!this._isPaused || !this._isPlaying) {
return this;
}
this._isPaused = false;
this._startTime += (time === undefined ? TWEEN.now() : time)
- this._pauseStart;
this._pauseStart = 0;
this._group.add(this);
return this;
},
stopChainedTweens: function () {
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
this._chainedTweens[i].stop();
}
},
group: function (group) {
this._group = group;
return this;
},
delay: function (amount) {
this._delayTime = amount;
return this;
},
repeat: function (times) {
this._repeat = times;
return this;
},
repeatDelay: function (amount) {
this._repeatDelayTime = amount;
return this;
},
yoyo: function (yoyo) {
this._yoyo = yoyo;
return this;
},
easing: function (easingFunction) {
this._easingFunction = easingFunction;
return this;
},
interpolation: function (interpolationFunction) {
this._interpolationFunction = interpolationFunction;
return this;
},
chain: function () {
this._chainedTweens = arguments;
return this;
},
onStart: function (callback) {
this._onStartCallback = callback;
return this;
},
onUpdate: function (callback) {
this._onUpdateCallback = callback;
return this;
},
onRepeat: function onRepeat(callback) {
this._onRepeatCallback = callback;
return this;
},
onComplete: function (callback) {
this._onCompleteCallback = callback;
return this;
},
onStop: function (callback) {
this._onStopCallback = callback;
return this;
},
update: function (time) {
var property;
var elapsed;
var value;
if (time < this._startTime) {
return true;
}
if (this._onStartCallbackFired === false) {
if (this._onStartCallback !== null) {
this._onStartCallback(this._object);
}
this._onStartCallbackFired = true;
}
elapsed = (time - this._startTime) / this._duration;
elapsed = (this._duration === 0 || elapsed > 1) ? 1 : elapsed;
value = this._easingFunction(elapsed);
for (property in this._valuesEnd) {
// Don't update properties that do not exist in the source object
if (this._valuesStart[property] === undefined) {
continue;
}
var start = this._valuesStart[property] || 0;
var end = this._valuesEnd[property];
if (end instanceof Array) {
this._object[property] = this._interpolationFunction(end, value);
} else {
// Parses relative end values with start as base (e.g.: +10, -3)
if (typeof (end) === 'string') {
if (end.charAt(0) === '+' || end.charAt(0) === '-') {
end = start + parseFloat(end);
} else {
end = parseFloat(end);
}
}
// Protect against non numeric properties.
if (typeof (end) === 'number') {
this._object[property] = start + (end - start) * value;
}
}
}
if (this._onUpdateCallback !== null) {
this._onUpdateCallback(this._object, elapsed);
}
if (elapsed === 1) {
if (this._repeat > 0) {
if (isFinite(this._repeat)) {
this._repeat--;
}
// Reassign starting values, restart by making startTime = now
for (property in this._valuesStartRepeat) {
if (typeof (this._valuesEnd[property]) === 'string') {
this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]);
}
if (this._yoyo) {
var tmp = this._valuesStartRepeat[property];
this._valuesStartRepeat[property] = this._valuesEnd[property];
this._valuesEnd[property] = tmp;
}
this._valuesStart[property] = this._valuesStartRepeat[property];
}
if (this._yoyo) {
this._reversed = !this._reversed;
}
if (this._repeatDelayTime !== undefined) {
this._startTime = time + this._repeatDelayTime;
} else {
this._startTime = time + this._delayTime;
}
if (this._onRepeatCallback !== null) {
this._onRepeatCallback(this._object);
}
return true;
} else {
if (this._onCompleteCallback !== null) {
this._onCompleteCallback(this._object);
}
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
// Make the chained tweens start exactly at the time they should,
// even if the `update()` method was called way past the duration of the tween
this._chainedTweens[i].start(this._startTime + this._duration);
}
return false;
}
}
return true;
}
};
TWEEN.Easing = {
Linear: {
None: function (k) {
return k;
}
},
Quadratic: {
In: function (k) {
return k * k;
},
Out: function (k) {
return k * (2 - k);
},
InOut: function (k) {
if ((k *= 2) < 1) {
return 0.5 * k * k;
}
return - 0.5 * (--k * (k - 2) - 1);
}
},
Cubic: {
In: function (k) {
return k * k * k;
},
Out: function (k) {
return --k * k * k + 1;
},
InOut: function (k) {
if ((k *= 2) < 1) {
return 0.5 * k * k * k;
}
return 0.5 * ((k -= 2) * k * k + 2);
}
},
Quartic: {
In: function (k) {
return k * k * k * k;
},
Out: function (k) {
return 1 - (--k * k * k * k);
},
InOut: function (k) {
if ((k *= 2) < 1) {
return 0.5 * k * k * k * k;
}
return - 0.5 * ((k -= 2) * k * k * k - 2);
}
},
Quintic: {
In: function (k) {
return k * k * k * k * k;
},
Out: function (k) {
return --k * k * k * k * k + 1;
},
InOut: function (k) {
if ((k *= 2) < 1) {
return 0.5 * k * k * k * k * k;
}
return 0.5 * ((k -= 2) * k * k * k * k + 2);
}
},
Sinusoidal: {
In: function (k) {
return 1 - Math.cos(k * Math.PI / 2);
},
Out: function (k) {
return Math.sin(k * Math.PI / 2);
},
InOut: function (k) {
return 0.5 * (1 - Math.cos(Math.PI * k));
}
},
Exponential: {
In: function (k) {
return k === 0 ? 0 : Math.pow(1024, k - 1);
},
Out: function (k) {
return k === 1 ? 1 : 1 - Math.pow(2, - 10 * k);
},
InOut: function (k) {
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
if ((k *= 2) < 1) {
return 0.5 * Math.pow(1024, k - 1);
}
return 0.5 * (- Math.pow(2, - 10 * (k - 1)) + 2);
}
},
Circular: {
In: function (k) {
return 1 - Math.sqrt(1 - k * k);
},
Out: function (k) {
return Math.sqrt(1 - (--k * k));
},
InOut: function (k) {
if ((k *= 2) < 1) {
return - 0.5 * (Math.sqrt(1 - k * k) - 1);
}
return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
}
},
Elastic: {
In: function (k) {
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
return -Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI);
},
Out: function (k) {
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
return Math.pow(2, -10 * k) * Math.sin((k - 0.1) * 5 * Math.PI) + 1;
},
InOut: function (k) {
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
k *= 2;
if (k < 1) {
return -0.5 * Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI);
}
return 0.5 * Math.pow(2, -10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI) + 1;
}
},
Back: {
In: function (k) {
var s = 1.70158;
return k * k * ((s + 1) * k - s);
},
Out: function (k) {
var s = 1.70158;
return --k * k * ((s + 1) * k + s) + 1;
},
InOut: function (k) {
var s = 1.70158 * 1.525;
if ((k *= 2) < 1) {
return 0.5 * (k * k * ((s + 1) * k - s));
}
return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
}
},
Bounce: {
In: function (k) {
return 1 - TWEEN.Easing.Bounce.Out(1 - k);
},
Out: function (k) {
if (k < (1 / 2.75)) {
return 7.5625 * k * k;
} else if (k < (2 / 2.75)) {
return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75;
} else if (k < (2.5 / 2.75)) {
return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375;
} else {
return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375;
}
},
InOut: function (k) {
if (k < 0.5) {
return TWEEN.Easing.Bounce.In(k * 2) * 0.5;
}
return TWEEN.Easing.Bounce.Out(k * 2 - 1) * 0.5 + 0.5;
}
}
};
TWEEN.Interpolation = {
Linear: function (v, k) {
var m = v.length - 1;
var f = m * k;
var i = Math.floor(f);
var fn = TWEEN.Interpolation.Utils.Linear;
if (k < 0) {
return fn(v[0], v[1], f);
}
if (k > 1) {
return fn(v[m], v[m - 1], m - f);
}
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i);
},
Bezier: function (v, k) {
var b = 0;
var n = v.length - 1;
var pw = Math.pow;
var bn = TWEEN.Interpolation.Utils.Bernstein;
for (var i = 0; i <= n; i++) {
b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i);
}
return b;
},
CatmullRom: function (v, k) {
var m = v.length - 1;
var f = m * k;
var i = Math.floor(f);
var fn = TWEEN.Interpolation.Utils.CatmullRom;
if (v[0] === v[m]) {
if (k < 0) {
i = Math.floor(f = m * (1 + k));
}
return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i);
} else {
if (k < 0) {
return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]);
}
if (k > 1) {
return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]);
}
return fn(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i);
}
},
Utils: {
Linear: function (p0, p1, t) {
return (p1 - p0) * t + p0;
},
Bernstein: function (n, i) {
var fc = TWEEN.Interpolation.Utils.Factorial;
return fc(n) / fc(i) / fc(n - i);
},
Factorial: (function () {
var a = [1];
return function (n) {
var s = 1;
if (a[n]) {
return a[n];
}
for (var i = n; i > 1; i--) {
s *= i;
}
a[n] = s;
return s;
};
})(),
CatmullRom: function (p0, p1, p2, p3, t) {
var v0 = (p2 - p0) * 0.5;
var v1 = (p3 - p1) * 0.5;
var t2 = t * t;
var t3 = t * t2;
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (- 3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
}
}
};
TWEEN.version = version;
return TWEEN;
})));
MY HTML:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Locate the user</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three#0.115/build/three.js"></script>
<script src="https://cdn.rawgit.com/mrdoob/three.js/master/examples/js/loaders/GLTFLoader.js"></script>
<script src="https://cdn.tutorialjinni.com/tween.js/18.5.0/Tween.js"></script>
<style>
body {
margin: 0;
}
canvas {
display: block;
}
</style>
</head>
<body>
<script src="js/capture.js"></script>
</body>
</html>
The issue is the field of view is wide.
Similar to the way a wide angle lens distorts
The code had a 75 degree field of view (75 vertically)
Here's a 25 degree field of view. Had to move to the camera back.
var scene = new THREE.Scene();
var fieldOfView = 25;
var camera = new THREE.PerspectiveCamera(fieldOfView, window.innerWidth / window.innerHeight, 0.1, 1000);
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0xff0000, .5);
document.body.appendChild(renderer.domElement);
var light1 = new THREE.AmbientLight(0xffffff);
light1.position.set(0, -70, 100).normalize();
scene.add(light1);
var light2 = new THREE.AmbientLight(0xffffff);
light2.position.set(0, 70, 100).normalize();
scene.add(light2);
camera.position.z = 80;
var loader = new THREE.GLTFLoader();
loader.crossOrigin = true;
loader.load('https://docs.mapbox.com/mapbox-gl-js/assets/34M_17/34M_17.gltf', function(gltf) {
cube = gltf.scene;
// gltf.scene.position.y -= 15;
// gltf.scene.position.x -= 24;
// gltf.scene.lookAt(camera.position);
gltf.scene.position.set(-40, 0, -3.75);
gltf.scene.scale.set(0.4, 0.4, 0.4);
// gltf.scene.rotation.y += 0.6;
// gltf.scene.rotation.z -= 0.3;
scene.add(gltf.scene);
renderer.render(scene, camera);
maketween();
});
//// Setup the animation loop.
function animate(time) {
requestAnimationFrame(animate);
TWEEN.update(time);
renderer.render(scene, camera);
}
requestAnimationFrame(animate);
function maketween() {
var randomX = Math.floor(Math.random() * 40) - 20;
var randomY = Math.floor(Math.random() * 20) - 10;
var tween = new TWEEN.Tween({
x: cube.position.x,
y: cube.position.y,
z: cube.position.z
}) // Create a new tween that modifies 'coords'.
.to({
x: randomX,
y: randomY,
z: 0
}, 1000) // Move to (300, 200) in 1 second.
.easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
.repeat(0)
.onUpdate(function(object) {
// console.log("tween",randomX,randomY,object.x);
if (object.x == randomX || object.x == 0) {
var randomX = Math.floor(Math.random() * 57) - 28;
var randomY = Math.floor(Math.random() * 23) - 10;
// console.log("*",randomX,randomY);
} else {
cube.position.x = object.x;
cube.position.y = object.y;
}
cube.lookAt(camera.position);
}).onComplete(() => {
// console.log("tween stopped");
maketween();
});
tween.chain(tween);
tween.start();
}
//BELOW THIS POINT IS TWEEN.JS (NOT MY CODE)
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.TWEEN = factory());
}(this, (function () { 'use strict';
var version = '18.4.2';
/**
* Tween.js - Licensed under the MIT license
* https://github.com/tweenjs/tween.js
* ----------------------------------------------
*
* See https://github.com/tweenjs/tween.js/graphs/contributors for the full list of contributors.
* Thank you all, you're awesome!
*/
var _Group = function () {
this._tweens = {};
this._tweensAddedDuringUpdate = {};
};
_Group.prototype = {
getAll: function () {
return Object.keys(this._tweens).map(function (tweenId) {
return this._tweens[tweenId];
}.bind(this));
},
removeAll: function () {
this._tweens = {};
},
add: function (tween) {
this._tweens[tween.getId()] = tween;
this._tweensAddedDuringUpdate[tween.getId()] = tween;
},
remove: function (tween) {
delete this._tweens[tween.getId()];
delete this._tweensAddedDuringUpdate[tween.getId()];
},
update: function (time, preserve) {
var tweenIds = Object.keys(this._tweens);
if (tweenIds.length === 0) {
return false;
}
time = time !== undefined ? time : TWEEN.now();
// Tweens are updated in "batches". If you add a new tween during an
// update, then the new tween will be updated in the next batch.
// If you remove a tween during an update, it may or may not be updated.
// However, if the removed tween was added during the current batch,
// then it will not be updated.
while (tweenIds.length > 0) {
this._tweensAddedDuringUpdate = {};
for (var i = 0; i < tweenIds.length; i++) {
var tween = this._tweens[tweenIds[i]];
if (tween && tween.update(time) === false) {
tween._isPlaying = false;
if (!preserve) {
delete this._tweens[tweenIds[i]];
}
}
}
tweenIds = Object.keys(this._tweensAddedDuringUpdate);
}
return true;
}
};
var TWEEN = new _Group();
TWEEN.Group = _Group;
TWEEN._nextId = 0;
TWEEN.nextId = function () {
return TWEEN._nextId++;
};
// Include a performance.now polyfill.
// In node.js, use process.hrtime.
if (typeof (self) === 'undefined' && typeof (process) !== 'undefined' && process.hrtime) {
TWEEN.now = function () {
var time = process.hrtime();
// Convert [seconds, nanoseconds] to milliseconds.
return time[0] * 1000 + time[1] / 1000000;
};
}
// In a browser, use self.performance.now if it is available.
else if (typeof (self) !== 'undefined' &&
self.performance !== undefined &&
self.performance.now !== undefined) {
// This must be bound, because directly assigning this function
// leads to an invocation exception in Chrome.
TWEEN.now = self.performance.now.bind(self.performance);
}
// Use Date.now if it is available.
else if (Date.now !== undefined) {
TWEEN.now = Date.now;
}
// Otherwise, use 'new Date().getTime()'.
else {
TWEEN.now = function () {
return new Date().getTime();
};
}
TWEEN.Tween = function (object, group) {
this._isPaused = false;
this._pauseStart = null;
this._object = object;
this._valuesStart = {};
this._valuesEnd = {};
this._valuesStartRepeat = {};
this._duration = 1000;
this._repeat = 0;
this._repeatDelayTime = undefined;
this._yoyo = false;
this._isPlaying = false;
this._reversed = false;
this._delayTime = 0;
this._startTime = null;
this._easingFunction = TWEEN.Easing.Linear.None;
this._interpolationFunction = TWEEN.Interpolation.Linear;
this._chainedTweens = [];
this._onStartCallback = null;
this._onStartCallbackFired = false;
this._onUpdateCallback = null;
this._onRepeatCallback = null;
this._onCompleteCallback = null;
this._onStopCallback = null;
this._group = group || TWEEN;
this._id = TWEEN.nextId();
};
TWEEN.Tween.prototype = {
getId: function () {
return this._id;
},
isPlaying: function () {
return this._isPlaying;
},
isPaused: function () {
return this._isPaused;
},
to: function (properties, duration) {
this._valuesEnd = Object.create(properties);
if (duration !== undefined) {
this._duration = duration;
}
return this;
},
duration: function duration(d) {
this._duration = d;
return this;
},
start: function (time) {
this._group.add(this);
this._isPlaying = true;
this._isPaused = false;
this._onStartCallbackFired = false;
this._startTime = time !== undefined ? typeof time === 'string' ? TWEEN.now() + parseFloat(time) : time : TWEEN.now();
this._startTime += this._delayTime;
for (var property in this._valuesEnd) {
// Check if an Array was provided as property value
if (this._valuesEnd[property] instanceof Array) {
if (this._valuesEnd[property].length === 0) {
continue;
}
// Create a local copy of the Array with the start value at the front
this._valuesEnd[property] = [this._object[property]].concat(this._valuesEnd[property]);
}
// If `to()` specifies a property that doesn't exist in the source object,
// we should not set that property in the object
if (this._object[property] === undefined) {
continue;
}
// Save the starting value, but only once.
if (typeof(this._valuesStart[property]) === 'undefined') {
this._valuesStart[property] = this._object[property];
}
if ((this._valuesStart[property] instanceof Array) === false) {
this._valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings
}
this._valuesStartRepeat[property] = this._valuesStart[property] || 0;
}
return this;
},
stop: function () {
if (!this._isPlaying) {
return this;
}
this._group.remove(this);
this._isPlaying = false;
this._isPaused = false;
if (this._onStopCallback !== null) {
this._onStopCallback(this._object);
}
this.stopChainedTweens();
return this;
},
end: function () {
this.update(Infinity);
return this;
},
pause: function(time) {
if (this._isPaused || !this._isPlaying) {
return this;
}
this._isPaused = true;
this._pauseStart = time === undefined ? TWEEN.now() : time;
this._group.remove(this);
return this;
},
resume: function(time) {
if (!this._isPaused || !this._isPlaying) {
return this;
}
this._isPaused = false;
this._startTime += (time === undefined ? TWEEN.now() : time)
- this._pauseStart;
this._pauseStart = 0;
this._group.add(this);
return this;
},
stopChainedTweens: function () {
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
this._chainedTweens[i].stop();
}
},
group: function (group) {
this._group = group;
return this;
},
delay: function (amount) {
this._delayTime = amount;
return this;
},
repeat: function (times) {
this._repeat = times;
return this;
},
repeatDelay: function (amount) {
this._repeatDelayTime = amount;
return this;
},
yoyo: function (yoyo) {
this._yoyo = yoyo;
return this;
},
easing: function (easingFunction) {
this._easingFunction = easingFunction;
return this;
},
interpolation: function (interpolationFunction) {
this._interpolationFunction = interpolationFunction;
return this;
},
chain: function () {
this._chainedTweens = arguments;
return this;
},
onStart: function (callback) {
this._onStartCallback = callback;
return this;
},
onUpdate: function (callback) {
this._onUpdateCallback = callback;
return this;
},
onRepeat: function onRepeat(callback) {
this._onRepeatCallback = callback;
return this;
},
onComplete: function (callback) {
this._onCompleteCallback = callback;
return this;
},
onStop: function (callback) {
this._onStopCallback = callback;
return this;
},
update: function (time) {
var property;
var elapsed;
var value;
if (time < this._startTime) {
return true;
}
if (this._onStartCallbackFired === false) {
if (this._onStartCallback !== null) {
this._onStartCallback(this._object);
}
this._onStartCallbackFired = true;
}
elapsed = (time - this._startTime) / this._duration;
elapsed = (this._duration === 0 || elapsed > 1) ? 1 : elapsed;
value = this._easingFunction(elapsed);
for (property in this._valuesEnd) {
// Don't update properties that do not exist in the source object
if (this._valuesStart[property] === undefined) {
continue;
}
var start = this._valuesStart[property] || 0;
var end = this._valuesEnd[property];
if (end instanceof Array) {
this._object[property] = this._interpolationFunction(end, value);
} else {
// Parses relative end values with start as base (e.g.: +10, -3)
if (typeof (end) === 'string') {
if (end.charAt(0) === '+' || end.charAt(0) === '-') {
end = start + parseFloat(end);
} else {
end = parseFloat(end);
}
}
// Protect against non numeric properties.
if (typeof (end) === 'number') {
this._object[property] = start + (end - start) * value;
}
}
}
if (this._onUpdateCallback !== null) {
this._onUpdateCallback(this._object, elapsed);
}
if (elapsed === 1) {
if (this._repeat > 0) {
if (isFinite(this._repeat)) {
this._repeat--;
}
// Reassign starting values, restart by making startTime = now
for (property in this._valuesStartRepeat) {
if (typeof (this._valuesEnd[property]) === 'string') {
this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property]);
}
if (this._yoyo) {
var tmp = this._valuesStartRepeat[property];
this._valuesStartRepeat[property] = this._valuesEnd[property];
this._valuesEnd[property] = tmp;
}
this._valuesStart[property] = this._valuesStartRepeat[property];
}
if (this._yoyo) {
this._reversed = !this._reversed;
}
if (this._repeatDelayTime !== undefined) {
this._startTime = time + this._repeatDelayTime;
} else {
this._startTime = time + this._delayTime;
}
if (this._onRepeatCallback !== null) {
this._onRepeatCallback(this._object);
}
return true;
} else {
if (this._onCompleteCallback !== null) {
this._onCompleteCallback(this._object);
}
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
// Make the chained tweens start exactly at the time they should,
// even if the `update()` method was called way past the duration of the tween
this._chainedTweens[i].start(this._startTime + this._duration);
}
return false;
}
}
return true;
}
};
TWEEN.Easing = {
Linear: {
None: function (k) {
return k;
}
},
Quadratic: {
In: function (k) {
return k * k;
},
Out: function (k) {
return k * (2 - k);
},
InOut: function (k) {
if ((k *= 2) < 1) {
return 0.5 * k * k;
}
return - 0.5 * (--k * (k - 2) - 1);
}
},
Cubic: {
In: function (k) {
return k * k * k;
},
Out: function (k) {
return --k * k * k + 1;
},
InOut: function (k) {
if ((k *= 2) < 1) {
return 0.5 * k * k * k;
}
return 0.5 * ((k -= 2) * k * k + 2);
}
},
Quartic: {
In: function (k) {
return k * k * k * k;
},
Out: function (k) {
return 1 - (--k * k * k * k);
},
InOut: function (k) {
if ((k *= 2) < 1) {
return 0.5 * k * k * k * k;
}
return - 0.5 * ((k -= 2) * k * k * k - 2);
}
},
Quintic: {
In: function (k) {
return k * k * k * k * k;
},
Out: function (k) {
return --k * k * k * k * k + 1;
},
InOut: function (k) {
if ((k *= 2) < 1) {
return 0.5 * k * k * k * k * k;
}
return 0.5 * ((k -= 2) * k * k * k * k + 2);
}
},
Sinusoidal: {
In: function (k) {
return 1 - Math.cos(k * Math.PI / 2);
},
Out: function (k) {
return Math.sin(k * Math.PI / 2);
},
InOut: function (k) {
return 0.5 * (1 - Math.cos(Math.PI * k));
}
},
Exponential: {
In: function (k) {
return k === 0 ? 0 : Math.pow(1024, k - 1);
},
Out: function (k) {
return k === 1 ? 1 : 1 - Math.pow(2, - 10 * k);
},
InOut: function (k) {
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
if ((k *= 2) < 1) {
return 0.5 * Math.pow(1024, k - 1);
}
return 0.5 * (- Math.pow(2, - 10 * (k - 1)) + 2);
}
},
Circular: {
In: function (k) {
return 1 - Math.sqrt(1 - k * k);
},
Out: function (k) {
return Math.sqrt(1 - (--k * k));
},
InOut: function (k) {
if ((k *= 2) < 1) {
return - 0.5 * (Math.sqrt(1 - k * k) - 1);
}
return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
}
},
Elastic: {
In: function (k) {
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
return -Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI);
},
Out: function (k) {
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
return Math.pow(2, -10 * k) * Math.sin((k - 0.1) * 5 * Math.PI) + 1;
},
InOut: function (k) {
if (k === 0) {
return 0;
}
if (k === 1) {
return 1;
}
k *= 2;
if (k < 1) {
return -0.5 * Math.pow(2, 10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI);
}
return 0.5 * Math.pow(2, -10 * (k - 1)) * Math.sin((k - 1.1) * 5 * Math.PI) + 1;
}
},
Back: {
In: function (k) {
var s = 1.70158;
return k * k * ((s + 1) * k - s);
},
Out: function (k) {
var s = 1.70158;
return --k * k * ((s + 1) * k + s) + 1;
},
InOut: function (k) {
var s = 1.70158 * 1.525;
if ((k *= 2) < 1) {
return 0.5 * (k * k * ((s + 1) * k - s));
}
return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
}
},
Bounce: {
In: function (k) {
return 1 - TWEEN.Easing.Bounce.Out(1 - k);
},
Out: function (k) {
if (k < (1 / 2.75)) {
return 7.5625 * k * k;
} else if (k < (2 / 2.75)) {
return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75;
} else if (k < (2.5 / 2.75)) {
return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375;
} else {
return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375;
}
},
InOut: function (k) {
if (k < 0.5) {
return TWEEN.Easing.Bounce.In(k * 2) * 0.5;
}
return TWEEN.Easing.Bounce.Out(k * 2 - 1) * 0.5 + 0.5;
}
}
};
TWEEN.Interpolation = {
Linear: function (v, k) {
var m = v.length - 1;
var f = m * k;
var i = Math.floor(f);
var fn = TWEEN.Interpolation.Utils.Linear;
if (k < 0) {
return fn(v[0], v[1], f);
}
if (k > 1) {
return fn(v[m], v[m - 1], m - f);
}
return fn(v[i], v[i + 1 > m ? m : i + 1], f - i);
},
Bezier: function (v, k) {
var b = 0;
var n = v.length - 1;
var pw = Math.pow;
var bn = TWEEN.Interpolation.Utils.Bernstein;
for (var i = 0; i <= n; i++) {
b += pw(1 - k, n - i) * pw(k, i) * v[i] * bn(n, i);
}
return b;
},
CatmullRom: function (v, k) {
var m = v.length - 1;
var f = m * k;
var i = Math.floor(f);
var fn = TWEEN.Interpolation.Utils.CatmullRom;
if (v[0] === v[m]) {
if (k < 0) {
i = Math.floor(f = m * (1 + k));
}
return fn(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i);
} else {
if (k < 0) {
return v[0] - (fn(v[0], v[0], v[1], v[1], -f) - v[0]);
}
if (k > 1) {
return v[m] - (fn(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]);
}
return fn(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i);
}
},
Utils: {
Linear: function (p0, p1, t) {
return (p1 - p0) * t + p0;
},
Bernstein: function (n, i) {
var fc = TWEEN.Interpolation.Utils.Factorial;
return fc(n) / fc(i) / fc(n - i);
},
Factorial: (function () {
var a = [1];
return function (n) {
var s = 1;
if (a[n]) {
return a[n];
}
for (var i = n; i > 1; i--) {
s *= i;
}
a[n] = s;
return s;
};
})(),
CatmullRom: function (p0, p1, p2, p3, t) {
var v0 = (p2 - p0) * 0.5;
var v1 = (p3 - p1) * 0.5;
var t2 = t * t;
var t3 = t * t2;
return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (- 3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
}
}
};
TWEEN.version = version;
return TWEEN;
})));
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Locate the user</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three#0.115/build/three.js"></script>
<script src="https://cdn.rawgit.com/mrdoob/three.js/master/examples/js/loaders/GLTFLoader.js"></script>
<script src="https://cdn.tutorialjinni.com/tween.js/18.5.0/Tween.js"></script>
<style>
body {
margin: 0;
}
canvas {
display: block;
}
</style>
</head>
<body>
<script src="js/capture.js"></script>
</body>
</html>

error in loader: JSON Parse error: Invalid number located in jquery

I am having trouble getting a page to load because the js loader is being effected by an error in query JSON parse.
This is the error in noted by Safari.
error in loader: JSON Parse error: Invalid number at line 2618: http://localhost:8888/iicode/jquery-1.11.2.min.js
here is a snippet of the code at line 2618, which has the asterix.
var vc = m.now(), wc = /\?/, xc = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
m.parseJSON = function(b) {
if (a.JSON && a.JSON.parse)
**return a.JSON.parse(b + "");**
var c, d = null, e = m.trim(b + "");
return e&&!m.trim(e.replace(xc, function(a, b, e, f) {
return c && b && (d = 0), 0 === d ? a : (c = e || b, d+=!f-!e, "")
})) ? Function("return " + e)() : m.error("Invalid JSON: " + b)
}, m.parseXML = function(b) {
var c, d;
if (!b || "string" != typeof b)
return null;
try {
a.DOMParser ? (d = new DOMParser, c = d.parseFromString(b, "text/xml")) : (c = new ActiveXObject("Microsoft.XMLDOM"), c.async = "false", c.loadXML(b))
} catch (e) {
c = void 0
}
return c && c.documentElement&&!c.getElementsByTagName("parsererror").length || m.error("Invalid XML: " + b), c
};
Here is the the first few lines of the js loader that the error is disabling, and I have no idea why. Safari highlighted the part that I asterix.
(function(window, jQuery) {
var namespace = 'de.kubikfoto', engine = null, args = {}, jsonFiles = {}, xmlFiles = {}, filesToLoad = 1, oldloadXML = null, oldloadJSON = null;
function logerror(errortext) {
if (typeof console === "object" && typeof console.error === "function") {
**console.error("error in loader: " + errortext)**
}
}
Any help would be appreciated my website is currently at a standstill.
As some have noted a potential problem with the Ajax, here is the call.
the ajax call I found was this : v[d](k[d]);
if (i = Mc(Ic, k, b, v)) {
v.readyState = 1, h && n.trigger("ajaxSend", [v, k]), k.async && k.timeout > 0 && (g = setTimeout(function() {
v.abort("timeout")
}, k.timeout));
try {
t = 1, i.send(r, x)
} catch (w) {
if (!(2 > t))
throw w;
x( - 1, w)
}
} else
x( - 1, "No Transport");
function x(a, b, c, d) {
var j, r, s, u, w, x = b;
2 !== t && (t = 2, g && clearTimeout(g), i = void 0, f = d || "", v.readyState = a > 0 ? 4 : 0, j = a >= 200 && 300 > a || 304 === a, c && (u = Oc(k, v, c)), u = Pc(k, u, v, j), j ? (k.ifModified && (w = v.getResponseHeader("Last-Modified"), w && (m.lastModified[e] = w), w = v.getResponseHeader("etag"), w && (m.etag[e] = w)), 204 === a || "HEAD" === k.type ? x = "nocontent" : 304 === a ? x = "notmodified" : (x = u.state, r = u.data, s = u.error, j=!s)) : (s = x, (a ||!x) && (x = "error", 0 > a && (a = 0))), v.status = a, v.statusText = (b || x) + "", j ? o.resolveWith(l, [r, x, v]) : o.rejectWith(l, [v, x, s]), v.statusCode(q), q = void 0, h && n.trigger(j ? "ajaxSuccess" : "ajaxError", [v, k, j ? r: s]), p.fireWith(l, [v, x]), h && (n.trigger("ajaxComplete", [v, k]), --m.active || m.event.trigger("ajaxStop")))
}

JavaScript Pi Spigot Algorithm not working

I have translated the following C++ code:
#include <iostream>
using namespace std;
#define NDIGITS 100
#define LEN (NDIGITS/4+1)*14
long a[LEN];
long b;
long c = LEN;
long d;
long e = 0;
long f = 10000;
long g;
long h = 0;
int main(void) {
cout<<b<<endl;
for(; (b=c-=14) > 0 ;){
for(; --b > 0 ;){
d *= b;
if( h == 0 )
d += 2000*f;
else
d += a[b]*f;
g=b+b-1;
a[b] = d % g;
d /= g;
}
h = printf("%ld",e+d/f);
d = e = d % f;
}
getchar();
return 0;
}
Into JavaScript:
function mod(n, m) {
return ((m % n) + n) % n;
} // mod function to fix javascript modulo bug
function calculate(NDIGITS){
var LEN = (NDIGITS / 4 + 1) * 14,
out = "",
a = [],
b = 0,
c = LEN,
d = 0,
e = 0,
f = 10000,
g = 0,
h = 0;
for( ; a.length != LEN; a.push(0));
for( ; (b=c-=14) > 0 ; ){
for(; --b > 0 ;){
d *= b;
if(h == 0)
d += 2000*f;
else
d += a[b]*f;
g=b+b-1;
a[b] = mod(d, g);
d /= g;
};
h = 4;
out += e + d / f;
d = e = mod(d, f);
};
return out;
};
calculate(100);
The problem is, the C++ (which is correct) output looks like this:
314159265358979323846264338327952884197169399375105820974944592307816406286208998628034825342117067
But the JavaScript (which is wrong) output looks like this:
3141.59265358979345928.3358757688158002.0385670499462603.1996016540431161.44919092773639662.2465149363658988.6127837844255865.38922090756173.61883094848226189.6324225085448150.3443440509899223.2179589088062808.1943642437717982.8973948575671840.86646781354151140.38694447211833938.5632867441137341.458720505086448.7384444661472807.14448220310268936.5521832735086764.9290682040381301.76585926509928223.4135991546457438.115065010927
Where did I mess up in my coding? Thanks for the help.
JavaScript does floating point division.
Arguments exchanged in modulo calculation function.
Here is code that produces the same result as the C++ code provided for the given sample (100) digits:
function mod(m, n) {
return ((m % n) + n) % n;
} // mod function to fix javascript modulo bug
function calculate(NDIGITS) {
var LEN = (NDIGITS / 4 + 1) * 14,
out = "",
a = [],
b = 0,
c = LEN,
d = 0,
e = 0,
f = 10000,
g = 0,
h = 0;
for (; a.length !== LEN; a.push(0));
for (; (b = c -= 14) > 0;) {
for (; --b > 0;) {
d *= b;
if (h === 0) {
d += 2000 * f;
} else {
d += a[b] * f;
}
g = b + b - 1;
a[b] = mod(d, g);
d = Math.floor(d / g);
}
h = Math.floor(e + d / f);
out += h;
h = h.length;
d = e = mod(d, f);
}
return out;
}
console.log(calculate(100));

How to repeat a function not continously but every 10 seconds?

I have this function which I use in Chrome Console. My question is how to edit the code so that this is executes every 10 seconds.
Thank you
var minValue = 1E-8,
maxLoss = 10000000000000,
aimedProfit = 10,
maxOps = 500000000000000,
endResult = 0,
ops = 0,
bet = function (a, b, c) {
var seed = window.document.getElementById('next_client_seed').value;
$.get("?op=double_your_btc&m=" + (b ? "lo" : "hi") + "&stake=" + a + "&multiplier=2&jackpot=0&client_seed=" + seed, function (d) {
d = d.split(":");
$("#balance").html(d[3]);
c(a, b, "w" === d[1])
})
}, martingale = function (a, b, c) {
c || a >= maxLoss && 0 !== maxLoss ? (b = !b, newValue = minValue) : newValue = 2 * a;
endResult = c ? endResult + a : endResult - a;
console.log((c ? "+" : "-") + a);
ops++;
(ops < maxOps || 0 === maxOps) && (endResult < aimedProfit || 0 === aimedProfit) ? bet(newValue, b, martingale) :
(console.log("Martingale finished in " + ops + " operations!"), console.log("Result: " + endResult))
};
martingale(minValue, !1, !1);
You can use either setTimeout or setInterval.
With setInterval your code will look as follows:
var myFunction = function () {
var minValue = 1E-8,
maxLoss = 10000000000000,
aimedProfit = 10,
maxOps = 500000000000000,
endResult = 0,
ops = 0,
bet = function (a, b, c) {
var seed = window.document.getElementById('next_client_seed').value;
$.get("?op=double_your_btc&m=" + (b ? "lo" : "hi") + "&stake=" + a + "&multiplier=2&jackpot=0&client_seed=" + seed, function (d) {
d = d.split(":");
$("#balance").html(d[3]);
c(a, b, "w" === d[1])
})
}, martingale = function (a, b, c) {
c || a >= maxLoss && 0 !== maxLoss ? (b = !b, newValue = minValue) : newValue = 2 * a;
endResult = c ? endResult + a : endResult - a;
console.log((c ? "+" : "-") + a);
ops++;
(ops < maxOps || 0 === maxOps) && (endResult < aimedProfit || 0 === aimedProfit) ? bet(newValue, b, martingale) :
(console.log("Martingale finished in " + ops + " operations!"), console.log("Result: " + endResult))
};
martingale(minValue, !1, !1);
};
setInterval(myFunction, 10000);
Try:
setInterval(funcion(){
martingale(minValue, !1, !1);
}, 10000);

Jquery Countdown... time is running out

I am trying to change the end of the countdown so it displays a countdown till the end date of 22nd of May 2014 on the below countdown, any idea how I do that?
Here is the webiste nordicitsourcing.com you will see it currently is counting down to a date I cannot even seem to find
Please help
Code here:
(function ($) {
function Countdown() {
this.regional = [];
this.regional[''] = {
labels: ['Years', 'Months', 'Weeks', 'Days', 'Hours', 'Minutes', 'Seconds'],
labels1: ['Year', 'Month', 'Week', 'Day', 'Hour', 'Minute', 'Second'],
compactLabels: ['y', 'm', 'w', 'd'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':',
isRTL: false
};
this._defaults = {
until: null,
since: null,
timezone: null,
serverSync: null,
format: 'dHMS',
layout: '',
compact: false,
significant: 0,
description: '',
expiryUrl: '',
expiryText: '',
alwaysExpire: false,
onExpiry: null,
onTick: null,
tickInterval: 1
};
$.extend(this._defaults, this.regional['']);
this._serverSyncs = [];
var c = (typeof Date.now == 'function' ? Date.now : function () {
return new Date().getTime()
});
var d = (window.performance && typeof window.performance.now == 'function');
function timerCallBack(a) {
var b = (a < 1e12 ? (d ? (performance.now() + performance.timing.navigationStart) : c()) : a || c());
if (b - f >= 1000) {
x._updateTargets();
f = b
}
e(timerCallBack)
}
var e = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || null;
var f = 0;
if (!e || $.noRequestAnimationFrame) {
$.noRequestAnimationFrame = null;
setInterval(function () {
x._updateTargets()
}, 980)
} else {
f = window.animationStartTime || window.webkitAnimationStartTime || window.mozAnimationStartTime || window.oAnimationStartTime || window.msAnimationStartTime || c();
e(timerCallBack)
}
}
var Y = 0;
var O = 1;
var W = 2;
var D = 3;
var H = 4;
var M = 5;
var S = 6;
$.extend(Countdown.prototype, {
markerClassName: 'hasCountdown',
propertyName: 'countdown',
_rtlClass: 'countdown_rtl',
_sectionClass: 'countdown_section',
_amountClass: 'countdown_amount',
_rowClass: 'countdown_row',
_holdingClass: 'countdown_holding',
_showClass: 'countdown_show',
_descrClass: 'countdown_descr',
_timerTargets: [],
setDefaults: function (a) {
this._resetExtraLabels(this._defaults, a);
$.extend(this._defaults, a || {})
},
UTCDate: function (a, b, c, e, f, g, h, i) {
if (typeof b == 'object' && b.constructor == Date) {
i = b.getMilliseconds();
h = b.getSeconds();
g = b.getMinutes();
f = b.getHours();
e = b.getDate();
c = b.getMonth();
b = b.getFullYear()
}
var d = new Date();
d.setUTCFullYear(b);
d.setUTCDate(1);
d.setUTCMonth(c || 0);
d.setUTCDate(e || 1);
d.setUTCHours(f || 0);
d.setUTCMinutes((g || 0) - (Math.abs(a) < 30 ? a * 60 : a));
d.setUTCSeconds(h || 0);
d.setUTCMilliseconds(i || 0);
return d
},
periodsToSeconds: function (a) {
return a[0] * 31557600 + a[1] * 2629800 + a[2] * 604800 + a[3] * 86400 + a[4] * 3600 + a[5] * 60 + a[6]
},
_attachPlugin: function (a, b) {
a = $(a);
if (a.hasClass(this.markerClassName)) {
return
}
var c = {
options: $.extend({}, this._defaults),
_periods: [0, 0, 0, 0, 0, 0, 0]
};
a.addClass(this.markerClassName).data(this.propertyName, c);
this._optionPlugin(a, b)
},
_addTarget: function (a) {
if (!this._hasTarget(a)) {
this._timerTargets.push(a)
}
},
_hasTarget: function (a) {
return ($.inArray(a, this._timerTargets) > -1)
},
_removeTarget: function (b) {
this._timerTargets = $.map(this._timerTargets, function (a) {
return (a == b ? null : a)
})
},
_updateTargets: function () {
for (var i = this._timerTargets.length - 1; i >= 0; i--) {
this._updateCountdown(this._timerTargets[i])
}
},
_optionPlugin: function (a, b, c) {
a = $(a);
var d = a.data(this.propertyName);
if (!b || (typeof b == 'string' && c == null)) {
var e = b;
b = (d || {}).options;
return (b && e ? b[e] : b)
}
if (!a.hasClass(this.markerClassName)) {
return
}
b = b || {};
if (typeof b == 'string') {
var e = b;
b = {};
b[e] = c
}
if (b.layout) {
b.layout = b.layout.replace(/</g, '<').replace(/>/g, '>')
}
this._resetExtraLabels(d.options, b);
var f = (d.options.timezone != b.timezone);
$.extend(d.options, b);
this._adjustSettings(a, d, b.until != null || b.since != null || f);
var g = new Date();
if ((d._since && d._since < g) || (d._until && d._until > g)) {
this._addTarget(a[0])
}
this._updateCountdown(a, d)
},
_updateCountdown: function (a, b) {
var c = $(a);
b = b || c.data(this.propertyName);
if (!b) {
return
}
c.html(this._generateHTML(b)).toggleClass(this._rtlClass, b.options.isRTL);
if ($.isFunction(b.options.onTick)) {
var d = b._hold != 'lap' ? b._periods : this._calculatePeriods(b, b._show, b.options.significant, new Date());
if (b.options.tickInterval == 1 || this.periodsToSeconds(d) % b.options.tickInterval == 0) {
b.options.onTick.apply(a, [d])
}
}
var e = b._hold != 'pause' && (b._since ? b._now.getTime() < b._since.getTime() : b._now.getTime() >= b._until.getTime());
if (e && !b._expiring) {
b._expiring = true;
if (this._hasTarget(a) || b.options.alwaysExpire) {
this._removeTarget(a);
if ($.isFunction(b.options.onExpiry)) {
b.options.onExpiry.apply(a, [])
}
if (b.options.expiryText) {
var f = b.options.layout;
b.options.layout = b.options.expiryText;
this._updateCountdown(a, b);
b.options.layout = f
}
if (b.options.expiryUrl) {
window.location = b.options.expiryUrl
}
}
b._expiring = false
} else if (b._hold == 'pause') {
this._removeTarget(a)
}
c.data(this.propertyName, b)
},
_resetExtraLabels: function (a, b) {
var c = false;
for (var n in b) {
if (n != 'whichLabels' && n.match(/[Ll]abels/)) {
c = true;
break
}
}
if (c) {
for (var n in a) {
if (n.match(/[Ll]abels[02-9]|compactLabels1/)) {
a[n] = null
}
}
}
},
_adjustSettings: function (a, b, c) {
var d;
var e = 0;
var f = null;
for (var i = 0; i < this._serverSyncs.length; i++) {
if (this._serverSyncs[i][0] == b.options.serverSync) {
f = this._serverSyncs[i][1];
break
}
}
if (f != null) {
e = (b.options.serverSync ? f : 0);
d = new Date()
} else {
var g = ($.isFunction(b.options.serverSync) ? b.options.serverSync.apply(a, []) : null);
d = new Date();
e = (g ? d.getTime() - g.getTime() : 0);
this._serverSyncs.push([b.options.serverSync, e])
}
var h = b.options.timezone;
h = (h == null ? -d.getTimezoneOffset() : h);
if (c || (!c && b._until == null && b._since == null)) {
b._since = b.options.since;
if (b._since != null) {
b._since = this.UTCDate(h, this._determineTime(b._since, null));
if (b._since && e) {
b._since.setMilliseconds(b._since.getMilliseconds() + e)
}
}
b._until = this.UTCDate(h, this._determineTime(b.options.until, d));
if (e) {
b._until.setMilliseconds(b._until.getMilliseconds() + e)
}
}
b._show = this._determineShow(b)
},
_destroyPlugin: function (a) {
a = $(a);
if (!a.hasClass(this.markerClassName)) {
return
}
this._removeTarget(a[0]);
a.removeClass(this.markerClassName).empty().removeData(this.propertyName)
},
_pausePlugin: function (a) {
this._hold(a, 'pause')
},
_lapPlugin: function (a) {
this._hold(a, 'lap')
},
_resumePlugin: function (a) {
this._hold(a, null)
},
_hold: function (a, b) {
var c = $.data(a, this.propertyName);
if (c) {
if (c._hold == 'pause' && !b) {
c._periods = c._savePeriods;
var d = (c._since ? '-' : '+');
c[c._since ? '_since' : '_until'] = this._determineTime(d + c._periods[0] + 'y' + d + c._periods[1] + 'o' + d + c._periods[2] + 'w' + d + c._periods[3] + 'd' + d + c._periods[4] + 'h' + d + c._periods[5] + 'm' + d + c._periods[6] + 's');
this._addTarget(a)
}
c._hold = b;
c._savePeriods = (b == 'pause' ? c._periods : null);
$.data(a, this.propertyName, c);
this._updateCountdown(a, c)
}
},
_getTimesPlugin: function (a) {
var b = $.data(a, this.propertyName);
return (!b ? null : (b._hold == 'pause' ? b._savePeriods : (!b._hold ? b._periods : this._calculatePeriods(b, b._show, b.options.significant, new Date()))))
},
_determineTime: function (k, l) {
var m = function (a) {
var b = new Date();
b.setTime(b.getTime() + a * 1000);
return b
};
var n = function (a) {
a = a.toLowerCase();
var b = new Date();
var c = b.getFullYear();
var d = b.getMonth();
var e = b.getDate();
var f = b.getHours();
var g = b.getMinutes();
var h = b.getSeconds();
var i = /([+-]?[0-9]+)\s*(s|m|h|d|w|o|y)?/g;
var j = i.exec(a);
while (j) {
switch (j[2] || 's') {
case 's':
h += parseInt(j[1], 10);
break;
case 'm':
g += parseInt(j[1], 10);
break;
case 'h':
f += parseInt(j[1], 10);
break;
case 'd':
e += parseInt(j[1], 10);
break;
case 'w':
e += parseInt(j[1], 10) * 7;
break;
case 'o':
d += parseInt(j[1], 10);
e = Math.min(e, x._getDaysInMonth(c, d));
break;
case 'y':
c += parseInt(j[1], 10);
e = Math.min(e, x._getDaysInMonth(c, d));
break
}
j = i.exec(a)
}
return new Date(c, d, e, f, g, h, 0)
};
var o = (k == null ? l : (typeof k == 'string' ? n(k) : (typeof k == 'number' ? m(k) : k)));
if (o) o.setMilliseconds(0);
return o
},
_getDaysInMonth: function (a, b) {
return 32 - new Date(a, b, 32).getDate()
},
_normalLabels: function (a) {
return a
},
_generateHTML: function (c) {
var d = this;
c._periods = (c._hold ? c._periods : this._calculatePeriods(c, c._show, c.options.significant, new Date()));
var e = false;
var f = 0;
var g = c.options.significant;
var h = $.extend({}, c._show);
for (var i = Y; i <= S; i++) {
e |= (c._show[i] == '?' && c._periods[i] > 0);
h[i] = (c._show[i] == '?' && !e ? null : c._show[i]);
f += (h[i] ? 1 : 0);
g -= (c._periods[i] > 0 ? 1 : 0)
}
var j = [false, false, false, false, false, false, false];
for (var i = S; i >= Y; i--) {
if (c._show[i]) {
if (c._periods[i]) {
j[i] = true
} else {
j[i] = g > 0;
g--
}
}
}
var k = (c.options.compact ? c.options.compactLabels : c.options.labels);
var l = c.options.whichLabels || this._normalLabels;
var m = function (a) {
var b = c.options['compactLabels' + l(c._periods[a])];
return (h[a] ? d._translateDigits(c, c._periods[a]) + (b ? b[a] : k[a]) + ' ' : '')
};
var n = function (a) {
var b = c.options['labels' + l(c._periods[a])];
return ((!c.options.significant && h[a]) || (c.options.significant && j[a]) ? '<span class="' + x._sectionClass + '">' + '<span class="' + x._amountClass + '">' + d._translateDigits(c, c._periods[a]) + '</span><br/>' + (b ? b[a] : k[a]) + '</span>' : '')
};
return (c.options.layout ? this._buildLayout(c, h, c.options.layout, c.options.compact, c.options.significant, j) : ((c.options.compact ? '<span class="' + this._rowClass + ' ' + this._amountClass + (c._hold ? ' ' + this._holdingClass : '') + '">' + m(Y) + m(O) + m(W) + m(D) + (h[H] ? this._minDigits(c, c._periods[H], 2) : '') + (h[M] ? (h[H] ? c.options.timeSeparator : '') + this._minDigits(c, c._periods[M], 2) : '') + (h[S] ? (h[H] || h[M] ? c.options.timeSeparator : '') + this._minDigits(c, c._periods[S], 2) : '') : '<span class="' + this._rowClass + ' ' + this._showClass + (c.options.significant || f) + (c._hold ? ' ' + this._holdingClass : '') + '">' + n(Y) + n(O) + n(W) + n(D) + n(H) + n(M) + n(S)) + '</span>' + (c.options.description ? '<span class="' + this._rowClass + ' ' + this._descrClass + '">' + c.options.description + '</span>' : '')))
},
_buildLayout: function (c, d, e, f, g, h) {
var j = c.options[f ? 'compactLabels' : 'labels'];
var k = c.options.whichLabels || this._normalLabels;
var l = function (a) {
return (c.options[(f ? 'compactLabels' : 'labels') + k(c._periods[a])] || j)[a]
};
var m = function (a, b) {
return c.options.digits[Math.floor(a / b) % 10]
};
var o = {
desc: c.options.description,
sep: c.options.timeSeparator,
yl: l(Y),
yn: this._minDigits(c, c._periods[Y], 1),
ynn: this._minDigits(c, c._periods[Y], 2),
ynnn: this._minDigits(c, c._periods[Y], 3),
y1: m(c._periods[Y], 1),
y10: m(c._periods[Y], 10),
y100: m(c._periods[Y], 100),
y1000: m(c._periods[Y], 1000),
ol: l(O),
on: this._minDigits(c, c._periods[O], 1),
onn: this._minDigits(c, c._periods[O], 2),
onnn: this._minDigits(c, c._periods[O], 3),
o1: m(c._periods[O], 1),
o10: m(c._periods[O], 10),
o100: m(c._periods[O], 100),
o1000: m(c._periods[O], 1000),
wl: l(W),
wn: this._minDigits(c, c._periods[W], 1),
wnn: this._minDigits(c, c._periods[W], 2),
wnnn: this._minDigits(c, c._periods[W], 3),
w1: m(c._periods[W], 1),
w10: m(c._periods[W], 10),
w100: m(c._periods[W], 100),
w1000: m(c._periods[W], 1000),
dl: l(D),
dn: this._minDigits(c, c._periods[D], 1),
dnn: this._minDigits(c, c._periods[D], 2),
dnnn: this._minDigits(c, c._periods[D], 3),
d1: m(c._periods[D], 1),
d10: m(c._periods[D], 10),
d100: m(c._periods[D], 100),
d1000: m(c._periods[D], 1000),
hl: l(H),
hn: this._minDigits(c, c._periods[H], 1),
hnn: this._minDigits(c, c._periods[H], 2),
hnnn: this._minDigits(c, c._periods[H], 3),
h1: m(c._periods[H], 1),
h10: m(c._periods[H], 10),
h100: m(c._periods[H], 100),
h1000: m(c._periods[H], 1000),
ml: l(M),
mn: this._minDigits(c, c._periods[M], 1),
mnn: this._minDigits(c, c._periods[M], 2),
mnnn: this._minDigits(c, c._periods[M], 3),
m1: m(c._periods[M], 1),
m10: m(c._periods[M], 10),
m100: m(c._periods[M], 100),
m1000: m(c._periods[M], 1000),
sl: l(S),
sn: this._minDigits(c, c._periods[S], 1),
snn: this._minDigits(c, c._periods[S], 2),
snnn: this._minDigits(c, c._periods[S], 3),
s1: m(c._periods[S], 1),
s10: m(c._periods[S], 10),
s100: m(c._periods[S], 100),
s1000: m(c._periods[S], 1000)
};
var p = e;
for (var i = Y; i <= S; i++) {
var q = 'yowdhms'.charAt(i);
var r = new RegExp('\\{' + q + '<\\}([\\s\\S]*)\\{' + q + '>\\}', 'g');
p = p.replace(r, ((!g && d[i]) || (g && h[i]) ? '$1' : ''))
}
$.each(o, function (n, v) {
var a = new RegExp('\\{' + n + '\\}', 'g');
p = p.replace(a, v)
});
return p
},
_minDigits: function (a, b, c) {
b = '' + b;
if (b.length >= c) {
return this._translateDigits(a, b)
}
b = '0000000000' + b;
return this._translateDigits(a, b.substr(b.length - c))
},
_translateDigits: function (b, c) {
return ('' + c).replace(/[0-9]/g, function (a) {
return b.options.digits[a]
})
},
_determineShow: function (a) {
var b = a.options.format;
var c = [];
c[Y] = (b.match('y') ? '?' : (b.match('Y') ? '!' : null));
c[O] = (b.match('o') ? '?' : (b.match('O') ? '!' : null));
c[W] = (b.match('w') ? '?' : (b.match('W') ? '!' : null));
c[D] = (b.match('d') ? '?' : (b.match('D') ? '!' : null));
c[H] = (b.match('h') ? '?' : (b.match('H') ? '!' : null));
c[M] = (b.match('m') ? '?' : (b.match('M') ? '!' : null));
c[S] = (b.match('s') ? '?' : (b.match('S') ? '!' : null));
return c
},
_calculatePeriods: function (c, d, e, f) {
c._now = f;
c._now.setMilliseconds(0);
var g = new Date(c._now.getTime());
if (c._since) {
if (f.getTime() < c._since.getTime()) {
c._now = f = g
} else {
f = c._since
}
} else {
g.setTime(c._until.getTime());
if (f.getTime() > c._until.getTime()) {
c._now = f = g
}
}
var h = [0, 0, 0, 0, 0, 0, 0];
if (d[Y] || d[O]) {
var i = x._getDaysInMonth(f.getFullYear(), f.getMonth());
var j = x._getDaysInMonth(g.getFullYear(), g.getMonth());
var k = (g.getDate() == f.getDate() || (g.getDate() >= Math.min(i, j) && f.getDate() >= Math.min(i, j)));
var l = function (a) {
return (a.getHours() * 60 + a.getMinutes()) * 60 + a.getSeconds()
};
var m = Math.max(0, (g.getFullYear() - f.getFullYear()) * 12 + g.getMonth() - f.getMonth() + ((g.getDate() < f.getDate() && !k) || (k && l(g) < l(f)) ? -1 : 0));
h[Y] = (d[Y] ? Math.floor(m / 12) : 0);
h[O] = (d[O] ? m - h[Y] * 12 : 0);
f = new Date(f.getTime());
var n = (f.getDate() == i);
var o = x._getDaysInMonth(f.getFullYear() + h[Y], f.getMonth() + h[O]);
if (f.getDate() > o) {
f.setDate(o)
}
f.setFullYear(f.getFullYear() + h[Y]);
f.setMonth(f.getMonth() + h[O]);
if (n) {
f.setDate(o)
}
}
var p = Math.floor((g.getTime() - f.getTime()) / 1000);
var q = function (a, b) {
h[a] = (d[a] ? Math.floor(p / b) : 0);
p -= h[a] * b
};
q(W, 604800);
q(D, 86400);
q(H, 3600);
q(M, 60);
q(S, 1);
if (p > 0 && !c._since) {
var r = [1, 12, 4.3482, 7, 24, 60, 60];
var s = S;
var t = 1;
for (var u = S; u >= Y; u--) {
if (d[u]) {
if (h[s] >= t) {
h[s] = 0;
p = 1
}
if (p > 0) {
h[u]++;
p = 0;
s = u;
t = 1
}
}
t *= r[u]
}
}
if (e) {
for (var u = Y; u <= S; u++) {
if (e && h[u]) {
e--
} else if (!e) {
h[u] = 0
}
}
}
return h
}
});
var w = ['getTimes'];
function isNotChained(a, b) {
if (a == 'option' && (b.length == 0 || (b.length == 1 && typeof b[0] == 'string'))) {
return true
}
return $.inArray(a, w) > -1
}
$.fn.countdown = function (a) {
var b = Array.prototype.slice.call(arguments, 1);
if (isNotChained(a, b)) {
return x['_' + a + 'Plugin'].apply(x, [this[0]].concat(b))
}
return this.each(function () {
if (typeof a == 'string') {
if (!x['_' + a + 'Plugin']) {
throw 'Unknown command: ' + a;
}
x['_' + a + 'Plugin'].apply(x, [this].concat(b))
} else {
x._attachPlugin(this, a || {})
}
})
};
var x = $.countdown = new Countdown()
})(jQuery);
There is a javascript file called custom.js
Here is the code to find you will see the date you have to modify,
Additional information regarding this plugin can be found http://keith-wood.name/countdown.html
// Countdown //
$('#countdown').countdown({
until: new Date(2014, 10 - 1, 9), // new Date(year, mth - 1, day, hr, min, sec) - date/time to count down to
// or numeric for seconds offset, or string for unit offset(s):
// 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
timezone: -4, // The timezone (hours or minutes from GMT) for the target times, or null for client local
layout: '{d<}<div class="span3"><div class="digit-container">{dn}<span class="label-container">{dl}</span></div></div>{d>}{h<}<div class="span3"><div class="digit-container">{hn}<span class="label-container">{hl}</span></div></div>{h>}{m<}<div class="span3"><div class="digit-container">{mn}<span class="label-container">{ml}</span></div></div>{m>}{s<}<div class="span3"><div class="digit-container">{sn}<span class="label-container">{sl}</span></div></div>{s>}',
timeSeparator: '', // Separator for time periods
isRTL: false, // True for right-to-left languages, false for left-to-right
format: 'dHMS', // Format for display - upper case for always, lower case only if non-zero,
// 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
alwaysExpire: true, // True to trigger onExpiry even if never counted down
onExpiry: liftOff // Callback when the countdown expires -
// receives no parameters and 'this' is the containing division
});

Categories

Resources