Skip to content

Use 'require' #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/easycoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
add_action('wp_enqueue_scripts', 'easycoder_enqueue_script', 2);
function easycoder_enqueue_script() {
wp_enqueue_script('easycoder_script', plugin_dir_url( __FILE__ )
. 'easycoder-min.js', array(), '2.5.6');
. 'easycoder-min.js', array(), '2.6.0');
}

// Set up default plugin and REST scripts
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>EasyCoder - coding made simple</title>
<link rel='stylesheet' href='resources/css/styles.css' type='text/css' media='all' />
<script type='text/javascript' src='easycoder/easycoder.js?ver=3.0.0'></script>
<script src='dist/easycoder.js?ver=2.6.0'></script>
</head>

<body>
Expand Down
4 changes: 2 additions & 2 deletions resources/codex/md/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ To deploy an ~ec~ script you need to embed it in a web page. The basic mechanism
## Plugins ##
The standard ~ec~ language includes a wide range of general-purpose programming constructs needed by any language; variables, values, conditionals, strings, numbers and so on. Everything else is provided by plugins. Some of these, notably browser features, JSON and REST, are loaded automatically (though this behavior can be changed if necessary) and several more are available as optional plugins. Plugins add commands to the language and must be loaded before any script that makes use of those keywords will compile.

The mechanism for requesting a plugin is very simple. Suppose you want to include a Google Map in your web page. You will need the ~code:gmap~ plugin, which is loaded like this:
The mechanism for requesting a plugin is very simple. Suppose you want to include a Google Map in your web page. You will need the ~code:gmap~ plugin, which is loaded like this, where the ~ec~ files are all in a top-level `easycoder` folder:

~pre:load plugin `gmap`~
~pre:require js `easycoder/plugins/gmap.js`~

In this example the plugin is a standard ~ec~ one but you can also load third-party plugins from any URL if you deal with CORS issues.

Expand Down
5 changes: 0 additions & 5 deletions resources/doc/core.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@
"description": "~m:index~ is a special command for array handling. In EasyCoder, all variables are arrays. Initially they only have one element but you can set an array to have as many elements as you like, using ~l:set!set the elements of {variable} to {value}~. Inside each array is the current index for the array, which you can set to any value within the number of elements in the array. The array is still used as if it were a simple variable and only the element pointed to by the index is affected by whatever you do with the array. Where multitasking is used - with ~l:fork~ or by handling an event - you must be careful to set the index before using the array if there~sq~s any chance it may have been modified by another part of the program.",
"examples": "index List to 5%0aput Result into List"
},
"load": {
"syntax": "load plugin {name}",
"description": "~m:load~ currently has just one purpose; to load an _**EasyCoder**_ plugin module prior to running a script that requires its functionality. Until the plugin is loaded, using any of its script commands will cause compilation errors. This feature of _**EasyCoder**_ avoids the need for all modules to be loaded up-front, which improves the start-up time. It also permits pages to use functionality in a dynamic manner, which can be important in the planning of large single-page websites.\n\nIn any instance of _**EasyCoder**_ there are 2 kinds of plugin. The first kind are loaded when _**EasyCoder**_ itself starts. These are globally-defined plugins that will be needed by every page of the website, such as _browser_ and (usually) _json_.\n\nThe second kind of plugin is loaded by a script so that it can be used by another script. Any number of scripts can be run, by loading the text of the script then calling ~l:run~. Scripts loaded and run in this way may need to employ plugins that were not defined globally, so these must be loaded before the script is run.\n\nNote that a script cannot load plugins for its own use. This would be an impossibility since each plugin contains the compiler for the extra commands it makes available.\n\n_**EasyCoder**_ includes a growing number of plugins, which are covered by this documentation. In addition, third-party plugins may also be available. It is relatively straightforward for any competent JavaScript programmer to write a custom plugin to provide features for a specific website page. The plugin can be hosted anywhere and is loaded by giving its URL.",
"examples": "load plugin `ckeditor`"
},
"negate": {
"syntax": "negate {variable}",
"description": "~mono:negate~ returns the value of the given variable subtracted from zero.",
Expand Down
4 changes: 2 additions & 2 deletions resources/ecs/about.ecs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
end

set ready
load plugin `codemirror`
require js `dist/plugins/codemirror.js`
stop

Start:
Expand All @@ -54,7 +54,7 @@ Start:
attach CodexButton to `about-codex`
on click CodexButton
begin
load plugin `codemirror`
require js `dist/plugins/codemirror.js`
rest get Codex from `/resources/ecs/codex`
send `hide` to parent
run Codex
Expand Down
4 changes: 2 additions & 2 deletions resources/ecs/codex.ecs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ L2:
! set Mobile
set ShowRun

load plugin `gmap`
load plugin `svg`
require js `dist/plugins/gmap.js`
require js `dist/plugins/svg.js`

codemirror init basic profile `https://` cat the hostname cat `/easycoder/plugins/codemirror-ecs.js`
require css `https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.46.0/addon/dialog/dialog.css`
Expand Down
2 changes: 1 addition & 1 deletion resources/ecs/main.ecs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ DoNotes:
stop

RunCodex:
load plugin `codemirror`
require js `dist/plugins/codemirror.js`
rest get Script from `/resources/ecs/codex.ecs`
send `pause` to CurrentModule
set style `display` of Body to `none`
Expand Down
2 changes: 1 addition & 1 deletion resources/scripts/codex.ecs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
! set Mobile
set ShowRun

load plugin `svg`
require js `dist/plugins/svg.js`

codemirror init basic profile `/easycoder/plugins/codemirror-ecs.js`
require css `https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.46.0/addon/dialog/dialog.css`
Expand Down
2 changes: 1 addition & 1 deletion resources/scripts/gmap_loader.ecs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
load plugin `gmap`
require js `dist/plugins/gmap.js`
2 changes: 1 addition & 1 deletion scripted.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
script ScriptEditor

variable Script
load plugin `codemirror`
require js `dist/plugins/codemirror.js`
rest get Script from `/resources/ecs/scripted.ecs`
run Script
</pre>
Expand Down