The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
3 posters

    javascript

    Rishikesh Anand
    Rishikesh Anand
    New Member


    Posts : 9
    Reputation : 1
    Language : english

    In progress javascript

    Post by Rishikesh Anand August 15th 2015, 12:15 am

    Technical Details


    Forum version : #PunBB
    Position : Founder
    Concerned browser(s) : Mozilla Firefox
    Who the problem concerns : Yourself
    Forum link : http://brevbeta.forumotion.pro

    Description of problem

    so here i uploaded some scripts ; and i wanna use them but i only know rendering them using HTML
    so can anyone help me?
    brandon_g
    brandon_g
    Manager
    Manager


    Male Posts : 10113
    Reputation : 923
    Language : English
    Location : USA

    In progress Re: javascript

    Post by brandon_g August 15th 2015, 12:18 am

    Hello,


    What is your problem/issue? Do you need help with a javascript , an html code? What exactly is your issue, may you provide descriptive details of the issue. Maybe a screenshot can help us better understand.


    -Brandon
    Rishikesh Anand
    Rishikesh Anand
    New Member


    Posts : 9
    Reputation : 1
    Language : english

    In progress Re: javascript

    Post by Rishikesh Anand August 15th 2015, 1:20 am

    ok so here is
    1. how it appears
    http://brevbeta.forumotion.pro/h3-gba
    2.how it should be.
    javascript Capture
    3. the code on the web
    Code:
    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title>GBA</title>

    <style>

    body {
       background: url('http://s17.postimg.org/4siw41ntb/image.png') no-repeat top center, -webkit-linear-gradient(#765490 560px, #6A4883 620px, #433061 900px);
       background: url('http://s17.postimg.org/4siw41ntb/image.png') no-repeat top center, -moz-linear-gradient(#765490 560px, #6A4883 620px, #433061 900px, #433061);
       text-align: center;
       margin: 0 0 15px;
       color: white;
       font-family: 'Calibri', 'Verdana', sans-serif;
       font-size: 15px;
       text-shadow: 0 2px rgba(0, 0, 0, 0.6);
    }

    button {
       font-family: 'Calibri', 'Verdana', sans-serif;
    }

    #screen {
       margin-top: 85px;
       margin-bottom: 150px;
    }

    #screen[width="240"] {
       margin-top: 42.5px;
       margin-bottom: -363px; /* Take up no height */
       image-rendering: -webkit-optimize-contrast;
       image-rendering: -moz-crisp-edges;
       image-rendering: -o-crisp-edges;
       zoom: 2;
       -o-transform: scale(2);
    }

    #controls::before {
       content: "";
       display: block;
       height: 30px;
       width: 647px;
       border-radius: 5px / 15px;
       border: 1px solid rgba(0, 0, 0, 0.4);
       border-width: 0 1px;
       margin: 0 -5px 20px;
       background: -webkit-linear-gradient(top, #8769A0, #9578B9 15%, #6A4883 50%, #433061);
       background: -moz-linear-gradient(top, #8769A0, #9578B9 15%, #6A4883 50%, #433061);
       box-shadow: 0 5px 4px -3px rgba(0, 0, 0, 0.6);
       position: absolute;
    }

    #controls {
       border-radius: 20px;
       border: 1px solid rgba(0, 0, 0, 0.4);
       border-top: none;
       box-shadow: 0 4px 4px -2px rgba(0, 0, 0, 0.9), 0 -40px 2px -1px #433061 inset;
       width: 640px;
       margin: auto;
       height: 200px;
       overflow: hidden;
       background-color: #765490;
    }

    #controls > div {
       margin-top: 30px;
       -moz-transform-origin: 50% 0;
       -moz-transform: rotateX(0deg);
       -moz-transition: -moz-transform linear 0.5s;
       -webkit-transform-origin-y: 2px;
       -webkit-transform: rotateX(0deg);
       -webkit-transition: -webkit-transform linear 0.5s;
    }

    #crash {
       margin-top: 100px;
       margin-bottom: 199px;
    }

    button {
       background-color: #6A4883;
       font-weight: bold;
       font-size: 18px;
       color: white;
       text-shadow: 0 3px #433061;
       padding: 2px 10px 5px;
       border-radius: 0 0 10px 10px;
       border: 0 solid rgba(0, 0, 0, 0.4);
       border-width: 3px 1px 0px;
       display: inline;
       box-shadow: 0 2px 6px -1px rgba(0, 0, 0, 0.2) inset;
       margin: 0 0 20px;
    }

    label, #sound, #controls > div > p {
       display: block;
       margin: 5px 30px;
       height: 18px;
    }

    label, #sound {
       float: left;
       clear: left;
    }

    #sound + p {
       margin-top: -23px !important;
    }

    #controls > div > p {
       float: right;
       clear: right;
    }

    input[type=checkbox] {
       margin: -3px 5px 0 0;
    }

    input[type=checkbox]::after {
       display: inline-block;
       content: "";
       background-color: #765490;
       border: 0 solid rgba(0, 0, 0, 0.3);
       border-width: 1px 1px 2px;
       width: 12px;
       height: 12px;
       border-radius: 3px;
       position: relative;
       top: -3px;
       visibility: visible;
    }

    input[type=checkbox]:checked::after {
       background-color: #6A4883;
       border-width: 2px 1px 1px;
       box-shadow: 0 2px 6px -1px rgba(0, 0, 0, 0.2) inset;
    }

    p:first-child {
       margin-top: 0;
    }

    a:link, a:visited {
       color: #fcb3f0;
    }

    .hidden {
       -moz-transform: rotateX(90deg) !important;
       -webkit-transform: rotateX(90deg) !important;
    }

    .dead {
       display: none;
    }

    input[type=file] {
       opacity: 0 !important;
       width: 0;
       height: 0;
       margin: 0;
       padding: 0;
       border: none;
    }

    input[type=range] {
       width: 100px;
       height: 14px;
       margin: 2px;
    }

    footer {
       font-size: 12px;
       padding-top: 8px;
    }

    p {
       margin: 0;
    }

    label p, #sound p {
       display: inline;
    }

    ul#links {
       display: block;
       text-align: center;
       padding: 0;
    }

    ul#links li {
       display: inline;
       list-style-type: none;
    }

    ul#links li:not(:first-child)::before {
       content: "•";
       margin: 0 0.5em;
    }

    </style>
    <script src="http://brevbeta.forumotion.pro/23271.js">
    </script>

    <script src="http://brevbeta.forumotion.pro/13349.js">
    </script>

    <script src="http://brevbeta.forumotion.pro/11098.js">
    </script>

    <script src="http://brevbeta.forumotion.pro/22961.js">
    </script>

    <script src="http://brevbeta.forumotion.pro/19762.js">
    </script>

    <script src="http://brevbeta.forumotion.pro/16584.js">
    </script>

    <script src="http://brevbeta.forumotion.pro/12137.js">
    </script>

    <script src="http://brevbeta.forumotion.pro/24256.js">
    </script>

    <script src="http://brevbeta.forumotion.pro/25320.js">
    </script>

    <script src="http://brevbeta.forumotion.pro/26355.js">
    </script>

    <script src="http://brevbeta.forumotion.pro/17652.js">
    </script>

    <script src="http://brevbeta.forumotion.pro/18684.js">
    </script>

    <script src="http://brevbeta.forumotion.pro/21928.js">
    </script>

    <script src="http://brevbeta.forumotion.pro/20805.js">
    </script>

    <script src="http://brevbeta.forumotion.pro/15549.js">
    </script>
    <script src="http://brevbeta.forumotion.pro/14400.js">
    </script>

    <script src="http://brevbeta.forumotion.pro/28439.js">
    </script>


    <script>
    var gba;
    var runCommands = [];
    var debug = null;

    try {
       gba = new GameBoyAdvance();
       gba.keypad.eatInput = true;
       gba.setLogger(function(level, error) {
          console.log(error);
          gba.pause();
          var screen = document.getElementById('screen');
          if (screen.getAttribute('class') == 'dead') {
             console.log('We appear to have crashed multiple times without reseting.');
             return;
          }
          var crash = document.createElement('img');
          crash.setAttribute('id', 'crash');
          crash.setAttribute('src', 'http://s17.postimg.org/rspjgdln3/crash.png');
          screen.parentElement.insertBefore(crash, screen);
          screen.setAttribute('class', 'dead');
       });
    } catch (exception) {
       gba = null;
    }

    window.onload = function() {
       if (gba && FileReader) {
          var canvas = document.getElementById('screen');
          gba.setCanvas(canvas);

          gba.logLevel = gba.LOG_ERROR;

          loadRom('resources/bios.bin', function(bios) {
             gba.setBios(bios);
          });

          if (!gba.audio.context) {
             // Remove the sound box if sound isn't available
             var soundbox = document.getElementById('sound');
             soundbox.parentElement.removeChild(soundbox);
          }

          if (window.navigator.appName == 'Microsoft Internet Explorer') {
             // Remove the pixelated option if it doesn't work
             var pixelatedBox = document.getElementById('pixelated');
             pixelatedBox.parentElement.removeChild(pixelatedBox);
          }
       } else {
          var dead = document.getElementById('controls');
          dead.parentElement.removeChild(dead);
       }
    }

    function fadeOut(id, nextId, kill) {
       var e = document.getElementById(id);
       var e2 = document.getElementById(nextId);
       if (!e) {
          return;
       }
       var removeSelf = function() {
          if (kill) {
             e.parentElement.removeChild(e);
          } else {
             e.setAttribute('class', 'dead');
             e.removeEventListener('webkitTransitionEnd', removeSelf);
             e.removeEventListener('oTransitionEnd', removeSelf);
             e.removeEventListener('transitionend', removeSelf);
          }
          if (e2) {
             e2.setAttribute('class', 'hidden');
             setTimeout(function() {
                e2.removeAttribute('class');
             }, 0);
          }
       }

       e.addEventListener('webkitTransitionEnd', removeSelf, false);
       e.addEventListener('oTransitionEnd', removeSelf, false);
       e.addEventListener('transitionend', removeSelf, false);
       e.setAttribute('class', 'hidden');
    }

    function run(file) {
       var dead = document.getElementById('loader');
       dead.value = '';
       var load = document.getElementById('select');
       load.textContent = 'Loading...';
       load.removeAttribute('onclick');
       var pause = document.getElementById('pause');
       pause.textContent = "PAUSE";
       gba.loadRomFromFile(file, function(result) {
          if (result) {
             for (var i = 0; i < runCommands.length; ++i) {
                runCommands[i]();
             }
             runCommands = [];
             fadeOut('preload', 'ingame');
             fadeOut('instructions', null, true);
             gba.runStable();
          } else {
             load.textContent = 'FAILED';
             setTimeout(function() {
                load.textContent = 'SELECT';
                load.onclick = function() {
                   
    document.getElementById('loader').click();
                
    }
             
    }, 3000);
          
    }
       
    });
    }


    function reset()
    {
       gba.pause();
       gba.reset();
       var load = document.getElementById('select');
       load.textContent = 'SELECT';
       var crash = document.getElementById('crash');
       
    if (crash)
     {
          var context = gba.targetCanvas.getContext('2d');
          context.clearRect(0, 0, 480, 320);
          gba.video.drawCallback();
          crash.parentElement.removeChild(crash);
          var canvas = document.getElementById('screen');
          canvas.removeAttribute('class');
       }
    else
    {
          lcdFade(gba.context, gba.targetCanvas.getContext('2d'), gba.video.drawCallback);
       
    }
       
    load.onclick = function()
    {
          document.getElementById('loader').click();
       
    }
       
    fadeOut('ingame', 'preload');
    }

    function uploadSavedataPending(file)
    {
       runCommands.push(function()
    { gba.loadSavedataFromFile(file) });
    }


    function togglePause()
    {
       var e = document.getElementById('pause');
       
    if (gba.paused)
    {
          if (debug && debug.gbaCon)
    {
             debug.gbaCon.run();
          }
     else
    {
             gba.runStable();
          }
          
    e.textContent = "PAUSE";
       }
     else
     {
          
    if (debug && debug.gbaCon)
    {
             debug.gbaCon.pause();
          }
     else
     {
             gba.pause();
          }
          
    e.textContent = "UNPAUSE";
       }
    }


    function screenshot()
    {
       var canvas = gba.indirectCanvas;
       window.open(canvas.toDataURL('image/png'), 'screenshot');
    }


    function lcdFade(context, target, callback)
    {
       var i = 0;
       var drawInterval = setInterval(function()
    {
          i++;
          var pixelData = context.getImageData(0, 0, 240, 160);
          for (var y = 0; y < 160; ++y)
    {
             for (var x = 0; x < 240; ++x)
    {
                var xDiff = Math.abs(x - 120);
                var yDiff = Math.abs(y - 80) * 0.8;
                var xFactor = (120 - i - xDiff) / 120;
                var yFactor = (80 - i - ((y & 1) * 10) - yDiff + Math.pow(xDiff, 1 / 2)) / 80;
                pixelData.data[(x + y * 240) * 4 + 3] *= Math.pow(xFactor, 1 / 3) * Math.pow(yFactor, 1 / 2);
             }
          }
          context.putImageData(pixelData, 0, 0);
          target.clearRect(0, 0, 480, 320);
          if (i > 40) {
             clearInterval(drawInterval);
          } else {
             callback();
          }
       }, 50);
    }

    function setVolume(value) {
       gba.audio.masterVolume = Math.pow(2, value) - 1;
    }

    function setPixelated(pixelated) {
       var screen = document.getElementById('screen');
       var context = screen.getContext('2d');
       if (context.webkitImageSmoothingEnabled) {
          context.webkitImageSmoothingEnabled = !pixelated;
       } else if (context.mozImageSmoothingEnabled) {
          context.mozImageSmoothingEnabled = !pixelated;
       }
     else if (window.navigator.appName != 'Microsoft Internet Explorer')
    {
             if (pixelated)
    {
                screen.setAttribute('width', '240');
                screen.setAttribute('height', '160');
             } else {
                screen.setAttribute('width', '480');
                screen.setAttribute('height', '320');
             }
             if (window.navigator.appName == 'Opera') {
             // Ugly hack! Ew!
             if (pixelated) {
                screen.style.marginTop = '0';
                screen.style.marginBottom = '-325px';
             } else {
                delete screen.style;
             }
          }
       }
    }

    function enableDebug() {
       window.onmessage = function(message) {
          if (message.origin != document.domain && (message.origin != 'file://' || document.domain)) {
             console.log('Failed XSS');
             return;
          }
          switch (message.data) {
          case 'connect':
             if (message.source == debug) {
                debug.postMessage('connect', document.domain || '*');
             }
             break;
          case 'connected':
             break;
          case 'disconnect':
             if (message.source == debug) {
                debug = null;
             }
          }
       }
       window.onunload = function() {
          if (debug && debug.postMessage) {
             debug.postMessage('disconnect', document.domain || '*');
          }
       }
       if (!debug || !debug.postMessage)
    {
          debug = window.open('http://brevbeta.forumotion.pro/h2-debugger', 'debug');
       }
     else
    {
          debug.postMessage('connect', document.domain || '*');
       }
    }

    document.addEventListener('webkitfullscreenchange', function() {
       var canvas = document.getElementById('screen');
       if (document.webkitIsFullScreen) {
          canvas.setAttribute('height', document.body.offsetHeight);
          canvas.setAttribute('width', document.body.offsetHeight / 2 * 3);
          canvas.setAttribute('style', 'margin: 0');
       } else {
          canvas.setAttribute('height', 320);
          canvas.setAttribute('width', 480);
          canvas.removeAttribute('style');
       }
    }, false);

    </script>

    </head>

    <body>

    <canvas id="screen" width="480" height="320">
    </canvas>

    <section id="controls">
       
    <div id="preload">
          
    <button class="bigbutton" id="select" onclick="document.getElementById('loader').click()">SELECT</button>
          
    <input id="loader" type="file" accept=".gba" onchange="run(this.files[0]);">
          
    <button onclick="document.getElementById('saveloader').click()">Upload Savegame</button>
          
    <input id="saveloader" type="file" onchange="uploadSavedataPending(this.files[0]);">
       
    </div>
       
    <div id="ingame" class="hidden">
          
    <button id="pause" class="bigbutton" onclick="togglePause()">PAUSE</button>
          
    <button class="bigbutton" onclick="reset()">RESET</button>
          
    <button onclick="gba.downloadSavedata()">Download Savegame</button>
          
    <button onclick="screenshot()">Screenshot</button>
          
    <label id="pixelated">
             
    <input type="checkbox" onchange="setPixelated(this.checked)">
             
    <p>Pixelated</p>
          
    </label>
          
    <div id="sound">
             
    <input type="checkbox" checked onchange="gba.audio.masterEnable = this.checked">
             
    <p>Sound</p>
             
    <input type="range" min="0" max="1" value="1" step="any" onchange="setVolume(this.value)">
          
    </div>
          
    <p id="openDebug" onclick="enableDebug()">Debugger</p>
       
    </div>

    </section>


    </body>

    </html>
    4.the local
    here
    brandon_g
    brandon_g
    Manager
    Manager


    Male Posts : 10113
    Reputation : 923
    Language : English
    Location : USA

    In progress Re: javascript

    Post by brandon_g August 15th 2015, 2:46 am

    What does the script do? Where did you get it?


    -Brandon



    javascript Brando10
    Remember to mark your topic javascript Solved15 when a solution is found.
    General Rules | Tips & Tricks | FAQ | Forgot Founder Password?

    javascript Scre1476
    Team Leader
    Review Section Rules | Request A Review | Sticker Points
    Rishikesh Anand
    Rishikesh Anand
    New Member


    Posts : 9
    Reputation : 1
    Language : english

    In progress Re: javascript

    Post by Rishikesh Anand August 15th 2015, 8:01 am

    so this is gba emulator on the browser; with the java scripts from github
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    In progress Re: javascript

    Post by Ange Tuteur August 15th 2015, 11:05 am

    Hey,

    Here's your problem :
    javascript Captur75

    When you install JS via JS codes management you must make sure that you place semi-colons where necessary. You should do this, because the JS is automatically minified, and during this minification the smallest thing, such as a missing semi-colon, can cause an error.

    Semi-colons should usually be at the end of statements. For example,
    Code:
    var a = 1,
        b = a + 1;

    function newFunc() {
      return alert('Called');
    };

    a = Math.round(a / (a + b) * 100);

    With that many errors, I'm assuming a semi-colon or two must've been omitted. It's hard to tell, but the errors in the console say the file + line 1, column 1884 ( 1:1884 )

      Current date/time is September 22nd 2024, 9:25 pm