UNPKG

@fusioncharts/constructor

Version:

JavaScript Data Visualisation Library

1 lines 3.48 kB
"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=true;exports.default=void 0;var _observer=_interopRequireDefault(require("./observer"));function _setChartSel(fcMain,dataString){if(dataString){fcMain.options._chartSel=dataString.substr(dataString.length/2);fcMain.options._mapper=dataString.substr(0,dataString.length/2)}else{fcMain.options._chartSel=null;fcMain.options._mapper=null}}var Redluom=function(){function Redluom(){}var _proto=Redluom.prototype;_proto._mapMain=function _mapMain(fcMain,text){var str="",mapper=this._generateDimeSet(fcMain);if(mapper.length>0&&text&&text.length>0){var set=this._generateCharSet();for(var index=0;index<text.length;index++){var setIndex=set.indexOf(text.substr(index,1));if(setIndex>-1){str+=mapper.substr(setIndex,1);mapper=this._rotateKey(mapper,text.charCodeAt(index))}}return str}return""};_proto._rotateKey=function _rotateKey(_tempKey,amount){var amt=amount;amt=amt%_tempKey.length;if(amt<0){amt=_tempKey.length+amt}if(amt!==0){return _tempKey.substr(_tempKey.length-amt,amt)+_tempKey.substr(0,_tempKey.length-amt)}return _tempKey};_proto.storeObj=function storeObj(fcMain,licenseObj){var _this=this;if(licenseObj&&(licenseObj.creditLabel===true||licenseObj.creditLabel===false)){var chartLabelwidth=this._mapMain(fcMain,licenseObj.key);_setChartSel(fcMain,chartLabelwidth);fcMain.options.isCreditLabel=licenseObj.creditLabel;var charts=fcMain.items;if(charts){Object.keys(charts).forEach((function(chartId){if(charts[chartId].hasRendered()){_this._mapperParent(fcMain,charts[chartId])}}))}}};_proto._mapperParent=function _mapperParent(fcMain,chartObj){var _fcMain$options=fcMain.options,_mapper=_fcMain$options._mapper,_chartSel=_fcMain$options._chartSel,isCreditLabel=_fcMain$options.isCreditLabel;var bytes=null;if(_mapper&&_chartSel){var cipherText=_mapper+_chartSel;bytes=this._tripod(fcMain,cipherText)}_observer.default._mapperSeed(chartObj,isCreditLabel,bytes,fcMain.versionDetails[1])};_proto._tripod=function _tripod(fcMain,value){var str="",helperStr=this._generateDimeSet(fcMain),key=this._generateCharSet();if(helperStr.length>0&&value.length>0){for(var index=0;index<value.length;index++){var helperIndex=helperStr.indexOf(value.substr(index,1));if(helperIndex>-1){str+=key.substr(helperIndex,1);key=this._rotateKey(key,-key.charCodeAt(helperIndex))}}return str}return""};_proto._generateDimeSet=function _generateDimeSet(fcMain){var str="",tar=[],charSet=this._generateCharSet(),isDimensionArrReady=false;var mainDimensionArr=fcMain.options.randomDimensionArr||[];if(mainDimensionArr&&mainDimensionArr.length>0){isDimensionArrReady=true}for(var c=0;c<charSet.length;c++){tar.push(charSet.substr(c,1));if(!isDimensionArrReady){mainDimensionArr.push(Math.random())}}if(!isDimensionArrReady){fcMain.options.randomDimensionArr=mainDimensionArr}for(var _c=0;_c<charSet.length;_c++){str+=tar.splice(Math.round(mainDimensionArr[_c]*(tar.length-1)),1)}return str};_proto._generateCharSet=function _generateCharSet(){var alpha="",beta="",limit=90,delimiter=25,counterLimit=80,counter=0,multiplier="";var aCharCode="a".charCodeAt(0);for(var _i=aCharCode;_i<=aCharCode+delimiter;_i++){multiplier+=String.fromCharCode(_i)}for(var i=limit-delimiter;i<=limit;i++){alpha+=String.fromCharCode(i);if(i>counterLimit){beta+=counter.toString();counter++}}return""+multiplier+alpha+beta+"%-="};return Redluom}();var _default=exports.default=Object.freeze(new Redluom);