Giter VIP home page Giter VIP logo

Comments (6)

hatemhosny avatar hatemhosny commented on May 18, 2024 1

this is now fixed by #345 and should be available in next release
you may test it here: https://dev.livecodes.io

this code should now work as expected:

<div id="livecodes-qlbo5jm6qm">
  <span>Open the project <a href="https://livecodes.io/?x=id/tse96fdpgz4" target="_blank">Untitled Project</a> in <a href="https://livecodes.io/" target="_blank">LiveCodes</a></span>
</div>

<script src="https://livecodes.io/sdk/livecodes.umd.js"></script>
<script>
const options = {
  appUrl: 'https://dev.livecodes.io/',
  params: {
    languages: "pyodide",
    autoupdate: false,
    console: "full",
  },
  import: "id/tse96fdpgz4",
  loading: "eager",
};
livecodes.createPlayground("#livecodes-qlbo5jm6qm", options);
</script>

open in LiveCodes

@moonpiedumplings please let me know if that solves your problem.

from livecodes.

hatemhosny avatar hatemhosny commented on May 18, 2024

hi @moonpiedumplings ,

your imported project (id/tse96fdpgz4) already provides the configuration object, so your config settings are overridden.
To override project config, use params

<div id="livecodes-qlbo5jm6qm">
  <span>Open the project <a href="https://livecodes.io/?x=id/tse96fdpgz4" target="_blank">Untitled Project</a> in <a href="https://livecodes.io/" target="_blank">LiveCodes</a></span>
</div>

<script src="https://livecodes.io/sdk/livecodes.umd.js"></script>
<script>
const options = {
  params: {
    languages: "pyodide",
    autoupdate: false,
    preview: false,
    console: "full",
  },
  import: "id/tse96fdpgz4",
  loading: "click",
};
livecodes.createPlayground("#livecodes-qlbo5jm6qm", options);
</script>

The result always runs when the playground is first loaded. autoupdate determines what happens when the code changes. If you do not want to run the playground, you may use the embed option loading: "click".

The params.preview option allows showing a faded preview of the html page behind the "click to load" screen. However, the script will still run before loading the playground. To prevent that, set it to false.

console: "full" is what you are asking for.

from livecodes.

hatemhosny avatar hatemhosny commented on May 18, 2024

I probably need to add a config option autorun to determine if the result page should run when the playground first loads.

also, the preview option needs to be documented

from livecodes.

hatemhosny avatar hatemhosny commented on May 18, 2024

I probably need to add a config option autorun to determine if the result page should run when the playground first loads.

on a second thought, if autoupdate is set to false the result page should not run, even when playground first loads.
this will prevent the confusion of having 2 similar options with different meanings.

to handle the scenario of wanting to run the page once when the playground loads:

import { createPlayground } from 'livecodes';

const options = {
  params: { autoupdate: false },
  // other embed options
};
createPlayground("#container", options).then(playground => {
  playground.run();
});

this is being addressed in #345 and should be available in next release

@moonpiedumplings thank you for reporting

from livecodes.

hatemhosny avatar hatemhosny commented on May 18, 2024

The params.preview option allows showing a faded preview of the html page behind the "click to load" screen. However, the script will still run before loading the playground. To prevent that, set it to false.

it is probably also not a good idea to have the preview page run by default, specially if the page sends alerts or starts sounds, etc.

from livecodes.

hatemhosny avatar hatemhosny commented on May 18, 2024

@moonpiedumplings I will close this as fixed.

If you still have a problem with this issue please feel free to re-open it.

from livecodes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.