Skip to content
Snippets Groups Projects
Commit 1ed6e43d authored by Maximilian Giller's avatar Maximilian Giller
Browse files

Made new storage interface more accessible for graph and editor and simplified imports

parent fd2881ba
No related branches found
No related tags found
No related merge requests found
......@@ -9,4 +9,5 @@ export const COLOR_PALETTE = [
];
// Just renaming a variable which is given by the PHP script. This avoids errors in all other files.
export const PLUGIN_PATH = plugin_path;
export const PLUGIN_PATH = plugin.path;
export const SPACE = space.id;
......@@ -520,7 +520,7 @@ let infoOverlay = null;
// Only execute, if corresponding dom is present
if (document.getElementById("3d-graph") !== null) {
G = new Graph(space_id); // space_id defined globaly through knowledge-space.php
G = new Graph(Config.SPACE); // space_id defined globaly through knowledge-space.php
filterOverlay = new FilterOverlay(G, "node");
infoOverlay = new NodeInfoOverlay(G);
G.infoOverlay = infoOverlay;
......
......@@ -3,6 +3,7 @@ import * as Graph from "./graph";
import { loadGraphJson } from "../../datasets/datasets";
import ForceGraph from "force-graph";
import * as Interactions from "./interactions";
import { SPACE } from "../../config";
export var state;
......@@ -20,7 +21,7 @@ window.onload = function () {
Interactions.initInteractions();
loadGraphJson(space_id) // space_id defined globaly through knowledge-space.php
loadGraphJson(SPACE) // space_id defined globaly through knowledge-space.php
.then((graphConfig) => {
state = new State();
graph = new Graph.Graph(graphConfig);
......
......@@ -14,17 +14,21 @@ function ks_add_graph($atts = []): string
$space_id = get_space_id_from_atts($atts);
$div = '<div id="3d-graph"></div>'; // The id "3d-graph" indicates, that the javascript associated with this should automatically be executed
$plugin_dir = plugin_dir_url(__FILE__);
//$dataset = $plugin_dir.'datasets/miserables.json';
$variables = "<script>
var plugin_path = '$plugin_dir';
var space_id = '$space_id';
</script>";
$script_path = $plugin_dir . 'build' . DIRECTORY_SEPARATOR . $GLOBALS['build'] . DIRECTORY_SEPARATOR . 'graph.js';
$script = "<script src='$script_path'></script>";
$script_path = 'build' . DIRECTORY_SEPARATOR . $GLOBALS['build'] . DIRECTORY_SEPARATOR . 'graph.js';
// $script = "<script src='$script_path'></script>";
//wp_enqueue_script('kg-script', $script_path);
wp_enqueue_script("ks-display-js", plugins_url($script_path, __FILE__), array('jquery'), false);
wp_localize_script(
'ks-display-js',
'ajax_object',
array('ajax_url' => admin_url('admin-ajax.php'))
);
wp_localize_script("ks-display-js", "space", array('id' => $space_id));
wp_localize_script("ks-display-js", "plugin", array('path' => $plugin_dir));
return $div . $variables . $script;
return $div . $variables;
// return $div . $variables . $script;
}
function ks_add_editor($atts = [])
......@@ -33,10 +37,8 @@ function ks_add_editor($atts = [])
$space_id = get_space_id_from_atts($atts);
$plugin_dir = plugin_dir_url(__FILE__);
echo "<script>
var plugin_path = '$plugin_dir';
var space_id = '$space_id';
</script>";
wp_localize_script("ks-editor-js", "space", array('id' => $space_id));
wp_localize_script("ks-editor-js", "plugin", array('path' => $plugin_dir));
require_once(__DIR__ . '/editor/editor.php');
}
......@@ -45,12 +47,15 @@ function ks_add_editor_dependencies()
{
$script_path = 'build' . DIRECTORY_SEPARATOR . $GLOBALS['build'] . DIRECTORY_SEPARATOR . 'graph.js';
// wp_enqueue_script('jquery');
// wp_enqueue_script('jquery');
wp_enqueue_script("ks-editor-js", plugins_url($script_path, __FILE__), array('jquery'), false);
//wp_register_script("ks-editor-js", plugins_url($script_path, __FILE__), array('jquery'), false);
wp_localize_script( 'ks-editor-js', 'ajax_object',
array( 'ajax_url' => admin_url( 'admin-ajax.php' )));
wp_localize_script(
'ks-editor-js',
'ajax_object',
array('ajax_url' => admin_url('admin-ajax.php'))
);
//wp_enqueue_script("ks-editor-js");
$style_file_version = date("ymd-Gis", filemtime(plugin_dir_path(__FILE__) . "editor/css/editor.css"));
......@@ -76,7 +81,8 @@ function escape_space_id($id)
);
}
function get_space_id_from_atts($atts) {
function get_space_id_from_atts($atts)
{
if ($atts != "" && array_key_exists("space", $atts)) {
return escape_space_id($atts["space"]);
} else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment