maxGraph/packages/html/stories/stashed/grapheditor/www/open.html

223 lines
5.7 KiB
HTML
Raw Normal View History

2012-05-21 20:32:26 +00:00
<!DOCTYPE html>
<html>
<head>
<title>Open Diagram</title>
<link rel="stylesheet" type="text/css" href="styles/grapheditor.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<script type="text/javascript">
// Reads files locally
function handleFiles(files)
{
2021-03-21 01:24:29 +00:00
for (let i = 0; i < files.length; i++)
2012-05-21 20:32:26 +00:00
{
(function(file)
{
2012-05-30 16:26:17 +00:00
// Small hack to support import
if (window.parent.openNew)
{
window.parent.open(window.parent.location.href);
}
2012-05-21 20:32:26 +00:00
2021-03-21 01:24:29 +00:00
let reader = new FileReader();
2012-05-21 20:32:26 +00:00
reader.onload = function(e)
{
window.parent.openFile.setData(e.target.result, file.name);
};
reader.onerror = function(e)
{
console.log(e);
};
reader.readAsText(file);
})(files[i]);
}
};
// Handles form-submit by preparing to process response
function handleSubmit()
{
2021-03-21 01:24:29 +00:00
let form = window.openForm || document.getElementById('openForm');
2012-05-21 20:32:26 +00:00
// Checks for support of the File API for local file access
2016-09-07 12:29:15 +00:00
// except for files where the parse is on the server
2016-05-09 10:56:11 +00:00
if (window.parent.Graph.fileSupport && form.upfile.files.length > 0)
2012-05-21 20:32:26 +00:00
{
handleFiles(form.upfile.files);
return false;
}
else
{
if (/(\.xml)$/i.test(form.upfile.value) || /(\.txt)$/i.test(form.upfile.value) ||
/(\.mxe)$/i.test(form.upfile.value))
{
2012-05-30 16:26:17 +00:00
// Small hack to support import
if (window.parent.openNew)
{
window.parent.open(window.parent.location.href);
}
2012-05-21 20:32:26 +00:00
// NOTE: File is loaded via JS injection into the iframe, which in turn sets the
// file contents in the parent window. The new window asks its opener if any file
// contents are available or waits for the contents to become available.
return true;
}
else
{
Finish converting core to ts, JSDoc conversion, consistency+convention changes, example bugfixes (#70) * reorganised directories; removed mx prefix * reduced directory hierarchies; removed mx prefix; type fixes * convert remaining javascript to ts * fix/add types * add type defs * type updates; moved codecs to where they're used * reorganise constants into enums+type additions * removed "Function:" and "Variable:" prefixes from comments, as they aren't needed in JSDoc * removed "Function:", "Variable:" and "Class:" prefixes from comments, as they aren't needed in JSDoc * removed "Function:" prefixes from comments, as they aren't needed in JSDoc * minor changes * convert code example blocks to markdown * module casing updates * converted parameter function documentation to JSDoc * documentation+type updates * removed react subdir (for now) * reorganised various `utils` functions into different files * type updates/bugfixes/workarounds * rename Rubberband and CellEditor to be *Handler to match the other plugins * move codec classes to where they're used to reduce cyclic dependencies * move codec classes to where they're used to reduce cyclic dependencies * type updates/reorganize layout file structure * renamed various files for consistency * import fixes * renamed GraphHandler SelectionHander and various fixes * convert EventObject parameters to objects * add basic better-docs config * update better-docs config * bugfix for shared variables in Graph persisting across instances * fixed accessing handlers in examples; renamed Model to GraphModel * fixed accessing handlers in examples; renamed Model to GraphModel * restored selection model * bugfix * renamed getModel to getDataModel * changed to use graph.batchUpdate() to reduce lines of code * changed to use graph.batchUpdate() to reduce lines of code * finished annotations+added TypeDoc * convert remaining Cell[] instances to CellArray * convert NaturalDocs links to JSDoc
2022-01-08 01:49:35 +00:00
window.parent.alert(window.parent.Translations.get('invalidOrMissingFile'));
2012-05-21 20:32:26 +00:00
return false;
}
}
};
// Hides this dialog
2013-12-20 16:51:26 +00:00
function hideWindow(cancel)
2012-05-21 20:32:26 +00:00
{
2013-12-20 16:51:26 +00:00
window.parent.openFile.cancel(cancel);
2012-05-21 20:32:26 +00:00
}
function fileChanged()
{
2021-03-21 01:24:29 +00:00
let form = window.openForm || document.getElementById('openForm');
let openButton = document.getElementById('openButton');
2012-05-21 20:32:26 +00:00
if (form.upfile.value.length > 0)
{
openButton.removeAttribute('disabled');
}
else
{
openButton.setAttribute('disabled', 'disabled');
}
}
function main()
{
2016-05-09 10:56:11 +00:00
if (window.parent.Editor.useLocalStorage)
2012-05-21 20:32:26 +00:00
{
document.body.innerHTML = '';
2021-03-21 01:24:29 +00:00
let div = document.createElement('div');
2012-05-21 20:32:26 +00:00
div.style.fontFamily = 'Arial';
if (localStorage.length == 0)
{
Finish converting core to ts, JSDoc conversion, consistency+convention changes, example bugfixes (#70) * reorganised directories; removed mx prefix * reduced directory hierarchies; removed mx prefix; type fixes * convert remaining javascript to ts * fix/add types * add type defs * type updates; moved codecs to where they're used * reorganise constants into enums+type additions * removed "Function:" and "Variable:" prefixes from comments, as they aren't needed in JSDoc * removed "Function:", "Variable:" and "Class:" prefixes from comments, as they aren't needed in JSDoc * removed "Function:" prefixes from comments, as they aren't needed in JSDoc * minor changes * convert code example blocks to markdown * module casing updates * converted parameter function documentation to JSDoc * documentation+type updates * removed react subdir (for now) * reorganised various `utils` functions into different files * type updates/bugfixes/workarounds * rename Rubberband and CellEditor to be *Handler to match the other plugins * move codec classes to where they're used to reduce cyclic dependencies * move codec classes to where they're used to reduce cyclic dependencies * type updates/reorganize layout file structure * renamed various files for consistency * import fixes * renamed GraphHandler SelectionHander and various fixes * convert EventObject parameters to objects * add basic better-docs config * update better-docs config * bugfix for shared variables in Graph persisting across instances * fixed accessing handlers in examples; renamed Model to GraphModel * fixed accessing handlers in examples; renamed Model to GraphModel * restored selection model * bugfix * renamed getModel to getDataModel * changed to use graph.batchUpdate() to reduce lines of code * changed to use graph.batchUpdate() to reduce lines of code * finished annotations+added TypeDoc * convert remaining Cell[] instances to CellArray * convert NaturalDocs links to JSDoc
2022-01-08 01:49:35 +00:00
window.parent.write(div, window.parent.Translations.get('noFiles'));
2012-05-21 20:32:26 +00:00
}
else
{
2021-03-21 01:24:29 +00:00
let keys = [];
2012-05-21 20:32:26 +00:00
2021-03-21 01:24:29 +00:00
for (let i = 0; i < localStorage.length; i++)
2012-05-21 20:32:26 +00:00
{
keys.push(localStorage.key(i));
}
// Sorts the array by filename (key)
2015-08-28 13:41:48 +00:00
keys.sort(function (a, b)
{
return a.toLowerCase().localeCompare(b.toLowerCase());
});
2012-05-21 20:32:26 +00:00
2021-03-21 01:24:29 +00:00
for (let i = 0; i < keys.length; i++)
2012-05-21 20:32:26 +00:00
{
2021-03-21 01:24:29 +00:00
let link = document.createElement('a');
2012-05-21 20:32:26 +00:00
link.style.fontDecoration = 'none';
link.style.fontSize = '14pt';
2021-03-21 01:24:29 +00:00
let key = keys[i];
2021-07-31 09:55:25 +00:00
window.parent.write(link, key);
2020-06-19 12:31:34 +00:00
link.style.cursor = 'pointer';
2012-05-21 20:32:26 +00:00
div.appendChild(link);
2021-03-21 01:24:29 +00:00
let img = document.createElement('span');
2013-06-28 19:07:06 +00:00
img.className = 'geSprite geSprite-delete';
2012-05-21 20:32:26 +00:00
img.style.position = 'relative';
img.style.cursor = 'pointer';
img.style.display = 'inline-block';
div.appendChild(img);
2021-07-31 09:55:25 +00:00
window.parent.br(div);
2012-05-21 20:32:26 +00:00
window.parent.mxEvent.addListener(img, 'click', (function(k)
{
return function()
{
Finish converting core to ts, JSDoc conversion, consistency+convention changes, example bugfixes (#70) * reorganised directories; removed mx prefix * reduced directory hierarchies; removed mx prefix; type fixes * convert remaining javascript to ts * fix/add types * add type defs * type updates; moved codecs to where they're used * reorganise constants into enums+type additions * removed "Function:" and "Variable:" prefixes from comments, as they aren't needed in JSDoc * removed "Function:", "Variable:" and "Class:" prefixes from comments, as they aren't needed in JSDoc * removed "Function:" prefixes from comments, as they aren't needed in JSDoc * minor changes * convert code example blocks to markdown * module casing updates * converted parameter function documentation to JSDoc * documentation+type updates * removed react subdir (for now) * reorganised various `utils` functions into different files * type updates/bugfixes/workarounds * rename Rubberband and CellEditor to be *Handler to match the other plugins * move codec classes to where they're used to reduce cyclic dependencies * move codec classes to where they're used to reduce cyclic dependencies * type updates/reorganize layout file structure * renamed various files for consistency * import fixes * renamed GraphHandler SelectionHander and various fixes * convert EventObject parameters to objects * add basic better-docs config * update better-docs config * bugfix for shared variables in Graph persisting across instances * fixed accessing handlers in examples; renamed Model to GraphModel * fixed accessing handlers in examples; renamed Model to GraphModel * restored selection model * bugfix * renamed getModel to getDataModel * changed to use graph.batchUpdate() to reduce lines of code * changed to use graph.batchUpdate() to reduce lines of code * finished annotations+added TypeDoc * convert remaining Cell[] instances to CellArray * convert NaturalDocs links to JSDoc
2022-01-08 01:49:35 +00:00
if (window.parent.confirm(window.parent.Translations.get('delete') + ' "' + k + '"?'))
2012-05-21 20:32:26 +00:00
{
localStorage.removeItem(k);
window.location.reload();
}
};
})(key));
window.parent.mxEvent.addListener(link, 'click', (function(k)
{
return function()
{
try
{
window.parent.open(window.parent.location.href);
window.parent.openFile.setData(localStorage.getItem(k), k);
}
catch (e)
{
2021-07-31 09:55:25 +00:00
window.parent.alert(e.message);
2012-05-21 20:32:26 +00:00
}
};
})(key));
}
}
2021-07-31 09:55:25 +00:00
window.parent.br(div);
window.parent.br(div);
2012-05-21 20:32:26 +00:00
Finish converting core to ts, JSDoc conversion, consistency+convention changes, example bugfixes (#70) * reorganised directories; removed mx prefix * reduced directory hierarchies; removed mx prefix; type fixes * convert remaining javascript to ts * fix/add types * add type defs * type updates; moved codecs to where they're used * reorganise constants into enums+type additions * removed "Function:" and "Variable:" prefixes from comments, as they aren't needed in JSDoc * removed "Function:", "Variable:" and "Class:" prefixes from comments, as they aren't needed in JSDoc * removed "Function:" prefixes from comments, as they aren't needed in JSDoc * minor changes * convert code example blocks to markdown * module casing updates * converted parameter function documentation to JSDoc * documentation+type updates * removed react subdir (for now) * reorganised various `utils` functions into different files * type updates/bugfixes/workarounds * rename Rubberband and CellEditor to be *Handler to match the other plugins * move codec classes to where they're used to reduce cyclic dependencies * move codec classes to where they're used to reduce cyclic dependencies * type updates/reorganize layout file structure * renamed various files for consistency * import fixes * renamed GraphHandler SelectionHander and various fixes * convert EventObject parameters to objects * add basic better-docs config * update better-docs config * bugfix for shared variables in Graph persisting across instances * fixed accessing handlers in examples; renamed Model to GraphModel * fixed accessing handlers in examples; renamed Model to GraphModel * restored selection model * bugfix * renamed getModel to getDataModel * changed to use graph.batchUpdate() to reduce lines of code * changed to use graph.batchUpdate() to reduce lines of code * finished annotations+added TypeDoc * convert remaining Cell[] instances to CellArray * convert NaturalDocs links to JSDoc
2022-01-08 01:49:35 +00:00
let cancelBtn = window.parent.button(window.parent.Translations.get('cancel'), function()
2012-05-21 20:32:26 +00:00
{
2013-12-20 16:51:26 +00:00
hideWindow(true);
2014-11-28 08:55:09 +00:00
});
cancelBtn.className = 'geBtn';
div.appendChild(cancelBtn);
2012-05-21 20:32:26 +00:00
document.body.appendChild(div);
}
else
{
2021-03-21 01:24:29 +00:00
let editLink = document.getElementById('editLink');
let openButton = document.getElementById('openButton');
Finish converting core to ts, JSDoc conversion, consistency+convention changes, example bugfixes (#70) * reorganised directories; removed mx prefix * reduced directory hierarchies; removed mx prefix; type fixes * convert remaining javascript to ts * fix/add types * add type defs * type updates; moved codecs to where they're used * reorganise constants into enums+type additions * removed "Function:" and "Variable:" prefixes from comments, as they aren't needed in JSDoc * removed "Function:", "Variable:" and "Class:" prefixes from comments, as they aren't needed in JSDoc * removed "Function:" prefixes from comments, as they aren't needed in JSDoc * minor changes * convert code example blocks to markdown * module casing updates * converted parameter function documentation to JSDoc * documentation+type updates * removed react subdir (for now) * reorganised various `utils` functions into different files * type updates/bugfixes/workarounds * rename Rubberband and CellEditor to be *Handler to match the other plugins * move codec classes to where they're used to reduce cyclic dependencies * move codec classes to where they're used to reduce cyclic dependencies * type updates/reorganize layout file structure * renamed various files for consistency * import fixes * renamed GraphHandler SelectionHander and various fixes * convert EventObject parameters to objects * add basic better-docs config * update better-docs config * bugfix for shared variables in Graph persisting across instances * fixed accessing handlers in examples; renamed Model to GraphModel * fixed accessing handlers in examples; renamed Model to GraphModel * restored selection model * bugfix * renamed getModel to getDataModel * changed to use graph.batchUpdate() to reduce lines of code * changed to use graph.batchUpdate() to reduce lines of code * finished annotations+added TypeDoc * convert remaining Cell[] instances to CellArray * convert NaturalDocs links to JSDoc
2022-01-08 01:49:35 +00:00
openButton.value = window.parent.Translations.get(window.parent.openKey || 'open');
2021-03-21 01:24:29 +00:00
let cancelButton = document.getElementById('cancelButton');
Finish converting core to ts, JSDoc conversion, consistency+convention changes, example bugfixes (#70) * reorganised directories; removed mx prefix * reduced directory hierarchies; removed mx prefix; type fixes * convert remaining javascript to ts * fix/add types * add type defs * type updates; moved codecs to where they're used * reorganise constants into enums+type additions * removed "Function:" and "Variable:" prefixes from comments, as they aren't needed in JSDoc * removed "Function:", "Variable:" and "Class:" prefixes from comments, as they aren't needed in JSDoc * removed "Function:" prefixes from comments, as they aren't needed in JSDoc * minor changes * convert code example blocks to markdown * module casing updates * converted parameter function documentation to JSDoc * documentation+type updates * removed react subdir (for now) * reorganised various `utils` functions into different files * type updates/bugfixes/workarounds * rename Rubberband and CellEditor to be *Handler to match the other plugins * move codec classes to where they're used to reduce cyclic dependencies * move codec classes to where they're used to reduce cyclic dependencies * type updates/reorganize layout file structure * renamed various files for consistency * import fixes * renamed GraphHandler SelectionHander and various fixes * convert EventObject parameters to objects * add basic better-docs config * update better-docs config * bugfix for shared variables in Graph persisting across instances * fixed accessing handlers in examples; renamed Model to GraphModel * fixed accessing handlers in examples; renamed Model to GraphModel * restored selection model * bugfix * renamed getModel to getDataModel * changed to use graph.batchUpdate() to reduce lines of code * changed to use graph.batchUpdate() to reduce lines of code * finished annotations+added TypeDoc * convert remaining Cell[] instances to CellArray * convert NaturalDocs links to JSDoc
2022-01-08 01:49:35 +00:00
cancelButton.value = window.parent.Translations.get('cancel');
2021-03-21 01:24:29 +00:00
let supportedText = document.getElementById('openSupported');
Finish converting core to ts, JSDoc conversion, consistency+convention changes, example bugfixes (#70) * reorganised directories; removed mx prefix * reduced directory hierarchies; removed mx prefix; type fixes * convert remaining javascript to ts * fix/add types * add type defs * type updates; moved codecs to where they're used * reorganise constants into enums+type additions * removed "Function:" and "Variable:" prefixes from comments, as they aren't needed in JSDoc * removed "Function:", "Variable:" and "Class:" prefixes from comments, as they aren't needed in JSDoc * removed "Function:" prefixes from comments, as they aren't needed in JSDoc * minor changes * convert code example blocks to markdown * module casing updates * converted parameter function documentation to JSDoc * documentation+type updates * removed react subdir (for now) * reorganised various `utils` functions into different files * type updates/bugfixes/workarounds * rename Rubberband and CellEditor to be *Handler to match the other plugins * move codec classes to where they're used to reduce cyclic dependencies * move codec classes to where they're used to reduce cyclic dependencies * type updates/reorganize layout file structure * renamed various files for consistency * import fixes * renamed GraphHandler SelectionHander and various fixes * convert EventObject parameters to objects * add basic better-docs config * update better-docs config * bugfix for shared variables in Graph persisting across instances * fixed accessing handlers in examples; renamed Model to GraphModel * fixed accessing handlers in examples; renamed Model to GraphModel * restored selection model * bugfix * renamed getModel to getDataModel * changed to use graph.batchUpdate() to reduce lines of code * changed to use graph.batchUpdate() to reduce lines of code * finished annotations+added TypeDoc * convert remaining Cell[] instances to CellArray * convert NaturalDocs links to JSDoc
2022-01-08 01:49:35 +00:00
supportedText.innerHTML = window.parent.Translations.get('openSupported');
2021-03-21 01:24:29 +00:00
let form = window.openForm || document.getElementById('openForm');
2015-02-09 10:42:21 +00:00
2012-05-21 20:32:26 +00:00
form.setAttribute('action', window.parent.OPEN_URL);
}
};
</script>
<body onload="main();">
<form method="POST" enctype="multipart/form-data" action="" name="openForm"
id="openForm" onsubmit="return handleSubmit();" accept-charset="UTF-8">
2015-02-09 10:42:21 +00:00
<table style="width:100%;">
2012-05-21 20:32:26 +00:00
<tr>
<td style="height:40px;vertical-align:top;" colspan="2">
<input type="file" name="upfile" onchange="fileChanged()">
</td>
</tr>
<tr>
2014-06-02 08:21:19 +00:00
<td colspan="2" height="120px" id="openSupported" style="font-family:arial;color:grey;font-size:9pt;vertical-align:top;text-align:left;">
2012-05-21 20:32:26 +00:00
</td>
</tr>
<tr>
<td>
</td>
<td style="vertical-align:middle;text-align:right;white-space:nowrap;">
2014-11-28 08:55:09 +00:00
<input type="button" id="cancelButton" class="geBtn" value="Cancel" onclick="hideWindow(true);">
<input type="submit" id="openButton" class="geBtn gePrimaryBtn" value="Open" disabled="disabled">
2012-05-21 20:32:26 +00:00
</td>
</tr>
</table>
</form>
</body>
</html>