├── .gitignore ├── AutoGems ├── res │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── bg.jpg │ ├── bg.png │ ├── oldgems │ │ ├── 1.png │ │ ├── 2.png │ │ ├── 3.png │ │ └── 4.png │ ├── start_btn_idle.png │ ├── stop_btn_idle.png │ ├── newgems │ │ ├── Gem-Blue.png │ │ ├── Gem-Green.png │ │ ├── Gem-Pink.png │ │ ├── Gem-Red.png │ │ ├── Gem-Orange.png │ │ └── Gem-Purple.png │ ├── start_btn_active.png │ └── stop_btn_active.png ├── libs │ └── starling.swc ├── .settings │ └── org.eclipse.core.resources.prefs ├── html-template │ ├── playerProductInstall.swf │ ├── history │ │ ├── history.css │ │ ├── historyFrame.html │ │ └── history.js │ ├── index.template.html │ └── swfobject.js ├── .project ├── src │ ├── com │ │ └── autogems │ │ │ ├── GemPool.as │ │ │ ├── AutoGemsGame.as │ │ │ ├── Gem.as │ │ │ └── GemBoard.as │ ├── AutoGems.as │ ├── Embeds.as │ └── StarlingGame.as └── .actionScriptProperties ├── README.md └── License /.gitignore: -------------------------------------------------------------------------------- 1 | AutoGems/bin-debug 2 | -------------------------------------------------------------------------------- /AutoGems/res/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/1.png -------------------------------------------------------------------------------- /AutoGems/res/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/2.png -------------------------------------------------------------------------------- /AutoGems/res/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/3.png -------------------------------------------------------------------------------- /AutoGems/res/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/4.png -------------------------------------------------------------------------------- /AutoGems/res/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/5.png -------------------------------------------------------------------------------- /AutoGems/res/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/6.png -------------------------------------------------------------------------------- /AutoGems/res/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/bg.jpg -------------------------------------------------------------------------------- /AutoGems/res/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/bg.png -------------------------------------------------------------------------------- /AutoGems/libs/starling.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/libs/starling.swc -------------------------------------------------------------------------------- /AutoGems/res/oldgems/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/oldgems/1.png -------------------------------------------------------------------------------- /AutoGems/res/oldgems/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/oldgems/2.png -------------------------------------------------------------------------------- /AutoGems/res/oldgems/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/oldgems/3.png -------------------------------------------------------------------------------- /AutoGems/res/oldgems/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/oldgems/4.png -------------------------------------------------------------------------------- /AutoGems/res/start_btn_idle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/start_btn_idle.png -------------------------------------------------------------------------------- /AutoGems/res/stop_btn_idle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/stop_btn_idle.png -------------------------------------------------------------------------------- /AutoGems/res/newgems/Gem-Blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/newgems/Gem-Blue.png -------------------------------------------------------------------------------- /AutoGems/res/newgems/Gem-Green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/newgems/Gem-Green.png -------------------------------------------------------------------------------- /AutoGems/res/newgems/Gem-Pink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/newgems/Gem-Pink.png -------------------------------------------------------------------------------- /AutoGems/res/newgems/Gem-Red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/newgems/Gem-Red.png -------------------------------------------------------------------------------- /AutoGems/res/start_btn_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/start_btn_active.png -------------------------------------------------------------------------------- /AutoGems/res/stop_btn_active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/stop_btn_active.png -------------------------------------------------------------------------------- /AutoGems/res/newgems/Gem-Orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/newgems/Gem-Orange.png -------------------------------------------------------------------------------- /AutoGems/res/newgems/Gem-Purple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/res/newgems/Gem-Purple.png -------------------------------------------------------------------------------- /AutoGems/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | #Sat Nov 23 13:37:11 GMT+05:30 2013 2 | eclipse.preferences.version=1 3 | encoding/=utf-8 4 | -------------------------------------------------------------------------------- /AutoGems/html-template/playerProductInstall.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quakeboy/Bejeweled-Clone/HEAD/AutoGems/html-template/playerProductInstall.swf -------------------------------------------------------------------------------- /AutoGems/html-template/history/history.css: -------------------------------------------------------------------------------- 1 | /* This CSS stylesheet defines styles used by required elements in a flex application page that supports browser history */ 2 | 3 | #ie_historyFrame { width: 0px; height: 0px; display:none } 4 | #firefox_anchorDiv { width: 0px; height: 0px; display:none } 5 | #safari_formDiv { width: 0px; height: 0px; display:none } 6 | #safari_rememberDiv { width: 0px; height: 0px; display:none } 7 | -------------------------------------------------------------------------------- /AutoGems/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | AutoGems 4 | 5 | 6 | 7 | 8 | 9 | com.adobe.flexbuilder.project.flexbuilder 10 | 11 | 12 | 13 | 14 | 15 | com.adobe.flexbuilder.project.actionscriptnature 16 | 17 | 18 | -------------------------------------------------------------------------------- /AutoGems/src/com/autogems/GemPool.as: -------------------------------------------------------------------------------- 1 | package com.autogems 2 | { 3 | public class GemPool 4 | { 5 | private var gems:Vector.; 6 | private var counter:int = 0; 7 | 8 | public function GemPool(max:int) 9 | { 10 | gems = new Vector.; 11 | gems.length = max; 12 | gems.fixed = true; 13 | } 14 | 15 | public function addGem(gem:Gem):void 16 | { 17 | gems[counter++] = gem; 18 | } 19 | 20 | public function getGem():Gem 21 | { 22 | return gems[--counter]; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Bejeweled-Clone 2 | =============== 3 | 4 | Boiler plate code for match-3 games like bejeweled and candy crush. 5 | 6 | Framework : Starling
7 | Language : Actionscript 3
8 | IDE : Flash Builder 4.6
9 | 10 | 13 | 14 |
15 | 16 | ===== Screenshot ===== 17 | 18 | 19 | -------------------------------------------------------------------------------- /AutoGems/src/AutoGems.as: -------------------------------------------------------------------------------- 1 | package 2 | { 3 | import flash.display.Sprite; 4 | import flash.events.Event; 5 | 6 | import starling.core.Starling; 7 | 8 | [SWF(width="640", height="640", frameRate="60", backgroundColor="#DDDDDD")] 9 | public class AutoGems extends Sprite 10 | { 11 | public function AutoGems() 12 | { 13 | this.addEventListener(Event.ADDED_TO_STAGE, init); 14 | } 15 | 16 | private function init (e:Event):void 17 | { 18 | this.removeEventListener(Event.ADDED_TO_STAGE, init); 19 | 20 | var starlingRoot:Starling = new Starling(StarlingGame, this.stage); 21 | starlingRoot.start(); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /AutoGems/html-template/history/historyFrame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 27 | Hidden frame for Browser History support. 28 | 29 | 30 | -------------------------------------------------------------------------------- /AutoGems/src/Embeds.as: -------------------------------------------------------------------------------- 1 | package 2 | { 3 | public class Embeds 4 | { 5 | public function Embeds() 6 | { 7 | } 8 | 9 | [Embed (source="../res/1.png" )] 10 | public static const Gem1:Class; 11 | 12 | [Embed (source="../res/2.png" )] 13 | public static const Gem2:Class; 14 | 15 | [Embed (source="../res/3.png" )] 16 | public static const Gem3:Class; 17 | 18 | [Embed (source="../res/4.png" )] 19 | public static const Gem4:Class; 20 | 21 | [Embed (source="../res/5.png" )] 22 | public static const Gem5:Class; 23 | 24 | [Embed (source="../res/6.png" )] 25 | public static const Gem6:Class; 26 | 27 | [Embed (source="../res/bg.png" )] 28 | public static const bg:Class; 29 | 30 | [Embed (source="../res/start_btn_active.png" )] 31 | public static const start_btn_active:Class; 32 | 33 | [Embed (source="../res/start_btn_idle.png" )] 34 | public static const start_btn_idle:Class; 35 | 36 | [Embed (source="../res/stop_btn_active.png" )] 37 | public static const stop_btn_active:Class; 38 | 39 | [Embed (source="../res/stop_btn_idle.png" )] 40 | public static const stop_btn_idle:Class; 41 | 42 | 43 | } 44 | } -------------------------------------------------------------------------------- /License: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) {{{2014}}} {{{Rajavanya Subramaniyan}}} 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | If you use this as a starting point for your game, for reference or use this is any way, 24 | please consider giving me credits, and linking back to my site http://www.rajavanya.com 25 | -------------------------------------------------------------------------------- /AutoGems/src/StarlingGame.as: -------------------------------------------------------------------------------- 1 | package 2 | { 3 | import com.autogems.AutoGemsGame; 4 | import com.autogems.GemBoard; 5 | 6 | import starling.display.Button; 7 | import starling.display.Image; 8 | import starling.display.Sprite; 9 | import starling.events.Event; 10 | 11 | public class StarlingGame extends Sprite 12 | { 13 | private var board:GemBoard = new GemBoard(); 14 | private var startBtn:Button; 15 | private var stopBtn:Button; 16 | 17 | 18 | public function StarlingGame() 19 | { 20 | super(); 21 | var game:AutoGemsGame = AutoGemsGame.instance(); 22 | 23 | board = new GemBoard(); 24 | board.addEventListener(GemBoard.NO_MATCH, noMatchAnymore); 25 | 26 | addChild(new Image(game.getAssetMgr().getTexture("bg"))); 27 | addChild(board); 28 | 29 | startBtn = new Button( 30 | game.getAssetMgr().getTexture("start_btn_idle"),"", 31 | game.getAssetMgr().getTexture("start_btn_active")); 32 | 33 | stopBtn = new Button( 34 | game.getAssetMgr().getTexture("stop_btn_idle"),"", 35 | game.getAssetMgr().getTexture("stop_btn_active")); 36 | 37 | startBtn.x = 270; 38 | startBtn.y = 550; 39 | startBtn.addEventListener(Event.TRIGGERED, btnPressed); 40 | stopBtn.x = 440; 41 | stopBtn.y = 550; 42 | stopBtn.addEventListener(Event.TRIGGERED, btnPressed); 43 | 44 | //addChild(startBtn); 45 | //addChild(stopBtn); 46 | 47 | stopBtn.enabled = false; 48 | } 49 | 50 | private function noMatchAnymore(e:Event):void 51 | { 52 | startBtn.enabled = true; 53 | stopBtn.enabled = false; 54 | } 55 | 56 | private function btnPressed(e:Event):void 57 | { 58 | if (e.target == startBtn) 59 | { 60 | board.start(); 61 | startBtn.enabled = false; 62 | stopBtn.enabled = true; 63 | } 64 | else if (e.target == stopBtn) 65 | { 66 | board.stop(); 67 | startBtn.enabled = true; 68 | stopBtn.enabled = false; 69 | } 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /AutoGems/src/com/autogems/AutoGemsGame.as: -------------------------------------------------------------------------------- 1 | package com.autogems 2 | { 3 | import flash.display.Bitmap; 4 | 5 | import starling.textures.Texture; 6 | import starling.utils.AssetManager; 7 | 8 | public class AutoGemsGame 9 | { 10 | private var assetMgr:AssetManager; 11 | private static var _instance:AutoGemsGame = null; 12 | 13 | public static const MAX_COLS:int = 8; 14 | public static const MAX_ROWS:int = 8; 15 | 16 | public function getAssetMgr():AssetManager 17 | { 18 | return assetMgr; 19 | } 20 | 21 | public function AutoGemsGame() 22 | { 23 | loadResources(); 24 | } 25 | 26 | public static function instance():AutoGemsGame 27 | { 28 | if (!_instance) 29 | _instance = new AutoGemsGame(); 30 | 31 | return _instance; 32 | } 33 | 34 | private function loadResources():void 35 | { 36 | var gem1:Bitmap = new Embeds.Gem1 as Bitmap; 37 | var gem1_texture:Texture = Texture.fromBitmap(gem1); 38 | 39 | var gem2:Bitmap = new Embeds.Gem2 as Bitmap; 40 | var gem2_texture:Texture = Texture.fromBitmap(gem2); 41 | 42 | var gem3:Bitmap = new Embeds.Gem3 as Bitmap; 43 | var gem3_texture:Texture = Texture.fromBitmap(gem3); 44 | 45 | var gem4:Bitmap = new Embeds.Gem4 as Bitmap; 46 | var gem4_texture:Texture = Texture.fromBitmap(gem4); 47 | 48 | var gem5:Bitmap = new Embeds.Gem5 as Bitmap; 49 | var gem5_texture:Texture = Texture.fromBitmap(gem5); 50 | 51 | var gem6:Bitmap = new Embeds.Gem6 as Bitmap; 52 | var gem6_texture:Texture = Texture.fromBitmap(gem6); 53 | 54 | var start_btn_active:Bitmap = new Embeds.start_btn_active as Bitmap; 55 | var start_btn_active_texture:Texture = Texture.fromBitmap(start_btn_active); 56 | 57 | var start_btn_idle:Bitmap = new Embeds.start_btn_idle as Bitmap; 58 | var start_btn_idle_texture:Texture = Texture.fromBitmap(start_btn_idle); 59 | 60 | var stop_btn_active:Bitmap = new Embeds.stop_btn_active as Bitmap; 61 | var stop_btn_active_texture:Texture = Texture.fromBitmap(stop_btn_active); 62 | 63 | var stop_btn_idle:Bitmap = new Embeds.stop_btn_idle as Bitmap; 64 | var stop_btn_idle_texture:Texture = Texture.fromBitmap(stop_btn_idle); 65 | 66 | 67 | var bg:Bitmap = new Embeds.bg as Bitmap; 68 | var bg_texture:Texture = Texture.fromBitmap(bg); 69 | 70 | assetMgr = new AssetManager(); 71 | assetMgr.addTexture("gem1", gem1_texture); 72 | assetMgr.addTexture("gem2", gem2_texture); 73 | assetMgr.addTexture("gem3", gem3_texture); 74 | assetMgr.addTexture("gem4", gem4_texture); 75 | assetMgr.addTexture("gem5", gem5_texture); 76 | assetMgr.addTexture("gem6", gem6_texture); 77 | 78 | assetMgr.addTexture("start_btn_active", start_btn_active_texture); 79 | assetMgr.addTexture("start_btn_idle", start_btn_idle_texture); 80 | assetMgr.addTexture("stop_btn_active", stop_btn_active_texture); 81 | assetMgr.addTexture("stop_btn_idle", stop_btn_idle_texture); 82 | 83 | assetMgr.addTexture("bg", bg_texture); 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /AutoGems/.actionScriptProperties: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /AutoGems/src/com/autogems/Gem.as: -------------------------------------------------------------------------------- 1 | package com.autogems 2 | { 3 | import flash.geom.Point; 4 | 5 | import starling.animation.Transitions; 6 | import starling.animation.Tween; 7 | import starling.core.Starling; 8 | import starling.display.Image; 9 | import starling.display.Sprite; 10 | import starling.events.Touch; 11 | import starling.events.TouchEvent; 12 | import starling.events.TouchPhase; 13 | import starling.textures.Texture; 14 | 15 | public class Gem extends Sprite 16 | { 17 | private var img:Image; 18 | private var gemTextures:Array; 19 | private var tween:Tween; 20 | private var tween1:Tween; 21 | 22 | public static const GEM_TOUCHED:String = "GemTouched"; 23 | public static const GEM_SWIPED:String = "GemSwiped"; 24 | public static const GEM_MOVED:String = "GemMoved"; 25 | 26 | public static const DISAPPEAR_DELAY:Number = 0.5; 27 | public static const MOVE_DELAY:Number = 0.2; 28 | 29 | private var holder:Sprite = new Sprite(); 30 | 31 | private function randomNumber(min:Number, max:Number):Number 32 | { 33 | return Math.floor(Math.random() * (1 + max - min) + min); 34 | } 35 | 36 | public function revive():void 37 | { 38 | this.alpha = holder.alpha = 1.0; 39 | this.marked = false; 40 | this.randomize(); 41 | this.scaleX = this.scaleY = this.holder.scaleX = this.holder.scaleY = 1; 42 | } 43 | 44 | public function Gem() 45 | { 46 | super(); 47 | 48 | var game:AutoGemsGame = AutoGemsGame.instance(); 49 | 50 | gemTextures = new Array( 51 | game.getAssetMgr().getTexture("gem1"), 52 | game.getAssetMgr().getTexture("gem2"), 53 | game.getAssetMgr().getTexture("gem3"), 54 | game.getAssetMgr().getTexture("gem4"), 55 | game.getAssetMgr().getTexture("gem5"), 56 | game.getAssetMgr().getTexture("gem6")); 57 | 58 | addChild(holder); 59 | 60 | img = new Image(gemTextures[0]); 61 | holder.addChild(img); 62 | img.x = -img.width/2; 63 | img.y = -img.height/2; 64 | holder.x = img.width/2; 65 | holder.y = img.height/2; 66 | 67 | this.alpha = 0; 68 | 69 | tween = new Tween(this, DISAPPEAR_DELAY, Transitions.EASE_IN); 70 | tween.fadeTo(1); 71 | Starling.juggler.add(tween); 72 | 73 | tween1 = new Tween(this, DISAPPEAR_DELAY, Transitions.EASE_OUT); 74 | 75 | 76 | this.addEventListener(TouchEvent.TOUCH, onTouch); 77 | 78 | //init gem to random type and set correct texture 79 | this.gemType = randomNumber(0, 5); 80 | if (this.gemType == 6) trace ("fuck"); 81 | 82 | } 83 | 84 | private var lastTouchX:Number, lastTouchY:Number; 85 | private const delta:int = 40; 86 | private var direction:Point = new Point(); 87 | private var swiped:Boolean = false; 88 | 89 | public function onTouch(e:TouchEvent):void 90 | { 91 | var touch:Touch = e.getTouch(stage); 92 | 93 | if (touch && touch.phase == TouchPhase.BEGAN) 94 | { 95 | swiped = false; 96 | lastTouchX = touch.globalX; 97 | lastTouchY = touch.globalY; 98 | 99 | this.dispatchEventWith(GEM_TOUCHED); 100 | } 101 | else if (!swiped && touch && touch.phase == TouchPhase.MOVED) 102 | { 103 | var dX:Number = touch.globalX - lastTouchX; 104 | var dY:Number = touch.globalY - lastTouchY; 105 | 106 | //now check if a certain delta has been crossed on X or Y axis 107 | if (Math.abs(dX) > delta) 108 | { 109 | this.dispatchEventWith(GEM_SWIPED, false, new Point( (dX>0?1:-1), 0)); 110 | swiped = true; 111 | } 112 | else if (Math.abs(dY) > delta) 113 | { 114 | this.dispatchEventWith(GEM_SWIPED, false, new Point(0, (dY>0?1:-1))); 115 | swiped = true; 116 | } 117 | 118 | 119 | } 120 | } 121 | 122 | public function moveTo(x:Number, y:Number, needCallback:Boolean = false):void 123 | { 124 | tween = new Tween(this, MOVE_DELAY, Transitions.EASE_IN); 125 | tween.moveTo(x, y); 126 | tween.fadeTo(1); 127 | if (needCallback) tween.onComplete = animationComplete; 128 | Starling.juggler.add(tween); 129 | } 130 | 131 | private function animationComplete():void 132 | { 133 | this.dispatchEventWith(GEM_MOVED); 134 | } 135 | 136 | public function disappear():Gem 137 | { 138 | //first grow and then shrink + fade 139 | tween = new Tween(holder, DISAPPEAR_DELAY, Transitions.EASE_IN); 140 | tween.scaleTo(1.1); 141 | 142 | tween1 = new Tween(holder, DISAPPEAR_DELAY, Transitions.EASE_OUT); 143 | tween1.scaleTo(1); 144 | tween1.fadeTo(0); 145 | tween.nextTween = tween1; 146 | 147 | Starling.juggler.add(tween); 148 | this.marked = true; 149 | 150 | return this; 151 | } 152 | 153 | //================ properties type, row and col ================== 154 | 155 | private var _marked:Boolean = false; 156 | public function get marked():Boolean { return _marked; } 157 | 158 | public function set marked(value:Boolean):void 159 | { 160 | if (_marked == value) 161 | return; 162 | _marked = value; 163 | } 164 | 165 | 166 | 167 | private var _gemType:int; 168 | public function get gemType():int { return _gemType; } 169 | 170 | public function set gemType(value:int):void 171 | { 172 | if (_gemType == value) 173 | return; 174 | 175 | _gemType = value; 176 | 177 | if (_gemType < gemTextures.length) 178 | img.texture = gemTextures[_gemType] as Texture; 179 | } 180 | 181 | private var _row:int; 182 | public function get row():int { return _row; } 183 | 184 | public function set row(value:int):void 185 | { 186 | if (_row == value) 187 | return; 188 | _row = value; 189 | } 190 | 191 | private var _col:int; 192 | public function get col():int { return _col; } 193 | 194 | public function set col(value:int):void 195 | { 196 | if (_col == value) 197 | return; 198 | _col = value; 199 | } 200 | 201 | public function cycle():void 202 | { 203 | if (this.gemType == 5) 204 | this.gemType = 0; 205 | else 206 | this.gemType++; 207 | } 208 | 209 | public function randomize():void 210 | { 211 | //1 in 16 chance for the wild card gem 212 | this.gemType = randomNumber(0, 5); 213 | if (this.gemType == 6) trace ("fuck"); 214 | } 215 | } 216 | } -------------------------------------------------------------------------------- /AutoGems/html-template/index.template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | ${title} 15 | 16 | 17 | 23 | 30 | 31 | 32 | 36 | 37 | 38 | 62 | 63 | 64 | 68 |
69 |

70 | To view this page ensure that Adobe Flash Player version 71 | ${version_major}.${version_minor}.${version_revision} or greater is installed. 72 |

73 | 78 |
79 | 80 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /AutoGems/src/com/autogems/GemBoard.as: -------------------------------------------------------------------------------- 1 | package com.autogems 2 | { 3 | import flash.geom.Point; 4 | 5 | import starling.core.Starling; 6 | import starling.display.Sprite; 7 | import starling.events.Event; 8 | 9 | public class GemBoard extends Sprite 10 | { 11 | public static const X_OFFSET:Number = 35; 12 | public static const Y_OFFSET:Number = 35; 13 | 14 | public static const GEM_WIDTH:Number = 60 15 | public static const GEM_HEIGHT:Number = 60; 16 | 17 | private var allgems:Vector.; 18 | private var gempool:GemPool; 19 | 20 | public static const NO_MATCH:String = "NoMatchEvent"; 21 | private var clicksLeft:int = 3; 22 | 23 | private var _running:Boolean; 24 | public function get running():Boolean { return _running; } 25 | 26 | public function set running(value:Boolean):void 27 | { 28 | if (_running == value) 29 | return; 30 | _running = value; 31 | 32 | if (running == false) 33 | clicksLeft = 3; 34 | } 35 | 36 | 37 | public function GemBoard() 38 | { 39 | //creating the gems 40 | allgems = new Vector.; 41 | allgems.length = AutoGemsGame.MAX_COLS * AutoGemsGame.MAX_ROWS; 42 | allgems.fixed = true; 43 | 44 | //create and fill the pool 45 | gempool = new GemPool(allgems.length); 46 | for (var n:int = 0; n < allgems.length; n++) 47 | gempool.addGem(new Gem()); 48 | 49 | for (var i:int = 0; i < AutoGemsGame.MAX_ROWS; i++) 50 | { 51 | for (var j:int = 0; j < AutoGemsGame.MAX_COLS; j++) 52 | { 53 | var g:Gem = gempool.getGem(); 54 | g.addEventListener(Gem.GEM_TOUCHED, gemTouched); 55 | g.addEventListener(Gem.GEM_SWIPED, gemSwiped); 56 | g.addEventListener(Gem.GEM_MOVED, gemMoved); 57 | 58 | putGemAtRowCol(g, i, j); 59 | 60 | g.x = X_OFFSET + j * GEM_WIDTH; 61 | g.y = Y_OFFSET + i * GEM_HEIGHT; 62 | 63 | addChild (g); 64 | } 65 | } 66 | 67 | //until a no match level is made successfully 68 | var result:Boolean = false; 69 | 70 | while (!result) 71 | result = makeLevelHaveNoMatch(); 72 | } 73 | 74 | private function makeLevelHaveNoMatch():Boolean 75 | { 76 | //assign a random gem to the current position 77 | 78 | //if there are 2 gems to the left, check horizontal match with left 2 gems 79 | //if there are 2 gems in the top, check vertical match with 2 gems in the bottom 80 | 81 | //if no match, move to next gem, else do it again 82 | 83 | for (var row:int = AutoGemsGame.MAX_ROWS -1 ; row > -1; row--) 84 | { 85 | for (var col:int = AutoGemsGame.MAX_COLS- 1; col > -1; col--) 86 | { 87 | var g:Gem = getGemAtRowCol(row, col); 88 | 89 | var match:Boolean = true; 90 | 91 | var n:int = 0; 92 | 93 | while (match && n < 100) 94 | { 95 | if (n == 0) 96 | g.randomize(); 97 | else 98 | g.cycle(); 99 | 100 | match = false; 101 | 102 | //search for horizontal match at point if it has three more elements on the right 103 | if (col < AutoGemsGame.MAX_COLS - 2) 104 | if (checkTripletAtPoint(row, col, true, false)) match = true; 105 | 106 | //search for vertical match at point if it has three more elements on the bottom 107 | if (row < AutoGemsGame.MAX_ROWS - 2) 108 | if (checkTripletAtPoint(row, col, false, false)) match = true; 109 | 110 | n++; 111 | 112 | if (n == 100) 113 | { 114 | trace ("1000 !!! row : " + row + " , col : " + col); 115 | return false; 116 | } 117 | } 118 | 119 | //trace ("row : " + row + " , col : " + col + " has gem type " + g.gemType); 120 | } 121 | } 122 | 123 | return true; 124 | } 125 | 126 | private function gemMoved(e:Event):void 127 | { 128 | searchForTriplets(); 129 | } 130 | 131 | private function gemSwiped(e:Event):void 132 | { 133 | var dir:Point = e.data as Point; 134 | 135 | var fromGem:Gem = e.target as Gem; 136 | var toGem:Gem = getGemAtRowCol(fromGem.row + dir.y, fromGem.col + dir.x); 137 | 138 | if (toGem) 139 | { 140 | //do the swipe and run the check once after the swipe animation is complete.. 141 | //trace ("Gem at " + (e.target as Gem).row + "," + (e.target as Gem).col + " has been swiped " + dir); 142 | moveGemToLocation(fromGem, toGem.row, toGem.col); 143 | moveGemToLocation(toGem, fromGem.row, fromGem.col, true); 144 | 145 | dir.x = fromGem.col; dir.y = fromGem.row; //reusing dir instead of another local var 146 | 147 | putGemAtRowCol(fromGem, toGem.row, toGem.col); 148 | putGemAtRowCol(toGem, dir.y, dir.x); 149 | } 150 | } 151 | 152 | private function gemTouched(e:starling.events.Event):void 153 | { 154 | 155 | // if (running) return; 156 | // 157 | // if (clicksLeft > 0) 158 | // { 159 | // var g:Gem = e.target as Gem; 160 | // g.gemType = 3; 161 | // clicksLeft--; 162 | // } 163 | 164 | 165 | } 166 | 167 | private function putGemAtRowCol(g:Gem, row:int, col:int, fromrow:int = -1, fromcol:int = -1):void 168 | { 169 | if (g) 170 | { 171 | g.row = row; 172 | g.col = col; 173 | } 174 | 175 | if (fromrow != -1 && fromcol != -1) 176 | allgems[fromcol + fromrow * AutoGemsGame.MAX_COLS] = null; 177 | 178 | allgems[col + row * AutoGemsGame.MAX_COLS] = g; 179 | } 180 | 181 | private function getGemAtRowCol(row:int, col:int):Gem 182 | { 183 | var idx:int = col + row*AutoGemsGame.MAX_COLS; 184 | 185 | if (row < 0 || col < 0 || row > AutoGemsGame.MAX_ROWS - 1 || col > AutoGemsGame.MAX_COLS - 1) return null; 186 | 187 | return (allgems[idx]) as Gem; 188 | } 189 | 190 | private function hasAnyMatch():Boolean 191 | { 192 | for (var row:int = 0; row < AutoGemsGame.MAX_ROWS; row++) 193 | { 194 | for (var col:int = 0; col < AutoGemsGame.MAX_COLS; col++) 195 | { 196 | //search for horizontal match at point if it has three more elements on the right 197 | if (col < AutoGemsGame.MAX_COLS - 2) 198 | if (checkTripletAtPoint(row, col, true, false)) 199 | return true; 200 | 201 | //search for vertical match at point if it has three more elements on the bottom 202 | if (row < AutoGemsGame.MAX_ROWS - 2) 203 | if (checkTripletAtPoint(row, col, false, false)) 204 | return true; 205 | } 206 | } 207 | 208 | return false; 209 | } 210 | 211 | private function swapAndSearch():void 212 | { 213 | if (!running) return; 214 | 215 | var matchFound:Boolean = false; 216 | 217 | //loop and swap until match found, 218 | outerLoop: for (var row:int = 0; row < AutoGemsGame.MAX_ROWS; row++) 219 | { 220 | for (var col:int = 0; col < AutoGemsGame.MAX_COLS; col++) 221 | { 222 | //if hori possible do it and check 223 | //if not, reverse 224 | var currentGem:Gem, nextGem:Gem; 225 | 226 | //horizontal swap check 227 | if ((col < AutoGemsGame.MAX_COLS - 1)) 228 | { 229 | currentGem = getGemAtRowCol(row, col); 230 | nextGem = getGemAtRowCol(row, col + 1); 231 | 232 | //swap non visually 233 | putGemAtRowCol(currentGem, row, col + 1); 234 | putGemAtRowCol(nextGem, row, col); 235 | 236 | if (hasAnyMatch()) 237 | { 238 | //move the gems visually 239 | moveGemToLocation(currentGem, row, col + 1); 240 | moveGemToLocation(nextGem, row, col); 241 | 242 | //set flag to say to do the usual game 243 | matchFound = true; 244 | //break loops 245 | break outerLoop; 246 | } 247 | else 248 | { 249 | //put them back in same place non-visually 250 | putGemAtRowCol(currentGem, row, col); 251 | putGemAtRowCol(nextGem, row, col + 1); 252 | } 253 | } 254 | 255 | //vertical swap check 256 | if ((row < AutoGemsGame.MAX_ROWS - 1)) 257 | { 258 | currentGem = getGemAtRowCol(row, col); 259 | nextGem = getGemAtRowCol(row + 1, col); 260 | 261 | //swap non visually 262 | putGemAtRowCol(currentGem, row + 1, col); 263 | putGemAtRowCol(nextGem, row, col); 264 | 265 | if (hasAnyMatch()) 266 | { 267 | //move the gems visually 268 | moveGemToLocation(currentGem, row + 1, col); 269 | moveGemToLocation(nextGem, row, col); 270 | 271 | //set flag to say to do the usual game 272 | matchFound = true; 273 | //break loops 274 | break outerLoop; 275 | } 276 | else 277 | { 278 | //put them back in same place non-visually 279 | putGemAtRowCol(currentGem, row, col); 280 | putGemAtRowCol(nextGem, row + 1, col); 281 | } 282 | } 283 | } 284 | } 285 | 286 | //when found swap visually and execute the usual game 287 | if (matchFound) 288 | Starling.juggler.delayCall(searchForTriplets, 1.0); 289 | //if not found stop game 290 | else 291 | { 292 | this.dispatchEventWith(GemBoard.NO_MATCH); 293 | running = false; 294 | } 295 | } 296 | 297 | private function searchForTriplets(autorun:Boolean = false):void 298 | { 299 | var anyMatch:Boolean = false; 300 | 301 | //loop through every element, in each row, length - 2 elements should be checked for horizontal match only vertical 302 | //in the each column, length - 2 elements should not be checked for vertical match only horizontal 303 | outerLoop: for (var row:int = 0; row < AutoGemsGame.MAX_ROWS; row++) 304 | { 305 | for (var col:int = 0; col < AutoGemsGame.MAX_COLS; col++) 306 | { 307 | //search for horizontal match at point if it has three more elements on the right 308 | if (col < AutoGemsGame.MAX_COLS - 2) 309 | if (checkTripletAtPoint(row, col)) 310 | anyMatch = true; 311 | 312 | //search for vertical match at point if it has three more elements on the bottom 313 | if (row < AutoGemsGame.MAX_ROWS - 2) 314 | if (checkTripletAtPoint(row, col, false)) 315 | anyMatch = true; 316 | } 317 | } 318 | 319 | if (anyMatch) 320 | { 321 | Starling.juggler.delayCall(gemsFillGaps, 0.8); 322 | Starling.juggler.delayCall(dropNewGems, 1.5); 323 | } 324 | else 325 | { 326 | if (autorun) 327 | Starling.juggler.delayCall(swapAndSearch, 0.5); 328 | } 329 | } 330 | 331 | private function moveGemToLocation(g:Gem, row:int, col:int, userInited:Boolean = false):void 332 | { 333 | g.moveTo( 334 | X_OFFSET + col * GEM_WIDTH, 335 | Y_OFFSET + row * GEM_HEIGHT, userInited); 336 | } 337 | 338 | private function locationForRowCol(row:int, col:int):Point 339 | { 340 | var p:Point = new Point(); 341 | p.x = X_OFFSET + col * GEM_WIDTH; 342 | p.y = Y_OFFSET + row * GEM_HEIGHT; 343 | 344 | return p; 345 | } 346 | 347 | private function dropNewGems():void 348 | { 349 | //from left col to right most 350 | for (var n:int = 0; n < AutoGemsGame.MAX_COLS; n++) 351 | { 352 | var gapStarted:Boolean = false; 353 | 354 | //from bottom cell of each col to top 355 | for (var m:int = AutoGemsGame.MAX_ROWS-1; m > -1; m--) 356 | { 357 | if (!gapStarted) 358 | { 359 | if (getGemAtRowCol(m, n)) 360 | continue; 361 | 362 | gapStarted = true; 363 | } 364 | 365 | var newgem:Gem = gempool.getGem(); 366 | newgem.revive(); 367 | putGemAtRowCol(newgem, m, n); 368 | 369 | //now make gem fall from top to down 370 | var p:Point = locationForRowCol(m, n); 371 | newgem.x = p.x; 372 | newgem.y = p.y - (AutoGemsGame.MAX_ROWS-2) * GEM_HEIGHT; 373 | moveGemToLocation(newgem, m, n); 374 | } 375 | } 376 | 377 | Starling.juggler.delayCall(searchForTriplets, 1.0); 378 | } 379 | 380 | private function gemsFillGaps():void 381 | { 382 | //first remove all marked gems 383 | for each (var g:Gem in allgems) 384 | if (g.marked) removeGemFromRowCol(g.row, g.col); 385 | 386 | //from left col to right most 387 | for (var n:int = 0; n < AutoGemsGame.MAX_COLS; n++) 388 | { 389 | //from bottom cell of each col to top 390 | EachRow: for (var m:int = AutoGemsGame.MAX_ROWS-1; m > -1; m--) 391 | { 392 | g = getGemAtRowCol(m, n); 393 | if (g) continue; 394 | else 395 | { 396 | //search for a gem in the above rows, when found bring it down 397 | //if nothing found until top, then fill all of them with new gems 398 | for (var o:int = m - 1; o > -1; o--) 399 | { 400 | var sg:Gem = getGemAtRowCol(o, n); 401 | if (sg) 402 | { 403 | //remove gem from current position, assign new position 404 | //make it move 405 | 406 | putGemAtRowCol(sg, m, n, o, n); 407 | moveGemToLocation(sg, m, n); 408 | continue EachRow; 409 | } 410 | } 411 | 412 | if (o == -1) 413 | break EachRow; 414 | } 415 | } 416 | } 417 | } 418 | 419 | private function checkTripletAtPoint(row:int, col:int, horizontal:Boolean = true, shouldDisappear:Boolean = true):Boolean 420 | { 421 | var colInc:int = horizontal? 1:0; 422 | var rowInc:int = horizontal? 0:1; 423 | 424 | var firstType:int = getGemAtRowCol(row, col).gemType; 425 | var matched:Boolean = true; 426 | 427 | if (!(getGemAtRowCol(row + rowInc, col + colInc).gemType == firstType)) 428 | matched = false; 429 | 430 | if (!(getGemAtRowCol(row + (rowInc<<1), col + (colInc<<1)).gemType == firstType)) 431 | matched = false; 432 | 433 | if (shouldDisappear && matched) 434 | { 435 | //mark for removal and do the rest 436 | getGemAtRowCol(row, col).disappear(); 437 | getGemAtRowCol(row + rowInc, col + colInc).disappear(); 438 | getGemAtRowCol(row + (rowInc<<1), col + (colInc<<1)).disappear(); 439 | } 440 | 441 | return matched; 442 | } 443 | 444 | private function removeGemFromRowCol(row:int, col:int):void 445 | { 446 | gempool.addGem(getGemAtRowCol(row, col)); 447 | putGemAtRowCol(null, row, col); 448 | } 449 | 450 | public function start():void 451 | { 452 | running = true; 453 | Starling.juggler.delayCall(searchForTriplets, 0.2, false); 454 | } 455 | 456 | public function stop():void 457 | { 458 | running = false; 459 | } 460 | } 461 | } -------------------------------------------------------------------------------- /AutoGems/html-template/history/history.js: -------------------------------------------------------------------------------- 1 | BrowserHistoryUtils = { 2 | addEvent: function(elm, evType, fn, useCapture) { 3 | useCapture = useCapture || false; 4 | if (elm.addEventListener) { 5 | elm.addEventListener(evType, fn, useCapture); 6 | return true; 7 | } 8 | else if (elm.attachEvent) { 9 | var r = elm.attachEvent('on' + evType, fn); 10 | return r; 11 | } 12 | else { 13 | elm['on' + evType] = fn; 14 | } 15 | } 16 | } 17 | 18 | BrowserHistory = (function() { 19 | // type of browser 20 | var browser = { 21 | ie: false, 22 | ie8: false, 23 | firefox: false, 24 | safari: false, 25 | opera: false, 26 | version: -1 27 | }; 28 | 29 | // Default app state URL to use when no fragment ID present 30 | var defaultHash = ''; 31 | 32 | // Last-known app state URL 33 | var currentHref = document.location.href; 34 | 35 | // Initial URL (used only by IE) 36 | var initialHref = document.location.href; 37 | 38 | // Initial URL (used only by IE) 39 | var initialHash = document.location.hash; 40 | 41 | // History frame source URL prefix (used only by IE) 42 | var historyFrameSourcePrefix = 'history/historyFrame.html?'; 43 | 44 | // History maintenance (used only by Safari) 45 | var currentHistoryLength = -1; 46 | 47 | // Flag to denote the existence of onhashchange 48 | var browserHasHashChange = false; 49 | 50 | var historyHash = []; 51 | 52 | var initialState = createState(initialHref, initialHref + '#' + initialHash, initialHash); 53 | 54 | var backStack = []; 55 | var forwardStack = []; 56 | 57 | var currentObjectId = null; 58 | 59 | //UserAgent detection 60 | var useragent = navigator.userAgent.toLowerCase(); 61 | 62 | if (useragent.indexOf("opera") != -1) { 63 | browser.opera = true; 64 | } else if (useragent.indexOf("msie") != -1) { 65 | browser.ie = true; 66 | browser.version = parseFloat(useragent.substring(useragent.indexOf('msie') + 4)); 67 | if (browser.version == 8) 68 | { 69 | browser.ie = false; 70 | browser.ie8 = true; 71 | } 72 | } else if (useragent.indexOf("safari") != -1) { 73 | browser.safari = true; 74 | browser.version = parseFloat(useragent.substring(useragent.indexOf('safari') + 7)); 75 | } else if (useragent.indexOf("gecko") != -1) { 76 | browser.firefox = true; 77 | } 78 | 79 | if (browser.ie == true && browser.version == 7) { 80 | window["_ie_firstload"] = false; 81 | } 82 | 83 | function hashChangeHandler() 84 | { 85 | currentHref = document.location.href; 86 | var flexAppUrl = getHash(); 87 | //ADR: to fix multiple 88 | if (typeof BrowserHistory_multiple != "undefined" && BrowserHistory_multiple == true) { 89 | var pl = getPlayers(); 90 | for (var i = 0; i < pl.length; i++) { 91 | pl[i].browserURLChange(flexAppUrl); 92 | } 93 | } else { 94 | getPlayer().browserURLChange(flexAppUrl); 95 | } 96 | } 97 | 98 | // Accessor functions for obtaining specific elements of the page. 99 | function getHistoryFrame() 100 | { 101 | return document.getElementById('ie_historyFrame'); 102 | } 103 | 104 | function getFormElement() 105 | { 106 | return document.getElementById('safari_formDiv'); 107 | } 108 | 109 | function getRememberElement() 110 | { 111 | return document.getElementById("safari_remember_field"); 112 | } 113 | 114 | // Get the Flash player object for performing ExternalInterface callbacks. 115 | // Updated for changes to SWFObject2. 116 | function getPlayer(id) { 117 | var i; 118 | 119 | if (id && document.getElementById(id)) { 120 | var r = document.getElementById(id); 121 | if (typeof r.SetVariable != "undefined") { 122 | return r; 123 | } 124 | else { 125 | var o = r.getElementsByTagName("object"); 126 | var e = r.getElementsByTagName("embed"); 127 | for (i = 0; i < o.length; i++) { 128 | if (typeof o[i].browserURLChange != "undefined") 129 | return o[i]; 130 | } 131 | for (i = 0; i < e.length; i++) { 132 | if (typeof e[i].browserURLChange != "undefined") 133 | return e[i]; 134 | } 135 | } 136 | } 137 | else { 138 | var o = document.getElementsByTagName("object"); 139 | var e = document.getElementsByTagName("embed"); 140 | for (i = 0; i < e.length; i++) { 141 | if (typeof e[i].browserURLChange != "undefined") 142 | { 143 | return e[i]; 144 | } 145 | } 146 | for (i = 0; i < o.length; i++) { 147 | if (typeof o[i].browserURLChange != "undefined") 148 | { 149 | return o[i]; 150 | } 151 | } 152 | } 153 | return undefined; 154 | } 155 | 156 | function getPlayers() { 157 | var i; 158 | var players = []; 159 | if (players.length == 0) { 160 | var tmp = document.getElementsByTagName('object'); 161 | for (i = 0; i < tmp.length; i++) 162 | { 163 | if (typeof tmp[i].browserURLChange != "undefined") 164 | players.push(tmp[i]); 165 | } 166 | } 167 | if (players.length == 0 || players[0].object == null) { 168 | var tmp = document.getElementsByTagName('embed'); 169 | for (i = 0; i < tmp.length; i++) 170 | { 171 | if (typeof tmp[i].browserURLChange != "undefined") 172 | players.push(tmp[i]); 173 | } 174 | } 175 | return players; 176 | } 177 | 178 | function getIframeHash() { 179 | var doc = getHistoryFrame().contentWindow.document; 180 | var hash = String(doc.location.search); 181 | if (hash.length == 1 && hash.charAt(0) == "?") { 182 | hash = ""; 183 | } 184 | else if (hash.length >= 2 && hash.charAt(0) == "?") { 185 | hash = hash.substring(1); 186 | } 187 | return hash; 188 | } 189 | 190 | /* Get the current location hash excluding the '#' symbol. */ 191 | function getHash() { 192 | // It would be nice if we could use document.location.hash here, 193 | // but it's faulty sometimes. 194 | var idx = document.location.href.indexOf('#'); 195 | return (idx >= 0) ? document.location.href.substr(idx+1) : ''; 196 | } 197 | 198 | /* Get the current location hash excluding the '#' symbol. */ 199 | function setHash(hash) { 200 | // It would be nice if we could use document.location.hash here, 201 | // but it's faulty sometimes. 202 | if (hash == '') hash = '#' 203 | document.location.hash = hash; 204 | } 205 | 206 | function createState(baseUrl, newUrl, flexAppUrl) { 207 | return { 'baseUrl': baseUrl, 'newUrl': newUrl, 'flexAppUrl': flexAppUrl, 'title': null }; 208 | } 209 | 210 | /* Add a history entry to the browser. 211 | * baseUrl: the portion of the location prior to the '#' 212 | * newUrl: the entire new URL, including '#' and following fragment 213 | * flexAppUrl: the portion of the location following the '#' only 214 | */ 215 | function addHistoryEntry(baseUrl, newUrl, flexAppUrl) { 216 | 217 | //delete all the history entries 218 | forwardStack = []; 219 | 220 | if (browser.ie) { 221 | //Check to see if we are being asked to do a navigate for the first 222 | //history entry, and if so ignore, because it's coming from the creation 223 | //of the history iframe 224 | if (flexAppUrl == defaultHash && document.location.href == initialHref && window['_ie_firstload']) { 225 | currentHref = initialHref; 226 | return; 227 | } 228 | if ((!flexAppUrl || flexAppUrl == defaultHash) && window['_ie_firstload']) { 229 | newUrl = baseUrl + '#' + defaultHash; 230 | flexAppUrl = defaultHash; 231 | } else { 232 | // for IE, tell the history frame to go somewhere without a '#' 233 | // in order to get this entry into the browser history. 234 | getHistoryFrame().src = historyFrameSourcePrefix + flexAppUrl; 235 | } 236 | setHash(flexAppUrl); 237 | } else { 238 | 239 | //ADR 240 | if (backStack.length == 0 && initialState.flexAppUrl == flexAppUrl) { 241 | initialState = createState(baseUrl, newUrl, flexAppUrl); 242 | } else if(backStack.length > 0 && backStack[backStack.length - 1].flexAppUrl == flexAppUrl) { 243 | backStack[backStack.length - 1] = createState(baseUrl, newUrl, flexAppUrl); 244 | } 245 | 246 | if (browser.safari && !browserHasHashChange) { 247 | // for Safari, submit a form whose action points to the desired URL 248 | if (browser.version <= 419.3) { 249 | var file = window.location.pathname.toString(); 250 | file = file.substring(file.lastIndexOf("/")+1); 251 | getFormElement().innerHTML = '
'; 252 | //get the current elements and add them to the form 253 | var qs = window.location.search.substring(1); 254 | var qs_arr = qs.split("&"); 255 | for (var i = 0; i < qs_arr.length; i++) { 256 | var tmp = qs_arr[i].split("="); 257 | var elem = document.createElement("input"); 258 | elem.type = "hidden"; 259 | elem.name = tmp[0]; 260 | elem.value = tmp[1]; 261 | document.forms.historyForm.appendChild(elem); 262 | } 263 | document.forms.historyForm.submit(); 264 | } else { 265 | top.location.hash = flexAppUrl; 266 | } 267 | // We also have to maintain the history by hand for Safari 268 | historyHash[history.length] = flexAppUrl; 269 | _storeStates(); 270 | } else { 271 | // Otherwise, just tell the browser to go there 272 | setHash(flexAppUrl); 273 | } 274 | } 275 | backStack.push(createState(baseUrl, newUrl, flexAppUrl)); 276 | } 277 | 278 | function _storeStates() { 279 | if (browser.safari) { 280 | getRememberElement().value = historyHash.join(","); 281 | } 282 | } 283 | 284 | function handleBackButton() { 285 | //The "current" page is always at the top of the history stack. 286 | var current = backStack.pop(); 287 | if (!current) { return; } 288 | var last = backStack[backStack.length - 1]; 289 | if (!last && backStack.length == 0){ 290 | last = initialState; 291 | } 292 | forwardStack.push(current); 293 | } 294 | 295 | function handleForwardButton() { 296 | //summary: private method. Do not call this directly. 297 | 298 | var last = forwardStack.pop(); 299 | if (!last) { return; } 300 | backStack.push(last); 301 | } 302 | 303 | function handleArbitraryUrl() { 304 | //delete all the history entries 305 | forwardStack = []; 306 | } 307 | 308 | /* Called periodically to poll to see if we need to detect navigation that has occurred */ 309 | function checkForUrlChange() { 310 | 311 | if (browser.ie) { 312 | if (currentHref != document.location.href && currentHref + '#' != document.location.href) { 313 | //This occurs when the user has navigated to a specific URL 314 | //within the app, and didn't use browser back/forward 315 | //IE seems to have a bug where it stops updating the URL it 316 | //shows the end-user at this point, but programatically it 317 | //appears to be correct. Do a full app reload to get around 318 | //this issue. 319 | if (browser.version < 7) { 320 | currentHref = document.location.href; 321 | document.location.reload(); 322 | } else { 323 | if (getHash() != getIframeHash()) { 324 | // this.iframe.src = this.blankURL + hash; 325 | var sourceToSet = historyFrameSourcePrefix + getHash(); 326 | getHistoryFrame().src = sourceToSet; 327 | currentHref = document.location.href; 328 | } 329 | } 330 | } 331 | } 332 | 333 | if (browser.safari && !browserHasHashChange) { 334 | // For Safari, we have to check to see if history.length changed. 335 | if (currentHistoryLength >= 0 && history.length != currentHistoryLength) { 336 | //alert("did change: " + history.length + ", " + historyHash.length + "|" + historyHash[history.length] + "|>" + historyHash.join("|")); 337 | var flexAppUrl = getHash(); 338 | if (browser.version < 528.16 /* Anything earlier than Safari 4.0 */) 339 | { 340 | // If it did change and we're running Safari 3.x or earlier, 341 | // then we have to look the old state up in our hand-maintained 342 | // array since document.location.hash won't have changed, 343 | // then call back into BrowserManager. 344 | currentHistoryLength = history.length; 345 | flexAppUrl = historyHash[currentHistoryLength]; 346 | } 347 | 348 | //ADR: to fix multiple 349 | if (typeof BrowserHistory_multiple != "undefined" && BrowserHistory_multiple == true) { 350 | var pl = getPlayers(); 351 | for (var i = 0; i < pl.length; i++) { 352 | pl[i].browserURLChange(flexAppUrl); 353 | } 354 | } else { 355 | getPlayer().browserURLChange(flexAppUrl); 356 | } 357 | _storeStates(); 358 | } 359 | } 360 | if (browser.firefox && !browserHasHashChange) { 361 | if (currentHref != document.location.href) { 362 | var bsl = backStack.length; 363 | 364 | var urlActions = { 365 | back: false, 366 | forward: false, 367 | set: false 368 | } 369 | 370 | if ((window.location.hash == initialHash || window.location.href == initialHref) && (bsl == 1)) { 371 | urlActions.back = true; 372 | // FIXME: could this ever be a forward button? 373 | // we can't clear it because we still need to check for forwards. Ugg. 374 | // clearInterval(this.locationTimer); 375 | handleBackButton(); 376 | } 377 | 378 | // first check to see if we could have gone forward. We always halt on 379 | // a no-hash item. 380 | if (forwardStack.length > 0) { 381 | if (forwardStack[forwardStack.length-1].flexAppUrl == getHash()) { 382 | urlActions.forward = true; 383 | handleForwardButton(); 384 | } 385 | } 386 | 387 | // ok, that didn't work, try someplace back in the history stack 388 | if ((bsl >= 2) && (backStack[bsl - 2])) { 389 | if (backStack[bsl - 2].flexAppUrl == getHash()) { 390 | urlActions.back = true; 391 | handleBackButton(); 392 | } 393 | } 394 | 395 | if (!urlActions.back && !urlActions.forward) { 396 | var foundInStacks = { 397 | back: -1, 398 | forward: -1 399 | } 400 | 401 | for (var i = 0; i < backStack.length; i++) { 402 | if (backStack[i].flexAppUrl == getHash() && i != (bsl - 2)) { 403 | arbitraryUrl = true; 404 | foundInStacks.back = i; 405 | } 406 | } 407 | for (var i = 0; i < forwardStack.length; i++) { 408 | if (forwardStack[i].flexAppUrl == getHash() && i != (bsl - 2)) { 409 | arbitraryUrl = true; 410 | foundInStacks.forward = i; 411 | } 412 | } 413 | handleArbitraryUrl(); 414 | } 415 | 416 | // Firefox changed; do a callback into BrowserManager to tell it. 417 | currentHref = document.location.href; 418 | var flexAppUrl = getHash(); 419 | //ADR: to fix multiple 420 | if (typeof BrowserHistory_multiple != "undefined" && BrowserHistory_multiple == true) { 421 | var pl = getPlayers(); 422 | for (var i = 0; i < pl.length; i++) { 423 | pl[i].browserURLChange(flexAppUrl); 424 | } 425 | } else { 426 | getPlayer().browserURLChange(flexAppUrl); 427 | } 428 | } 429 | } 430 | } 431 | 432 | var _initialize = function () { 433 | 434 | browserHasHashChange = ("onhashchange" in document.body); 435 | 436 | if (browser.ie) 437 | { 438 | var scripts = document.getElementsByTagName('script'); 439 | for (var i = 0, s; s = scripts[i]; i++) { 440 | if (s.src.indexOf("history.js") > -1) { 441 | var iframe_location = (new String(s.src)).replace("history.js", "historyFrame.html"); 442 | } 443 | } 444 | historyFrameSourcePrefix = iframe_location + "?"; 445 | var src = historyFrameSourcePrefix; 446 | 447 | var iframe = document.createElement("iframe"); 448 | iframe.id = 'ie_historyFrame'; 449 | iframe.name = 'ie_historyFrame'; 450 | iframe.src = 'javascript:false;'; 451 | 452 | try { 453 | document.body.appendChild(iframe); 454 | } catch(e) { 455 | setTimeout(function() { 456 | document.body.appendChild(iframe); 457 | }, 0); 458 | } 459 | } 460 | 461 | if (browser.safari && !browserHasHashChange) 462 | { 463 | var rememberDiv = document.createElement("div"); 464 | rememberDiv.id = 'safari_rememberDiv'; 465 | document.body.appendChild(rememberDiv); 466 | rememberDiv.innerHTML = ''; 467 | 468 | var formDiv = document.createElement("div"); 469 | formDiv.id = 'safari_formDiv'; 470 | document.body.appendChild(formDiv); 471 | 472 | var reloader_content = document.createElement('div'); 473 | reloader_content.id = 'safarireloader'; 474 | var scripts = document.getElementsByTagName('script'); 475 | for (var i = 0, s; s = scripts[i]; i++) { 476 | if (s.src.indexOf("history.js") > -1) { 477 | html = (new String(s.src)).replace(".js", ".html"); 478 | } 479 | } 480 | reloader_content.innerHTML = ''; 481 | document.body.appendChild(reloader_content); 482 | reloader_content.style.position = 'absolute'; 483 | reloader_content.style.left = reloader_content.style.top = '-9999px'; 484 | iframe = reloader_content.getElementsByTagName('iframe')[0]; 485 | 486 | if (document.getElementById("safari_remember_field").value != "" ) { 487 | historyHash = document.getElementById("safari_remember_field").value.split(","); 488 | } 489 | } 490 | 491 | if (browserHasHashChange) 492 | document.body.onhashchange = hashChangeHandler; 493 | } 494 | 495 | return { 496 | historyHash: historyHash, 497 | backStack: function() { return backStack; }, 498 | forwardStack: function() { return forwardStack }, 499 | getPlayer: getPlayer, 500 | initialize: function(src) { 501 | _initialize(src); 502 | }, 503 | setURL: function(url) { 504 | document.location.href = url; 505 | }, 506 | getURL: function() { 507 | return document.location.href; 508 | }, 509 | getTitle: function() { 510 | return document.title; 511 | }, 512 | setTitle: function(title) { 513 | try { 514 | backStack[backStack.length - 1].title = title; 515 | } catch(e) { } 516 | //if on safari, set the title to be the empty string. 517 | if (browser.safari) { 518 | if (title == "") { 519 | try { 520 | var tmp = window.location.href.toString(); 521 | title = tmp.substring((tmp.lastIndexOf("/")+1), tmp.lastIndexOf("#")); 522 | } catch(e) { 523 | title = ""; 524 | } 525 | } 526 | } 527 | document.title = title; 528 | }, 529 | setDefaultURL: function(def) 530 | { 531 | defaultHash = def; 532 | def = getHash(); 533 | //trailing ? is important else an extra frame gets added to the history 534 | //when navigating back to the first page. Alternatively could check 535 | //in history frame navigation to compare # and ?. 536 | if (browser.ie) 537 | { 538 | window['_ie_firstload'] = true; 539 | var sourceToSet = historyFrameSourcePrefix + def; 540 | var func = function() { 541 | getHistoryFrame().src = sourceToSet; 542 | window.location.replace("#" + def); 543 | setInterval(checkForUrlChange, 50); 544 | } 545 | try { 546 | func(); 547 | } catch(e) { 548 | window.setTimeout(function() { func(); }, 0); 549 | } 550 | } 551 | 552 | if (browser.safari) 553 | { 554 | currentHistoryLength = history.length; 555 | if (historyHash.length == 0) { 556 | historyHash[currentHistoryLength] = def; 557 | var newloc = "#" + def; 558 | window.location.replace(newloc); 559 | } else { 560 | //alert(historyHash[historyHash.length-1]); 561 | } 562 | setInterval(checkForUrlChange, 50); 563 | } 564 | 565 | 566 | if (browser.firefox || browser.opera) 567 | { 568 | var reg = new RegExp("#" + def + "$"); 569 | if (window.location.toString().match(reg)) { 570 | } else { 571 | var newloc ="#" + def; 572 | window.location.replace(newloc); 573 | } 574 | setInterval(checkForUrlChange, 50); 575 | } 576 | 577 | }, 578 | 579 | /* Set the current browser URL; called from inside BrowserManager to propagate 580 | * the application state out to the container. 581 | */ 582 | setBrowserURL: function(flexAppUrl, objectId) { 583 | if (browser.ie && typeof objectId != "undefined") { 584 | currentObjectId = objectId; 585 | } 586 | //fromIframe = fromIframe || false; 587 | //fromFlex = fromFlex || false; 588 | //alert("setBrowserURL: " + flexAppUrl); 589 | //flexAppUrl = (flexAppUrl == "") ? defaultHash : flexAppUrl ; 590 | 591 | var pos = document.location.href.indexOf('#'); 592 | var baseUrl = pos != -1 ? document.location.href.substr(0, pos) : document.location.href; 593 | var newUrl = baseUrl + '#' + flexAppUrl; 594 | 595 | if (document.location.href != newUrl && document.location.href + '#' != newUrl) { 596 | currentHref = newUrl; 597 | addHistoryEntry(baseUrl, newUrl, flexAppUrl); 598 | currentHistoryLength = history.length; 599 | } 600 | }, 601 | 602 | browserURLChange: function(flexAppUrl) { 603 | var objectId = null; 604 | if (browser.ie && currentObjectId != null) { 605 | objectId = currentObjectId; 606 | } 607 | 608 | if (typeof BrowserHistory_multiple != "undefined" && BrowserHistory_multiple == true) { 609 | var pl = getPlayers(); 610 | for (var i = 0; i < pl.length; i++) { 611 | try { 612 | pl[i].browserURLChange(flexAppUrl); 613 | } catch(e) { } 614 | } 615 | } else { 616 | try { 617 | getPlayer(objectId).browserURLChange(flexAppUrl); 618 | } catch(e) { } 619 | } 620 | 621 | currentObjectId = null; 622 | }, 623 | getUserAgent: function() { 624 | return navigator.userAgent; 625 | }, 626 | getPlatform: function() { 627 | return navigator.platform; 628 | } 629 | 630 | } 631 | 632 | })(); 633 | 634 | // Initialization 635 | 636 | // Automated unit testing and other diagnostics 637 | 638 | function setURL(url) 639 | { 640 | document.location.href = url; 641 | } 642 | 643 | function backButton() 644 | { 645 | history.back(); 646 | } 647 | 648 | function forwardButton() 649 | { 650 | history.forward(); 651 | } 652 | 653 | function goForwardOrBackInHistory(step) 654 | { 655 | history.go(step); 656 | } 657 | 658 | //BrowserHistoryUtils.addEvent(window, "load", function() { BrowserHistory.initialize(); }); 659 | (function(i) { 660 | var u =navigator.userAgent;var e=/*@cc_on!@*/false; 661 | var st = setTimeout; 662 | if(/webkit/i.test(u)){ 663 | st(function(){ 664 | var dr=document.readyState; 665 | if(dr=="loaded"||dr=="complete"){i()} 666 | else{st(arguments.callee,10);}},10); 667 | } else if((/mozilla/i.test(u)&&!/(compati)/.test(u)) || (/opera/i.test(u))){ 668 | document.addEventListener("DOMContentLoaded",i,false); 669 | } else if(e){ 670 | (function(){ 671 | var t=document.createElement('doc:rdy'); 672 | try{t.doScroll('left'); 673 | i();t=null; 674 | }catch(e){st(arguments.callee,0);}})(); 675 | } else{ 676 | window.onload=i; 677 | } 678 | })( function() {BrowserHistory.initialize();} ); 679 | -------------------------------------------------------------------------------- /AutoGems/html-template/swfobject.js: -------------------------------------------------------------------------------- 1 | /*! SWFObject v2.2 2 | is released under the MIT License 3 | */ 4 | 5 | var swfobject = function() { 6 | 7 | var UNDEF = "undefined", 8 | OBJECT = "object", 9 | SHOCKWAVE_FLASH = "Shockwave Flash", 10 | SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash", 11 | FLASH_MIME_TYPE = "application/x-shockwave-flash", 12 | EXPRESS_INSTALL_ID = "SWFObjectExprInst", 13 | ON_READY_STATE_CHANGE = "onreadystatechange", 14 | 15 | win = window, 16 | doc = document, 17 | nav = navigator, 18 | 19 | plugin = false, 20 | domLoadFnArr = [main], 21 | regObjArr = [], 22 | objIdArr = [], 23 | listenersArr = [], 24 | storedAltContent, 25 | storedAltContentId, 26 | storedCallbackFn, 27 | storedCallbackObj, 28 | isDomLoaded = false, 29 | isExpressInstallActive = false, 30 | dynamicStylesheet, 31 | dynamicStylesheetMedia, 32 | autoHideShow = true, 33 | 34 | /* Centralized function for browser feature detection 35 | - User agent string detection is only used when no good alternative is possible 36 | - Is executed directly for optimal performance 37 | */ 38 | ua = function() { 39 | var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF, 40 | u = nav.userAgent.toLowerCase(), 41 | p = nav.platform.toLowerCase(), 42 | windows = p ? /win/.test(p) : /win/.test(u), 43 | mac = p ? /mac/.test(p) : /mac/.test(u), 44 | webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit 45 | ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution: http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html 46 | playerVersion = [0,0,0], 47 | d = null; 48 | if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) { 49 | d = nav.plugins[SHOCKWAVE_FLASH].description; 50 | if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+ 51 | plugin = true; 52 | ie = false; // cascaded feature detection for Internet Explorer 53 | d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1"); 54 | playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10); 55 | playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10); 56 | playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0; 57 | } 58 | } 59 | else if (typeof win.ActiveXObject != UNDEF) { 60 | try { 61 | var a = new ActiveXObject(SHOCKWAVE_FLASH_AX); 62 | if (a) { // a will return null when ActiveX is disabled 63 | d = a.GetVariable("$version"); 64 | if (d) { 65 | ie = true; // cascaded feature detection for Internet Explorer 66 | d = d.split(" ")[1].split(","); 67 | playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]; 68 | } 69 | } 70 | } 71 | catch(e) {} 72 | } 73 | return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac }; 74 | }(), 75 | 76 | /* Cross-browser onDomLoad 77 | - Will fire an event as soon as the DOM of a web page is loaded 78 | - Internet Explorer workaround based on Diego Perini's solution: http://javascript.nwbox.com/IEContentLoaded/ 79 | - Regular onload serves as fallback 80 | */ 81 | onDomLoad = function() { 82 | if (!ua.w3) { return; } 83 | if ((typeof doc.readyState != UNDEF && doc.readyState == "complete") || (typeof doc.readyState == UNDEF && (doc.getElementsByTagName("body")[0] || doc.body))) { // function is fired after onload, e.g. when script is inserted dynamically 84 | callDomLoadFunctions(); 85 | } 86 | if (!isDomLoaded) { 87 | if (typeof doc.addEventListener != UNDEF) { 88 | doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, false); 89 | } 90 | if (ua.ie && ua.win) { 91 | doc.attachEvent(ON_READY_STATE_CHANGE, function() { 92 | if (doc.readyState == "complete") { 93 | doc.detachEvent(ON_READY_STATE_CHANGE, arguments.callee); 94 | callDomLoadFunctions(); 95 | } 96 | }); 97 | if (win == top) { // if not inside an iframe 98 | (function(){ 99 | if (isDomLoaded) { return; } 100 | try { 101 | doc.documentElement.doScroll("left"); 102 | } 103 | catch(e) { 104 | setTimeout(arguments.callee, 0); 105 | return; 106 | } 107 | callDomLoadFunctions(); 108 | })(); 109 | } 110 | } 111 | if (ua.wk) { 112 | (function(){ 113 | if (isDomLoaded) { return; } 114 | if (!/loaded|complete/.test(doc.readyState)) { 115 | setTimeout(arguments.callee, 0); 116 | return; 117 | } 118 | callDomLoadFunctions(); 119 | })(); 120 | } 121 | addLoadEvent(callDomLoadFunctions); 122 | } 123 | }(); 124 | 125 | function callDomLoadFunctions() { 126 | if (isDomLoaded) { return; } 127 | try { // test if we can really add/remove elements to/from the DOM; we don't want to fire it too early 128 | var t = doc.getElementsByTagName("body")[0].appendChild(createElement("span")); 129 | t.parentNode.removeChild(t); 130 | } 131 | catch (e) { return; } 132 | isDomLoaded = true; 133 | var dl = domLoadFnArr.length; 134 | for (var i = 0; i < dl; i++) { 135 | domLoadFnArr[i](); 136 | } 137 | } 138 | 139 | function addDomLoadEvent(fn) { 140 | if (isDomLoaded) { 141 | fn(); 142 | } 143 | else { 144 | domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+ 145 | } 146 | } 147 | 148 | /* Cross-browser onload 149 | - Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/ 150 | - Will fire an event as soon as a web page including all of its assets are loaded 151 | */ 152 | function addLoadEvent(fn) { 153 | if (typeof win.addEventListener != UNDEF) { 154 | win.addEventListener("load", fn, false); 155 | } 156 | else if (typeof doc.addEventListener != UNDEF) { 157 | doc.addEventListener("load", fn, false); 158 | } 159 | else if (typeof win.attachEvent != UNDEF) { 160 | addListener(win, "onload", fn); 161 | } 162 | else if (typeof win.onload == "function") { 163 | var fnOld = win.onload; 164 | win.onload = function() { 165 | fnOld(); 166 | fn(); 167 | }; 168 | } 169 | else { 170 | win.onload = fn; 171 | } 172 | } 173 | 174 | /* Main function 175 | - Will preferably execute onDomLoad, otherwise onload (as a fallback) 176 | */ 177 | function main() { 178 | if (plugin) { 179 | testPlayerVersion(); 180 | } 181 | else { 182 | matchVersions(); 183 | } 184 | } 185 | 186 | /* Detect the Flash Player version for non-Internet Explorer browsers 187 | - Detecting the plug-in version via the object element is more precise than using the plugins collection item's description: 188 | a. Both release and build numbers can be detected 189 | b. Avoid wrong descriptions by corrupt installers provided by Adobe 190 | c. Avoid wrong descriptions by multiple Flash Player entries in the plugin Array, caused by incorrect browser imports 191 | - Disadvantage of this method is that it depends on the availability of the DOM, while the plugins collection is immediately available 192 | */ 193 | function testPlayerVersion() { 194 | var b = doc.getElementsByTagName("body")[0]; 195 | var o = createElement(OBJECT); 196 | o.setAttribute("type", FLASH_MIME_TYPE); 197 | var t = b.appendChild(o); 198 | if (t) { 199 | var counter = 0; 200 | (function(){ 201 | if (typeof t.GetVariable != UNDEF) { 202 | var d = t.GetVariable("$version"); 203 | if (d) { 204 | d = d.split(" ")[1].split(","); 205 | ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]; 206 | } 207 | } 208 | else if (counter < 10) { 209 | counter++; 210 | setTimeout(arguments.callee, 10); 211 | return; 212 | } 213 | b.removeChild(o); 214 | t = null; 215 | matchVersions(); 216 | })(); 217 | } 218 | else { 219 | matchVersions(); 220 | } 221 | } 222 | 223 | /* Perform Flash Player and SWF version matching; static publishing only 224 | */ 225 | function matchVersions() { 226 | var rl = regObjArr.length; 227 | if (rl > 0) { 228 | for (var i = 0; i < rl; i++) { // for each registered object element 229 | var id = regObjArr[i].id; 230 | var cb = regObjArr[i].callbackFn; 231 | var cbObj = {success:false, id:id}; 232 | if (ua.pv[0] > 0) { 233 | var obj = getElementById(id); 234 | if (obj) { 235 | if (hasPlayerVersion(regObjArr[i].swfVersion) && !(ua.wk && ua.wk < 312)) { // Flash Player version >= published SWF version: Houston, we have a match! 236 | setVisibility(id, true); 237 | if (cb) { 238 | cbObj.success = true; 239 | cbObj.ref = getObjectById(id); 240 | cb(cbObj); 241 | } 242 | } 243 | else if (regObjArr[i].expressInstall && canExpressInstall()) { // show the Adobe Express Install dialog if set by the web page author and if supported 244 | var att = {}; 245 | att.data = regObjArr[i].expressInstall; 246 | att.width = obj.getAttribute("width") || "0"; 247 | att.height = obj.getAttribute("height") || "0"; 248 | if (obj.getAttribute("class")) { att.styleclass = obj.getAttribute("class"); } 249 | if (obj.getAttribute("align")) { att.align = obj.getAttribute("align"); } 250 | // parse HTML object param element's name-value pairs 251 | var par = {}; 252 | var p = obj.getElementsByTagName("param"); 253 | var pl = p.length; 254 | for (var j = 0; j < pl; j++) { 255 | if (p[j].getAttribute("name").toLowerCase() != "movie") { 256 | par[p[j].getAttribute("name")] = p[j].getAttribute("value"); 257 | } 258 | } 259 | showExpressInstall(att, par, id, cb); 260 | } 261 | else { // Flash Player and SWF version mismatch or an older Webkit engine that ignores the HTML object element's nested param elements: display alternative content instead of SWF 262 | displayAltContent(obj); 263 | if (cb) { cb(cbObj); } 264 | } 265 | } 266 | } 267 | else { // if no Flash Player is installed or the fp version cannot be detected we let the HTML object element do its job (either show a SWF or alternative content) 268 | setVisibility(id, true); 269 | if (cb) { 270 | var o = getObjectById(id); // test whether there is an HTML object element or not 271 | if (o && typeof o.SetVariable != UNDEF) { 272 | cbObj.success = true; 273 | cbObj.ref = o; 274 | } 275 | cb(cbObj); 276 | } 277 | } 278 | } 279 | } 280 | } 281 | 282 | function getObjectById(objectIdStr) { 283 | var r = null; 284 | var o = getElementById(objectIdStr); 285 | if (o && o.nodeName == "OBJECT") { 286 | if (typeof o.SetVariable != UNDEF) { 287 | r = o; 288 | } 289 | else { 290 | var n = o.getElementsByTagName(OBJECT)[0]; 291 | if (n) { 292 | r = n; 293 | } 294 | } 295 | } 296 | return r; 297 | } 298 | 299 | /* Requirements for Adobe Express Install 300 | - only one instance can be active at a time 301 | - fp 6.0.65 or higher 302 | - Win/Mac OS only 303 | - no Webkit engines older than version 312 304 | */ 305 | function canExpressInstall() { 306 | return !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac) && !(ua.wk && ua.wk < 312); 307 | } 308 | 309 | /* Show the Adobe Express Install dialog 310 | - Reference: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75 311 | */ 312 | function showExpressInstall(att, par, replaceElemIdStr, callbackFn) { 313 | isExpressInstallActive = true; 314 | storedCallbackFn = callbackFn || null; 315 | storedCallbackObj = {success:false, id:replaceElemIdStr}; 316 | var obj = getElementById(replaceElemIdStr); 317 | if (obj) { 318 | if (obj.nodeName == "OBJECT") { // static publishing 319 | storedAltContent = abstractAltContent(obj); 320 | storedAltContentId = null; 321 | } 322 | else { // dynamic publishing 323 | storedAltContent = obj; 324 | storedAltContentId = replaceElemIdStr; 325 | } 326 | att.id = EXPRESS_INSTALL_ID; 327 | if (typeof att.width == UNDEF || (!/%$/.test(att.width) && parseInt(att.width, 10) < 310)) { att.width = "310"; } 328 | if (typeof att.height == UNDEF || (!/%$/.test(att.height) && parseInt(att.height, 10) < 137)) { att.height = "137"; } 329 | doc.title = doc.title.slice(0, 47) + " - Flash Player Installation"; 330 | var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn", 331 | fv = "MMredirectURL=" + encodeURI(window.location).toString().replace(/&/g,"%26") + "&MMplayerType=" + pt + "&MMdoctitle=" + doc.title; 332 | if (typeof par.flashvars != UNDEF) { 333 | par.flashvars += "&" + fv; 334 | } 335 | else { 336 | par.flashvars = fv; 337 | } 338 | // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it, 339 | // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work 340 | if (ua.ie && ua.win && obj.readyState != 4) { 341 | var newObj = createElement("div"); 342 | replaceElemIdStr += "SWFObjectNew"; 343 | newObj.setAttribute("id", replaceElemIdStr); 344 | obj.parentNode.insertBefore(newObj, obj); // insert placeholder div that will be replaced by the object element that loads expressinstall.swf 345 | obj.style.display = "none"; 346 | (function(){ 347 | if (obj.readyState == 4) { 348 | obj.parentNode.removeChild(obj); 349 | } 350 | else { 351 | setTimeout(arguments.callee, 10); 352 | } 353 | })(); 354 | } 355 | createSWF(att, par, replaceElemIdStr); 356 | } 357 | } 358 | 359 | /* Functions to abstract and display alternative content 360 | */ 361 | function displayAltContent(obj) { 362 | if (ua.ie && ua.win && obj.readyState != 4) { 363 | // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it, 364 | // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work 365 | var el = createElement("div"); 366 | obj.parentNode.insertBefore(el, obj); // insert placeholder div that will be replaced by the alternative content 367 | el.parentNode.replaceChild(abstractAltContent(obj), el); 368 | obj.style.display = "none"; 369 | (function(){ 370 | if (obj.readyState == 4) { 371 | obj.parentNode.removeChild(obj); 372 | } 373 | else { 374 | setTimeout(arguments.callee, 10); 375 | } 376 | })(); 377 | } 378 | else { 379 | obj.parentNode.replaceChild(abstractAltContent(obj), obj); 380 | } 381 | } 382 | 383 | function abstractAltContent(obj) { 384 | var ac = createElement("div"); 385 | if (ua.win && ua.ie) { 386 | ac.innerHTML = obj.innerHTML; 387 | } 388 | else { 389 | var nestedObj = obj.getElementsByTagName(OBJECT)[0]; 390 | if (nestedObj) { 391 | var c = nestedObj.childNodes; 392 | if (c) { 393 | var cl = c.length; 394 | for (var i = 0; i < cl; i++) { 395 | if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) { 396 | ac.appendChild(c[i].cloneNode(true)); 397 | } 398 | } 399 | } 400 | } 401 | } 402 | return ac; 403 | } 404 | 405 | /* Cross-browser dynamic SWF creation 406 | */ 407 | function createSWF(attObj, parObj, id) { 408 | var r, el = getElementById(id); 409 | if (ua.wk && ua.wk < 312) { return r; } 410 | if (el) { 411 | if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content 412 | attObj.id = id; 413 | } 414 | if (ua.ie && ua.win) { // Internet Explorer + the HTML object element + W3C DOM methods do not combine: fall back to outerHTML 415 | var att = ""; 416 | for (var i in attObj) { 417 | if (attObj[i] != Object.prototype[i]) { // filter out prototype additions from other potential libraries 418 | if (i.toLowerCase() == "data") { 419 | parObj.movie = attObj[i]; 420 | } 421 | else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword 422 | att += ' class="' + attObj[i] + '"'; 423 | } 424 | else if (i.toLowerCase() != "classid") { 425 | att += ' ' + i + '="' + attObj[i] + '"'; 426 | } 427 | } 428 | } 429 | var par = ""; 430 | for (var j in parObj) { 431 | if (parObj[j] != Object.prototype[j]) { // filter out prototype additions from other potential libraries 432 | par += ''; 433 | } 434 | } 435 | el.outerHTML = '' + par + ''; 436 | objIdArr[objIdArr.length] = attObj.id; // stored to fix object 'leaks' on unload (dynamic publishing only) 437 | r = getElementById(attObj.id); 438 | } 439 | else { // well-behaving browsers 440 | var o = createElement(OBJECT); 441 | o.setAttribute("type", FLASH_MIME_TYPE); 442 | for (var m in attObj) { 443 | if (attObj[m] != Object.prototype[m]) { // filter out prototype additions from other potential libraries 444 | if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword 445 | o.setAttribute("class", attObj[m]); 446 | } 447 | else if (m.toLowerCase() != "classid") { // filter out IE specific attribute 448 | o.setAttribute(m, attObj[m]); 449 | } 450 | } 451 | } 452 | for (var n in parObj) { 453 | if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") { // filter out prototype additions from other potential libraries and IE specific param element 454 | createObjParam(o, n, parObj[n]); 455 | } 456 | } 457 | el.parentNode.replaceChild(o, el); 458 | r = o; 459 | } 460 | } 461 | return r; 462 | } 463 | 464 | function createObjParam(el, pName, pValue) { 465 | var p = createElement("param"); 466 | p.setAttribute("name", pName); 467 | p.setAttribute("value", pValue); 468 | el.appendChild(p); 469 | } 470 | 471 | /* Cross-browser SWF removal 472 | - Especially needed to safely and completely remove a SWF in Internet Explorer 473 | */ 474 | function removeSWF(id) { 475 | var obj = getElementById(id); 476 | if (obj && obj.nodeName == "OBJECT") { 477 | if (ua.ie && ua.win) { 478 | obj.style.display = "none"; 479 | (function(){ 480 | if (obj.readyState == 4) { 481 | removeObjectInIE(id); 482 | } 483 | else { 484 | setTimeout(arguments.callee, 10); 485 | } 486 | })(); 487 | } 488 | else { 489 | obj.parentNode.removeChild(obj); 490 | } 491 | } 492 | } 493 | 494 | function removeObjectInIE(id) { 495 | var obj = getElementById(id); 496 | if (obj) { 497 | for (var i in obj) { 498 | if (typeof obj[i] == "function") { 499 | obj[i] = null; 500 | } 501 | } 502 | obj.parentNode.removeChild(obj); 503 | } 504 | } 505 | 506 | /* Functions to optimize JavaScript compression 507 | */ 508 | function getElementById(id) { 509 | var el = null; 510 | try { 511 | el = doc.getElementById(id); 512 | } 513 | catch (e) {} 514 | return el; 515 | } 516 | 517 | function createElement(el) { 518 | return doc.createElement(el); 519 | } 520 | 521 | /* Updated attachEvent function for Internet Explorer 522 | - Stores attachEvent information in an Array, so on unload the detachEvent functions can be called to avoid memory leaks 523 | */ 524 | function addListener(target, eventType, fn) { 525 | target.attachEvent(eventType, fn); 526 | listenersArr[listenersArr.length] = [target, eventType, fn]; 527 | } 528 | 529 | /* Flash Player and SWF content version matching 530 | */ 531 | function hasPlayerVersion(rv) { 532 | var pv = ua.pv, v = rv.split("."); 533 | v[0] = parseInt(v[0], 10); 534 | v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0" 535 | v[2] = parseInt(v[2], 10) || 0; 536 | return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false; 537 | } 538 | 539 | /* Cross-browser dynamic CSS creation 540 | - Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php 541 | */ 542 | function createCSS(sel, decl, media, newStyle) { 543 | if (ua.ie && ua.mac) { return; } 544 | var h = doc.getElementsByTagName("head")[0]; 545 | if (!h) { return; } // to also support badly authored HTML pages that lack a head element 546 | var m = (media && typeof media == "string") ? media : "screen"; 547 | if (newStyle) { 548 | dynamicStylesheet = null; 549 | dynamicStylesheetMedia = null; 550 | } 551 | if (!dynamicStylesheet || dynamicStylesheetMedia != m) { 552 | // create dynamic stylesheet + get a global reference to it 553 | var s = createElement("style"); 554 | s.setAttribute("type", "text/css"); 555 | s.setAttribute("media", m); 556 | dynamicStylesheet = h.appendChild(s); 557 | if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) { 558 | dynamicStylesheet = doc.styleSheets[doc.styleSheets.length - 1]; 559 | } 560 | dynamicStylesheetMedia = m; 561 | } 562 | // add style rule 563 | if (ua.ie && ua.win) { 564 | if (dynamicStylesheet && typeof dynamicStylesheet.addRule == OBJECT) { 565 | dynamicStylesheet.addRule(sel, decl); 566 | } 567 | } 568 | else { 569 | if (dynamicStylesheet && typeof doc.createTextNode != UNDEF) { 570 | dynamicStylesheet.appendChild(doc.createTextNode(sel + " {" + decl + "}")); 571 | } 572 | } 573 | } 574 | 575 | function setVisibility(id, isVisible) { 576 | if (!autoHideShow) { return; } 577 | var v = isVisible ? "visible" : "hidden"; 578 | if (isDomLoaded && getElementById(id)) { 579 | getElementById(id).style.visibility = v; 580 | } 581 | else { 582 | createCSS("#" + id, "visibility:" + v); 583 | } 584 | } 585 | 586 | /* Filter to avoid XSS attacks 587 | */ 588 | function urlEncodeIfNecessary(s) { 589 | var regex = /[\\\"<>\.;]/; 590 | var hasBadChars = regex.exec(s) != null; 591 | return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s; 592 | } 593 | 594 | /* Release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/NetConnections to disconnect (Internet Explorer only) 595 | */ 596 | var cleanup = function() { 597 | if (ua.ie && ua.win) { 598 | window.attachEvent("onunload", function() { 599 | // remove listeners to avoid memory leaks 600 | var ll = listenersArr.length; 601 | for (var i = 0; i < ll; i++) { 602 | listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]); 603 | } 604 | // cleanup dynamically embedded objects to fix audio/video threads and force open sockets and NetConnections to disconnect 605 | var il = objIdArr.length; 606 | for (var j = 0; j < il; j++) { 607 | removeSWF(objIdArr[j]); 608 | } 609 | // cleanup library's main closures to avoid memory leaks 610 | for (var k in ua) { 611 | ua[k] = null; 612 | } 613 | ua = null; 614 | for (var l in swfobject) { 615 | swfobject[l] = null; 616 | } 617 | swfobject = null; 618 | }); 619 | } 620 | }(); 621 | 622 | return { 623 | /* Public API 624 | - Reference: http://code.google.com/p/swfobject/wiki/documentation 625 | */ 626 | registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr, callbackFn) { 627 | if (ua.w3 && objectIdStr && swfVersionStr) { 628 | var regObj = {}; 629 | regObj.id = objectIdStr; 630 | regObj.swfVersion = swfVersionStr; 631 | regObj.expressInstall = xiSwfUrlStr; 632 | regObj.callbackFn = callbackFn; 633 | regObjArr[regObjArr.length] = regObj; 634 | setVisibility(objectIdStr, false); 635 | } 636 | else if (callbackFn) { 637 | callbackFn({success:false, id:objectIdStr}); 638 | } 639 | }, 640 | 641 | getObjectById: function(objectIdStr) { 642 | if (ua.w3) { 643 | return getObjectById(objectIdStr); 644 | } 645 | }, 646 | 647 | embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) { 648 | var callbackObj = {success:false, id:replaceElemIdStr}; 649 | if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) { 650 | setVisibility(replaceElemIdStr, false); 651 | addDomLoadEvent(function() { 652 | widthStr += ""; // auto-convert to string 653 | heightStr += ""; 654 | var att = {}; 655 | if (attObj && typeof attObj === OBJECT) { 656 | for (var i in attObj) { // copy object to avoid the use of references, because web authors often reuse attObj for multiple SWFs 657 | att[i] = attObj[i]; 658 | } 659 | } 660 | att.data = swfUrlStr; 661 | att.width = widthStr; 662 | att.height = heightStr; 663 | var par = {}; 664 | if (parObj && typeof parObj === OBJECT) { 665 | for (var j in parObj) { // copy object to avoid the use of references, because web authors often reuse parObj for multiple SWFs 666 | par[j] = parObj[j]; 667 | } 668 | } 669 | if (flashvarsObj && typeof flashvarsObj === OBJECT) { 670 | for (var k in flashvarsObj) { // copy object to avoid the use of references, because web authors often reuse flashvarsObj for multiple SWFs 671 | if (typeof par.flashvars != UNDEF) { 672 | par.flashvars += "&" + k + "=" + flashvarsObj[k]; 673 | } 674 | else { 675 | par.flashvars = k + "=" + flashvarsObj[k]; 676 | } 677 | } 678 | } 679 | if (hasPlayerVersion(swfVersionStr)) { // create SWF 680 | var obj = createSWF(att, par, replaceElemIdStr); 681 | if (att.id == replaceElemIdStr) { 682 | setVisibility(replaceElemIdStr, true); 683 | } 684 | callbackObj.success = true; 685 | callbackObj.ref = obj; 686 | } 687 | else if (xiSwfUrlStr && canExpressInstall()) { // show Adobe Express Install 688 | att.data = xiSwfUrlStr; 689 | showExpressInstall(att, par, replaceElemIdStr, callbackFn); 690 | return; 691 | } 692 | else { // show alternative content 693 | setVisibility(replaceElemIdStr, true); 694 | } 695 | if (callbackFn) { callbackFn(callbackObj); } 696 | }); 697 | } 698 | else if (callbackFn) { callbackFn(callbackObj); } 699 | }, 700 | 701 | switchOffAutoHideShow: function() { 702 | autoHideShow = false; 703 | }, 704 | 705 | ua: ua, 706 | 707 | getFlashPlayerVersion: function() { 708 | return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] }; 709 | }, 710 | 711 | hasFlashPlayerVersion: hasPlayerVersion, 712 | 713 | createSWF: function(attObj, parObj, replaceElemIdStr) { 714 | if (ua.w3) { 715 | return createSWF(attObj, parObj, replaceElemIdStr); 716 | } 717 | else { 718 | return undefined; 719 | } 720 | }, 721 | 722 | showExpressInstall: function(att, par, replaceElemIdStr, callbackFn) { 723 | if (ua.w3 && canExpressInstall()) { 724 | showExpressInstall(att, par, replaceElemIdStr, callbackFn); 725 | } 726 | }, 727 | 728 | removeSWF: function(objElemIdStr) { 729 | if (ua.w3) { 730 | removeSWF(objElemIdStr); 731 | } 732 | }, 733 | 734 | createCSS: function(selStr, declStr, mediaStr, newStyleBoolean) { 735 | if (ua.w3) { 736 | createCSS(selStr, declStr, mediaStr, newStyleBoolean); 737 | } 738 | }, 739 | 740 | addDomLoadEvent: addDomLoadEvent, 741 | 742 | addLoadEvent: addLoadEvent, 743 | 744 | getQueryParamValue: function(param) { 745 | var q = doc.location.search || doc.location.hash; 746 | if (q) { 747 | if (/\?/.test(q)) { q = q.split("?")[1]; } // strip question mark 748 | if (param == null) { 749 | return urlEncodeIfNecessary(q); 750 | } 751 | var pairs = q.split("&"); 752 | for (var i = 0; i < pairs.length; i++) { 753 | if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) { 754 | return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=") + 1))); 755 | } 756 | } 757 | } 758 | return ""; 759 | }, 760 | 761 | // For internal usage only 762 | expressInstallCallback: function() { 763 | if (isExpressInstallActive) { 764 | var obj = getElementById(EXPRESS_INSTALL_ID); 765 | if (obj && storedAltContent) { 766 | obj.parentNode.replaceChild(storedAltContent, obj); 767 | if (storedAltContentId) { 768 | setVisibility(storedAltContentId, true); 769 | if (ua.ie && ua.win) { storedAltContent.style.display = "block"; } 770 | } 771 | if (storedCallbackFn) { storedCallbackFn(storedCallbackObj); } 772 | } 773 | isExpressInstallActive = false; 774 | } 775 | } 776 | }; 777 | }(); 778 | --------------------------------------------------------------------------------