Commit 93b68087 authored by yangbowen.x's avatar yangbowen.x

fix: 添加 certainty.js

parent 654582cf
......@@ -2,5 +2,5 @@
node_modules
.idea
dist
package-lock.json
# package-lock.json
.DS_Store
\ No newline at end of file
......@@ -115,6 +115,141 @@
return n;
})
: (c["seed" + p] = n);
})("undefined" != typeof self ? self : this, [], Math);
Math.seedrandom('yrecord');
})("undefined" != typeof self ? self : this, [], Math);
Math.seedrandom('yrecord');
//时间
(function(name, definition) {
if (typeof define === 'function') { // AMD
define(definition);
} else if (typeof module !== 'undefined' && module.exports) { // Node.js
module.exports = definition();
} else { // Browser
var timemachine = definition(),
global = this,
old = global[name];
timemachine.noConflict = function() {
global[name] = old;
return timemachine;
};
global[name] = timemachine;
}
})('yrecord_timer', function() {
const OriginalDate = Date;
const Timemachine = {
timestamp: 0,
tick: false,
tickStartDate: null,
keepTime: false,
difference: 0,
config: function(options) {
this.timestamp = OriginalDate.parse(options.dateString) || options.timestamp || this.timestamp;
this.difference = options.difference || this.difference;
this.keepTime = options.keepTime || this.keepTime;
this.tick = options.tick || this.tick;
if (this.tick) {
this.tickStartDate = new OriginalDate();
}
this._apply();
},
reset: function() {
this.timestamp = 0;
this.tick = false;
this.tickStartDate = null;
this.keepTime = false;
this.difference = 0;
Date = OriginalDate;
Date.prototype = OriginalDate.prototype;
},
_apply: function() {
var self = this;
Date = function() {
var date;
if (self.keepTime) {
date = new OriginalDate();
} else if (arguments.length === 1) {
date = new OriginalDate(arguments[0]);
} else if (arguments.length === 2) {
date = new OriginalDate(arguments[0], arguments[1]);
} else if (arguments.length === 3) {
date = new OriginalDate(arguments[0], arguments[1], arguments[2]);
} else if (arguments.length === 4) {
date = new OriginalDate(arguments[0], arguments[1], arguments[2], arguments[3]);
} else if (arguments.length === 5) {
date = new OriginalDate(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]);
} else if (arguments.length === 6) {
date = new OriginalDate(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
} else if (arguments.length === 7) {
date = new OriginalDate(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6]);
} else {
date = new OriginalDate(self.timestamp);
}
if (arguments.length === 0) {
var difference = self._getDifference();
if (difference !== 0) {
date = new OriginalDate(date.getTime() + difference);
}
}
return date;
};
Date.prototype = OriginalDate.prototype;
Date.now = function() {
var timestamp = self.keepTime ? OriginalDate.now() : self.timestamp;
return timestamp + self._getDifference();
};
Date.OriginalDate = OriginalDate;
Date.UTC = OriginalDate.UTC;
},
_getDifference: function() {
var difference = this.difference;
if (this.tick) {
difference += OriginalDate.now() - this.tickStartDate.getTime();
}
return difference;
},
};
Timemachine._apply();
return Timemachine;
});
fetch("http://localhost:7001/records/getTime", {
"method": "POST",
"headers": {
"user-agent": "vscode-restclient",
"content-type": "application/json",
"authorization": "Bearer eyJhbGciOiJIUzI1NiJ9.dGVzdA.GfxRk-CtH6rXPrQstXkm8pkjEhPFO1h5kFEBciCZN48"
},
"body": JSON.stringify({
"_id": "628b6d4f1fde64d672cf7769"
})
})
.then(response => {
response.text().then((res)=>{
timeObj = JSON.parse(res);
console.log(yrecord_timer)
yrecord_timer.config({
timestamp: Number(timeObj.data),
tick:true,
});
});
})
.catch(err => {
console.error(err);
});
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment