3
3
var GameDistributionLibrary = {
4
4
5
5
$Context : {
6
- listener : null
6
+ listener : null ,
7
+ activeElementId : null ,
7
8
} ,
8
9
9
10
GameDistribution_PlatformInit : function ( gameId , debug ) {
10
11
window [ "GD_DEFOLD" ] = {
11
12
"onEvent" : function ( event ) {
13
+ if ( event . name == "SDK_GAME_START" && Context . activeElementId ) {
14
+ var element = document . getElementById ( activeElementId ) ;
15
+ if ( element ) {
16
+ element . focus ( ) ;
17
+ }
18
+ }
12
19
var listener = Context . listener ;
13
20
if ( ! listener ) {
14
21
console . log ( "No listener set" ) ;
@@ -53,6 +60,10 @@ var GameDistributionLibrary = {
53
60
54
61
GameDistribution_PlatformShowInterstitialAd : function ( ) {
55
62
if ( typeof gdsdk !== 'undefined' && gdsdk . showAd !== 'undefined' ) {
63
+ var activeElement = document . activeElement ;
64
+ if ( activeElement ) {
65
+ Context . activeElementId = document . activeElement . id ;
66
+ }
56
67
gdsdk . showAd ( gdsdk . AdType . Interstitial )
57
68
. then ( ( ) => console . info ( 'showAd(AdType.Interstitial) resolved.' ) )
58
69
. catch ( error => console . error ( error ) ) ;
@@ -61,6 +72,10 @@ var GameDistributionLibrary = {
61
72
62
73
GameDistribution_PlatformShowRewardedAd : function ( ) {
63
74
if ( typeof gdsdk !== 'undefined' && gdsdk . showAd !== 'undefined' ) {
75
+ var activeElement = document . activeElement ;
76
+ if ( activeElement ) {
77
+ Context . activeElementId = document . activeElement . id ;
78
+ }
64
79
gdsdk . showAd ( gdsdk . AdType . Rewarded )
65
80
. then ( ( ) => console . info ( 'showAd(AdType.Rewarded) resolved.' ) )
66
81
. catch ( error => console . error ( error ) ) ;
0 commit comments