Reformat _server & delete map
This commit is contained in:
parent
bff5298c7a
commit
81df4a9b19
@ -1,154 +1,285 @@
|
|||||||
/* BASICS */
|
/* BASICS */
|
||||||
|
|
||||||
.CodeMirror {
|
.CodeMirror {
|
||||||
/* Set height, width, borders, and global font properties here */
|
/* Set height, width, borders, and global font properties here */
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
height: 300px;
|
height: 300px;
|
||||||
color: black;
|
color: black;
|
||||||
direction: ltr;
|
direction: ltr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PADDING */
|
/* PADDING */
|
||||||
|
|
||||||
.CodeMirror-lines {
|
.CodeMirror-lines {
|
||||||
padding: 4px 0; /* Vertical padding around content */
|
padding: 4px 0; /* Vertical padding around content */
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror pre {
|
.CodeMirror pre {
|
||||||
padding: 0 4px; /* Horizontal padding of content */
|
padding: 0 4px; /* Horizontal padding of content */
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
||||||
background-color: white; /* The little square between H and V scrollbars */
|
background-color: white; /* The little square between H and V scrollbars */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* GUTTER */
|
/* GUTTER */
|
||||||
|
|
||||||
.CodeMirror-gutters {
|
.CodeMirror-gutters {
|
||||||
border-right: 1px solid #ddd;
|
border-right: 1px solid #ddd;
|
||||||
background-color: #f7f7f7;
|
background-color: #f7f7f7;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
|
||||||
.CodeMirror-linenumbers {}
|
|
||||||
.CodeMirror-linenumber {
|
|
||||||
padding: 0 3px 0 5px;
|
|
||||||
min-width: 20px;
|
|
||||||
text-align: right;
|
|
||||||
color: #999;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-guttermarker { color: black; }
|
.CodeMirror-linenumbers {
|
||||||
.CodeMirror-guttermarker-subtle { color: #999; }
|
}
|
||||||
|
|
||||||
|
.CodeMirror-linenumber {
|
||||||
|
padding: 0 3px 0 5px;
|
||||||
|
min-width: 20px;
|
||||||
|
text-align: right;
|
||||||
|
color: #999;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-guttermarker {
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-guttermarker-subtle {
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
/* CURSOR */
|
/* CURSOR */
|
||||||
|
|
||||||
.CodeMirror-cursor {
|
.CodeMirror-cursor {
|
||||||
border-left: 1px solid black;
|
border-left: 1px solid black;
|
||||||
border-right: none;
|
border-right: none;
|
||||||
width: 0;
|
width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Shown when moving in bi-directional text */
|
/* Shown when moving in bi-directional text */
|
||||||
.CodeMirror div.CodeMirror-secondarycursor {
|
.CodeMirror div.CodeMirror-secondarycursor {
|
||||||
border-left: 1px solid silver;
|
border-left: 1px solid silver;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cm-fat-cursor .CodeMirror-cursor {
|
.cm-fat-cursor .CodeMirror-cursor {
|
||||||
width: auto;
|
width: auto;
|
||||||
border: 0 !important;
|
border: 0 !important;
|
||||||
background: #7e7;
|
background: #7e7;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cm-fat-cursor div.CodeMirror-cursors {
|
.cm-fat-cursor div.CodeMirror-cursors {
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cm-fat-cursor-mark {
|
.cm-fat-cursor-mark {
|
||||||
background-color: rgba(20, 255, 20, 0.5);
|
background-color: rgba(20, 255, 20, 0.5);
|
||||||
-webkit-animation: blink 1.06s steps(1) infinite;
|
-webkit-animation: blink 1.06s steps(1) infinite;
|
||||||
-moz-animation: blink 1.06s steps(1) infinite;
|
-moz-animation: blink 1.06s steps(1) infinite;
|
||||||
animation: blink 1.06s steps(1) infinite;
|
animation: blink 1.06s steps(1) infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cm-animate-fat-cursor {
|
.cm-animate-fat-cursor {
|
||||||
width: auto;
|
width: auto;
|
||||||
border: 0;
|
border: 0;
|
||||||
-webkit-animation: blink 1.06s steps(1) infinite;
|
-webkit-animation: blink 1.06s steps(1) infinite;
|
||||||
-moz-animation: blink 1.06s steps(1) infinite;
|
-moz-animation: blink 1.06s steps(1) infinite;
|
||||||
animation: blink 1.06s steps(1) infinite;
|
animation: blink 1.06s steps(1) infinite;
|
||||||
background-color: #7e7;
|
background-color: #7e7;
|
||||||
}
|
}
|
||||||
|
|
||||||
@-moz-keyframes blink {
|
@-moz-keyframes blink {
|
||||||
0% {}
|
0% {
|
||||||
50% { background-color: transparent; }
|
}
|
||||||
100% {}
|
50% {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@-webkit-keyframes blink {
|
@-webkit-keyframes blink {
|
||||||
0% {}
|
0% {
|
||||||
50% { background-color: transparent; }
|
}
|
||||||
100% {}
|
50% {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes blink {
|
@keyframes blink {
|
||||||
0% {}
|
0% {
|
||||||
50% { background-color: transparent; }
|
}
|
||||||
100% {}
|
50% {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Can style cursor different in overwrite (non-insert) mode */
|
/* Can style cursor different in overwrite (non-insert) mode */
|
||||||
.CodeMirror-overwrite .CodeMirror-cursor {}
|
.CodeMirror-overwrite .CodeMirror-cursor {
|
||||||
|
}
|
||||||
|
|
||||||
.cm-tab { display: inline-block; text-decoration: inherit; }
|
.cm-tab {
|
||||||
|
display: inline-block;
|
||||||
|
text-decoration: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
.CodeMirror-rulers {
|
.CodeMirror-rulers {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0; right: 0; top: -50px; bottom: -20px;
|
left: 0;
|
||||||
overflow: hidden;
|
right: 0;
|
||||||
|
top: -50px;
|
||||||
|
bottom: -20px;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-ruler {
|
.CodeMirror-ruler {
|
||||||
border-left: 1px solid #ccc;
|
border-left: 1px solid #ccc;
|
||||||
top: 0; bottom: 0;
|
top: 0;
|
||||||
position: absolute;
|
bottom: 0;
|
||||||
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DEFAULT THEME */
|
/* DEFAULT THEME */
|
||||||
|
|
||||||
.cm-s-default .cm-header {color: blue;}
|
.cm-s-default .cm-header {
|
||||||
.cm-s-default .cm-quote {color: #090;}
|
color: blue;
|
||||||
.cm-negative {color: #d44;}
|
}
|
||||||
.cm-positive {color: #292;}
|
|
||||||
.cm-header, .cm-strong {font-weight: bold;}
|
.cm-s-default .cm-quote {
|
||||||
.cm-em {font-style: italic;}
|
color: #090;
|
||||||
.cm-link {text-decoration: underline;}
|
}
|
||||||
.cm-strikethrough {text-decoration: line-through;}
|
|
||||||
|
.cm-negative {
|
||||||
|
color: #d44;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-positive {
|
||||||
|
color: #292;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-header, .cm-strong {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-em {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-link {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-strikethrough {
|
||||||
|
text-decoration: line-through;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-keyword {
|
||||||
|
color: #708;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-atom {
|
||||||
|
color: #219;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-number {
|
||||||
|
color: #164;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-def {
|
||||||
|
color: #00f;
|
||||||
|
}
|
||||||
|
|
||||||
.cm-s-default .cm-keyword {color: #708;}
|
|
||||||
.cm-s-default .cm-atom {color: #219;}
|
|
||||||
.cm-s-default .cm-number {color: #164;}
|
|
||||||
.cm-s-default .cm-def {color: #00f;}
|
|
||||||
.cm-s-default .cm-variable,
|
.cm-s-default .cm-variable,
|
||||||
.cm-s-default .cm-punctuation,
|
.cm-s-default .cm-punctuation,
|
||||||
.cm-s-default .cm-property,
|
.cm-s-default .cm-property,
|
||||||
.cm-s-default .cm-operator {}
|
.cm-s-default .cm-operator {
|
||||||
.cm-s-default .cm-variable-2 {color: #05a;}
|
}
|
||||||
.cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;}
|
|
||||||
.cm-s-default .cm-comment {color: #a50;}
|
|
||||||
.cm-s-default .cm-string {color: #a11;}
|
|
||||||
.cm-s-default .cm-string-2 {color: #f50;}
|
|
||||||
.cm-s-default .cm-meta {color: #555;}
|
|
||||||
.cm-s-default .cm-qualifier {color: #555;}
|
|
||||||
.cm-s-default .cm-builtin {color: #30a;}
|
|
||||||
.cm-s-default .cm-bracket {color: #997;}
|
|
||||||
.cm-s-default .cm-tag {color: #170;}
|
|
||||||
.cm-s-default .cm-attribute {color: #00c;}
|
|
||||||
.cm-s-default .cm-hr {color: #999;}
|
|
||||||
.cm-s-default .cm-link {color: #00c;}
|
|
||||||
|
|
||||||
.cm-s-default .cm-error {color: #f00;}
|
.cm-s-default .cm-variable-2 {
|
||||||
.cm-invalidchar {color: #f00;}
|
color: #05a;
|
||||||
|
}
|
||||||
|
|
||||||
.CodeMirror-composing { border-bottom: 2px solid; }
|
.cm-s-default .cm-variable-3, .cm-s-default .cm-type {
|
||||||
|
color: #085;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-comment {
|
||||||
|
color: #a50;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-string {
|
||||||
|
color: #a11;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-string-2 {
|
||||||
|
color: #f50;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-meta {
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-qualifier {
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-builtin {
|
||||||
|
color: #30a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-bracket {
|
||||||
|
color: #997;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-tag {
|
||||||
|
color: #170;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-attribute {
|
||||||
|
color: #00c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-hr {
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-link {
|
||||||
|
color: #00c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-s-default .cm-error {
|
||||||
|
color: #f00;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cm-invalidchar {
|
||||||
|
color: #f00;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-composing {
|
||||||
|
border-bottom: 2px solid;
|
||||||
|
}
|
||||||
|
|
||||||
/* Default styles for common addons */
|
/* Default styles for common addons */
|
||||||
|
|
||||||
div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;}
|
div.CodeMirror span.CodeMirror-matchingbracket {
|
||||||
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
|
color: #0b0;
|
||||||
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
|
}
|
||||||
.CodeMirror-activeline-background {background: #e8f2ff;}
|
|
||||||
|
div.CodeMirror span.CodeMirror-nonmatchingbracket {
|
||||||
|
color: #a22;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-matchingtag {
|
||||||
|
background: rgba(255, 150, 0, .3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-activeline-background {
|
||||||
|
background: #e8f2ff;
|
||||||
|
}
|
||||||
|
|
||||||
/* STOP */
|
/* STOP */
|
||||||
|
|
||||||
@ -156,129 +287,162 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
|
|||||||
the editor. You probably shouldn't touch them. */
|
the editor. You probably shouldn't touch them. */
|
||||||
|
|
||||||
.CodeMirror {
|
.CodeMirror {
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: white;
|
background: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-scroll {
|
.CodeMirror-scroll {
|
||||||
overflow: scroll !important; /* Things will break if this is overridden */
|
overflow: scroll !important; /* Things will break if this is overridden */
|
||||||
/* 30px is the magic margin used to hide the element's real scrollbars */
|
/* 30px is the magic margin used to hide the element's real scrollbars */
|
||||||
/* See overflow: hidden in .CodeMirror */
|
/* See overflow: hidden in .CodeMirror */
|
||||||
margin-bottom: -30px; margin-right: -30px;
|
margin-bottom: -30px;
|
||||||
padding-bottom: 30px;
|
margin-right: -30px;
|
||||||
height: 100%;
|
padding-bottom: 30px;
|
||||||
outline: none; /* Prevent dragging from highlighting the element */
|
height: 100%;
|
||||||
position: relative;
|
outline: none; /* Prevent dragging from highlighting the element */
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-sizer {
|
.CodeMirror-sizer {
|
||||||
position: relative;
|
position: relative;
|
||||||
border-right: 30px solid transparent;
|
border-right: 30px solid transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
||||||
before actual scrolling happens, thus preventing shaking and
|
before actual scrolling happens, thus preventing shaking and
|
||||||
flickering artifacts. */
|
flickering artifacts. */
|
||||||
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 6;
|
z-index: 6;
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-vscrollbar {
|
.CodeMirror-vscrollbar {
|
||||||
right: 0; top: 0;
|
right: 0;
|
||||||
overflow-x: hidden;
|
top: 0;
|
||||||
overflow-y: scroll;
|
overflow-x: hidden;
|
||||||
|
overflow-y: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-hscrollbar {
|
.CodeMirror-hscrollbar {
|
||||||
bottom: 0; left: 0;
|
bottom: 0;
|
||||||
overflow-y: hidden;
|
left: 0;
|
||||||
overflow-x: scroll;
|
overflow-y: hidden;
|
||||||
|
overflow-x: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-scrollbar-filler {
|
.CodeMirror-scrollbar-filler {
|
||||||
right: 0; bottom: 0;
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-gutter-filler {
|
.CodeMirror-gutter-filler {
|
||||||
left: 0; bottom: 0;
|
left: 0;
|
||||||
|
bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-gutters {
|
.CodeMirror-gutters {
|
||||||
position: absolute; left: 0; top: 0;
|
position: absolute;
|
||||||
min-height: 100%;
|
left: 0;
|
||||||
z-index: 3;
|
top: 0;
|
||||||
|
min-height: 100%;
|
||||||
|
z-index: 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-gutter {
|
.CodeMirror-gutter {
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
margin-bottom: -30px;
|
margin-bottom: -30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-gutter-wrapper {
|
.CodeMirror-gutter-wrapper {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 4;
|
z-index: 4;
|
||||||
background: none !important;
|
background: none !important;
|
||||||
border: none !important;
|
border: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-gutter-background {
|
.CodeMirror-gutter-background {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0; bottom: 0;
|
top: 0;
|
||||||
z-index: 4;
|
bottom: 0;
|
||||||
|
z-index: 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-gutter-elt {
|
.CodeMirror-gutter-elt {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
z-index: 4;
|
z-index: 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-gutter-wrapper ::selection {
|
||||||
|
background-color: transparent
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-gutter-wrapper ::-moz-selection {
|
||||||
|
background-color: transparent
|
||||||
}
|
}
|
||||||
.CodeMirror-gutter-wrapper ::selection { background-color: transparent }
|
|
||||||
.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }
|
|
||||||
|
|
||||||
.CodeMirror-lines {
|
.CodeMirror-lines {
|
||||||
cursor: text;
|
cursor: text;
|
||||||
min-height: 1px; /* prevents collapsing before first draw */
|
min-height: 1px; /* prevents collapsing before first draw */
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror pre {
|
.CodeMirror pre {
|
||||||
/* Reset some styles that the rest of the page might have set */
|
/* Reset some styles that the rest of the page might have set */
|
||||||
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
|
-moz-border-radius: 0;
|
||||||
border-width: 0;
|
-webkit-border-radius: 0;
|
||||||
background: transparent;
|
border-radius: 0;
|
||||||
font-family: inherit;
|
border-width: 0;
|
||||||
font-size: inherit;
|
background: transparent;
|
||||||
margin: 0;
|
font-family: inherit;
|
||||||
white-space: pre;
|
font-size: inherit;
|
||||||
word-wrap: normal;
|
margin: 0;
|
||||||
line-height: inherit;
|
white-space: pre;
|
||||||
color: inherit;
|
word-wrap: normal;
|
||||||
z-index: 2;
|
line-height: inherit;
|
||||||
position: relative;
|
color: inherit;
|
||||||
overflow: visible;
|
z-index: 2;
|
||||||
-webkit-tap-highlight-color: transparent;
|
position: relative;
|
||||||
-webkit-font-variant-ligatures: contextual;
|
overflow: visible;
|
||||||
font-variant-ligatures: contextual;
|
-webkit-tap-highlight-color: transparent;
|
||||||
|
-webkit-font-variant-ligatures: contextual;
|
||||||
|
font-variant-ligatures: contextual;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-wrap pre {
|
.CodeMirror-wrap pre {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
word-break: normal;
|
word-break: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-linebackground {
|
.CodeMirror-linebackground {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0; right: 0; top: 0; bottom: 0;
|
left: 0;
|
||||||
z-index: 0;
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-linewidget {
|
.CodeMirror-linewidget {
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
padding: 0.1px; /* Force widget margins to stay inside of the container */
|
padding: 0.1px; /* Force widget margins to stay inside of the container */
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-widget {}
|
.CodeMirror-widget {
|
||||||
|
}
|
||||||
|
|
||||||
.CodeMirror-rtl pre { direction: rtl; }
|
.CodeMirror-rtl pre {
|
||||||
|
direction: rtl;
|
||||||
|
}
|
||||||
|
|
||||||
.CodeMirror-code {
|
.CodeMirror-code {
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Force content-box sizing for the elements where we expect it */
|
/* Force content-box sizing for the elements where we expect it */
|
||||||
@ -287,60 +451,84 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
|
|||||||
.CodeMirror-gutter,
|
.CodeMirror-gutter,
|
||||||
.CodeMirror-gutters,
|
.CodeMirror-gutters,
|
||||||
.CodeMirror-linenumber {
|
.CodeMirror-linenumber {
|
||||||
-moz-box-sizing: content-box;
|
-moz-box-sizing: content-box;
|
||||||
box-sizing: content-box;
|
box-sizing: content-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-measure {
|
.CodeMirror-measure {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 0;
|
height: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-cursor {
|
.CodeMirror-cursor {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-measure pre {
|
||||||
|
position: static;
|
||||||
}
|
}
|
||||||
.CodeMirror-measure pre { position: static; }
|
|
||||||
|
|
||||||
div.CodeMirror-cursors {
|
div.CodeMirror-cursors {
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 3;
|
z-index: 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.CodeMirror-dragcursors {
|
div.CodeMirror-dragcursors {
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-focused div.CodeMirror-cursors {
|
.CodeMirror-focused div.CodeMirror-cursors {
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-selected { background: #d9d9d9; }
|
.CodeMirror-selected {
|
||||||
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
|
background: #d9d9d9;
|
||||||
.CodeMirror-crosshair { cursor: crosshair; }
|
}
|
||||||
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
|
|
||||||
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
|
.CodeMirror-focused .CodeMirror-selected {
|
||||||
|
background: #d7d4f0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-crosshair {
|
||||||
|
cursor: crosshair;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection {
|
||||||
|
background: #d7d4f0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection {
|
||||||
|
background: #d7d4f0;
|
||||||
|
}
|
||||||
|
|
||||||
.cm-searching {
|
.cm-searching {
|
||||||
background-color: #ffa;
|
background-color: #ffa;
|
||||||
background-color: rgba(255, 255, 0, .4);
|
background-color: rgba(255, 255, 0, .4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Used to force a border model for a node */
|
/* Used to force a border model for a node */
|
||||||
.cm-force-border { padding-right: .1px; }
|
.cm-force-border {
|
||||||
|
padding-right: .1px;
|
||||||
|
}
|
||||||
|
|
||||||
@media print {
|
@media print {
|
||||||
/* Hide the cursor when printing */
|
/* Hide the cursor when printing */
|
||||||
.CodeMirror div.CodeMirror-cursors {
|
.CodeMirror div.CodeMirror-cursors {
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See issue #2901 */
|
/* See issue #2901 */
|
||||||
.cm-tab-wrap-hack:after { content: ''; }
|
.cm-tab-wrap-hack:after {
|
||||||
|
content: '';
|
||||||
|
}
|
||||||
|
|
||||||
/* Help users use markselection to safely style text background */
|
/* Help users use markselection to safely style text background */
|
||||||
span.CodeMirror-selectedtext { background: none; }
|
span.CodeMirror-selectedtext {
|
||||||
|
background: none;
|
||||||
|
}
|
||||||
|
|||||||
@ -1,156 +1,165 @@
|
|||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||||
|
|
||||||
(function(mod) {
|
(function (mod) {
|
||||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||||
mod(require("../../lib/codemirror"));
|
mod(require("../../lib/codemirror"));
|
||||||
else if (typeof define == "function" && define.amd) // AMD
|
else if (typeof define == "function" && define.amd) // AMD
|
||||||
define(["../../lib/codemirror"], mod);
|
define(["../../lib/codemirror"], mod);
|
||||||
else // Plain browser env
|
else // Plain browser env
|
||||||
mod(CodeMirror);
|
mod(CodeMirror);
|
||||||
})(function(CodeMirror) {
|
})(function (CodeMirror) {
|
||||||
var Pos = CodeMirror.Pos;
|
var Pos = CodeMirror.Pos;
|
||||||
|
|
||||||
function forEach(arr, f) {
|
function forEach(arr, f) {
|
||||||
for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
|
for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function arrayContains(arr, item) {
|
function arrayContains(arr, item) {
|
||||||
if (!Array.prototype.indexOf) {
|
if (!Array.prototype.indexOf) {
|
||||||
var i = arr.length;
|
var i = arr.length;
|
||||||
while (i--) {
|
while (i--) {
|
||||||
if (arr[i] === item) {
|
if (arr[i] === item) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return arr.indexOf(item) != -1;
|
||||||
}
|
|
||||||
return arr.indexOf(item) != -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function scriptHint(editor, keywords, getToken, options) {
|
function scriptHint(editor, keywords, getToken, options) {
|
||||||
// Find the token at the cursor
|
// Find the token at the cursor
|
||||||
var cur = editor.getCursor(), token = getToken(editor, cur);
|
var cur = editor.getCursor(), token = getToken(editor, cur);
|
||||||
if (/\b(?:string|comment)\b/.test(token.type)) return;
|
if (/\b(?:string|comment)\b/.test(token.type)) return;
|
||||||
token.state = CodeMirror.innerMode(editor.getMode(), token.state).state;
|
token.state = CodeMirror.innerMode(editor.getMode(), token.state).state;
|
||||||
|
|
||||||
// If it's not a 'word-style' token, ignore the token.
|
// If it's not a 'word-style' token, ignore the token.
|
||||||
if (!/^[\w$_]*$/.test(token.string)) {
|
if (!/^[\w$_]*$/.test(token.string)) {
|
||||||
token = {start: cur.ch, end: cur.ch, string: "", state: token.state,
|
token = {
|
||||||
type: token.string == "." ? "property" : null};
|
start: cur.ch, end: cur.ch, string: "", state: token.state,
|
||||||
} else if (token.end > cur.ch) {
|
type: token.string == "." ? "property" : null
|
||||||
token.end = cur.ch;
|
};
|
||||||
token.string = token.string.slice(0, cur.ch - token.start);
|
} else if (token.end > cur.ch) {
|
||||||
}
|
token.end = cur.ch;
|
||||||
|
token.string = token.string.slice(0, cur.ch - token.start);
|
||||||
var tprop = token;
|
}
|
||||||
// If it is a property, find out what it is a property of.
|
|
||||||
while (tprop.type == "property") {
|
var tprop = token;
|
||||||
tprop = getToken(editor, Pos(cur.line, tprop.start));
|
// If it is a property, find out what it is a property of.
|
||||||
if (tprop.string != ".") return;
|
while (tprop.type == "property") {
|
||||||
tprop = getToken(editor, Pos(cur.line, tprop.start));
|
tprop = getToken(editor, Pos(cur.line, tprop.start));
|
||||||
if (!context) var context = [];
|
if (tprop.string != ".") return;
|
||||||
context.push(tprop);
|
tprop = getToken(editor, Pos(cur.line, tprop.start));
|
||||||
}
|
if (!context) var context = [];
|
||||||
return {list: getCompletions(token, context, keywords, options),
|
context.push(tprop);
|
||||||
from: Pos(cur.line, token.start),
|
}
|
||||||
to: Pos(cur.line, token.end)};
|
return {
|
||||||
|
list: getCompletions(token, context, keywords, options),
|
||||||
|
from: Pos(cur.line, token.start),
|
||||||
|
to: Pos(cur.line, token.end)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function javascriptHint(editor, options) {
|
function javascriptHint(editor, options) {
|
||||||
return scriptHint(editor, javascriptKeywords,
|
return scriptHint(editor, javascriptKeywords,
|
||||||
function (e, cur) {return e.getTokenAt(cur);},
|
function (e, cur) {
|
||||||
options);
|
return e.getTokenAt(cur);
|
||||||
|
},
|
||||||
|
options);
|
||||||
};
|
};
|
||||||
CodeMirror.registerHelper("hint", "javascript", javascriptHint);
|
CodeMirror.registerHelper("hint", "javascript", javascriptHint);
|
||||||
|
|
||||||
function getCoffeeScriptToken(editor, cur) {
|
function getCoffeeScriptToken(editor, cur) {
|
||||||
// This getToken, it is for coffeescript, imitates the behavior of
|
// This getToken, it is for coffeescript, imitates the behavior of
|
||||||
// getTokenAt method in javascript.js, that is, returning "property"
|
// getTokenAt method in javascript.js, that is, returning "property"
|
||||||
// type and treat "." as indepenent token.
|
// type and treat "." as indepenent token.
|
||||||
var token = editor.getTokenAt(cur);
|
var token = editor.getTokenAt(cur);
|
||||||
if (cur.ch == token.start + 1 && token.string.charAt(0) == '.') {
|
if (cur.ch == token.start + 1 && token.string.charAt(0) == '.') {
|
||||||
token.end = token.start;
|
token.end = token.start;
|
||||||
token.string = '.';
|
token.string = '.';
|
||||||
token.type = "property";
|
token.type = "property";
|
||||||
}
|
}
|
||||||
else if (/^\.[\w$_]*$/.test(token.string)) {
|
else if (/^\.[\w$_]*$/.test(token.string)) {
|
||||||
token.type = "property";
|
token.type = "property";
|
||||||
token.start++;
|
token.start++;
|
||||||
token.string = token.string.replace(/\./, '');
|
token.string = token.string.replace(/\./, '');
|
||||||
}
|
}
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
function coffeescriptHint(editor, options) {
|
function coffeescriptHint(editor, options) {
|
||||||
return scriptHint(editor, coffeescriptKeywords, getCoffeeScriptToken, options);
|
return scriptHint(editor, coffeescriptKeywords, getCoffeeScriptToken, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeMirror.registerHelper("hint", "coffeescript", coffeescriptHint);
|
CodeMirror.registerHelper("hint", "coffeescript", coffeescriptHint);
|
||||||
|
|
||||||
var stringProps = ("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight " +
|
var stringProps = ("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight " +
|
||||||
"toUpperCase toLowerCase split concat match replace search").split(" ");
|
"toUpperCase toLowerCase split concat match replace search").split(" ");
|
||||||
var arrayProps = ("length concat join splice push pop shift unshift slice reverse sort indexOf " +
|
var arrayProps = ("length concat join splice push pop shift unshift slice reverse sort indexOf " +
|
||||||
"lastIndexOf every some filter forEach map reduce reduceRight ").split(" ");
|
"lastIndexOf every some filter forEach map reduce reduceRight ").split(" ");
|
||||||
var funcProps = "prototype apply call bind".split(" ");
|
var funcProps = "prototype apply call bind".split(" ");
|
||||||
var javascriptKeywords = ("break case catch class const continue debugger default delete do else export extends false finally for function " +
|
var javascriptKeywords = ("break case catch class const continue debugger default delete do else export extends false finally for function " +
|
||||||
"if in import instanceof new null return super switch this throw true try typeof var void while with yield").split(" ");
|
"if in import instanceof new null return super switch this throw true try typeof var void while with yield").split(" ");
|
||||||
var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
|
var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
|
||||||
"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");
|
"if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");
|
||||||
|
|
||||||
function forAllProps(obj, callback) {
|
function forAllProps(obj, callback) {
|
||||||
if (!Object.getOwnPropertyNames || !Object.getPrototypeOf) {
|
if (!Object.getOwnPropertyNames || !Object.getPrototypeOf) {
|
||||||
for (var name in obj) callback(name)
|
for (var name in obj) callback(name)
|
||||||
} else {
|
} else {
|
||||||
for (var o = obj; o; o = Object.getPrototypeOf(o))
|
for (var o = obj; o; o = Object.getPrototypeOf(o))
|
||||||
Object.getOwnPropertyNames(o).forEach(callback)
|
Object.getOwnPropertyNames(o).forEach(callback)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCompletions(token, context, keywords, options) {
|
|
||||||
var found = [], start = token.string, global = options && options.globalScope || window;
|
|
||||||
function maybeAdd(str) {
|
|
||||||
if (str==null || str==undefined) return;
|
|
||||||
if (str.lastIndexOf(start, 0) == 0 && !arrayContains(found, str)) found.push(str);
|
|
||||||
}
|
|
||||||
function gatherCompletions(obj) {
|
|
||||||
if (typeof obj == "string") forEach(stringProps, maybeAdd);
|
|
||||||
else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
|
|
||||||
else if (obj instanceof Function) forEach(funcProps, maybeAdd);
|
|
||||||
forAllProps(obj, maybeAdd)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (context && context.length) {
|
|
||||||
// If this is a property, see if it belongs to some object we can
|
|
||||||
// find in the current environment.
|
|
||||||
var obj = context.pop(), base;
|
|
||||||
if (obj.type && obj.type.indexOf("variable") === 0) {
|
|
||||||
if (options && options.additionalContext)
|
|
||||||
base = options.additionalContext[obj.string];
|
|
||||||
if (!options || options.useGlobalScope !== false)
|
|
||||||
base = base || global[obj.string];
|
|
||||||
} else if (obj.type == "string") {
|
|
||||||
base = "";
|
|
||||||
} else if (obj.type == "atom") {
|
|
||||||
base = 1;
|
|
||||||
} else if (obj.type == "function") {
|
|
||||||
if (global.jQuery != null && (obj.string == '$' || obj.string == 'jQuery') &&
|
|
||||||
(typeof global.jQuery == 'function'))
|
|
||||||
base = global.jQuery();
|
|
||||||
else if (global._ != null && (obj.string == '_') && (typeof global._ == 'function'))
|
|
||||||
base = global._();
|
|
||||||
}
|
}
|
||||||
while (base != null && context.length)
|
|
||||||
base = base[context.pop().string];
|
|
||||||
if (base != null) gatherCompletions(base);
|
|
||||||
} else {
|
|
||||||
// If not, just look in the global object and any local scope
|
|
||||||
// (reading into JS mode internals to get at the local and global variables)
|
|
||||||
for (var v = token.state.localVars; v; v = v.next) maybeAdd(v.name);
|
|
||||||
for (var v = token.state.globalVars; v; v = v.next) maybeAdd(v.name);
|
|
||||||
if (!options || options.useGlobalScope !== false)
|
|
||||||
gatherCompletions(global);
|
|
||||||
forEach(keywords, maybeAdd);
|
|
||||||
}
|
|
||||||
return found;
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
function getCompletions(token, context, keywords, options) {
|
||||||
|
var found = [], start = token.string, global = options && options.globalScope || window;
|
||||||
|
|
||||||
|
function maybeAdd(str) {
|
||||||
|
if (str == null || str == undefined) return;
|
||||||
|
if (str.lastIndexOf(start, 0) == 0 && !arrayContains(found, str)) found.push(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
function gatherCompletions(obj) {
|
||||||
|
if (typeof obj == "string") forEach(stringProps, maybeAdd);
|
||||||
|
else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
|
||||||
|
else if (obj instanceof Function) forEach(funcProps, maybeAdd);
|
||||||
|
forAllProps(obj, maybeAdd)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context && context.length) {
|
||||||
|
// If this is a property, see if it belongs to some object we can
|
||||||
|
// find in the current environment.
|
||||||
|
var obj = context.pop(), base;
|
||||||
|
if (obj.type && obj.type.indexOf("variable") === 0) {
|
||||||
|
if (options && options.additionalContext)
|
||||||
|
base = options.additionalContext[obj.string];
|
||||||
|
if (!options || options.useGlobalScope !== false)
|
||||||
|
base = base || global[obj.string];
|
||||||
|
} else if (obj.type == "string") {
|
||||||
|
base = "";
|
||||||
|
} else if (obj.type == "atom") {
|
||||||
|
base = 1;
|
||||||
|
} else if (obj.type == "function") {
|
||||||
|
if (global.jQuery != null && (obj.string == '$' || obj.string == 'jQuery') &&
|
||||||
|
(typeof global.jQuery == 'function'))
|
||||||
|
base = global.jQuery();
|
||||||
|
else if (global._ != null && (obj.string == '_') && (typeof global._ == 'function'))
|
||||||
|
base = global._();
|
||||||
|
}
|
||||||
|
while (base != null && context.length)
|
||||||
|
base = base[context.pop().string];
|
||||||
|
if (base != null) gatherCompletions(base);
|
||||||
|
} else {
|
||||||
|
// If not, just look in the global object and any local scope
|
||||||
|
// (reading into JS mode internals to get at the local and global variables)
|
||||||
|
for (var v = token.state.localVars; v; v = v.next) maybeAdd(v.name);
|
||||||
|
for (var v = token.state.globalVars; v; v = v.next) maybeAdd(v.name);
|
||||||
|
if (!options || options.useGlobalScope !== false)
|
||||||
|
gatherCompletions(global);
|
||||||
|
forEach(keywords, maybeAdd);
|
||||||
|
}
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -1,63 +1,64 @@
|
|||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||||
|
|
||||||
(function(mod) {
|
(function (mod) {
|
||||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||||
mod(require("../../lib/codemirror"));
|
mod(require("../../lib/codemirror"));
|
||||||
else if (typeof define == "function" && define.amd) // AMD
|
else if (typeof define == "function" && define.amd) // AMD
|
||||||
define(["../../lib/codemirror"], mod);
|
define(["../../lib/codemirror"], mod);
|
||||||
else // Plain browser env
|
else // Plain browser env
|
||||||
mod(CodeMirror);
|
mod(CodeMirror);
|
||||||
})(function(CodeMirror) {
|
})(function (CodeMirror) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// declare global: JSHINT
|
// declare global: JSHINT
|
||||||
|
|
||||||
function validator(text, options) {
|
function validator(text, options) {
|
||||||
if (!window.JSHINT) {
|
if (!window.JSHINT) {
|
||||||
if (window.console) {
|
|
||||||
window.console.error("Error: window.JSHINT not defined, CodeMirror JavaScript linting cannot run.");
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
if (!options.indent) // JSHint error.character actually is a column index, this fixes underlining on lines using tabs for indentation
|
|
||||||
options.indent = 1; // JSHint default value is 4
|
|
||||||
JSHINT(text, options, options.globals);
|
|
||||||
var errors = JSHINT.data().errors, result = [];
|
|
||||||
if (errors) parseErrors(errors, result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
CodeMirror.registerHelper("lint", "javascript", validator);
|
|
||||||
|
|
||||||
function parseErrors(errors, output) {
|
|
||||||
for ( var i = 0; i < errors.length; i++) {
|
|
||||||
var error = errors[i];
|
|
||||||
if (error) {
|
|
||||||
if (error.line <= 0) {
|
|
||||||
if (window.console) {
|
if (window.console) {
|
||||||
window.console.warn("Cannot display JSHint error (invalid line " + error.line + ")", error);
|
window.console.error("Error: window.JSHINT not defined, CodeMirror JavaScript linting cannot run.");
|
||||||
}
|
}
|
||||||
continue;
|
return [];
|
||||||
}
|
|
||||||
|
|
||||||
var start = error.character - 1, end = start + 1;
|
|
||||||
if (error.evidence) {
|
|
||||||
var index = error.evidence.substring(start).search(/.\b/);
|
|
||||||
if (index > -1) {
|
|
||||||
end += index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert to format expected by validation service
|
|
||||||
var hint = {
|
|
||||||
message: error.reason,
|
|
||||||
severity: error.code ? (error.code.startsWith('W') ? "warning" : "error") : "error",
|
|
||||||
from: CodeMirror.Pos(error.line - 1, start),
|
|
||||||
to: CodeMirror.Pos(error.line - 1, end)
|
|
||||||
};
|
|
||||||
|
|
||||||
output.push(hint);
|
|
||||||
}
|
}
|
||||||
}
|
if (!options.indent) // JSHint error.character actually is a column index, this fixes underlining on lines using tabs for indentation
|
||||||
|
options.indent = 1; // JSHint default value is 4
|
||||||
|
JSHINT(text, options, options.globals);
|
||||||
|
var errors = JSHINT.data().errors, result = [];
|
||||||
|
if (errors) parseErrors(errors, result);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
CodeMirror.registerHelper("lint", "javascript", validator);
|
||||||
|
|
||||||
|
function parseErrors(errors, output) {
|
||||||
|
for (var i = 0; i < errors.length; i++) {
|
||||||
|
var error = errors[i];
|
||||||
|
if (error) {
|
||||||
|
if (error.line <= 0) {
|
||||||
|
if (window.console) {
|
||||||
|
window.console.warn("Cannot display JSHint error (invalid line " + error.line + ")", error);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var start = error.character - 1, end = start + 1;
|
||||||
|
if (error.evidence) {
|
||||||
|
var index = error.evidence.substring(start).search(/.\b/);
|
||||||
|
if (index > -1) {
|
||||||
|
end += index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert to format expected by validation service
|
||||||
|
var hint = {
|
||||||
|
message: error.reason,
|
||||||
|
severity: error.code ? (error.code.startsWith('W') ? "warning" : "error") : "error",
|
||||||
|
from: CodeMirror.Pos(error.line - 1, start),
|
||||||
|
to: CodeMirror.Pos(error.line - 1, end)
|
||||||
|
};
|
||||||
|
|
||||||
|
output.push(hint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -1,9 +1,9 @@
|
|||||||
/* The lint marker gutter */
|
/* The lint marker gutter */
|
||||||
.CodeMirror-lint-markers {
|
.CodeMirror-lint-markers {
|
||||||
width: 16px;
|
width: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-lint-tooltip {
|
.CodeMirror-lint-tooltip {
|
||||||
background-color: #ffd;
|
background-color: #ffd;
|
||||||
border: 1px solid black;
|
border: 1px solid black;
|
||||||
border-radius: 4px 4px 4px 4px;
|
border-radius: 4px 4px 4px 4px;
|
||||||
@ -23,24 +23,22 @@
|
|||||||
-webkit-transition: opacity .4s;
|
-webkit-transition: opacity .4s;
|
||||||
-o-transition: opacity .4s;
|
-o-transition: opacity .4s;
|
||||||
-ms-transition: opacity .4s;
|
-ms-transition: opacity .4s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-lint-mark-error, .CodeMirror-lint-mark-warning {
|
.CodeMirror-lint-mark-error, .CodeMirror-lint-mark-warning {
|
||||||
background-position: left bottom;
|
background-position: left bottom;
|
||||||
background-repeat: repeat-x;
|
background-repeat: repeat-x;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-lint-mark-error {
|
.CodeMirror-lint-mark-error {
|
||||||
background-image:
|
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==");
|
||||||
url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==")
|
}
|
||||||
;
|
|
||||||
}
|
.CodeMirror-lint-mark-warning {
|
||||||
|
|
||||||
.CodeMirror-lint-mark-warning {
|
|
||||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII=");
|
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII=");
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-lint-marker-error, .CodeMirror-lint-marker-warning {
|
.CodeMirror-lint-marker-error, .CodeMirror-lint-marker-warning {
|
||||||
background-position: center center;
|
background-position: center center;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@ -49,25 +47,26 @@
|
|||||||
width: 16px;
|
width: 16px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-lint-message-error, .CodeMirror-lint-message-warning {
|
.CodeMirror-lint-message-error, .CodeMirror-lint-message-warning {
|
||||||
padding-left: 18px;
|
padding-left: 18px;
|
||||||
background-position: top left;
|
background-position: top left;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-lint-marker-error, .CodeMirror-lint-message-error {
|
.CodeMirror-lint-marker-error, .CodeMirror-lint-message-error {
|
||||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII=");
|
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAHlBMVEW7AAC7AACxAAC7AAC7AAAAAAC4AAC5AAD///+7AAAUdclpAAAABnRSTlMXnORSiwCK0ZKSAAAATUlEQVR42mWPOQ7AQAgDuQLx/z8csYRmPRIFIwRGnosRrpamvkKi0FTIiMASR3hhKW+hAN6/tIWhu9PDWiTGNEkTtIOucA5Oyr9ckPgAWm0GPBog6v4AAAAASUVORK5CYII=");
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-lint-marker-warning, .CodeMirror-lint-message-warning {
|
.CodeMirror-lint-marker-warning, .CodeMirror-lint-message-warning {
|
||||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII=");
|
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAANlBMVEX/uwDvrwD/uwD/uwD/uwD/uwD/uwD/uwD/uwD6twD/uwAAAADurwD2tQD7uAD+ugAAAAD/uwDhmeTRAAAADHRSTlMJ8mN1EYcbmiixgACm7WbuAAAAVklEQVR42n3PUQqAIBBFUU1LLc3u/jdbOJoW1P08DA9Gba8+YWJ6gNJoNYIBzAA2chBth5kLmG9YUoG0NHAUwFXwO9LuBQL1giCQb8gC9Oro2vp5rncCIY8L8uEx5ZkAAAAASUVORK5CYII=");
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-lint-marker-multiple {
|
.CodeMirror-lint-marker-multiple {
|
||||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC");
|
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAMAAADzjKfhAAAACVBMVEUAAAAAAAC/v7914kyHAAAAAXRSTlMAQObYZgAAACNJREFUeNo1ioEJAAAIwmz/H90iFFSGJgFMe3gaLZ0od+9/AQZ0ADosbYraAAAAAElFTkSuQmCC");
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-position: right bottom;
|
background-position: right bottom;
|
||||||
width: 100%; height: 100%;
|
width: 100%;
|
||||||
}
|
height: 100%;
|
||||||
|
}
|
||||||
@ -1,252 +1,277 @@
|
|||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||||
|
|
||||||
(function(mod) {
|
(function (mod) {
|
||||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||||
mod(require("../../lib/codemirror"));
|
mod(require("../../lib/codemirror"));
|
||||||
else if (typeof define == "function" && define.amd) // AMD
|
else if (typeof define == "function" && define.amd) // AMD
|
||||||
define(["../../lib/codemirror"], mod);
|
define(["../../lib/codemirror"], mod);
|
||||||
else // Plain browser env
|
else // Plain browser env
|
||||||
mod(CodeMirror);
|
mod(CodeMirror);
|
||||||
})(function(CodeMirror) {
|
})(function (CodeMirror) {
|
||||||
"use strict";
|
"use strict";
|
||||||
var GUTTER_ID = "CodeMirror-lint-markers";
|
var GUTTER_ID = "CodeMirror-lint-markers";
|
||||||
|
|
||||||
function showTooltip(e, content) {
|
function showTooltip(e, content) {
|
||||||
var tt = document.createElement("div");
|
var tt = document.createElement("div");
|
||||||
tt.className = "CodeMirror-lint-tooltip";
|
tt.className = "CodeMirror-lint-tooltip";
|
||||||
tt.appendChild(content.cloneNode(true));
|
tt.appendChild(content.cloneNode(true));
|
||||||
document.body.appendChild(tt);
|
document.body.appendChild(tt);
|
||||||
|
|
||||||
function position(e) {
|
function position(e) {
|
||||||
if (!tt.parentNode) return CodeMirror.off(document, "mousemove", position);
|
if (!tt.parentNode) return CodeMirror.off(document, "mousemove", position);
|
||||||
tt.style.top = Math.max(0, e.clientY - tt.offsetHeight - 5) + "px";
|
tt.style.top = Math.max(0, e.clientY - tt.offsetHeight - 5) + "px";
|
||||||
tt.style.left = (e.clientX + 5) + "px";
|
tt.style.left = (e.clientX + 5) + "px";
|
||||||
}
|
}
|
||||||
CodeMirror.on(document, "mousemove", position);
|
|
||||||
position(e);
|
CodeMirror.on(document, "mousemove", position);
|
||||||
if (tt.style.opacity != null) tt.style.opacity = 1;
|
position(e);
|
||||||
return tt;
|
if (tt.style.opacity != null) tt.style.opacity = 1;
|
||||||
|
return tt;
|
||||||
}
|
}
|
||||||
|
|
||||||
function rm(elt) {
|
function rm(elt) {
|
||||||
if (elt.parentNode) elt.parentNode.removeChild(elt);
|
if (elt.parentNode) elt.parentNode.removeChild(elt);
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideTooltip(tt) {
|
function hideTooltip(tt) {
|
||||||
if (!tt.parentNode) return;
|
if (!tt.parentNode) return;
|
||||||
if (tt.style.opacity == null) rm(tt);
|
if (tt.style.opacity == null) rm(tt);
|
||||||
tt.style.opacity = 0;
|
tt.style.opacity = 0;
|
||||||
setTimeout(function() { rm(tt); }, 600);
|
setTimeout(function () {
|
||||||
|
rm(tt);
|
||||||
|
}, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showTooltipFor(e, content, node) {
|
function showTooltipFor(e, content, node) {
|
||||||
var tooltip = showTooltip(e, content);
|
var tooltip = showTooltip(e, content);
|
||||||
function hide() {
|
|
||||||
CodeMirror.off(node, "mouseout", hide);
|
function hide() {
|
||||||
if (tooltip) { hideTooltip(tooltip); tooltip = null; }
|
CodeMirror.off(node, "mouseout", hide);
|
||||||
}
|
if (tooltip) {
|
||||||
var poll = setInterval(function() {
|
hideTooltip(tooltip);
|
||||||
if (tooltip) for (var n = node;; n = n.parentNode) {
|
tooltip = null;
|
||||||
if (n && n.nodeType == 11) n = n.host;
|
}
|
||||||
if (n == document.body) return;
|
|
||||||
if (!n) { hide(); break; }
|
|
||||||
}
|
}
|
||||||
if (!tooltip) return clearInterval(poll);
|
|
||||||
}, 400);
|
var poll = setInterval(function () {
|
||||||
CodeMirror.on(node, "mouseout", hide);
|
if (tooltip) for (var n = node; ; n = n.parentNode) {
|
||||||
|
if (n && n.nodeType == 11) n = n.host;
|
||||||
|
if (n == document.body) return;
|
||||||
|
if (!n) {
|
||||||
|
hide();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!tooltip) return clearInterval(poll);
|
||||||
|
}, 400);
|
||||||
|
CodeMirror.on(node, "mouseout", hide);
|
||||||
}
|
}
|
||||||
|
|
||||||
function LintState(cm, options, hasGutter) {
|
function LintState(cm, options, hasGutter) {
|
||||||
this.marked = [];
|
this.marked = [];
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.timeout = null;
|
this.timeout = null;
|
||||||
this.hasGutter = hasGutter;
|
this.hasGutter = hasGutter;
|
||||||
this.onMouseOver = function(e) { onMouseOver(cm, e); };
|
this.onMouseOver = function (e) {
|
||||||
this.waitingFor = 0
|
onMouseOver(cm, e);
|
||||||
|
};
|
||||||
|
this.waitingFor = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseOptions(_cm, options) {
|
function parseOptions(_cm, options) {
|
||||||
if (options instanceof Function) return {getAnnotations: options};
|
if (options instanceof Function) return {getAnnotations: options};
|
||||||
if (!options || options === true) options = {};
|
if (!options || options === true) options = {};
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearMarks(cm) {
|
function clearMarks(cm) {
|
||||||
var state = cm.state.lint;
|
var state = cm.state.lint;
|
||||||
if (state.hasGutter) cm.clearGutter(GUTTER_ID);
|
if (state.hasGutter) cm.clearGutter(GUTTER_ID);
|
||||||
for (var i = 0; i < state.marked.length; ++i)
|
for (var i = 0; i < state.marked.length; ++i)
|
||||||
state.marked[i].clear();
|
state.marked[i].clear();
|
||||||
state.marked.length = 0;
|
state.marked.length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeMarker(labels, severity, multiple, tooltips) {
|
function makeMarker(labels, severity, multiple, tooltips) {
|
||||||
var marker = document.createElement("div"), inner = marker;
|
var marker = document.createElement("div"), inner = marker;
|
||||||
marker.className = "CodeMirror-lint-marker-" + severity;
|
marker.className = "CodeMirror-lint-marker-" + severity;
|
||||||
if (multiple) {
|
if (multiple) {
|
||||||
inner = marker.appendChild(document.createElement("div"));
|
inner = marker.appendChild(document.createElement("div"));
|
||||||
inner.className = "CodeMirror-lint-marker-multiple";
|
inner.className = "CodeMirror-lint-marker-multiple";
|
||||||
}
|
|
||||||
|
|
||||||
if (tooltips != false) CodeMirror.on(inner, "mouseover", function(e) {
|
|
||||||
showTooltipFor(e, labels, inner);
|
|
||||||
});
|
|
||||||
|
|
||||||
return marker;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getMaxSeverity(a, b) {
|
|
||||||
if (a == "error") return a;
|
|
||||||
else return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
function groupByLine(annotations) {
|
|
||||||
var lines = [];
|
|
||||||
for (var i = 0; i < annotations.length; ++i) {
|
|
||||||
var ann = annotations[i], line = ann.from.line;
|
|
||||||
(lines[line] || (lines[line] = [])).push(ann);
|
|
||||||
}
|
|
||||||
return lines;
|
|
||||||
}
|
|
||||||
|
|
||||||
function annotationTooltip(ann) {
|
|
||||||
var severity = ann.severity;
|
|
||||||
if (!severity) severity = "error";
|
|
||||||
var tip = document.createElement("div");
|
|
||||||
tip.className = "CodeMirror-lint-message-" + severity;
|
|
||||||
if (typeof ann.messageHTML != 'undefined') {
|
|
||||||
tip.innerHTML = ann.messageHTML;
|
|
||||||
} else {
|
|
||||||
tip.appendChild(document.createTextNode(ann.message));
|
|
||||||
}
|
|
||||||
return tip;
|
|
||||||
}
|
|
||||||
|
|
||||||
function lintAsync(cm, getAnnotations, passOptions) {
|
|
||||||
var state = cm.state.lint
|
|
||||||
var id = ++state.waitingFor
|
|
||||||
function abort() {
|
|
||||||
id = -1
|
|
||||||
cm.off("change", abort)
|
|
||||||
}
|
|
||||||
cm.on("change", abort)
|
|
||||||
getAnnotations(cm.getValue(), function(annotations, arg2) {
|
|
||||||
cm.off("change", abort)
|
|
||||||
if (state.waitingFor != id) return
|
|
||||||
if (arg2 && annotations instanceof CodeMirror) annotations = arg2
|
|
||||||
cm.operation(function() {updateLinting(cm, annotations)})
|
|
||||||
}, passOptions, cm);
|
|
||||||
}
|
|
||||||
|
|
||||||
function startLinting(cm) {
|
|
||||||
var state = cm.state.lint, options = state.options;
|
|
||||||
/*
|
|
||||||
* Passing rules in `options` property prevents JSHint (and other linters) from complaining
|
|
||||||
* about unrecognized rules like `onUpdateLinting`, `delay`, `lintOnChange`, etc.
|
|
||||||
*/
|
|
||||||
var passOptions = options.options || options;
|
|
||||||
var getAnnotations = options.getAnnotations || cm.getHelper(CodeMirror.Pos(0, 0), "lint");
|
|
||||||
if (!getAnnotations) return;
|
|
||||||
if (options.async || getAnnotations.async) {
|
|
||||||
lintAsync(cm, getAnnotations, passOptions)
|
|
||||||
} else {
|
|
||||||
var annotations = getAnnotations(cm.getValue(), passOptions, cm);
|
|
||||||
if (!annotations) return;
|
|
||||||
if (annotations.then) annotations.then(function(issues) {
|
|
||||||
cm.operation(function() {updateLinting(cm, issues)})
|
|
||||||
});
|
|
||||||
else cm.operation(function() {updateLinting(cm, annotations)})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateLinting(cm, annotationsNotSorted) {
|
|
||||||
clearMarks(cm);
|
|
||||||
var state = cm.state.lint, options = state.options;
|
|
||||||
|
|
||||||
var annotations = groupByLine(annotationsNotSorted);
|
|
||||||
|
|
||||||
for (var line = 0; line < annotations.length; ++line) {
|
|
||||||
var anns = annotations[line];
|
|
||||||
if (!anns) continue;
|
|
||||||
|
|
||||||
var maxSeverity = null;
|
|
||||||
var tipLabel = state.hasGutter && document.createDocumentFragment();
|
|
||||||
|
|
||||||
for (var i = 0; i < anns.length; ++i) {
|
|
||||||
var ann = anns[i];
|
|
||||||
var severity = ann.severity;
|
|
||||||
if (!severity) severity = "error";
|
|
||||||
maxSeverity = getMaxSeverity(maxSeverity, severity);
|
|
||||||
|
|
||||||
if (options.formatAnnotation) ann = options.formatAnnotation(ann);
|
|
||||||
if (state.hasGutter) tipLabel.appendChild(annotationTooltip(ann));
|
|
||||||
|
|
||||||
if (ann.to) state.marked.push(cm.markText(ann.from, ann.to, {
|
|
||||||
className: "CodeMirror-lint-mark-" + severity,
|
|
||||||
__annotation: ann
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.hasGutter)
|
if (tooltips != false) CodeMirror.on(inner, "mouseover", function (e) {
|
||||||
cm.setGutterMarker(line, GUTTER_ID, makeMarker(tipLabel, maxSeverity, anns.length > 1,
|
showTooltipFor(e, labels, inner);
|
||||||
state.options.tooltips));
|
});
|
||||||
}
|
|
||||||
if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm);
|
return marker;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onChange(cm) {
|
function getMaxSeverity(a, b) {
|
||||||
var state = cm.state.lint;
|
if (a == "error") return a;
|
||||||
if (!state) return;
|
else return b;
|
||||||
clearTimeout(state.timeout);
|
|
||||||
state.timeout = setTimeout(function(){startLinting(cm);}, state.options.delay || 500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function popupTooltips(annotations, e) {
|
function groupByLine(annotations) {
|
||||||
var target = e.target || e.srcElement;
|
var lines = [];
|
||||||
var tooltip = document.createDocumentFragment();
|
for (var i = 0; i < annotations.length; ++i) {
|
||||||
for (var i = 0; i < annotations.length; i++) {
|
var ann = annotations[i], line = ann.from.line;
|
||||||
var ann = annotations[i];
|
(lines[line] || (lines[line] = [])).push(ann);
|
||||||
tooltip.appendChild(annotationTooltip(ann));
|
}
|
||||||
}
|
return lines;
|
||||||
showTooltipFor(e, tooltip, target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMouseOver(cm, e) {
|
function annotationTooltip(ann) {
|
||||||
var target = e.target || e.srcElement;
|
var severity = ann.severity;
|
||||||
if (!/\bCodeMirror-lint-mark-/.test(target.className)) return;
|
if (!severity) severity = "error";
|
||||||
var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2;
|
var tip = document.createElement("div");
|
||||||
var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client"));
|
tip.className = "CodeMirror-lint-message-" + severity;
|
||||||
|
if (typeof ann.messageHTML != 'undefined') {
|
||||||
var annotations = [];
|
tip.innerHTML = ann.messageHTML;
|
||||||
for (var i = 0; i < spans.length; ++i) {
|
} else {
|
||||||
var ann = spans[i].__annotation;
|
tip.appendChild(document.createTextNode(ann.message));
|
||||||
if (ann) annotations.push(ann);
|
}
|
||||||
}
|
return tip;
|
||||||
if (annotations.length) popupTooltips(annotations, e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeMirror.defineOption("lint", false, function(cm, val, old) {
|
function lintAsync(cm, getAnnotations, passOptions) {
|
||||||
if (old && old != CodeMirror.Init) {
|
var state = cm.state.lint
|
||||||
|
var id = ++state.waitingFor
|
||||||
|
|
||||||
|
function abort() {
|
||||||
|
id = -1
|
||||||
|
cm.off("change", abort)
|
||||||
|
}
|
||||||
|
|
||||||
|
cm.on("change", abort)
|
||||||
|
getAnnotations(cm.getValue(), function (annotations, arg2) {
|
||||||
|
cm.off("change", abort)
|
||||||
|
if (state.waitingFor != id) return
|
||||||
|
if (arg2 && annotations instanceof CodeMirror) annotations = arg2
|
||||||
|
cm.operation(function () {
|
||||||
|
updateLinting(cm, annotations)
|
||||||
|
})
|
||||||
|
}, passOptions, cm);
|
||||||
|
}
|
||||||
|
|
||||||
|
function startLinting(cm) {
|
||||||
|
var state = cm.state.lint, options = state.options;
|
||||||
|
/*
|
||||||
|
* Passing rules in `options` property prevents JSHint (and other linters) from complaining
|
||||||
|
* about unrecognized rules like `onUpdateLinting`, `delay`, `lintOnChange`, etc.
|
||||||
|
*/
|
||||||
|
var passOptions = options.options || options;
|
||||||
|
var getAnnotations = options.getAnnotations || cm.getHelper(CodeMirror.Pos(0, 0), "lint");
|
||||||
|
if (!getAnnotations) return;
|
||||||
|
if (options.async || getAnnotations.async) {
|
||||||
|
lintAsync(cm, getAnnotations, passOptions)
|
||||||
|
} else {
|
||||||
|
var annotations = getAnnotations(cm.getValue(), passOptions, cm);
|
||||||
|
if (!annotations) return;
|
||||||
|
if (annotations.then) annotations.then(function (issues) {
|
||||||
|
cm.operation(function () {
|
||||||
|
updateLinting(cm, issues)
|
||||||
|
})
|
||||||
|
});
|
||||||
|
else cm.operation(function () {
|
||||||
|
updateLinting(cm, annotations)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateLinting(cm, annotationsNotSorted) {
|
||||||
clearMarks(cm);
|
clearMarks(cm);
|
||||||
if (cm.state.lint.options.lintOnChange !== false)
|
var state = cm.state.lint, options = state.options;
|
||||||
cm.off("change", onChange);
|
|
||||||
CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver);
|
var annotations = groupByLine(annotationsNotSorted);
|
||||||
clearTimeout(cm.state.lint.timeout);
|
|
||||||
delete cm.state.lint;
|
for (var line = 0; line < annotations.length; ++line) {
|
||||||
}
|
var anns = annotations[line];
|
||||||
|
if (!anns) continue;
|
||||||
if (val) {
|
|
||||||
var gutters = cm.getOption("gutters"), hasLintGutter = false;
|
var maxSeverity = null;
|
||||||
for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
|
var tipLabel = state.hasGutter && document.createDocumentFragment();
|
||||||
var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter);
|
|
||||||
if (state.options.lintOnChange !== false)
|
for (var i = 0; i < anns.length; ++i) {
|
||||||
cm.on("change", onChange);
|
var ann = anns[i];
|
||||||
if (state.options.tooltips != false && state.options.tooltips != "gutter")
|
var severity = ann.severity;
|
||||||
CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
|
if (!severity) severity = "error";
|
||||||
|
maxSeverity = getMaxSeverity(maxSeverity, severity);
|
||||||
startLinting(cm);
|
|
||||||
}
|
if (options.formatAnnotation) ann = options.formatAnnotation(ann);
|
||||||
|
if (state.hasGutter) tipLabel.appendChild(annotationTooltip(ann));
|
||||||
|
|
||||||
|
if (ann.to) state.marked.push(cm.markText(ann.from, ann.to, {
|
||||||
|
className: "CodeMirror-lint-mark-" + severity,
|
||||||
|
__annotation: ann
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.hasGutter)
|
||||||
|
cm.setGutterMarker(line, GUTTER_ID, makeMarker(tipLabel, maxSeverity, anns.length > 1,
|
||||||
|
state.options.tooltips));
|
||||||
|
}
|
||||||
|
if (options.onUpdateLinting) options.onUpdateLinting(annotationsNotSorted, annotations, cm);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onChange(cm) {
|
||||||
|
var state = cm.state.lint;
|
||||||
|
if (!state) return;
|
||||||
|
clearTimeout(state.timeout);
|
||||||
|
state.timeout = setTimeout(function () {
|
||||||
|
startLinting(cm);
|
||||||
|
}, state.options.delay || 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
function popupTooltips(annotations, e) {
|
||||||
|
var target = e.target || e.srcElement;
|
||||||
|
var tooltip = document.createDocumentFragment();
|
||||||
|
for (var i = 0; i < annotations.length; i++) {
|
||||||
|
var ann = annotations[i];
|
||||||
|
tooltip.appendChild(annotationTooltip(ann));
|
||||||
|
}
|
||||||
|
showTooltipFor(e, tooltip, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseOver(cm, e) {
|
||||||
|
var target = e.target || e.srcElement;
|
||||||
|
if (!/\bCodeMirror-lint-mark-/.test(target.className)) return;
|
||||||
|
var box = target.getBoundingClientRect(), x = (box.left + box.right) / 2, y = (box.top + box.bottom) / 2;
|
||||||
|
var spans = cm.findMarksAt(cm.coordsChar({left: x, top: y}, "client"));
|
||||||
|
|
||||||
|
var annotations = [];
|
||||||
|
for (var i = 0; i < spans.length; ++i) {
|
||||||
|
var ann = spans[i].__annotation;
|
||||||
|
if (ann) annotations.push(ann);
|
||||||
|
}
|
||||||
|
if (annotations.length) popupTooltips(annotations, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
CodeMirror.defineOption("lint", false, function (cm, val, old) {
|
||||||
|
if (old && old != CodeMirror.Init) {
|
||||||
|
clearMarks(cm);
|
||||||
|
if (cm.state.lint.options.lintOnChange !== false)
|
||||||
|
cm.off("change", onChange);
|
||||||
|
CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver);
|
||||||
|
clearTimeout(cm.state.lint.timeout);
|
||||||
|
delete cm.state.lint;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (val) {
|
||||||
|
var gutters = cm.getOption("gutters"), hasLintGutter = false;
|
||||||
|
for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
|
||||||
|
var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter);
|
||||||
|
if (state.options.lintOnChange !== false)
|
||||||
|
cm.on("change", onChange);
|
||||||
|
if (state.options.tooltips != false && state.options.tooltips != "gutter")
|
||||||
|
CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
|
||||||
|
|
||||||
|
startLinting(cm);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
CodeMirror.defineExtension("performLint", function() {
|
CodeMirror.defineExtension("performLint", function () {
|
||||||
if (this.state.lint) startLinting(this);
|
if (this.state.lint) startLinting(this);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -3,34 +3,34 @@
|
|||||||
z-index: 301;
|
z-index: 301;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
|
|
||||||
-webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
-webkit-box-shadow: 2px 3px 5px rgba(0, 0, 0, .2);
|
||||||
-moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
-moz-box-shadow: 2px 3px 5px rgba(0, 0, 0, .2);
|
||||||
box-shadow: 2px 3px 5px rgba(0,0,0,.2);
|
box-shadow: 2px 3px 5px rgba(0, 0, 0, .2);
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
border: 1px solid silver;
|
border: 1px solid silver;
|
||||||
|
|
||||||
background: white;
|
background: white;
|
||||||
font-size: 90%;
|
font-size: 90%;
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
|
|
||||||
max-height: 20em;
|
max-height: 20em;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.CodeMirror-hint {
|
.CodeMirror-hint {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0 4px;
|
padding: 0 4px;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
color: black;
|
color: black;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
li.CodeMirror-hint-active {
|
li.CodeMirror-hint-active {
|
||||||
background: #08f;
|
background: #08f;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
@ -1,432 +1,484 @@
|
|||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||||
|
|
||||||
(function(mod) {
|
(function (mod) {
|
||||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||||
mod(require("../../lib/codemirror"));
|
mod(require("../../lib/codemirror"));
|
||||||
else if (typeof define == "function" && define.amd) // AMD
|
else if (typeof define == "function" && define.amd) // AMD
|
||||||
define(["../../lib/codemirror"], mod);
|
define(["../../lib/codemirror"], mod);
|
||||||
else // Plain browser env
|
else // Plain browser env
|
||||||
mod(CodeMirror);
|
mod(CodeMirror);
|
||||||
})(function(CodeMirror) {
|
})(function (CodeMirror) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var HINT_ELEMENT_CLASS = "CodeMirror-hint";
|
var HINT_ELEMENT_CLASS = "CodeMirror-hint";
|
||||||
var ACTIVE_HINT_ELEMENT_CLASS = "CodeMirror-hint-active";
|
var ACTIVE_HINT_ELEMENT_CLASS = "CodeMirror-hint-active";
|
||||||
|
|
||||||
// This is the old interface, kept around for now to stay
|
// This is the old interface, kept around for now to stay
|
||||||
// backwards-compatible.
|
// backwards-compatible.
|
||||||
CodeMirror.showHint = function(cm, getHints, options) {
|
CodeMirror.showHint = function (cm, getHints, options) {
|
||||||
if (!getHints) return cm.showHint(options);
|
if (!getHints) return cm.showHint(options);
|
||||||
if (options && options.async) getHints.async = true;
|
if (options && options.async) getHints.async = true;
|
||||||
var newOpts = {hint: getHints};
|
var newOpts = {hint: getHints};
|
||||||
if (options) for (var prop in options) newOpts[prop] = options[prop];
|
if (options) for (var prop in options) newOpts[prop] = options[prop];
|
||||||
return cm.showHint(newOpts);
|
return cm.showHint(newOpts);
|
||||||
};
|
};
|
||||||
|
|
||||||
CodeMirror.defineExtension("showHint", function(options) {
|
CodeMirror.defineExtension("showHint", function (options) {
|
||||||
options = parseOptions(this, this.getCursor("start"), options);
|
options = parseOptions(this, this.getCursor("start"), options);
|
||||||
var selections = this.listSelections()
|
var selections = this.listSelections()
|
||||||
if (selections.length > 1) return;
|
if (selections.length > 1) return;
|
||||||
// By default, don't allow completion when something is selected.
|
// By default, don't allow completion when something is selected.
|
||||||
// A hint function can have a `supportsSelection` property to
|
// A hint function can have a `supportsSelection` property to
|
||||||
// indicate that it can handle selections.
|
// indicate that it can handle selections.
|
||||||
if (this.somethingSelected()) {
|
if (this.somethingSelected()) {
|
||||||
if (!options.hint.supportsSelection) return;
|
if (!options.hint.supportsSelection) return;
|
||||||
// Don't try with cross-line selections
|
// Don't try with cross-line selections
|
||||||
for (var i = 0; i < selections.length; i++)
|
for (var i = 0; i < selections.length; i++)
|
||||||
if (selections[i].head.line != selections[i].anchor.line) return;
|
if (selections[i].head.line != selections[i].anchor.line) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.state.completionActive) this.state.completionActive.close();
|
if (this.state.completionActive) this.state.completionActive.close();
|
||||||
var completion = this.state.completionActive = new Completion(this, options);
|
var completion = this.state.completionActive = new Completion(this, options);
|
||||||
if (!completion.options.hint) return;
|
if (!completion.options.hint) return;
|
||||||
|
|
||||||
CodeMirror.signal(this, "startCompletion", this);
|
CodeMirror.signal(this, "startCompletion", this);
|
||||||
completion.update(true);
|
completion.update(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
function Completion(cm, options) {
|
function Completion(cm, options) {
|
||||||
this.cm = cm;
|
this.cm = cm;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.widget = null;
|
this.widget = null;
|
||||||
this.debounce = 0;
|
this.debounce = 0;
|
||||||
this.tick = 0;
|
this.tick = 0;
|
||||||
this.startPos = this.cm.getCursor("start");
|
this.startPos = this.cm.getCursor("start");
|
||||||
this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length;
|
this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length;
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); });
|
cm.on("cursorActivity", this.activityFunc = function () {
|
||||||
|
self.cursorActivity();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var requestAnimationFrame = window.requestAnimationFrame || function(fn) {
|
var requestAnimationFrame = window.requestAnimationFrame || function (fn) {
|
||||||
return setTimeout(fn, 1000/60);
|
return setTimeout(fn, 1000 / 60);
|
||||||
};
|
};
|
||||||
var cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout;
|
var cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout;
|
||||||
|
|
||||||
Completion.prototype = {
|
Completion.prototype = {
|
||||||
close: function() {
|
close: function () {
|
||||||
if (!this.active()) return;
|
if (!this.active()) return;
|
||||||
this.cm.state.completionActive = null;
|
this.cm.state.completionActive = null;
|
||||||
this.tick = null;
|
this.tick = null;
|
||||||
this.cm.off("cursorActivity", this.activityFunc);
|
this.cm.off("cursorActivity", this.activityFunc);
|
||||||
|
|
||||||
if (this.widget && this.data) CodeMirror.signal(this.data, "close");
|
if (this.widget && this.data) CodeMirror.signal(this.data, "close");
|
||||||
if (this.widget) this.widget.close();
|
if (this.widget) this.widget.close();
|
||||||
CodeMirror.signal(this.cm, "endCompletion", this.cm);
|
CodeMirror.signal(this.cm, "endCompletion", this.cm);
|
||||||
},
|
},
|
||||||
|
|
||||||
active: function() {
|
active: function () {
|
||||||
return this.cm.state.completionActive == this;
|
return this.cm.state.completionActive == this;
|
||||||
},
|
},
|
||||||
|
|
||||||
pick: function(data, i) {
|
pick: function (data, i) {
|
||||||
var completion = data.list[i];
|
var completion = data.list[i];
|
||||||
if (completion.hint) completion.hint(this.cm, data, completion);
|
if (completion.hint) completion.hint(this.cm, data, completion);
|
||||||
else this.cm.replaceRange(getText(completion), completion.from || data.from,
|
else this.cm.replaceRange(getText(completion), completion.from || data.from,
|
||||||
completion.to || data.to, "complete");
|
completion.to || data.to, "complete");
|
||||||
CodeMirror.signal(data, "pick", completion);
|
CodeMirror.signal(data, "pick", completion);
|
||||||
this.close();
|
this.close();
|
||||||
},
|
},
|
||||||
|
|
||||||
cursorActivity: function() {
|
cursorActivity: function () {
|
||||||
if (this.debounce) {
|
if (this.debounce) {
|
||||||
cancelAnimationFrame(this.debounce);
|
cancelAnimationFrame(this.debounce);
|
||||||
this.debounce = 0;
|
this.debounce = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var pos = this.cm.getCursor(), line = this.cm.getLine(pos.line);
|
var pos = this.cm.getCursor(), line = this.cm.getLine(pos.line);
|
||||||
if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch ||
|
if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch ||
|
||||||
pos.ch < this.startPos.ch || this.cm.somethingSelected() ||
|
pos.ch < this.startPos.ch || this.cm.somethingSelected() ||
|
||||||
(pos.ch && this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) {
|
(pos.ch && this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) {
|
||||||
this.close();
|
this.close();
|
||||||
} else {
|
} else {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.debounce = requestAnimationFrame(function() {self.update();});
|
this.debounce = requestAnimationFrame(function () {
|
||||||
if (this.widget) this.widget.disable();
|
self.update();
|
||||||
}
|
});
|
||||||
},
|
if (this.widget) this.widget.disable();
|
||||||
|
}
|
||||||
update: function(first) {
|
},
|
||||||
if (this.tick == null) return
|
|
||||||
var self = this, myTick = ++this.tick
|
update: function (first) {
|
||||||
fetchHints(this.options.hint, this.cm, this.options, function(data) {
|
if (this.tick == null) return
|
||||||
if (self.tick == myTick) self.finishUpdate(data, first)
|
var self = this, myTick = ++this.tick
|
||||||
})
|
fetchHints(this.options.hint, this.cm, this.options, function (data) {
|
||||||
},
|
if (self.tick == myTick) self.finishUpdate(data, first)
|
||||||
|
|
||||||
finishUpdate: function(data, first) {
|
|
||||||
if (this.data) CodeMirror.signal(this.data, "update");
|
|
||||||
|
|
||||||
var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);
|
|
||||||
if (this.widget) this.widget.close();
|
|
||||||
|
|
||||||
this.data = data;
|
|
||||||
|
|
||||||
if (data && data.list.length) {
|
|
||||||
if (picked && data.list.length == 1) {
|
|
||||||
this.pick(data, 0);
|
|
||||||
} else {
|
|
||||||
this.widget = new Widget(this, data);
|
|
||||||
CodeMirror.signal(data, "shown");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function parseOptions(cm, pos, options) {
|
|
||||||
var editor = cm.options.hintOptions;
|
|
||||||
var out = {};
|
|
||||||
for (var prop in defaultOptions) out[prop] = defaultOptions[prop];
|
|
||||||
if (editor) for (var prop in editor)
|
|
||||||
if (editor[prop] !== undefined) out[prop] = editor[prop];
|
|
||||||
if (options) for (var prop in options)
|
|
||||||
if (options[prop] !== undefined) out[prop] = options[prop];
|
|
||||||
if (out.hint.resolve) out.hint = out.hint.resolve(cm, pos)
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getText(completion) {
|
|
||||||
if (typeof completion == "string") return completion;
|
|
||||||
else return completion.text;
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildKeyMap(completion, handle) {
|
|
||||||
var baseMap = {
|
|
||||||
Up: function() {handle.moveFocus(-1);},
|
|
||||||
Down: function() {handle.moveFocus(1);},
|
|
||||||
PageUp: function() {handle.moveFocus(-handle.menuSize() + 1, true);},
|
|
||||||
PageDown: function() {handle.moveFocus(handle.menuSize() - 1, true);},
|
|
||||||
Home: function() {handle.setFocus(0);},
|
|
||||||
End: function() {handle.setFocus(handle.length - 1);},
|
|
||||||
Enter: handle.pick,
|
|
||||||
Tab: handle.pick,
|
|
||||||
Esc: handle.close
|
|
||||||
};
|
|
||||||
var custom = completion.options.customKeys;
|
|
||||||
var ourMap = custom ? {} : baseMap;
|
|
||||||
function addBinding(key, val) {
|
|
||||||
var bound;
|
|
||||||
if (typeof val != "string")
|
|
||||||
bound = function(cm) { return val(cm, handle); };
|
|
||||||
// This mechanism is deprecated
|
|
||||||
else if (baseMap.hasOwnProperty(val))
|
|
||||||
bound = baseMap[val];
|
|
||||||
else
|
|
||||||
bound = val;
|
|
||||||
ourMap[key] = bound;
|
|
||||||
}
|
|
||||||
if (custom)
|
|
||||||
for (var key in custom) if (custom.hasOwnProperty(key))
|
|
||||||
addBinding(key, custom[key]);
|
|
||||||
var extra = completion.options.extraKeys;
|
|
||||||
if (extra)
|
|
||||||
for (var key in extra) if (extra.hasOwnProperty(key))
|
|
||||||
addBinding(key, extra[key]);
|
|
||||||
return ourMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getHintElement(hintsElement, el) {
|
|
||||||
while (el && el != hintsElement) {
|
|
||||||
if (el.nodeName.toUpperCase() === "LI" && el.parentNode == hintsElement) return el;
|
|
||||||
el = el.parentNode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function Widget(completion, data) {
|
|
||||||
this.completion = completion;
|
|
||||||
this.data = data;
|
|
||||||
this.picked = false;
|
|
||||||
var widget = this, cm = completion.cm;
|
|
||||||
|
|
||||||
var hints = this.hints = document.createElement("ul");
|
|
||||||
hints.className = "CodeMirror-hints";
|
|
||||||
this.selectedHint = data.selectedHint || 0;
|
|
||||||
|
|
||||||
var completions = data.list;
|
|
||||||
for (var i = 0; i < completions.length; ++i) {
|
|
||||||
var elt = hints.appendChild(document.createElement("li")), cur = completions[i];
|
|
||||||
var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS);
|
|
||||||
if (cur.className != null) className = cur.className + " " + className;
|
|
||||||
elt.className = className;
|
|
||||||
if (cur.render) cur.render(elt, data, cur);
|
|
||||||
else elt.appendChild(document.createTextNode(cur.displayText || getText(cur)));
|
|
||||||
elt.hintId = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
var pos = cm.cursorCoords(completion.options.alignWithWord ? data.from : null);
|
|
||||||
var left = pos.left, top = pos.bottom, below = true;
|
|
||||||
hints.style.left = left + "px";
|
|
||||||
hints.style.top = top + "px";
|
|
||||||
// If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
|
|
||||||
var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
|
|
||||||
var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
|
|
||||||
(completion.options.container || document.body).appendChild(hints);
|
|
||||||
var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
|
|
||||||
var scrolls = hints.scrollHeight > hints.clientHeight + 1
|
|
||||||
var startScroll = cm.getScrollInfo();
|
|
||||||
|
|
||||||
if (overlapY > 0) {
|
|
||||||
var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top);
|
|
||||||
if (curTop - height > 0) { // Fits above cursor
|
|
||||||
hints.style.top = (top = pos.top - height) + "px";
|
|
||||||
below = false;
|
|
||||||
} else if (height > winH) {
|
|
||||||
hints.style.height = (winH - 5) + "px";
|
|
||||||
hints.style.top = (top = pos.bottom - box.top) + "px";
|
|
||||||
var cursor = cm.getCursor();
|
|
||||||
if (data.from.ch != cursor.ch) {
|
|
||||||
pos = cm.cursorCoords(cursor);
|
|
||||||
hints.style.left = (left = pos.left) + "px";
|
|
||||||
box = hints.getBoundingClientRect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var overlapX = box.right - winW;
|
|
||||||
if (overlapX > 0) {
|
|
||||||
if (box.right - box.left > winW) {
|
|
||||||
hints.style.width = (winW - 5) + "px";
|
|
||||||
overlapX -= (box.right - box.left) - winW;
|
|
||||||
}
|
|
||||||
hints.style.left = (left = pos.left - overlapX) + "px";
|
|
||||||
}
|
|
||||||
if (scrolls) for (var node = hints.firstChild; node; node = node.nextSibling)
|
|
||||||
node.style.paddingRight = cm.display.nativeBarWidth + "px"
|
|
||||||
|
|
||||||
cm.addKeyMap(this.keyMap = buildKeyMap(completion, {
|
|
||||||
moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); },
|
|
||||||
setFocus: function(n) { widget.changeActive(n); },
|
|
||||||
menuSize: function() { return widget.screenAmount(); },
|
|
||||||
length: completions.length,
|
|
||||||
close: function() { completion.close(); },
|
|
||||||
pick: function() { widget.pick(); },
|
|
||||||
data: data
|
|
||||||
}));
|
|
||||||
|
|
||||||
if (completion.options.closeOnUnfocus) {
|
|
||||||
var closingOnBlur;
|
|
||||||
cm.on("blur", this.onBlur = function() { closingOnBlur = setTimeout(function() { completion.close(); }, 100); });
|
|
||||||
cm.on("focus", this.onFocus = function() { clearTimeout(closingOnBlur); });
|
|
||||||
}
|
|
||||||
|
|
||||||
cm.on("scroll", this.onScroll = function() {
|
|
||||||
var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
|
|
||||||
var newTop = top + startScroll.top - curScroll.top;
|
|
||||||
var point = newTop - (window.pageYOffset || (document.documentElement || document.body).scrollTop);
|
|
||||||
if (!below) point += hints.offsetHeight;
|
|
||||||
if (point <= editor.top || point >= editor.bottom) return completion.close();
|
|
||||||
hints.style.top = newTop + "px";
|
|
||||||
hints.style.left = (left + startScroll.left - curScroll.left) + "px";
|
|
||||||
});
|
|
||||||
|
|
||||||
CodeMirror.on(hints, "dblclick", function(e) {
|
|
||||||
var t = getHintElement(hints, e.target || e.srcElement);
|
|
||||||
if (t && t.hintId != null) {widget.changeActive(t.hintId); widget.pick();}
|
|
||||||
});
|
|
||||||
|
|
||||||
CodeMirror.on(hints, "click", function(e) {
|
|
||||||
var t = getHintElement(hints, e.target || e.srcElement);
|
|
||||||
if (t && t.hintId != null) {
|
|
||||||
widget.changeActive(t.hintId);
|
|
||||||
if (completion.options.completeOnSingleClick) widget.pick();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
CodeMirror.on(hints, "mousedown", function() {
|
|
||||||
setTimeout(function(){cm.focus();}, 20);
|
|
||||||
});
|
|
||||||
|
|
||||||
CodeMirror.signal(data, "select", completions[this.selectedHint], hints.childNodes[this.selectedHint]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget.prototype = {
|
|
||||||
close: function() {
|
|
||||||
if (this.completion.widget != this) return;
|
|
||||||
this.completion.widget = null;
|
|
||||||
this.hints.parentNode.removeChild(this.hints);
|
|
||||||
this.completion.cm.removeKeyMap(this.keyMap);
|
|
||||||
|
|
||||||
var cm = this.completion.cm;
|
|
||||||
if (this.completion.options.closeOnUnfocus) {
|
|
||||||
cm.off("blur", this.onBlur);
|
|
||||||
cm.off("focus", this.onFocus);
|
|
||||||
}
|
|
||||||
cm.off("scroll", this.onScroll);
|
|
||||||
},
|
|
||||||
|
|
||||||
disable: function() {
|
|
||||||
this.completion.cm.removeKeyMap(this.keyMap);
|
|
||||||
var widget = this;
|
|
||||||
this.keyMap = {Enter: function() { widget.picked = true; }};
|
|
||||||
this.completion.cm.addKeyMap(this.keyMap);
|
|
||||||
},
|
|
||||||
|
|
||||||
pick: function() {
|
|
||||||
this.completion.pick(this.data, this.selectedHint);
|
|
||||||
},
|
|
||||||
|
|
||||||
changeActive: function(i, avoidWrap) {
|
|
||||||
if (i >= this.data.list.length)
|
|
||||||
i = avoidWrap ? this.data.list.length - 1 : 0;
|
|
||||||
else if (i < 0)
|
|
||||||
i = avoidWrap ? 0 : this.data.list.length - 1;
|
|
||||||
if (this.selectedHint == i) return;
|
|
||||||
var node = this.hints.childNodes[this.selectedHint];
|
|
||||||
node.className = node.className.replace(" " + ACTIVE_HINT_ELEMENT_CLASS, "");
|
|
||||||
node = this.hints.childNodes[this.selectedHint = i];
|
|
||||||
node.className += " " + ACTIVE_HINT_ELEMENT_CLASS;
|
|
||||||
if (node.offsetTop < this.hints.scrollTop)
|
|
||||||
this.hints.scrollTop = node.offsetTop - 3;
|
|
||||||
else if (node.offsetTop + node.offsetHeight > this.hints.scrollTop + this.hints.clientHeight)
|
|
||||||
this.hints.scrollTop = node.offsetTop + node.offsetHeight - this.hints.clientHeight + 3;
|
|
||||||
CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node);
|
|
||||||
},
|
|
||||||
|
|
||||||
screenAmount: function() {
|
|
||||||
return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight) || 1;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function applicableHelpers(cm, helpers) {
|
|
||||||
if (!cm.somethingSelected()) return helpers
|
|
||||||
var result = []
|
|
||||||
for (var i = 0; i < helpers.length; i++)
|
|
||||||
if (helpers[i].supportsSelection) result.push(helpers[i])
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
function fetchHints(hint, cm, options, callback) {
|
|
||||||
if (hint.async) {
|
|
||||||
hint(cm, callback, options)
|
|
||||||
} else {
|
|
||||||
var result = hint(cm, options)
|
|
||||||
if (result && result.then) result.then(callback)
|
|
||||||
else callback(result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function resolveAutoHints(cm, pos) {
|
|
||||||
var helpers = cm.getHelpers(pos, "hint"), words
|
|
||||||
if (helpers.length) {
|
|
||||||
var resolved = function(cm, callback, options) {
|
|
||||||
var app = applicableHelpers(cm, helpers);
|
|
||||||
function run(i) {
|
|
||||||
if (i == app.length) return callback(null)
|
|
||||||
fetchHints(app[i], cm, options, function(result) {
|
|
||||||
if (result && result.list.length > 0) callback(result)
|
|
||||||
else run(i + 1)
|
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
run(0)
|
|
||||||
|
finishUpdate: function (data, first) {
|
||||||
|
if (this.data) CodeMirror.signal(this.data, "update");
|
||||||
|
|
||||||
|
var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);
|
||||||
|
if (this.widget) this.widget.close();
|
||||||
|
|
||||||
|
this.data = data;
|
||||||
|
|
||||||
|
if (data && data.list.length) {
|
||||||
|
if (picked && data.list.length == 1) {
|
||||||
|
this.pick(data, 0);
|
||||||
|
} else {
|
||||||
|
this.widget = new Widget(this, data);
|
||||||
|
CodeMirror.signal(data, "shown");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
resolved.async = true
|
|
||||||
resolved.supportsSelection = true
|
|
||||||
return resolved
|
|
||||||
} else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
|
|
||||||
return function(cm) { return CodeMirror.hint.fromList(cm, {words: words}) }
|
|
||||||
} else if (CodeMirror.hint.anyword) {
|
|
||||||
return function(cm, options) { return CodeMirror.hint.anyword(cm, options) }
|
|
||||||
} else {
|
|
||||||
return function() {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CodeMirror.registerHelper("hint", "auto", {
|
|
||||||
resolve: resolveAutoHints
|
|
||||||
});
|
|
||||||
|
|
||||||
CodeMirror.registerHelper("hint", "fromList", function(cm, options) {
|
|
||||||
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
|
|
||||||
var to = CodeMirror.Pos(cur.line, token.end);
|
|
||||||
if (token.string && /\w/.test(token.string[token.string.length - 1])) {
|
|
||||||
var term = token.string, from = CodeMirror.Pos(cur.line, token.start);
|
|
||||||
} else {
|
|
||||||
var term = "", from = to;
|
|
||||||
}
|
|
||||||
var found = [];
|
|
||||||
for (var i = 0; i < options.words.length; i++) {
|
|
||||||
var word = options.words[i];
|
|
||||||
if (word.slice(0, term.length) == term)
|
|
||||||
found.push(word);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (found.length) return {list: found, from: from, to: to};
|
|
||||||
});
|
|
||||||
|
|
||||||
CodeMirror.commands.autocomplete = CodeMirror.showHint;
|
|
||||||
|
|
||||||
var defaultOptions = {
|
|
||||||
hint: CodeMirror.hint.auto,
|
|
||||||
completeSingle: true,
|
|
||||||
alignWithWord: true,
|
|
||||||
closeCharacters: /[\s()\[\]{};:>,]/,
|
|
||||||
closeOnUnfocus: true,
|
|
||||||
completeOnSingleClick: true,
|
|
||||||
container: null,
|
|
||||||
customKeys: null,
|
|
||||||
extraKeys: null
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function parseOptions(cm, pos, options) {
|
||||||
|
var editor = cm.options.hintOptions;
|
||||||
|
var out = {};
|
||||||
|
for (var prop in defaultOptions) out[prop] = defaultOptions[prop];
|
||||||
|
if (editor) for (var prop in editor)
|
||||||
|
if (editor[prop] !== undefined) out[prop] = editor[prop];
|
||||||
|
if (options) for (var prop in options)
|
||||||
|
if (options[prop] !== undefined) out[prop] = options[prop];
|
||||||
|
if (out.hint.resolve) out.hint = out.hint.resolve(cm, pos)
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getText(completion) {
|
||||||
|
if (typeof completion == "string") return completion;
|
||||||
|
else return completion.text;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildKeyMap(completion, handle) {
|
||||||
|
var baseMap = {
|
||||||
|
Up: function () {
|
||||||
|
handle.moveFocus(-1);
|
||||||
|
},
|
||||||
|
Down: function () {
|
||||||
|
handle.moveFocus(1);
|
||||||
|
},
|
||||||
|
PageUp: function () {
|
||||||
|
handle.moveFocus(-handle.menuSize() + 1, true);
|
||||||
|
},
|
||||||
|
PageDown: function () {
|
||||||
|
handle.moveFocus(handle.menuSize() - 1, true);
|
||||||
|
},
|
||||||
|
Home: function () {
|
||||||
|
handle.setFocus(0);
|
||||||
|
},
|
||||||
|
End: function () {
|
||||||
|
handle.setFocus(handle.length - 1);
|
||||||
|
},
|
||||||
|
Enter: handle.pick,
|
||||||
|
Tab: handle.pick,
|
||||||
|
Esc: handle.close
|
||||||
|
};
|
||||||
|
var custom = completion.options.customKeys;
|
||||||
|
var ourMap = custom ? {} : baseMap;
|
||||||
|
|
||||||
|
function addBinding(key, val) {
|
||||||
|
var bound;
|
||||||
|
if (typeof val != "string")
|
||||||
|
bound = function (cm) {
|
||||||
|
return val(cm, handle);
|
||||||
|
};
|
||||||
|
// This mechanism is deprecated
|
||||||
|
else if (baseMap.hasOwnProperty(val))
|
||||||
|
bound = baseMap[val];
|
||||||
|
else
|
||||||
|
bound = val;
|
||||||
|
ourMap[key] = bound;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (custom)
|
||||||
|
for (var key in custom) if (custom.hasOwnProperty(key))
|
||||||
|
addBinding(key, custom[key]);
|
||||||
|
var extra = completion.options.extraKeys;
|
||||||
|
if (extra)
|
||||||
|
for (var key in extra) if (extra.hasOwnProperty(key))
|
||||||
|
addBinding(key, extra[key]);
|
||||||
|
return ourMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getHintElement(hintsElement, el) {
|
||||||
|
while (el && el != hintsElement) {
|
||||||
|
if (el.nodeName.toUpperCase() === "LI" && el.parentNode == hintsElement) return el;
|
||||||
|
el = el.parentNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Widget(completion, data) {
|
||||||
|
this.completion = completion;
|
||||||
|
this.data = data;
|
||||||
|
this.picked = false;
|
||||||
|
var widget = this, cm = completion.cm;
|
||||||
|
|
||||||
|
var hints = this.hints = document.createElement("ul");
|
||||||
|
hints.className = "CodeMirror-hints";
|
||||||
|
this.selectedHint = data.selectedHint || 0;
|
||||||
|
|
||||||
|
var completions = data.list;
|
||||||
|
for (var i = 0; i < completions.length; ++i) {
|
||||||
|
var elt = hints.appendChild(document.createElement("li")), cur = completions[i];
|
||||||
|
var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS);
|
||||||
|
if (cur.className != null) className = cur.className + " " + className;
|
||||||
|
elt.className = className;
|
||||||
|
if (cur.render) cur.render(elt, data, cur);
|
||||||
|
else elt.appendChild(document.createTextNode(cur.displayText || getText(cur)));
|
||||||
|
elt.hintId = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
var pos = cm.cursorCoords(completion.options.alignWithWord ? data.from : null);
|
||||||
|
var left = pos.left, top = pos.bottom, below = true;
|
||||||
|
hints.style.left = left + "px";
|
||||||
|
hints.style.top = top + "px";
|
||||||
|
// If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
|
||||||
|
var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
|
||||||
|
var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
|
||||||
|
(completion.options.container || document.body).appendChild(hints);
|
||||||
|
var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
|
||||||
|
var scrolls = hints.scrollHeight > hints.clientHeight + 1
|
||||||
|
var startScroll = cm.getScrollInfo();
|
||||||
|
|
||||||
|
if (overlapY > 0) {
|
||||||
|
var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top);
|
||||||
|
if (curTop - height > 0) { // Fits above cursor
|
||||||
|
hints.style.top = (top = pos.top - height) + "px";
|
||||||
|
below = false;
|
||||||
|
} else if (height > winH) {
|
||||||
|
hints.style.height = (winH - 5) + "px";
|
||||||
|
hints.style.top = (top = pos.bottom - box.top) + "px";
|
||||||
|
var cursor = cm.getCursor();
|
||||||
|
if (data.from.ch != cursor.ch) {
|
||||||
|
pos = cm.cursorCoords(cursor);
|
||||||
|
hints.style.left = (left = pos.left) + "px";
|
||||||
|
box = hints.getBoundingClientRect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var overlapX = box.right - winW;
|
||||||
|
if (overlapX > 0) {
|
||||||
|
if (box.right - box.left > winW) {
|
||||||
|
hints.style.width = (winW - 5) + "px";
|
||||||
|
overlapX -= (box.right - box.left) - winW;
|
||||||
|
}
|
||||||
|
hints.style.left = (left = pos.left - overlapX) + "px";
|
||||||
|
}
|
||||||
|
if (scrolls) for (var node = hints.firstChild; node; node = node.nextSibling)
|
||||||
|
node.style.paddingRight = cm.display.nativeBarWidth + "px"
|
||||||
|
|
||||||
|
cm.addKeyMap(this.keyMap = buildKeyMap(completion, {
|
||||||
|
moveFocus: function (n, avoidWrap) {
|
||||||
|
widget.changeActive(widget.selectedHint + n, avoidWrap);
|
||||||
|
},
|
||||||
|
setFocus: function (n) {
|
||||||
|
widget.changeActive(n);
|
||||||
|
},
|
||||||
|
menuSize: function () {
|
||||||
|
return widget.screenAmount();
|
||||||
|
},
|
||||||
|
length: completions.length,
|
||||||
|
close: function () {
|
||||||
|
completion.close();
|
||||||
|
},
|
||||||
|
pick: function () {
|
||||||
|
widget.pick();
|
||||||
|
},
|
||||||
|
data: data
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (completion.options.closeOnUnfocus) {
|
||||||
|
var closingOnBlur;
|
||||||
|
cm.on("blur", this.onBlur = function () {
|
||||||
|
closingOnBlur = setTimeout(function () {
|
||||||
|
completion.close();
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
cm.on("focus", this.onFocus = function () {
|
||||||
|
clearTimeout(closingOnBlur);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
cm.on("scroll", this.onScroll = function () {
|
||||||
|
var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
|
||||||
|
var newTop = top + startScroll.top - curScroll.top;
|
||||||
|
var point = newTop - (window.pageYOffset || (document.documentElement || document.body).scrollTop);
|
||||||
|
if (!below) point += hints.offsetHeight;
|
||||||
|
if (point <= editor.top || point >= editor.bottom) return completion.close();
|
||||||
|
hints.style.top = newTop + "px";
|
||||||
|
hints.style.left = (left + startScroll.left - curScroll.left) + "px";
|
||||||
|
});
|
||||||
|
|
||||||
|
CodeMirror.on(hints, "dblclick", function (e) {
|
||||||
|
var t = getHintElement(hints, e.target || e.srcElement);
|
||||||
|
if (t && t.hintId != null) {
|
||||||
|
widget.changeActive(t.hintId);
|
||||||
|
widget.pick();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
CodeMirror.on(hints, "click", function (e) {
|
||||||
|
var t = getHintElement(hints, e.target || e.srcElement);
|
||||||
|
if (t && t.hintId != null) {
|
||||||
|
widget.changeActive(t.hintId);
|
||||||
|
if (completion.options.completeOnSingleClick) widget.pick();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
CodeMirror.on(hints, "mousedown", function () {
|
||||||
|
setTimeout(function () {
|
||||||
|
cm.focus();
|
||||||
|
}, 20);
|
||||||
|
});
|
||||||
|
|
||||||
|
CodeMirror.signal(data, "select", completions[this.selectedHint], hints.childNodes[this.selectedHint]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget.prototype = {
|
||||||
|
close: function () {
|
||||||
|
if (this.completion.widget != this) return;
|
||||||
|
this.completion.widget = null;
|
||||||
|
this.hints.parentNode.removeChild(this.hints);
|
||||||
|
this.completion.cm.removeKeyMap(this.keyMap);
|
||||||
|
|
||||||
|
var cm = this.completion.cm;
|
||||||
|
if (this.completion.options.closeOnUnfocus) {
|
||||||
|
cm.off("blur", this.onBlur);
|
||||||
|
cm.off("focus", this.onFocus);
|
||||||
|
}
|
||||||
|
cm.off("scroll", this.onScroll);
|
||||||
|
},
|
||||||
|
|
||||||
|
disable: function () {
|
||||||
|
this.completion.cm.removeKeyMap(this.keyMap);
|
||||||
|
var widget = this;
|
||||||
|
this.keyMap = {
|
||||||
|
Enter: function () {
|
||||||
|
widget.picked = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.completion.cm.addKeyMap(this.keyMap);
|
||||||
|
},
|
||||||
|
|
||||||
|
pick: function () {
|
||||||
|
this.completion.pick(this.data, this.selectedHint);
|
||||||
|
},
|
||||||
|
|
||||||
|
changeActive: function (i, avoidWrap) {
|
||||||
|
if (i >= this.data.list.length)
|
||||||
|
i = avoidWrap ? this.data.list.length - 1 : 0;
|
||||||
|
else if (i < 0)
|
||||||
|
i = avoidWrap ? 0 : this.data.list.length - 1;
|
||||||
|
if (this.selectedHint == i) return;
|
||||||
|
var node = this.hints.childNodes[this.selectedHint];
|
||||||
|
node.className = node.className.replace(" " + ACTIVE_HINT_ELEMENT_CLASS, "");
|
||||||
|
node = this.hints.childNodes[this.selectedHint = i];
|
||||||
|
node.className += " " + ACTIVE_HINT_ELEMENT_CLASS;
|
||||||
|
if (node.offsetTop < this.hints.scrollTop)
|
||||||
|
this.hints.scrollTop = node.offsetTop - 3;
|
||||||
|
else if (node.offsetTop + node.offsetHeight > this.hints.scrollTop + this.hints.clientHeight)
|
||||||
|
this.hints.scrollTop = node.offsetTop + node.offsetHeight - this.hints.clientHeight + 3;
|
||||||
|
CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node);
|
||||||
|
},
|
||||||
|
|
||||||
|
screenAmount: function () {
|
||||||
|
return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight) || 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function applicableHelpers(cm, helpers) {
|
||||||
|
if (!cm.somethingSelected()) return helpers
|
||||||
|
var result = []
|
||||||
|
for (var i = 0; i < helpers.length; i++)
|
||||||
|
if (helpers[i].supportsSelection) result.push(helpers[i])
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchHints(hint, cm, options, callback) {
|
||||||
|
if (hint.async) {
|
||||||
|
hint(cm, callback, options)
|
||||||
|
} else {
|
||||||
|
var result = hint(cm, options)
|
||||||
|
if (result && result.then) result.then(callback)
|
||||||
|
else callback(result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveAutoHints(cm, pos) {
|
||||||
|
var helpers = cm.getHelpers(pos, "hint"), words
|
||||||
|
if (helpers.length) {
|
||||||
|
var resolved = function (cm, callback, options) {
|
||||||
|
var app = applicableHelpers(cm, helpers);
|
||||||
|
|
||||||
|
function run(i) {
|
||||||
|
if (i == app.length) return callback(null)
|
||||||
|
fetchHints(app[i], cm, options, function (result) {
|
||||||
|
if (result && result.list.length > 0) callback(result)
|
||||||
|
else run(i + 1)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
run(0)
|
||||||
|
}
|
||||||
|
resolved.async = true
|
||||||
|
resolved.supportsSelection = true
|
||||||
|
return resolved
|
||||||
|
} else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
|
||||||
|
return function (cm) {
|
||||||
|
return CodeMirror.hint.fromList(cm, {words: words})
|
||||||
|
}
|
||||||
|
} else if (CodeMirror.hint.anyword) {
|
||||||
|
return function (cm, options) {
|
||||||
|
return CodeMirror.hint.anyword(cm, options)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return function () {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CodeMirror.registerHelper("hint", "auto", {
|
||||||
|
resolve: resolveAutoHints
|
||||||
|
});
|
||||||
|
|
||||||
|
CodeMirror.registerHelper("hint", "fromList", function (cm, options) {
|
||||||
|
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
|
||||||
|
var to = CodeMirror.Pos(cur.line, token.end);
|
||||||
|
if (token.string && /\w/.test(token.string[token.string.length - 1])) {
|
||||||
|
var term = token.string, from = CodeMirror.Pos(cur.line, token.start);
|
||||||
|
} else {
|
||||||
|
var term = "", from = to;
|
||||||
|
}
|
||||||
|
var found = [];
|
||||||
|
for (var i = 0; i < options.words.length; i++) {
|
||||||
|
var word = options.words[i];
|
||||||
|
if (word.slice(0, term.length) == term)
|
||||||
|
found.push(word);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found.length) return {list: found, from: from, to: to};
|
||||||
|
});
|
||||||
|
|
||||||
|
CodeMirror.commands.autocomplete = CodeMirror.showHint;
|
||||||
|
|
||||||
|
var defaultOptions = {
|
||||||
|
hint: CodeMirror.hint.auto,
|
||||||
|
completeSingle: true,
|
||||||
|
alignWithWord: true,
|
||||||
|
closeCharacters: /[\s()\[\]{};:>,]/,
|
||||||
|
closeOnUnfocus: true,
|
||||||
|
completeOnSingleClick: true,
|
||||||
|
container: null,
|
||||||
|
customKeys: null,
|
||||||
|
extraKeys: null
|
||||||
|
};
|
||||||
|
|
||||||
CodeMirror.defineOption("hintOptions", null);
|
CodeMirror.defineOption("hintOptions", null);
|
||||||
});
|
});
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -1,74 +1,74 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="96px" height="124px">
|
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="96px" height="124px">
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
#background {
|
#background {
|
||||||
fill: none;
|
fill: none;
|
||||||
}
|
}
|
||||||
.arrows {
|
.arrows {
|
||||||
fill: #000;
|
fill: #000;
|
||||||
stroke: none;
|
stroke: none;
|
||||||
}
|
}
|
||||||
.selected>.arrows {
|
.selected>.arrows {
|
||||||
fill: #fff;
|
fill: #fff;
|
||||||
}
|
}
|
||||||
.checkmark {
|
.checkmark {
|
||||||
fill: #000;
|
fill: #000;
|
||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
font-size: 10pt;
|
font-size: 10pt;
|
||||||
text-anchor: middle;
|
text-anchor: middle;
|
||||||
}
|
}
|
||||||
.trash {
|
.trash {
|
||||||
fill: #888;
|
fill: #888;
|
||||||
}
|
}
|
||||||
.zoom {
|
.zoom {
|
||||||
fill: none;
|
fill: none;
|
||||||
stroke: #888;
|
stroke: #888;
|
||||||
stroke-width: 2;
|
stroke-width: 2;
|
||||||
stroke-linecap: round;
|
stroke-linecap: round;
|
||||||
}
|
}
|
||||||
.zoom>.center {
|
.zoom>.center {
|
||||||
fill: #888;
|
fill: #888;
|
||||||
stroke-width: 0;
|
stroke-width: 0;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<rect id="background" width="96" height="124" x="0" y="0" />
|
<rect id="background" width="96" height="124" x="0" y="0"/>
|
||||||
|
|
||||||
<g>
|
<g>
|
||||||
<path class="arrows" d="M 13,1.5 13,14.5 1.74,8 z" />
|
<path class="arrows" d="M 13,1.5 13,14.5 1.74,8 z"/>
|
||||||
<path class="arrows" d="M 17.5,3 30.5,3 24,14.26 z" />
|
<path class="arrows" d="M 17.5,3 30.5,3 24,14.26 z"/>
|
||||||
<path class="arrows" d="M 35,1.5 35,14.5 46.26,8 z" />
|
<path class="arrows" d="M 35,1.5 35,14.5 46.26,8 z"/>
|
||||||
</g>
|
</g>
|
||||||
<g class="selected" transform="translate(0, 16)">
|
<g class="selected" transform="translate(0, 16)">
|
||||||
<path class="arrows" d="M 13,1.5 13,14.5 1.74,8 z" />
|
<path class="arrows" d="M 13,1.5 13,14.5 1.74,8 z"/>
|
||||||
<path class="arrows" d="M 17.5,3 30.5,3 24,14.26 z" />
|
<path class="arrows" d="M 17.5,3 30.5,3 24,14.26 z"/>
|
||||||
<path class="arrows" d="M 35,1.5 35,14.5 46.26,8 z" />
|
<path class="arrows" d="M 35,1.5 35,14.5 46.26,8 z"/>
|
||||||
</g>
|
</g>
|
||||||
|
|
||||||
<text class="checkmark" x="55.5" y="28">✓</text>
|
<text class="checkmark" x="55.5" y="28">✓</text>
|
||||||
|
|
||||||
<g class="trash">
|
<g class="trash">
|
||||||
<path d="M 2,41 v 6 h 42 v -6 h -10.5 l -3,-3 h -15 l -3,3 z" />
|
<path d="M 2,41 v 6 h 42 v -6 h -10.5 l -3,-3 h -15 l -3,3 z"/>
|
||||||
<rect width="36" height="20" x="5" y="50" />
|
<rect width="36" height="20" x="5" y="50"/>
|
||||||
<rect width="36" height="42" x="5" y="50" rx="4" ry="4" />
|
<rect width="36" height="42" x="5" y="50" rx="4" ry="4"/>
|
||||||
</g>
|
</g>
|
||||||
|
|
||||||
<g class="zoom">
|
<g class="zoom">
|
||||||
<circle r="11.5" cx="16" cy="108" />
|
<circle r="11.5" cx="16" cy="108"/>
|
||||||
<circle r="4.3" cx="16" cy="108" class="center" />
|
<circle r="4.3" cx="16" cy="108" class="center"/>
|
||||||
<path d="m 28,108 h3" />
|
<path d="m 28,108 h3"/>
|
||||||
<path d="m 1,108 h3" />
|
<path d="m 1,108 h3"/>
|
||||||
<path d="m 16,120 v3" />
|
<path d="m 16,120 v3"/>
|
||||||
<path d="m 16,93 v3" />
|
<path d="m 16,93 v3"/>
|
||||||
</g>
|
</g>
|
||||||
|
|
||||||
<g class="zoom">
|
<g class="zoom">
|
||||||
<circle r="15" cx="48" cy="108" />
|
<circle r="15" cx="48" cy="108"/>
|
||||||
<path d="m 48,101.6 v12.8" />
|
<path d="m 48,101.6 v12.8"/>
|
||||||
<path d="m 41.6,108 h12.8" />
|
<path d="m 41.6,108 h12.8"/>
|
||||||
</g>
|
</g>
|
||||||
|
|
||||||
<g class="zoom">
|
<g class="zoom">
|
||||||
<circle r="15" cx="80" cy="108" />
|
<circle r="15" cx="80" cy="108"/>
|
||||||
<path d="m 73.6,108 h12.8" />
|
<path d="m 73.6,108 h12.8"/>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2.0 KiB |
@ -1,302 +1,346 @@
|
|||||||
|
|
||||||
html,body,div,img{margin:0;padding:0;}
|
html, body, div, img {
|
||||||
body{
|
margin: 0;
|
||||||
font-family: Roboto,"Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;;
|
padding: 0;
|
||||||
background-color: #F5F5F5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: Roboto, "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;;
|
||||||
|
background-color: #F5F5F5;
|
||||||
|
}
|
||||||
|
|
||||||
/* ::-webkit-scrollbar {
|
/* ::-webkit-scrollbar {
|
||||||
width: 5px;
|
width: 5px;
|
||||||
} */
|
} */
|
||||||
.main {
|
.main {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
min-height: 500px;
|
min-height: 500px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
|
||||||
#left, #mid, #right{
|
|
||||||
border-radius: 2px;
|
|
||||||
box-sizing: border-box;
|
|
||||||
box-shadow: 0 2px 2px 0 rgba(0,0,0,.14), 0 3px 1px -2px rgba(0,0,0,.2), 0 1px 5px 0 rgba(0,0,0,.12);
|
|
||||||
}
|
|
||||||
#left{
|
|
||||||
position: absolute;
|
|
||||||
left: 5px;
|
|
||||||
top: 10px;
|
|
||||||
width: 435px;
|
|
||||||
height: 630px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#editArea{
|
#left, #mid, #right {
|
||||||
position: absolute;
|
border-radius: 2px;
|
||||||
width: 100%;
|
box-sizing: border-box;
|
||||||
height: 70%;
|
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);
|
||||||
left: 0;
|
|
||||||
top: 0;
|
|
||||||
/* padding: 10px 5px; */
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
}
|
||||||
#pout{
|
|
||||||
display: block;
|
#left {
|
||||||
width: 410px;
|
position: absolute;
|
||||||
height: 100%;
|
left: 5px;
|
||||||
box-sizing: border-box;
|
top: 10px;
|
||||||
margin-left: 22px;
|
width: 435px;
|
||||||
margin-top: 23px;
|
height: 630px;
|
||||||
line-height: 20px;
|
|
||||||
font-size: 12.3px;
|
|
||||||
font-family: 'Lucida Console', Monaco, monospace;
|
|
||||||
white-space: pre;
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
border-radius: 2px;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
}
|
||||||
#editTip{
|
|
||||||
position: absolute;
|
#editArea {
|
||||||
width: 100%;
|
position: absolute;
|
||||||
height: 80px;
|
width: 100%;
|
||||||
bottom:10px;
|
height: 70%;
|
||||||
left: 10px;
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
/* padding: 10px 5px; */
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
#editArea p{
|
|
||||||
margin: 10px;
|
#pout {
|
||||||
display: block;
|
display: block;
|
||||||
width: 70%;
|
width: 410px;
|
||||||
line-height: 20px;
|
height: 100%;
|
||||||
text-align: left;
|
box-sizing: border-box;
|
||||||
font-size: 14px;
|
margin-left: 22px;
|
||||||
|
margin-top: 23px;
|
||||||
|
line-height: 20px;
|
||||||
|
font-size: 12.3px;
|
||||||
|
font-family: 'Lucida Console', Monaco, monospace;
|
||||||
|
white-space: pre;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 2px;
|
||||||
|
overflow: auto;
|
||||||
}
|
}
|
||||||
#editTip .btn{
|
|
||||||
float: right;
|
#editTip {
|
||||||
margin-right: 20px;
|
position: absolute;
|
||||||
margin-top: 5px;
|
width: 100%;
|
||||||
|
margin-bottom: 120px;
|
||||||
|
bottom: 0;
|
||||||
|
left: 10px;
|
||||||
}
|
}
|
||||||
#mid{
|
|
||||||
position: absolute;
|
#editArea p {
|
||||||
left: 448px;
|
margin: 10px;
|
||||||
top: 10px;
|
display: block;
|
||||||
width: 440px;
|
width: 70%;
|
||||||
height: 630px;
|
line-height: 20px;
|
||||||
|
text-align: left;
|
||||||
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#editTip .btn {
|
||||||
|
float: right;
|
||||||
|
margin-right: 20px;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#mid {
|
||||||
|
position: absolute;
|
||||||
|
left: 448px;
|
||||||
|
top: 10px;
|
||||||
|
width: 440px;
|
||||||
|
height: 630px;
|
||||||
|
}
|
||||||
|
|
||||||
.map {
|
.map {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 20px;
|
left: 20px;
|
||||||
top: 21px;
|
top: 21px;
|
||||||
width: 416px;
|
width: 416px;
|
||||||
height: 416px;
|
height: 416px;
|
||||||
}
|
}
|
||||||
#mid .tools{
|
|
||||||
position: absolute;
|
#mid .tools {
|
||||||
width: 425px;
|
position: absolute;
|
||||||
height: 180px;
|
width: 425px;
|
||||||
left: 0;
|
height: 180px;
|
||||||
bottom: 0;
|
left: 0;
|
||||||
border-top: 1px solid #ccc;
|
bottom: 0;
|
||||||
padding: 10px 5px;
|
border-top: 1px solid #ccc;
|
||||||
margin-left: 8px;;
|
padding: 10px 5px;
|
||||||
box-sizing: border-box;
|
margin-left: 8px;;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
#tip{
|
|
||||||
float: right;
|
#tip {
|
||||||
width: 50%;
|
float: right;
|
||||||
height: 95%;
|
width: 50%;
|
||||||
padding: 5px 10px 10px 10px;
|
height: 95%;
|
||||||
margin-right: 0;
|
padding: 5px 10px 10px 10px;
|
||||||
box-sizing: border-box;
|
margin-right: 0;
|
||||||
border: 1px solid #ccc;
|
box-sizing: border-box;
|
||||||
border-radius: 2px;
|
border: 1px solid #ccc;
|
||||||
font-size: 15px;
|
border-radius: 2px;
|
||||||
line-height: 14px;
|
font-size: 15px;
|
||||||
|
line-height: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.files {
|
.files {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
height: 120px;
|
height: 120px;
|
||||||
/* padding: 10px; */
|
/* padding: 10px; */
|
||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
}
|
}
|
||||||
.input{
|
|
||||||
display: block;
|
.input {
|
||||||
max-width: 150px;
|
display: block;
|
||||||
height: 20px;
|
max-width: 150px;
|
||||||
padding: 6px 12px;
|
height: 20px;
|
||||||
font-size: 14px;
|
padding: 6px 12px;
|
||||||
margin-top: 10px;
|
font-size: 14px;
|
||||||
color: #555;
|
margin-top: 10px;
|
||||||
background-color: #fff;
|
color: #555;
|
||||||
border: 1px solid #ccc;
|
background-color: #fff;
|
||||||
border-radius: 3px;
|
border: 1px solid #ccc;
|
||||||
box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
|
border-radius: 3px;
|
||||||
|
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
|
||||||
}
|
}
|
||||||
#bgSelect{
|
|
||||||
width: 50%;
|
#bgSelect {
|
||||||
height: 100px;
|
width: 50%;
|
||||||
margin-top: 10px;
|
height: 100px;
|
||||||
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
#bgSelect span{
|
|
||||||
/* display: block; */
|
#bgSelect span {
|
||||||
font-size: 14px;
|
/* display: block; */
|
||||||
line-height: 30px;
|
font-size: 14px;
|
||||||
|
line-height: 30px;
|
||||||
}
|
}
|
||||||
#printOut{
|
|
||||||
margin-top: 10px;
|
#printOut {
|
||||||
height: 20px;
|
margin-top: 10px;
|
||||||
|
height: 20px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn {
|
.btn {
|
||||||
width: 80px;
|
width: 80px;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
line-height: 30px;
|
line-height: 30px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
min-width: 50px;
|
min-width: 50px;
|
||||||
padding: 0 5px;
|
padding: 0 5px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
/* text-transform: uppercase; */
|
/* text-transform: uppercase; */
|
||||||
letter-spacing: 0;
|
letter-spacing: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
border: 0;
|
border: 0;
|
||||||
background: rgba(158,158,158,.2);
|
background: rgba(158, 158, 158, .2);
|
||||||
box-shadow: 0 1px 1px 0 rgba(0,0,0,.14), 0 2px 1px -1px rgba(0,0,0,.2), 0 1px 3px 0 rgba(0,0,0,.12);
|
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .14), 0 2px 1px -1px rgba(0, 0, 0, .2), 0 1px 3px 0 rgba(0, 0, 0, .12);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
background-color: #26A69A;
|
background-color: #26A69A;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn:hover {
|
.btn:hover {
|
||||||
background-color: #009688;
|
background-color: #009688;
|
||||||
box-shadow: 0 2px 2px 0 rgba(0,0,0,.14), 0 3px 1px -2px rgba(0,0,0,.2), 0 1px 5px 0 rgba(0,0,0,.12);
|
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);
|
||||||
}
|
}
|
||||||
#right{
|
|
||||||
position: absolute;
|
#right {
|
||||||
left: 900px;
|
position: absolute;
|
||||||
top: 10px;
|
left: 900px;
|
||||||
width: 440px;
|
top: 10px;
|
||||||
height: 630px;
|
width: 440px;
|
||||||
/* border: 1px solid rgb(238, 13, 13); */
|
height: 630px;
|
||||||
|
/* border: 1px solid rgb(238, 13, 13); */
|
||||||
}
|
}
|
||||||
#iconLib{
|
|
||||||
position: absolute;
|
#iconLib {
|
||||||
width: 435px;
|
position: absolute;
|
||||||
height: 620px;
|
width: 435px;
|
||||||
left: 5px;
|
height: 620px;
|
||||||
top: 5px;
|
left: 5px;
|
||||||
overflow: auto;
|
top: 5px;
|
||||||
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.egameCanvas {
|
.egameCanvas {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
.gameCanvas {
|
.gameCanvas {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
#dataSelection , .appendSelection{
|
|
||||||
position: absolute;
|
#dataSelection, .appendSelection {
|
||||||
/* top:0;
|
position: absolute;
|
||||||
left:320px; */
|
/* top:0;
|
||||||
z-index:75;
|
left:320px; */
|
||||||
width:26px;
|
z-index: 75;
|
||||||
height:26px;
|
width: 26px;
|
||||||
margin: 3px 0 0 3px;
|
height: 26px;
|
||||||
padding:0;
|
margin: 3px 0 0 3px;
|
||||||
/* display: none; */
|
padding: 0;
|
||||||
box-sizing: border-box;
|
/* display: none; */
|
||||||
background-color:rgba(255, 255, 255, 0.0);
|
box-sizing: border-box;
|
||||||
border: 1px solid #000;
|
background-color: rgba(255, 255, 255, 0.0);
|
||||||
box-shadow: 0 0 0 2px #fff,
|
border: 1px solid #000;
|
||||||
0 0 0 3px #000;
|
box-shadow: 0 0 0 2px #fff,
|
||||||
|
0 0 0 3px #000;
|
||||||
}
|
}
|
||||||
.warnText{
|
|
||||||
color: #D50000;
|
.warnText {
|
||||||
font-weight: 700;
|
color: #D50000;
|
||||||
font-size: 14px;
|
font-weight: 700;
|
||||||
line-height: 1.2em;
|
font-size: 14px;
|
||||||
|
line-height: 1.2em;
|
||||||
}
|
}
|
||||||
.infoText{
|
|
||||||
color: #2196F3;
|
.infoText {
|
||||||
|
color: #2196F3;
|
||||||
}
|
}
|
||||||
.successText{
|
|
||||||
color: #00897B;
|
.successText {
|
||||||
line-height: 1.2em;
|
color: #00897B;
|
||||||
|
line-height: 1.2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
table, td {
|
table, td {
|
||||||
border: 1px solid #fff;
|
border: 1px solid #fff;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
cursor:crosshair;
|
cursor: crosshair;
|
||||||
}
|
}
|
||||||
table.col{
|
|
||||||
position: relative;
|
table.col {
|
||||||
|
position: relative;
|
||||||
text-align: center;
|
|
||||||
border-collapse: collapse;
|
text-align: center;
|
||||||
|
border-collapse: collapse;
|
||||||
}
|
}
|
||||||
table.col td{
|
|
||||||
background-color: #4DB6AC;
|
table.col td {
|
||||||
|
background-color: #4DB6AC;
|
||||||
}
|
}
|
||||||
#arrColMark td{
|
|
||||||
width: 16px;
|
#arrColMark td {
|
||||||
|
width: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#arrColMark {
|
#arrColMark {
|
||||||
top: 2px;
|
top: 2px;
|
||||||
left: 36px;
|
left: 36px;
|
||||||
width: 385px;
|
width: 385px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#mapColMark {
|
#mapColMark {
|
||||||
top: 2px;
|
top: 2px;
|
||||||
left: 19px;
|
left: 19px;
|
||||||
width: 418px;
|
width: 418px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
#mapColMark td{
|
|
||||||
width: 29px;
|
#mapColMark td {
|
||||||
|
width: 29px;
|
||||||
}
|
}
|
||||||
#mapColMark td:hover .colBlock{
|
|
||||||
position: absolute;
|
#mapColMark td:hover .colBlock {
|
||||||
top: 19px;
|
position: absolute;
|
||||||
height: 416px;
|
top: 19px;
|
||||||
width: 32px;
|
height: 416px;
|
||||||
z-index: 100;
|
width: 32px;
|
||||||
background-color: rgba(38,166,154,.5);
|
z-index: 100;
|
||||||
|
background-color: rgba(38, 166, 154, .5);
|
||||||
}
|
}
|
||||||
table.row{
|
|
||||||
position: relative;
|
table.row {
|
||||||
text-align: right;
|
position: relative;
|
||||||
vertical-align:middle;
|
text-align: right;
|
||||||
border-collapse: collapse;
|
vertical-align: middle;
|
||||||
|
border-collapse: collapse;
|
||||||
}
|
}
|
||||||
table.row td{
|
|
||||||
background-color: #4C221B;
|
table.row td {
|
||||||
|
background-color: #4C221B;
|
||||||
}
|
}
|
||||||
#arrRowMark{
|
|
||||||
top: 5px;
|
#arrRowMark {
|
||||||
left: 2px;
|
top: 5px;
|
||||||
width: 16px;
|
left: 2px;
|
||||||
height: 262px;
|
width: 16px;
|
||||||
font-size: 12px;
|
height: 262px;
|
||||||
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
#mapRowMark{
|
|
||||||
top: 1px;
|
#mapRowMark {
|
||||||
left: 2px;
|
top: 1px;
|
||||||
width: 16px;
|
left: 2px;
|
||||||
height: 416px;
|
width: 16px;
|
||||||
font-size: 12px;
|
height: 416px;
|
||||||
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
#mapRowMark td{
|
|
||||||
height: 29px;
|
#mapRowMark td {
|
||||||
|
height: 29px;
|
||||||
}
|
}
|
||||||
#mapRowMark td:hover .rowBlock{
|
|
||||||
position: absolute;
|
#mapRowMark td:hover .rowBlock {
|
||||||
left: 18px;
|
position: absolute;
|
||||||
height: 32px;
|
left: 18px;
|
||||||
width: 416px;
|
height: 32px;
|
||||||
z-index: 100;
|
width: 416px;
|
||||||
background-color: rgba(76,34,27,.5);
|
z-index: 100;
|
||||||
|
background-color: rgba(76, 34, 27, .5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* for vue dom */
|
/* for vue dom */
|
||||||
[v-cloak] {
|
[v-cloak] {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,170 +1,203 @@
|
|||||||
.leftTab {
|
.leftTab {
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
box-shadow: 0 2px 2px 0 rgba(0,0,0,.14), 0 3px 1px -2px rgba(0,0,0,.2), 0 1px 5px 0 rgba(0,0,0,.12);
|
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);
|
||||||
}
|
|
||||||
|
|
||||||
.leftTab {
|
|
||||||
overflow: auto;
|
|
||||||
position: absolute;
|
|
||||||
height: 630px;
|
|
||||||
}
|
}
|
||||||
.leftTab > *{margin:2.5px 5px;}
|
|
||||||
.leftTab > :first-child{margin-top:5px;}
|
|
||||||
.leftTab > :last-child{margin-bottom:5px;}
|
|
||||||
|
|
||||||
.leftTab {
|
.leftTab {
|
||||||
left: 5px;
|
overflow: auto;
|
||||||
top: 10px;
|
position: absolute;
|
||||||
width: 435px;
|
height: 630px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leftTab > * {
|
||||||
|
margin: 2.5px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leftTab > :first-child {
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leftTab > :last-child {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.leftTab {
|
||||||
|
left: 5px;
|
||||||
|
top: 10px;
|
||||||
|
width: 435px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.leftTab .leftTabHeader {
|
.leftTab .leftTabHeader {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 15px;
|
top: 15px;
|
||||||
left: 15px;
|
left: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.leftTab .leftTabContent {
|
.leftTab .leftTabContent {
|
||||||
padding-top: 50px;
|
padding-top: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#appendPicSelection span {
|
#appendPicSelection span {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
font-size:11px;
|
font-size: 11px;
|
||||||
-webkit-text-stroke: 1px red;
|
-webkit-text-stroke: 1px red;
|
||||||
text-shadow: black 1px 0, black 0 1px, black -1px 0, black 0 -1px;
|
text-shadow: black 1px 0, black 0 1px, black -1px 0, black 0 -1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#left6 {
|
#left6 {
|
||||||
left: 5px;
|
left: 5px;
|
||||||
top: 5px;
|
top: 5px;
|
||||||
z-index: 200;
|
z-index: 200;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
background-color: rgb(245, 245, 245);
|
background-color: rgb(245, 245, 245);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
#left6 #blocklyArea {
|
#left6 #blocklyArea {
|
||||||
float: left;
|
float: left;
|
||||||
width: 60%;
|
width: 60%;
|
||||||
height: 95%;
|
height: 95%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#left6 #blocklyDiv {
|
#left6 #blocklyDiv {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
#left6 .CodeMirror {
|
#left6 .CodeMirror {
|
||||||
border: 1px solid #eee;
|
border: 1px solid #eee;
|
||||||
float: left;
|
float: left;
|
||||||
height: 95%;
|
height: 95%;
|
||||||
width: 35%;
|
width: 35%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#left6 #codeArea {
|
||||||
|
width: 99.5%;
|
||||||
|
height: 15.4em;
|
||||||
|
overflow: y; /* resize:none; */
|
||||||
}
|
}
|
||||||
#left6 #codeArea {width: 99.5%; height: 15.4em;overflow:y;/* resize:none; */}
|
|
||||||
|
|
||||||
#left7 {
|
#left7 {
|
||||||
/* height: 440px; width: 375px;float:left; */
|
/* height: 440px; width: 375px;float:left; */
|
||||||
left: 5px;
|
left: 5px;
|
||||||
top: 5px;
|
top: 5px;
|
||||||
z-index: 200;
|
z-index: 200;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
background-color: rgb(245, 245, 245);
|
background-color: rgb(245, 245, 245);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#left7 .CodeMirror {
|
#left7 .CodeMirror {
|
||||||
/* border-top: 1px solid black;
|
/* border-top: 1px solid black;
|
||||||
border-bottom: 1px solid black; */
|
border-bottom: 1px solid black; */
|
||||||
border: 1px solid #eee;
|
border: 1px solid #eee;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
height: 95%;
|
height: 95%;
|
||||||
width: 95%;
|
width: 95%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.etable table,
|
.etable table,
|
||||||
.etable table td {
|
.etable table td {
|
||||||
color: #000;
|
color: #000;
|
||||||
cursor: auto;
|
cursor: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy from github-css https://github.com/sindresorhus/github-markdown-css */
|
/* copy from github-css https://github.com/sindresorhus/github-markdown-css */
|
||||||
.etable table {
|
.etable table {
|
||||||
border-spacing: 0;
|
border-spacing: 0;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
}
|
}
|
||||||
|
|
||||||
.etable table {
|
.etable table {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.etable table {
|
.etable table {
|
||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.etable table th {
|
.etable table th {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.etable table th,
|
.etable table th,
|
||||||
.etable table td {
|
.etable table td {
|
||||||
padding: 6px 13px;
|
padding: 6px 13px;
|
||||||
border: 1px solid #dfe2e5;
|
border: 1px solid #dfe2e5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.etable table tr {
|
.etable table tr {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border-top: 1px solid #c6cbd1;
|
border-top: 1px solid #c6cbd1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.etable table tr:nth-child(2n) {
|
.etable table tr:nth-child(2n) {
|
||||||
background-color: #f6f8fa;
|
background-color: #f6f8fa;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy end --------------------------------------------- */
|
/* copy end --------------------------------------------- */
|
||||||
|
|
||||||
.etable tr {width:100%}
|
.etable tr {
|
||||||
.etable tr > :nth-child(1) {width:20%}
|
width: 100%
|
||||||
.etable tr > :nth-child(2) {width:20%}
|
}
|
||||||
.etable tr > :nth-child(3) {width:60%}
|
|
||||||
|
.etable tr > :nth-child(1) {
|
||||||
|
width: 20%
|
||||||
|
}
|
||||||
|
|
||||||
|
.etable tr > :nth-child(2) {
|
||||||
|
width: 20%
|
||||||
|
}
|
||||||
|
|
||||||
|
.etable tr > :nth-child(3) {
|
||||||
|
width: 60%
|
||||||
|
}
|
||||||
|
|
||||||
.etable table {
|
.etable table {
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
.etable tr:not(:first-child) > :last-child:hover {
|
.etable tr:not(:first-child) > :last-child:hover {
|
||||||
border: 1px solid rgb(87, 198, 232);
|
border: 1px solid rgb(87, 198, 232);
|
||||||
box-shadow: 0px 0px 3px rgb(87, 198, 232);
|
box-shadow: 0px 0px 3px rgb(87, 198, 232);
|
||||||
}
|
}
|
||||||
|
|
||||||
.etable tr:not(:first-child) > :nth-child(2):hover,
|
.etable tr:not(:first-child) > :nth-child(2):hover,
|
||||||
.etable tr:not(:first-child) > :nth-child(1):hover {
|
.etable tr:not(:first-child) > :nth-child(1):hover {
|
||||||
border: 1px solid rgb(87, 232, 198);
|
border: 1px solid rgb(87, 232, 198);
|
||||||
box-shadow: 0px 0px 3px rgb(87, 232, 198);
|
box-shadow: 0px 0px 3px rgb(87, 232, 198);
|
||||||
}
|
}
|
||||||
|
|
||||||
.etable tr:not(:first-child) > :last-child {
|
.etable tr:not(:first-child) > :last-child {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.etableInputDiv {
|
div.etableInputDiv {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
padding: 5px 0 0 5px;
|
padding: 5px 0 0 5px;
|
||||||
top: 0;
|
top: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.etableInputDiv > * {
|
.etableInputDiv > * {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background-color: rgba(255, 255, 255, 0);
|
background-color: rgba(255, 255, 255, 0);
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.etableInputDiv input[type="text"] {
|
.etableInputDiv input[type="text"] {
|
||||||
@ -172,22 +205,23 @@ div.etableInputDiv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.etableInputDiv input[type="checkbox"] {
|
.etableInputDiv input[type="checkbox"] {
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
margin-left: -8px;
|
margin-left: -8px;
|
||||||
margin-top: -8px;
|
margin-top: -8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.etableInputDiv select {
|
.etableInputDiv select {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.etableInputDiv textarea {
|
.etableInputDiv textarea {
|
||||||
resize: none;
|
resize: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.etableInputDiv textarea:hover {
|
.etableInputDiv textarea:hover {
|
||||||
margin: -5px;
|
margin: -5px;
|
||||||
}
|
}
|
||||||
|
|||||||
1082
_server/editor.js
1082
_server/editor.js
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,8 @@
|
|||||||
editor_blockly = function(){
|
editor_blockly = function () {
|
||||||
|
|
||||||
var editor_blockly = {};
|
var editor_blockly = {};
|
||||||
|
|
||||||
initscript=String.raw`
|
initscript = String.raw`
|
||||||
(function(){
|
(function(){
|
||||||
var getCategory = function(name){
|
var getCategory = function(name){
|
||||||
for(var node of document.getElementById('toolbox').children) {
|
for(var node of document.getElementById('toolbox').children) {
|
||||||
@ -278,161 +278,163 @@ document.getElementById('blocklyDiv').onmousewheel = function(e){
|
|||||||
})();
|
})();
|
||||||
`;
|
`;
|
||||||
|
|
||||||
var input_='';
|
var input_ = '';
|
||||||
editor_blockly.runOne = function (){
|
editor_blockly.runOne = function () {
|
||||||
//var printf = console.log;
|
//var printf = console.log;
|
||||||
//var printf = function(){};
|
//var printf = function(){};
|
||||||
var grammerFile = input_;
|
var grammerFile = input_;
|
||||||
converter = new Converter().init();
|
converter = new Converter().init();
|
||||||
converter.generBlocks(grammerFile);
|
converter.generBlocks(grammerFile);
|
||||||
//printf(converter.blocks);
|
//printf(converter.blocks);
|
||||||
converter.renderGrammerName();
|
converter.renderGrammerName();
|
||||||
//converter.generToolbox();
|
//converter.generToolbox();
|
||||||
converter.generMainFile();
|
converter.generMainFile();
|
||||||
//printf(converter.mainFile.join(''));
|
//printf(converter.mainFile.join(''));
|
||||||
//console.log(converter);
|
//console.log(converter);
|
||||||
|
|
||||||
|
|
||||||
|
var script = document.createElement('script');
|
||||||
var script = document.createElement('script');
|
//var initscript = document.getElementById('initscript').innerText;
|
||||||
//var initscript = document.getElementById('initscript').innerText;
|
script.innerHTML = converter.mainFile[5] + initscript;
|
||||||
script.innerHTML = converter.mainFile[5]+initscript;
|
document.body.appendChild(script);
|
||||||
document.body.appendChild(script);
|
|
||||||
}
|
|
||||||
var xhr=new XMLHttpRequest();
|
|
||||||
xhr.onreadystatechange = function (){
|
|
||||||
if(xhr.readyState!=4) return;
|
|
||||||
if(xhr.status!=200) {
|
|
||||||
alert("无法在file://下加载");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
input_=xhr.responseText;
|
var xhr = new XMLHttpRequest();
|
||||||
editor_blockly.runOne();
|
xhr.onreadystatechange = function () {
|
||||||
}
|
if (xhr.readyState != 4) return;
|
||||||
xhr.open('GET','_server/blockly/MotaAction.g4',true);
|
if (xhr.status != 200) {
|
||||||
xhr.send(null);
|
alert("无法在file://下加载");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
input_ = xhr.responseText;
|
||||||
|
editor_blockly.runOne();
|
||||||
|
}
|
||||||
|
xhr.open('GET', '_server/blockly/MotaAction.g4', true);
|
||||||
|
xhr.send(null);
|
||||||
|
|
||||||
codeAreaHL = CodeMirror.fromTextArea(document.getElementById("codeArea"), {
|
codeAreaHL = CodeMirror.fromTextArea(document.getElementById("codeArea"), {
|
||||||
lineNumbers: true,
|
lineNumbers: true,
|
||||||
matchBrackets: true,
|
matchBrackets: true,
|
||||||
lineWrapping: true,
|
lineWrapping: true,
|
||||||
continueComments: "Enter",
|
continueComments: "Enter",
|
||||||
extraKeys: {"Ctrl-Q": "toggleComment"}
|
extraKeys: {"Ctrl-Q": "toggleComment"}
|
||||||
});
|
|
||||||
|
|
||||||
editor_blockly.showXML = function () {
|
|
||||||
var xml = Blockly.Xml.workspaceToDom(editor_blockly.workspace);
|
|
||||||
var xml_text = Blockly.Xml.domToPrettyText(xml);
|
|
||||||
console.log(xml_text);
|
|
||||||
var xml_text = Blockly.Xml.domToText(xml);
|
|
||||||
console.log(xml_text);
|
|
||||||
console.log(xml);
|
|
||||||
}
|
|
||||||
|
|
||||||
editor_blockly.runCode = function () {
|
|
||||||
// Generate JavaScript code and run it.
|
|
||||||
window.LoopTrap = 1000;
|
|
||||||
Blockly.JavaScript.INFINITE_LOOP_TRAP =
|
|
||||||
'if (--window.LoopTrap == 0) throw "Infinite loop.";\n';
|
|
||||||
var code = Blockly.JavaScript.workspaceToCode(editor_blockly.workspace);
|
|
||||||
Blockly.JavaScript.INFINITE_LOOP_TRAP = null;
|
|
||||||
try {
|
|
||||||
eval('obj=' + code);
|
|
||||||
console.log(obj);
|
|
||||||
} catch (e) {
|
|
||||||
alert(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
editor_blockly.parse = function () {
|
|
||||||
MotaActionFunctions.parse(
|
|
||||||
eval('obj=' + codeAreaHL.getValue().replace(/[<>&]/g,function(c){return {'<':'<','>':'>','&':'&'}[c];})),
|
|
||||||
document.getElementById('entryType').value
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
editor_blockly.id='';
|
|
||||||
|
|
||||||
editor_blockly.import = function(id_,args){
|
|
||||||
var thisTr = document.getElementById(id_);
|
|
||||||
if(!thisTr)return false;
|
|
||||||
var input = thisTr.children[2].children[0].children[0];
|
|
||||||
var field = thisTr.children[0].getAttribute('title');
|
|
||||||
var type = args.type;
|
|
||||||
if(!type)return false;
|
|
||||||
editor_blockly.id=id_;
|
|
||||||
codeAreaHL.setValue(input.value);
|
|
||||||
document.getElementById('entryType').value = type;
|
|
||||||
editor_blockly.parse();
|
|
||||||
editor_blockly.show();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var blocklyWidgetDiv = document.getElementsByClassName('blocklyWidgetDiv');
|
|
||||||
editor_blockly.show = function(){
|
|
||||||
if(typeof(selectBox)!==typeof(undefined))selectBox.isSelected = false;
|
|
||||||
document.getElementById('left6').style='';
|
|
||||||
for(var ii =0,node;node=blocklyWidgetDiv[ii];ii++){
|
|
||||||
node.style.zIndex = 201;
|
|
||||||
node.style.opacity = '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
editor_blockly.hide = function(){
|
|
||||||
document.getElementById('left6').style='z-index:-1;opacity: 0;';
|
|
||||||
for(var ii =0,node;node=blocklyWidgetDiv[ii];ii++){
|
|
||||||
node.style.zIndex = -1;
|
|
||||||
node.style.opacity = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
editor_blockly.cancel = function(){
|
|
||||||
editor_blockly.id='';
|
|
||||||
editor_blockly.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
editor_blockly.confirm = function (){
|
|
||||||
if(!editor_blockly.id){
|
|
||||||
editor_blockly.id='';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var setvalue = function(value){
|
|
||||||
var thisTr = document.getElementById(editor_blockly.id);
|
|
||||||
editor_blockly.id='';
|
|
||||||
var input = thisTr.children[2].children[0].children[0];
|
|
||||||
input.value = value;
|
|
||||||
editor_blockly.hide();
|
|
||||||
input.onchange();
|
|
||||||
}
|
|
||||||
if(codeAreaHL.getValue()===''){
|
|
||||||
setvalue('null');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var code = Blockly.JavaScript.workspaceToCode(editor_blockly.workspace);
|
|
||||||
eval('var obj=' + code);
|
|
||||||
setvalue(JSON.stringify(obj));
|
|
||||||
}
|
|
||||||
|
|
||||||
editor_blockly.doubleClickBlock = function (blockId){
|
|
||||||
var b=editor_blockly.workspace.getBlockById(blockId);
|
|
||||||
//console.log(b);
|
|
||||||
var textStringDict = {
|
|
||||||
'text_0_s':'EvalString_0',
|
|
||||||
'text_1_s':'EvalString_2',
|
|
||||||
'autoText_s':'EvalString_2',
|
|
||||||
'choices_s':'EvalString_0',
|
|
||||||
'function_s':'RawEvalString_0',
|
|
||||||
}
|
|
||||||
var f=b?textStringDict[b.type]:null;
|
|
||||||
if(f){
|
|
||||||
var value = b.getFieldValue(f);
|
|
||||||
//多行编辑
|
|
||||||
editor_multi.multiLineEdit(value,b,f,{'lint':f==='RawEvalString_0'},function(newvalue,b,f){
|
|
||||||
if(textStringDict[b.type]!=='RawEvalString_0'){}
|
|
||||||
b.setFieldValue(newvalue.split('\n').join('\\n'),f);
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return editor_blockly;
|
editor_blockly.showXML = function () {
|
||||||
|
var xml = Blockly.Xml.workspaceToDom(editor_blockly.workspace);
|
||||||
|
var xml_text = Blockly.Xml.domToPrettyText(xml);
|
||||||
|
console.log(xml_text);
|
||||||
|
var xml_text = Blockly.Xml.domToText(xml);
|
||||||
|
console.log(xml_text);
|
||||||
|
console.log(xml);
|
||||||
|
}
|
||||||
|
|
||||||
|
editor_blockly.runCode = function () {
|
||||||
|
// Generate JavaScript code and run it.
|
||||||
|
window.LoopTrap = 1000;
|
||||||
|
Blockly.JavaScript.INFINITE_LOOP_TRAP =
|
||||||
|
'if (--window.LoopTrap == 0) throw "Infinite loop.";\n';
|
||||||
|
var code = Blockly.JavaScript.workspaceToCode(editor_blockly.workspace);
|
||||||
|
Blockly.JavaScript.INFINITE_LOOP_TRAP = null;
|
||||||
|
try {
|
||||||
|
eval('obj=' + code);
|
||||||
|
console.log(obj);
|
||||||
|
} catch (e) {
|
||||||
|
alert(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
editor_blockly.parse = function () {
|
||||||
|
MotaActionFunctions.parse(
|
||||||
|
eval('obj=' + codeAreaHL.getValue().replace(/[<>&]/g, function (c) {
|
||||||
|
return {'<': '<', '>': '>', '&': '&'}[c];
|
||||||
|
})),
|
||||||
|
document.getElementById('entryType').value
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
editor_blockly.id = '';
|
||||||
|
|
||||||
|
editor_blockly.import = function (id_, args) {
|
||||||
|
var thisTr = document.getElementById(id_);
|
||||||
|
if (!thisTr) return false;
|
||||||
|
var input = thisTr.children[2].children[0].children[0];
|
||||||
|
var field = thisTr.children[0].getAttribute('title');
|
||||||
|
var type = args.type;
|
||||||
|
if (!type) return false;
|
||||||
|
editor_blockly.id = id_;
|
||||||
|
codeAreaHL.setValue(input.value);
|
||||||
|
document.getElementById('entryType').value = type;
|
||||||
|
editor_blockly.parse();
|
||||||
|
editor_blockly.show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var blocklyWidgetDiv = document.getElementsByClassName('blocklyWidgetDiv');
|
||||||
|
editor_blockly.show = function () {
|
||||||
|
if (typeof(selectBox) !== typeof(undefined)) selectBox.isSelected = false;
|
||||||
|
document.getElementById('left6').style = '';
|
||||||
|
for (var ii = 0, node; node = blocklyWidgetDiv[ii]; ii++) {
|
||||||
|
node.style.zIndex = 201;
|
||||||
|
node.style.opacity = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
editor_blockly.hide = function () {
|
||||||
|
document.getElementById('left6').style = 'z-index:-1;opacity: 0;';
|
||||||
|
for (var ii = 0, node; node = blocklyWidgetDiv[ii]; ii++) {
|
||||||
|
node.style.zIndex = -1;
|
||||||
|
node.style.opacity = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
editor_blockly.cancel = function () {
|
||||||
|
editor_blockly.id = '';
|
||||||
|
editor_blockly.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
editor_blockly.confirm = function () {
|
||||||
|
if (!editor_blockly.id) {
|
||||||
|
editor_blockly.id = '';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var setvalue = function (value) {
|
||||||
|
var thisTr = document.getElementById(editor_blockly.id);
|
||||||
|
editor_blockly.id = '';
|
||||||
|
var input = thisTr.children[2].children[0].children[0];
|
||||||
|
input.value = value;
|
||||||
|
editor_blockly.hide();
|
||||||
|
input.onchange();
|
||||||
|
}
|
||||||
|
if (codeAreaHL.getValue() === '') {
|
||||||
|
setvalue('null');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var code = Blockly.JavaScript.workspaceToCode(editor_blockly.workspace);
|
||||||
|
eval('var obj=' + code);
|
||||||
|
setvalue(JSON.stringify(obj));
|
||||||
|
}
|
||||||
|
|
||||||
|
editor_blockly.doubleClickBlock = function (blockId) {
|
||||||
|
var b = editor_blockly.workspace.getBlockById(blockId);
|
||||||
|
//console.log(b);
|
||||||
|
var textStringDict = {
|
||||||
|
'text_0_s': 'EvalString_0',
|
||||||
|
'text_1_s': 'EvalString_2',
|
||||||
|
'autoText_s': 'EvalString_2',
|
||||||
|
'choices_s': 'EvalString_0',
|
||||||
|
'function_s': 'RawEvalString_0',
|
||||||
|
}
|
||||||
|
var f = b ? textStringDict[b.type] : null;
|
||||||
|
if (f) {
|
||||||
|
var value = b.getFieldValue(f);
|
||||||
|
//多行编辑
|
||||||
|
editor_multi.multiLineEdit(value, b, f, {'lint': f === 'RawEvalString_0'}, function (newvalue, b, f) {
|
||||||
|
if (textStringDict[b.type] !== 'RawEvalString_0') {
|
||||||
|
}
|
||||||
|
b.setFieldValue(newvalue.split('\n').join('\\n'), f);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return editor_blockly;
|
||||||
}
|
}
|
||||||
//editor_blockly=editor_blockly();
|
//editor_blockly=editor_blockly();
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,142 +1,157 @@
|
|||||||
editor_multi = function(){
|
editor_multi = function () {
|
||||||
|
|
||||||
var editor_multi = {};
|
var editor_multi = {};
|
||||||
|
|
||||||
var codeEditor = CodeMirror.fromTextArea(document.getElementById("multiLineCode"), {
|
var codeEditor = CodeMirror.fromTextArea(document.getElementById("multiLineCode"), {
|
||||||
lineNumbers: true,
|
lineNumbers: true,
|
||||||
matchBrackets: true,
|
matchBrackets: true,
|
||||||
indentUnit: 4,
|
indentUnit: 4,
|
||||||
tabSize: 4,
|
tabSize: 4,
|
||||||
indentWithTabs: true,
|
indentWithTabs: true,
|
||||||
smartIndent: true,
|
smartIndent: true,
|
||||||
mode: {name: "javascript", globalVars: true, localVars: true},
|
mode: {name: "javascript", globalVars: true, localVars: true},
|
||||||
lineWrapping: true,
|
lineWrapping: true,
|
||||||
continueComments: "Enter",
|
continueComments: "Enter",
|
||||||
gutters: ["CodeMirror-lint-markers"],
|
gutters: ["CodeMirror-lint-markers"],
|
||||||
lint: true,
|
lint: true,
|
||||||
autocomplete: true,
|
autocomplete: true,
|
||||||
extraKeys: {"Ctrl-Q": "toggleComment"},
|
extraKeys: {"Ctrl-Q": "toggleComment"},
|
||||||
});
|
});
|
||||||
|
|
||||||
codeEditor.on("keyup", function (cm, event) {
|
codeEditor.on("keyup", function (cm, event) {
|
||||||
if (codeEditor.getOption("autocomplete") && (event.keyCode >= 65 && event.keyCode<=90) || (event.keyCode>=49 && event.keyCode<=57) || event.keyCode==190) {
|
if (codeEditor.getOption("autocomplete") && (event.keyCode >= 65 && event.keyCode <= 90) || (event.keyCode >= 49 && event.keyCode <= 57) || event.keyCode == 190) {
|
||||||
try {
|
try {
|
||||||
CodeMirror.commands.autocomplete(cm, null, {completeSingle: false});
|
CodeMirror.commands.autocomplete(cm, null, {completeSingle: false});
|
||||||
} catch (e) {}
|
} catch (e) {
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
editor_multi.id='';
|
editor_multi.id = '';
|
||||||
editor_multi.isString=false;
|
editor_multi.isString = false;
|
||||||
editor_multi.lintAutocomplete=false;
|
editor_multi.lintAutocomplete = false;
|
||||||
|
|
||||||
editor_multi.show = function(){
|
editor_multi.show = function () {
|
||||||
if(typeof(selectBox)!==typeof(undefined))selectBox.isSelected = false;
|
if (typeof(selectBox) !== typeof(undefined)) selectBox.isSelected = false;
|
||||||
var valueNow = codeEditor.getValue();
|
var valueNow = codeEditor.getValue();
|
||||||
//try{eval('function _asdygakufyg_() { return '+valueNow+'\n}');editor_multi.lintAutocomplete=true;}catch(ee){}
|
//try{eval('function _asdygakufyg_() { return '+valueNow+'\n}');editor_multi.lintAutocomplete=true;}catch(ee){}
|
||||||
if(valueNow.slice(0,8)==='function')editor_multi.lintAutocomplete=true;
|
if (valueNow.slice(0, 8) === 'function') editor_multi.lintAutocomplete = true;
|
||||||
editor_multi.setLint();
|
editor_multi.setLint();
|
||||||
document.getElementById('left7').style='';
|
document.getElementById('left7').style = '';
|
||||||
}
|
|
||||||
editor_multi.hide = function(){document.getElementById('left7').style='z-index:-1;opacity: 0;';}
|
|
||||||
editor_multi.setLint = function() {
|
|
||||||
codeEditor.setOption("lint", editor_multi.lintAutocomplete);
|
|
||||||
codeEditor.setOption("autocomplete", editor_multi.lintAutocomplete);
|
|
||||||
document.getElementById("lintCheckbox").checked = editor_multi.lintAutocomplete;
|
|
||||||
}
|
|
||||||
editor_multi.toggerLint = function() {
|
|
||||||
editor_multi.lintAutocomplete = document.getElementById("lintCheckbox").checked;
|
|
||||||
editor_multi.setLint();
|
|
||||||
}
|
|
||||||
|
|
||||||
editor_multi.indent = function(field){
|
|
||||||
if(typeof(editor)!==typeof(undefined) && editor && editor.mode && editor.mode.indent)return editor.mode.indent(field);
|
|
||||||
return '\t';
|
|
||||||
}
|
|
||||||
|
|
||||||
editor_multi.import = function(id_,args){
|
|
||||||
var thisTr = document.getElementById(id_);
|
|
||||||
if(!thisTr)return false;
|
|
||||||
var input = thisTr.children[2].children[0].children[0];
|
|
||||||
var field = thisTr.children[0].getAttribute('title');
|
|
||||||
var comment = thisTr.children[1].getAttribute('title');
|
|
||||||
if(!input.type || input.type!=='textarea')return false;
|
|
||||||
editor_multi.id=id_;
|
|
||||||
editor_multi.isString=false;
|
|
||||||
editor_multi.lintAutocomplete=false;
|
|
||||||
if(args.lint===true)editor_multi.lintAutocomplete=true;
|
|
||||||
if(field.indexOf('Effect') !== -1)editor_multi.lintAutocomplete=true;
|
|
||||||
if(input.value.slice(0,1)==='"'){
|
|
||||||
editor_multi.isString=true;
|
|
||||||
codeEditor.setValue(JSON.parse(input.value)||'');
|
|
||||||
} else {
|
|
||||||
var num = editor_multi.indent(field);
|
|
||||||
eval('var tobj='+(input.value||'null'));
|
|
||||||
var tmap={};
|
|
||||||
var tstr = JSON.stringify(tobj,function(k,v){if(typeof(v)===typeof('') && v.slice(0,8)==='function'){var id_ = editor.guid();tmap[id_]=v.toString();return id_;}else return v},num);
|
|
||||||
for(var id_ in tmap){
|
|
||||||
tstr = tstr.replace('"'+id_+'"',tmap[id_])
|
|
||||||
}
|
}
|
||||||
codeEditor.setValue(tstr||'');
|
editor_multi.hide = function () {
|
||||||
}
|
document.getElementById('left7').style = 'z-index:-1;opacity: 0;';
|
||||||
editor_multi.show();
|
}
|
||||||
return true;
|
editor_multi.setLint = function () {
|
||||||
}
|
codeEditor.setOption("lint", editor_multi.lintAutocomplete);
|
||||||
|
codeEditor.setOption("autocomplete", editor_multi.lintAutocomplete);
|
||||||
editor_multi.cancel = function(){
|
document.getElementById("lintCheckbox").checked = editor_multi.lintAutocomplete;
|
||||||
editor_multi.hide();
|
}
|
||||||
editor_multi.id='';
|
editor_multi.toggerLint = function () {
|
||||||
multiLineArgs=[null,null,null];
|
editor_multi.lintAutocomplete = document.getElementById("lintCheckbox").checked;
|
||||||
}
|
editor_multi.setLint();
|
||||||
|
|
||||||
editor_multi.confirm = function (){
|
|
||||||
if(!editor_multi.id){
|
|
||||||
editor_multi.id='';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(editor_multi.id==='callFromBlockly'){
|
|
||||||
editor_multi.id='';
|
|
||||||
editor_multi.multiLineDone();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var setvalue = function(value){
|
|
||||||
var thisTr = document.getElementById(editor_multi.id);
|
|
||||||
editor_multi.id='';
|
|
||||||
var input = thisTr.children[2].children[0].children[0];
|
|
||||||
if(editor_multi.isString){
|
|
||||||
input.value = JSON.stringify(value);
|
|
||||||
} else {
|
|
||||||
eval('var tobj='+(value||'null'));
|
|
||||||
var tmap={};
|
|
||||||
var tstr = JSON.stringify(tobj,function(k,v){if(v instanceof Function){var id_ = editor.guid();tmap[id_]=v.toString();return id_;}else return v},4);
|
|
||||||
for(var id_ in tmap){
|
|
||||||
tstr = tstr.replace('"'+id_+'"',JSON.stringify(tmap[id_]))
|
|
||||||
}
|
|
||||||
input.value = tstr;
|
|
||||||
}
|
}
|
||||||
editor_multi.hide();
|
|
||||||
input.onchange();
|
|
||||||
}
|
|
||||||
setvalue(codeEditor.getValue()||'');
|
|
||||||
}
|
|
||||||
|
|
||||||
var multiLineArgs=[null,null,null];
|
editor_multi.indent = function (field) {
|
||||||
editor_multi.multiLineEdit = function(value,b,f,args,callback){
|
if (typeof(editor) !== typeof(undefined) && editor && editor.mode && editor.mode.indent) return editor.mode.indent(field);
|
||||||
editor_multi.id='callFromBlockly';
|
return '\t';
|
||||||
codeEditor.setValue(value.split('\\n').join('\n')||'');
|
}
|
||||||
multiLineArgs[0]=b;
|
|
||||||
multiLineArgs[1]=f;
|
|
||||||
multiLineArgs[2]=callback;
|
|
||||||
editor_multi.lintAutocomplete=Boolean(args.lint);
|
|
||||||
editor_multi.show();
|
|
||||||
}
|
|
||||||
editor_multi.multiLineDone = function(){
|
|
||||||
editor_multi.hide();
|
|
||||||
if(!multiLineArgs[0] || !multiLineArgs[1] || !multiLineArgs[2])return;
|
|
||||||
var newvalue = codeEditor.getValue()||'';
|
|
||||||
multiLineArgs[2](newvalue,multiLineArgs[0],multiLineArgs[1])
|
|
||||||
}
|
|
||||||
|
|
||||||
return editor_multi;
|
editor_multi.import = function (id_, args) {
|
||||||
|
var thisTr = document.getElementById(id_);
|
||||||
|
if (!thisTr) return false;
|
||||||
|
var input = thisTr.children[2].children[0].children[0];
|
||||||
|
var field = thisTr.children[0].getAttribute('title');
|
||||||
|
var comment = thisTr.children[1].getAttribute('title');
|
||||||
|
if (!input.type || input.type !== 'textarea') return false;
|
||||||
|
editor_multi.id = id_;
|
||||||
|
editor_multi.isString = false;
|
||||||
|
editor_multi.lintAutocomplete = false;
|
||||||
|
if (args.lint === true) editor_multi.lintAutocomplete = true;
|
||||||
|
if (field.indexOf('Effect') !== -1) editor_multi.lintAutocomplete = true;
|
||||||
|
if (input.value.slice(0, 1) === '"') {
|
||||||
|
editor_multi.isString = true;
|
||||||
|
codeEditor.setValue(JSON.parse(input.value) || '');
|
||||||
|
} else {
|
||||||
|
var num = editor_multi.indent(field);
|
||||||
|
eval('var tobj=' + (input.value || 'null'));
|
||||||
|
var tmap = {};
|
||||||
|
var tstr = JSON.stringify(tobj, function (k, v) {
|
||||||
|
if (typeof(v) === typeof('') && v.slice(0, 8) === 'function') {
|
||||||
|
var id_ = editor.guid();
|
||||||
|
tmap[id_] = v.toString();
|
||||||
|
return id_;
|
||||||
|
} else return v
|
||||||
|
}, num);
|
||||||
|
for (var id_ in tmap) {
|
||||||
|
tstr = tstr.replace('"' + id_ + '"', tmap[id_])
|
||||||
|
}
|
||||||
|
codeEditor.setValue(tstr || '');
|
||||||
|
}
|
||||||
|
editor_multi.show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
editor_multi.cancel = function () {
|
||||||
|
editor_multi.hide();
|
||||||
|
editor_multi.id = '';
|
||||||
|
multiLineArgs = [null, null, null];
|
||||||
|
}
|
||||||
|
|
||||||
|
editor_multi.confirm = function () {
|
||||||
|
if (!editor_multi.id) {
|
||||||
|
editor_multi.id = '';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (editor_multi.id === 'callFromBlockly') {
|
||||||
|
editor_multi.id = '';
|
||||||
|
editor_multi.multiLineDone();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var setvalue = function (value) {
|
||||||
|
var thisTr = document.getElementById(editor_multi.id);
|
||||||
|
editor_multi.id = '';
|
||||||
|
var input = thisTr.children[2].children[0].children[0];
|
||||||
|
if (editor_multi.isString) {
|
||||||
|
input.value = JSON.stringify(value);
|
||||||
|
} else {
|
||||||
|
eval('var tobj=' + (value || 'null'));
|
||||||
|
var tmap = {};
|
||||||
|
var tstr = JSON.stringify(tobj, function (k, v) {
|
||||||
|
if (v instanceof Function) {
|
||||||
|
var id_ = editor.guid();
|
||||||
|
tmap[id_] = v.toString();
|
||||||
|
return id_;
|
||||||
|
} else return v
|
||||||
|
}, 4);
|
||||||
|
for (var id_ in tmap) {
|
||||||
|
tstr = tstr.replace('"' + id_ + '"', JSON.stringify(tmap[id_]))
|
||||||
|
}
|
||||||
|
input.value = tstr;
|
||||||
|
}
|
||||||
|
editor_multi.hide();
|
||||||
|
input.onchange();
|
||||||
|
}
|
||||||
|
setvalue(codeEditor.getValue() || '');
|
||||||
|
}
|
||||||
|
|
||||||
|
var multiLineArgs = [null, null, null];
|
||||||
|
editor_multi.multiLineEdit = function (value, b, f, args, callback) {
|
||||||
|
editor_multi.id = 'callFromBlockly';
|
||||||
|
codeEditor.setValue(value.split('\\n').join('\n') || '');
|
||||||
|
multiLineArgs[0] = b;
|
||||||
|
multiLineArgs[1] = f;
|
||||||
|
multiLineArgs[2] = callback;
|
||||||
|
editor_multi.lintAutocomplete = Boolean(args.lint);
|
||||||
|
editor_multi.show();
|
||||||
|
}
|
||||||
|
editor_multi.multiLineDone = function () {
|
||||||
|
editor_multi.hide();
|
||||||
|
if (!multiLineArgs[0] || !multiLineArgs[1] || !multiLineArgs[2]) return;
|
||||||
|
var newvalue = codeEditor.getValue() || '';
|
||||||
|
multiLineArgs[2](newvalue, multiLineArgs[0], multiLineArgs[1])
|
||||||
|
}
|
||||||
|
|
||||||
|
return editor_multi;
|
||||||
}
|
}
|
||||||
//editor_multi=editor_multi();
|
//editor_multi=editor_multi();
|
||||||
188
_server/fs.js
188
_server/fs.js
@ -1,101 +1,103 @@
|
|||||||
(function(){
|
(function () {
|
||||||
fs = {};
|
fs = {};
|
||||||
var postsomething = function (data,_ip,callback) {
|
var postsomething = function (data, _ip, callback) {
|
||||||
//callback:function(err, data)
|
//callback:function(err, data)
|
||||||
//data:字符串
|
//data:字符串
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.onreadystatechange = function(){
|
xhr.onreadystatechange = function () {
|
||||||
switch(xhr.readyState){
|
switch (xhr.readyState) {
|
||||||
case 4 :
|
case 4 :
|
||||||
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304) {
|
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304) {
|
||||||
if (Boolean(callback)){
|
if (Boolean(callback)) {
|
||||||
if (xhr.responseText.slice(0,6)=='error:'){
|
if (xhr.responseText.slice(0, 6) == 'error:') {
|
||||||
callback(xhr.responseText,null);
|
callback(xhr.responseText, null);
|
||||||
} else {
|
} else {
|
||||||
callback(null,xhr.responseText);
|
callback(null, xhr.responseText);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
//printf(xhr.responseText)
|
||||||
|
} else {
|
||||||
|
if (Boolean(callback)) callback(xhr.status, null);
|
||||||
|
//printf('error:' + xhr.status+'<br>'+(xhr.responseText||''));
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
//printf(xhr.responseText)
|
}
|
||||||
}else{
|
xhr.open('post', _ip);
|
||||||
if (Boolean(callback))callback(xhr.status,null);
|
xhr.setRequestHeader('Content-Type', 'text/plain');
|
||||||
//printf('error:' + xhr.status+'<br>'+(xhr.responseText||''));
|
if (typeof(data) == typeof([][0]) || data == null) data = JSON.stringify({1: 2});
|
||||||
}
|
xhr.send(data);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
xhr.open('post',_ip);
|
|
||||||
xhr.setRequestHeader('Content-Type','text/plain');
|
|
||||||
if(typeof(data)==typeof([][0]) || data==null)data=JSON.stringify({1:2});
|
|
||||||
xhr.send(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.readFile = function (filename,encoding,callback) {
|
fs.readFile = function (filename, encoding, callback) {
|
||||||
if (typeof(filename)!=typeof(''))
|
if (typeof(filename) != typeof(''))
|
||||||
throw 'Type Error in fs.readFile';
|
throw 'Type Error in fs.readFile';
|
||||||
if (encoding=='utf-8'){
|
if (encoding == 'utf-8') {
|
||||||
//读文本文件
|
//读文本文件
|
||||||
//filename:支持"/"做分隔符
|
//filename:支持"/"做分隔符
|
||||||
//callback:function(err, data)
|
//callback:function(err, data)
|
||||||
//data:字符串
|
//data:字符串
|
||||||
var data='';
|
var data = '';
|
||||||
data+='type=utf8&';
|
data += 'type=utf8&';
|
||||||
data+='name='+filename;
|
data += 'name=' + filename;
|
||||||
postsomething(data,'/readFile',callback);
|
postsomething(data, '/readFile', callback);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
if (encoding == 'base64') {
|
||||||
|
//读二进制文件
|
||||||
|
//filename:支持"/"做分隔符
|
||||||
|
//callback:function(err, data)
|
||||||
|
//data:base64字符串
|
||||||
|
var data = '';
|
||||||
|
data += 'type=base64&';
|
||||||
|
data += 'name=' + filename;
|
||||||
|
postsomething(data, '/readFile', callback);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw 'Type Error in fs.readFile';
|
||||||
}
|
}
|
||||||
if (encoding=='base64'){
|
|
||||||
//读二进制文件
|
|
||||||
//filename:支持"/"做分隔符
|
|
||||||
//callback:function(err, data)
|
|
||||||
//data:base64字符串
|
|
||||||
var data='';
|
|
||||||
data+='type=base64&';
|
|
||||||
data+='name='+filename;
|
|
||||||
postsomething(data,'/readFile',callback);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
throw 'Type Error in fs.readFile';
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.writeFile = function (filename,datastr,encoding,callback) {
|
fs.writeFile = function (filename, datastr, encoding, callback) {
|
||||||
if (typeof(filename)!=typeof('') || typeof(datastr)!=typeof(''))
|
if (typeof(filename) != typeof('') || typeof(datastr) != typeof(''))
|
||||||
throw 'Type Error in fs.writeFile';
|
throw 'Type Error in fs.writeFile';
|
||||||
if (encoding=='utf-8'){
|
if (encoding == 'utf-8') {
|
||||||
//写文本文件
|
//写文本文件
|
||||||
//filename:支持"/"做分隔符
|
//filename:支持"/"做分隔符
|
||||||
//callback:function(err)
|
//callback:function(err)
|
||||||
//datastr:字符串
|
//datastr:字符串
|
||||||
var data='';
|
var data = '';
|
||||||
data+='type=utf8&';
|
data += 'type=utf8&';
|
||||||
data+='name='+filename;
|
data += 'name=' + filename;
|
||||||
data+='&value='+datastr;
|
data += '&value=' + datastr;
|
||||||
postsomething(data,'/writeFile',callback);
|
postsomething(data, '/writeFile', callback);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
if (encoding == 'base64') {
|
||||||
|
//写二进制文件
|
||||||
|
//filename:支持"/"做分隔符
|
||||||
|
//callback:function(err)
|
||||||
|
//datastr:base64字符串
|
||||||
|
var data = '';
|
||||||
|
data += 'type=base64&';
|
||||||
|
data += 'name=' + filename;
|
||||||
|
data += '&value=' + datastr;
|
||||||
|
postsomething(data, '/writeFile', callback);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw 'Type Error in fs.writeFile';
|
||||||
}
|
}
|
||||||
if (encoding=='base64'){
|
|
||||||
//写二进制文件
|
|
||||||
//filename:支持"/"做分隔符
|
|
||||||
//callback:function(err)
|
|
||||||
//datastr:base64字符串
|
|
||||||
var data='';
|
|
||||||
data+='type=base64&';
|
|
||||||
data+='name='+filename;
|
|
||||||
data+='&value='+datastr;
|
|
||||||
postsomething(data,'/writeFile',callback);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
throw 'Type Error in fs.writeFile';
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.readdir = function (path, callback) {
|
fs.readdir = function (path, callback) {
|
||||||
//callback:function(err, data)
|
//callback:function(err, data)
|
||||||
//path:支持"/"做分隔符,不以"/"结尾
|
//path:支持"/"做分隔符,不以"/"结尾
|
||||||
//data:[filename1,filename2,..] filename是字符串,只包含文件不包含目录
|
//data:[filename1,filename2,..] filename是字符串,只包含文件不包含目录
|
||||||
if (typeof(path)!=typeof(''))
|
if (typeof(path) != typeof(''))
|
||||||
throw 'Type Error in fs.readdir';
|
throw 'Type Error in fs.readdir';
|
||||||
var data='';
|
var data = '';
|
||||||
data+='name='+path;
|
data += 'name=' + path;
|
||||||
postsomething(data,'/listFile',function(err, data){callback(err,JSON.parse(data))});
|
postsomething(data, '/listFile', function (err, data) {
|
||||||
return;
|
callback(err, JSON.parse(data))
|
||||||
}
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
@ -1,24 +1,41 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head><meta charset="utf-8"></head>
|
<head>
|
||||||
<body>
|
<meta charset="utf-8">
|
||||||
<script src="./fs.js"></script>
|
</head>
|
||||||
<script>
|
<body>
|
||||||
fs.writeFile('_test.txt','123中a文bc','utf-8',function(e,d){console.log(e);console.log(d);})
|
<script src="./fs.js"></script>
|
||||||
setTimeout(function() {
|
<script>
|
||||||
fs.writeFile('_test_bin.txt','abc=','base64',function(e,d){console.log(e);console.log(d);})
|
fs.writeFile('_test.txt', '123中a文bc', 'utf-8', function (e, d) {
|
||||||
}, 1000);
|
console.log(e);
|
||||||
setTimeout(function() {
|
console.log(d);
|
||||||
fs.readFile('_test.txt','utf-8',function(e,d){console.log(e);console.log(d);})
|
})
|
||||||
}, 2000);
|
setTimeout(function () {
|
||||||
setTimeout(function() {
|
fs.writeFile('_test_bin.txt', 'abc=', 'base64', function (e, d) {
|
||||||
fs.readFile('_test_bin.txt','base64',function(e,d){console.log(e);console.log(d);})
|
console.log(e);
|
||||||
}, 3000);
|
console.log(d);
|
||||||
setTimeout(function() {
|
})
|
||||||
fs.readdir('.',function(e,d){console.log(e);console.log(d);})
|
}, 1000);
|
||||||
}, 4000);
|
setTimeout(function () {
|
||||||
|
fs.readFile('_test.txt', 'utf-8', function (e, d) {
|
||||||
|
console.log(e);
|
||||||
</script>
|
console.log(d);
|
||||||
</body>
|
})
|
||||||
|
}, 2000);
|
||||||
|
setTimeout(function () {
|
||||||
|
fs.readFile('_test_bin.txt', 'base64', function (e, d) {
|
||||||
|
console.log(e);
|
||||||
|
console.log(d);
|
||||||
|
})
|
||||||
|
}, 3000);
|
||||||
|
setTimeout(function () {
|
||||||
|
fs.readdir('.', function (e, d) {
|
||||||
|
console.log(e);
|
||||||
|
console.log(d);
|
||||||
|
})
|
||||||
|
}, 4000);
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
638
_server/vm.js
638
_server/vm.js
@ -1,339 +1,375 @@
|
|||||||
// vue 相关处理
|
// vue 相关处理
|
||||||
|
|
||||||
document.body.onmousedown = function(e){
|
document.body.onmousedown = function (e) {
|
||||||
//console.log(e);
|
//console.log(e);
|
||||||
var eid=[];
|
var eid = [];
|
||||||
e.path.forEach(function(node){
|
e.path.forEach(function (node) {
|
||||||
if(!node.getAttribute)return;
|
if (!node.getAttribute) return;
|
||||||
var id_ = node.getAttribute('id');
|
var id_ = node.getAttribute('id');
|
||||||
if (id_){
|
if (id_) {
|
||||||
if(['left','left1','left2','left3','left4','left5','left8'].indexOf(id_)!==-1)eid.push('edit');
|
if (['left', 'left1', 'left2', 'left3', 'left4', 'left5', 'left8'].indexOf(id_) !== -1) eid.push('edit');
|
||||||
eid.push(id_);
|
eid.push(id_);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//console.log(eid);
|
//console.log(eid);
|
||||||
if(eid.indexOf('edit')===-1){
|
if (eid.indexOf('edit') === -1) {
|
||||||
if(eid.indexOf('tip')===-1) {
|
if (eid.indexOf('tip') === -1) {
|
||||||
if (selectBox.isSelected) {
|
if (selectBox.isSelected) {
|
||||||
editor_mode.onmode('');
|
editor_mode.onmode('');
|
||||||
editor.file.saveFloorFile(function(err){if(err){printe(err);throw(err)};printf('地图保存成功');});
|
editor.file.saveFloorFile(function (err) {
|
||||||
}
|
if (err) {
|
||||||
selectBox.isSelected = false;
|
printe(err);
|
||||||
}
|
throw(err)
|
||||||
}
|
}
|
||||||
//editor.mode.onmode('');
|
;printf('地图保存成功');
|
||||||
editor.info = {};
|
});
|
||||||
}
|
}
|
||||||
iconLib.onmousedown = function(e){
|
selectBox.isSelected = false;
|
||||||
e.stopPropagation();
|
}
|
||||||
}
|
}
|
||||||
var exportM = new Vue({
|
//editor.mode.onmode('');
|
||||||
el: '#exportM',
|
editor.info = {};
|
||||||
data: {
|
}
|
||||||
isExport: false,
|
iconLib.onmousedown = function (e) {
|
||||||
},
|
e.stopPropagation();
|
||||||
methods: {
|
}
|
||||||
exportMap: function(){
|
var exportMap = new Vue({
|
||||||
editor.updateMap();
|
el: '#exportMap',
|
||||||
|
data: {
|
||||||
var filestr='';
|
isExport: false,
|
||||||
for (var yy = 0; yy < 13; yy++){
|
},
|
||||||
filestr+='['
|
methods: {
|
||||||
for (var xx = 0; xx < 13; xx++) {
|
exportMap: function () {
|
||||||
var mapxy=editor.map[yy][xx];
|
editor.updateMap();
|
||||||
if(typeof(mapxy)==typeof({})){
|
|
||||||
if ('idnum' in mapxy)mapxy=mapxy.idnum;
|
var filestr = '';
|
||||||
else {
|
for (var yy = 0; yy < 13; yy++) {
|
||||||
// mapxy='!!?';
|
filestr += '['
|
||||||
tip.whichShow = 3;
|
for (var xx = 0; xx < 13; xx++) {
|
||||||
return;
|
var mapxy = editor.map[yy][xx];
|
||||||
}
|
if (typeof(mapxy) == typeof({})) {
|
||||||
}else if(typeof(mapxy)=='undefined'){
|
if ('idnum' in mapxy) mapxy = mapxy.idnum;
|
||||||
tip.whichShow = 3;
|
else {
|
||||||
return;
|
// mapxy='!!?';
|
||||||
}
|
tip.whichShow = 3;
|
||||||
mapxy=String(mapxy);
|
return;
|
||||||
mapxy=Array(Math.max(4-mapxy.length,0)).join(' ')+mapxy;
|
}
|
||||||
filestr+=mapxy+(xx==12?'':',')
|
} else if (typeof(mapxy) == 'undefined') {
|
||||||
|
tip.whichShow = 3;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mapxy = String(mapxy);
|
||||||
|
mapxy = Array(Math.max(4 - mapxy.length, 0)).join(' ') + mapxy;
|
||||||
|
filestr += mapxy + (xx == 12 ? '' : ',')
|
||||||
|
}
|
||||||
|
|
||||||
|
filestr += ']' + (yy == 12 ? '' : ',\n');
|
||||||
|
}
|
||||||
|
pout.value = filestr;
|
||||||
|
editArea.mapArr = filestr;
|
||||||
|
this.isExport = true;
|
||||||
|
editArea.error = 0;
|
||||||
|
tip.whichShow = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
filestr += ']'+(yy==12?'':',\n');
|
|
||||||
}
|
|
||||||
pout.value = filestr;
|
|
||||||
editArea.mapArr = filestr;
|
|
||||||
this.isExport = true;
|
|
||||||
editArea.error = 0;
|
|
||||||
tip.whichShow = 2;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
var editArea = new Vue({
|
var editArea = new Vue({
|
||||||
el: '#editArea',
|
el: '#editArea',
|
||||||
data: {
|
data: {
|
||||||
mapArr: '',
|
mapArr: '',
|
||||||
errors: [ // 编号1,2,3,4
|
errors: [ // 编号1,2,3,4
|
||||||
"格式错误!请使用正确格式(13*13数组,如不清楚,可先点击生成地图查看正确格式)",
|
"格式错误!请使用正确格式(13*13数组,如不清楚,可先点击生成地图查看正确格式)",
|
||||||
"当前有未定义ID(在地图区域显示红块),请修改ID或者到icons.js和maps.js中进行定义!",
|
"当前有未定义ID(在地图区域显示红块),请修改ID或者到icons.js和maps.js中进行定义!",
|
||||||
"ID越界(在地图区域显示红块),当前编辑器暂时支持编号小于400,请修改编号!",
|
"ID越界(在地图区域显示红块),当前编辑器暂时支持编号小于400,请修改编号!",
|
||||||
// "发生错误!",
|
// "发生错误!",
|
||||||
],
|
],
|
||||||
error: 0,
|
error: 0,
|
||||||
formatTimer: null,
|
formatTimer: null,
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
mapArr: function (val, oldval) {
|
|
||||||
var that = this;
|
|
||||||
if(val=='') return;
|
|
||||||
if(exportM.isExport){
|
|
||||||
exportM.isExport = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(that.formatArr()){
|
|
||||||
that.error = 0;
|
|
||||||
|
|
||||||
setTimeout(function(){
|
|
||||||
that.mapArr = that.formatArr();
|
|
||||||
that.drawMap();
|
|
||||||
tip.whichShow = 8
|
|
||||||
}, 1000);
|
|
||||||
that.formatTimer = setTimeout(function(){
|
|
||||||
pout.value = that.formatArr();
|
|
||||||
}, 5000); //5s后再格式化,不然光标跳到最后很烦
|
|
||||||
}else{
|
|
||||||
that.error = 1;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
error: function(){
|
watch: {
|
||||||
// console.log(editArea.mapArr);
|
mapArr: function (val, oldval) {
|
||||||
}
|
var that = this;
|
||||||
},
|
if (val == '') return;
|
||||||
methods: {
|
if (exportMap.isExport) {
|
||||||
drawMap: function(){
|
exportMap.isExport = false;
|
||||||
var that = this;
|
return;
|
||||||
|
}
|
||||||
|
if (that.formatArr()) {
|
||||||
|
that.error = 0;
|
||||||
|
|
||||||
// var mapArray = that.mapArr.split(/\D+/).join(' ').trim().split(' ');
|
setTimeout(function () {
|
||||||
var mapArray = JSON.parse('['+that.mapArr+']');
|
that.mapArr = that.formatArr();
|
||||||
for(var y=0; y<13; y++)
|
that.drawMap();
|
||||||
for(var x=0; x<13; x++){
|
tip.whichShow = 8
|
||||||
var num = mapArray[y][x];
|
}, 1000);
|
||||||
if(num == 0 )
|
that.formatTimer = setTimeout(function () {
|
||||||
editor.map[y][x] = 0;
|
pout.value = that.formatArr();
|
||||||
else if(num >= 1000){
|
}, 5000); //5s后再格式化,不然光标跳到最后很烦
|
||||||
that.error = 3;
|
} else {
|
||||||
editor.map[y][x] = undefined;
|
that.error = 1;
|
||||||
}else if(typeof(editor.indexs[num][0]) == 'undefined'){
|
}
|
||||||
that.error = 2;
|
},
|
||||||
editor.map[y][x] = undefined;
|
error: function () {
|
||||||
}else editor.map[y][x] = editor.ids[[editor.indexs[num][0]]];
|
// console.log(editArea.mapArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
editor.updateMap();
|
|
||||||
|
|
||||||
},
|
},
|
||||||
formatArr: function(){
|
methods: {
|
||||||
var formatArrStr = '';
|
drawMap: function () {
|
||||||
var that = this;
|
var that = this;
|
||||||
clearTimeout(that.formatTimer);
|
|
||||||
if(this.mapArr.split(/\D+/).join(' ').trim().split(' ').length != 169) return false;
|
|
||||||
var arr = this.mapArr.replace(/\s+/g, '').split('],[');
|
|
||||||
|
|
||||||
if(arr.length != 13) return ;
|
|
||||||
for(var i =0; i<13; i++){
|
|
||||||
var a = [];
|
|
||||||
formatArrStr +='[';
|
|
||||||
if(i==0||i==12) a = arr[i].split(/\D+/).join(' ').trim().split(' ');
|
|
||||||
else a = arr[i].split(/\D+/);
|
|
||||||
if(a.length != 13){
|
|
||||||
formatArrStr = '';
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(var k=0; k<13; k++){
|
// var mapArray = that.mapArr.split(/\D+/).join(' ').trim().split(' ');
|
||||||
var num = parseInt(a[k]);
|
var mapArray = JSON.parse('[' + that.mapArr + ']');
|
||||||
formatArrStr += Array(Math.max(4-String(num).length,0)).join(' ')+num+(k==12?'':',');
|
for (var y = 0; y < 13; y++)
|
||||||
|
for (var x = 0; x < 13; x++) {
|
||||||
|
var num = mapArray[y][x];
|
||||||
|
if (num == 0)
|
||||||
|
editor.map[y][x] = 0;
|
||||||
|
else if (num >= 1000) {
|
||||||
|
that.error = 3;
|
||||||
|
editor.map[y][x] = undefined;
|
||||||
|
} else if (typeof(editor.indexs[num][0]) == 'undefined') {
|
||||||
|
that.error = 2;
|
||||||
|
editor.map[y][x] = undefined;
|
||||||
|
} else editor.map[y][x] = editor.ids[[editor.indexs[num][0]]];
|
||||||
|
}
|
||||||
|
|
||||||
|
editor.updateMap();
|
||||||
|
|
||||||
|
},
|
||||||
|
formatArr: function () {
|
||||||
|
var formatArrStr = '';
|
||||||
|
var that = this;
|
||||||
|
clearTimeout(that.formatTimer);
|
||||||
|
if (this.mapArr.split(/\D+/).join(' ').trim().split(' ').length != 169) return false;
|
||||||
|
var arr = this.mapArr.replace(/\s+/g, '').split('],[');
|
||||||
|
|
||||||
|
if (arr.length != 13) return;
|
||||||
|
for (var i = 0; i < 13; i++) {
|
||||||
|
var a = [];
|
||||||
|
formatArrStr += '[';
|
||||||
|
if (i == 0 || i == 12) a = arr[i].split(/\D+/).join(' ').trim().split(' ');
|
||||||
|
else a = arr[i].split(/\D+/);
|
||||||
|
if (a.length != 13) {
|
||||||
|
formatArrStr = '';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var k = 0; k < 13; k++) {
|
||||||
|
var num = parseInt(a[k]);
|
||||||
|
formatArrStr += Array(Math.max(4 - String(num).length, 0)).join(' ') + num + (k == 12 ? '' : ',');
|
||||||
|
}
|
||||||
|
formatArrStr += ']' + (i == 12 ? '' : ',\n');
|
||||||
|
}
|
||||||
|
return formatArrStr;
|
||||||
}
|
}
|
||||||
formatArrStr += ']'+(i==12?'':',\n');
|
|
||||||
}
|
|
||||||
return formatArrStr;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
var editTip = new Vue({
|
var copyMap = new Vue({
|
||||||
el: '#editTip',
|
el: '#copyMap',
|
||||||
data: {
|
data: {
|
||||||
err: ''
|
err: ''
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
copyMap: function(){
|
copyMap: function () {
|
||||||
|
|
||||||
tip.whichShow = 0;
|
tip.whichShow = 0;
|
||||||
if(pout.value.trim() != ''){
|
if (pout.value.trim() != '') {
|
||||||
if(editArea.error) {
|
if (editArea.error) {
|
||||||
this.err = editArea.errors[editArea.error-1];
|
this.err = editArea.errors[editArea.error - 1];
|
||||||
tip.whichShow = 5
|
tip.whichShow = 5
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
pout.select();
|
||||||
|
document.execCommand("Copy");
|
||||||
|
tip.whichShow = 6;
|
||||||
|
} catch (e) {
|
||||||
|
this.err = e;
|
||||||
|
tip.whichShow = 5;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tip.whichShow = 7;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try{
|
},
|
||||||
pout.select();
|
|
||||||
document.execCommand("Copy");
|
|
||||||
tip.whichShow = 6;
|
|
||||||
}catch(e){
|
|
||||||
this.err= e;
|
|
||||||
tip.whichShow = 5;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
tip.whichShow = 7;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
var clear = new Vue({
|
var clearMap = new Vue({
|
||||||
el: '#clear',
|
el: '#clearMap',
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
clearMap: function(){
|
clearMap: function () {
|
||||||
editor.mapInit();
|
editor.mapInit();
|
||||||
editor.updateMap();
|
editor_mode.onmode('');
|
||||||
clearTimeout(editArea.formatTimer);
|
editor.file.saveFloorFile(function (err) {
|
||||||
clearTimeout(tip.timer);
|
if (err) {
|
||||||
pout.value = '';
|
printe(err);
|
||||||
editArea.mapArr = '';
|
throw(err)
|
||||||
tip.whichShow = 4;
|
}
|
||||||
editArea.error = 0;
|
;printf('地图清除成功');
|
||||||
|
});
|
||||||
|
editor.updateMap();
|
||||||
|
clearTimeout(editArea.formatTimer);
|
||||||
|
clearTimeout(tip.timer);
|
||||||
|
pout.value = '';
|
||||||
|
editArea.mapArr = '';
|
||||||
|
tip.whichShow = 4;
|
||||||
|
editArea.error = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
printf = function(str_,type) {
|
var deleteMap = new Vue({
|
||||||
selectBox.isSelected = false;
|
el: '#deleteMap',
|
||||||
if(!type){
|
methods: {
|
||||||
tip.whichShow=11;
|
deleteMap: function () {
|
||||||
} else {
|
editor_mode.onmode('');
|
||||||
tip.whichShow=12;
|
var index = core.floorIds.indexOf(editor.currentFloorId);
|
||||||
}
|
if (index>=0) {
|
||||||
setTimeout(function(){
|
core.floorIds.splice(index,1);
|
||||||
if(!type){
|
editor.file.editTower([['change', "['main']['floorIds']", core.floorIds]], function (objs_) {/*console.log(objs_);*/
|
||||||
tip.msgs[11]=String(str_);
|
if (objs_.slice(-1)[0] != null) {
|
||||||
tip.whichShow=12;
|
printe(objs_.slice(-1)[0]);
|
||||||
|
throw(objs_.slice(-1)[0])
|
||||||
|
}
|
||||||
|
;printe('删除成功,请F5刷新编辑器生效');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else printe('删除成功,请F5刷新编辑器生效');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
printf = function (str_, type) {
|
||||||
|
selectBox.isSelected = false;
|
||||||
|
if (!type) {
|
||||||
|
tip.whichShow = 11;
|
||||||
} else {
|
} else {
|
||||||
tip.msgs[10]=String(str_);
|
tip.whichShow = 12;
|
||||||
tip.whichShow=11;
|
|
||||||
}
|
}
|
||||||
},1);
|
setTimeout(function () {
|
||||||
|
if (!type) {
|
||||||
|
tip.msgs[11] = String(str_);
|
||||||
|
tip.whichShow = 12;
|
||||||
|
} else {
|
||||||
|
tip.msgs[10] = String(str_);
|
||||||
|
tip.whichShow = 11;
|
||||||
|
}
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
|
printe = function (str_) {
|
||||||
|
printf(str_, 'error')
|
||||||
}
|
}
|
||||||
printe = function(str_){printf(str_,'error')}
|
|
||||||
tip_in_showMode = [
|
tip_in_showMode = [
|
||||||
'涉及图片的更改需要F5刷新浏览器来生效',
|
'涉及图片的更改需要F5刷新浏览器来生效',
|
||||||
'文本域可以通过双击,在文本编辑器或事件编辑器中编辑',
|
'文本域可以通过双击,在文本编辑器或事件编辑器中编辑',
|
||||||
'事件编辑器中的显示文本和自定义脚本的方块也可以双击',
|
'事件编辑器中的显示文本和自定义脚本的方块也可以双击',
|
||||||
"画出的地图要点击\"保存地图\"才会写入到文件中",
|
"画出的地图要点击\"保存地图\"才会写入到文件中",
|
||||||
];
|
];
|
||||||
var tip = new Vue({
|
var tip = new Vue({
|
||||||
el: '#tip',
|
el: '#tip',
|
||||||
data: {
|
data: {
|
||||||
infos: {},
|
infos: {},
|
||||||
hasId: true,
|
hasId: true,
|
||||||
isAutotile: false,
|
isAutotile: false,
|
||||||
isSelectedBlock: false,
|
isSelectedBlock: false,
|
||||||
isClearBlock: false,
|
isClearBlock: false,
|
||||||
geneMapSuccess: false,
|
geneMapSuccess: false,
|
||||||
timer: null,
|
timer: null,
|
||||||
msgs: [ //分别编号1,2,3,4,5,6,7,8,9,10;奇数警告,偶数成功
|
msgs: [ //分别编号1,2,3,4,5,6,7,8,9,10;奇数警告,偶数成功
|
||||||
"当前未选择任何图块,请先在右边选择要画的图块!",
|
"当前未选择任何图块,请先在右边选择要画的图块!",
|
||||||
"生成地图成功!可点击复制按钮复制地图数组到剪切板",
|
"生成地图成功!可点击复制按钮复制地图数组到剪切板",
|
||||||
"生成失败! 地图中有未定义的图块,建议先用其他有效图块覆盖或点击清除地图!",
|
"生成失败! 地图中有未定义的图块,建议先用其他有效图块覆盖或点击清除地图!",
|
||||||
"地图清除成功!",
|
"地图清除成功!",
|
||||||
"复制失败!",
|
"复制失败!",
|
||||||
"复制成功!可直接粘贴到楼层文件的地图数组中。",
|
"复制成功!可直接粘贴到楼层文件的地图数组中。",
|
||||||
"复制失败!当前还没有数据",
|
"复制失败!当前还没有数据",
|
||||||
"修改成功!可点击复制按钮复制地图数组到剪切板",
|
"修改成功!可点击复制按钮复制地图数组到剪切板",
|
||||||
"选择背景图片失败!文件名格式错误或图片不存在!",
|
"选择背景图片失败!文件名格式错误或图片不存在!",
|
||||||
"更新背景图片成功!",
|
"更新背景图片成功!",
|
||||||
"11:警告",
|
"11:警告",
|
||||||
"12:成功"
|
"12:成功"
|
||||||
],
|
],
|
||||||
mapMsg: '',
|
mapMsg: '',
|
||||||
whichShow: 0,
|
whichShow: 0,
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
infos: {
|
|
||||||
handler: function(val, oldval){
|
|
||||||
this.isClearBlock = false;
|
|
||||||
if(typeof(val) != 'undefined'){
|
|
||||||
if(val==0) {
|
|
||||||
this.isClearBlock = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if('id' in val){
|
|
||||||
this.hasId = true;
|
|
||||||
}else{
|
|
||||||
this.hasId = false;
|
|
||||||
}
|
|
||||||
this.isAutotile = false;
|
|
||||||
if(val.images == "autotile" && this.hasId) this.isAutotile = true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
deep: true
|
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
infos: {
|
||||||
|
handler: function (val, oldval) {
|
||||||
|
this.isClearBlock = false;
|
||||||
|
if (typeof(val) != 'undefined') {
|
||||||
|
if (val == 0) {
|
||||||
|
this.isClearBlock = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ('id' in val) {
|
||||||
|
this.hasId = true;
|
||||||
|
} else {
|
||||||
|
this.hasId = false;
|
||||||
|
}
|
||||||
|
this.isAutotile = false;
|
||||||
|
if (val.images == "autotile" && this.hasId) this.isAutotile = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
deep: true
|
||||||
|
},
|
||||||
|
|
||||||
whichShow: function(){
|
whichShow: function () {
|
||||||
var that = this;
|
var that = this;
|
||||||
that.mapMsg = '';
|
that.mapMsg = '';
|
||||||
that.msgs[4] = "复制失败!"+editTip.err;
|
that.msgs[4] = "复制失败!" + editTip.err;
|
||||||
clearTimeout(that.timer);
|
clearTimeout(that.timer);
|
||||||
if(that.whichShow){
|
if (that.whichShow) {
|
||||||
that.mapMsg = that.msgs[that.whichShow-1];
|
that.mapMsg = that.msgs[that.whichShow - 1];
|
||||||
that.timer = setTimeout(function() {
|
that.timer = setTimeout(function () {
|
||||||
if(!(that.whichShow%2))
|
if (!(that.whichShow % 2))
|
||||||
that.whichShow = 0;
|
that.whichShow = 0;
|
||||||
}, 5000); //5秒后自动清除success,warn不清除
|
}, 5000); //5秒后自动清除success,warn不清除
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
var selectBox = new Vue({
|
var selectBox = new Vue({
|
||||||
el: '#selectBox',
|
el: '#selectBox',
|
||||||
data: {
|
data: {
|
||||||
isSelected: false
|
isSelected: false
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
isSelected: function(){
|
isSelected: function () {
|
||||||
tip.isSelectedBlock = this.isSelected;
|
tip.isSelectedBlock = this.isSelected;
|
||||||
tip.whichShow = 0;
|
tip.whichShow = 0;
|
||||||
clearTimeout(tip.timer);
|
clearTimeout(tip.timer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
var bgSelect = new Vue({
|
var bgSelect = new Vue({
|
||||||
el: '#bgSelect',
|
el: '#bgSelect',
|
||||||
data: {
|
data: {
|
||||||
bgs: {},
|
bgs: {},
|
||||||
selectedBg: 'ground',
|
selectedBg: 'ground',
|
||||||
imgname: ''
|
imgname: ''
|
||||||
},
|
},
|
||||||
watch:{
|
watch: {
|
||||||
selectedBg: function(){
|
selectedBg: function () {
|
||||||
editor.bgY = this.bgs.indexOf(this.selectedBg);
|
editor.bgY = this.bgs.indexOf(this.selectedBg);
|
||||||
editor.drawMapBg();
|
editor.drawMapBg();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
updatebg: function () {
|
||||||
|
tip.whichShow = 0;
|
||||||
|
var regx = /\S+\.(png|bmp|jpg|jpeg|gif)$/i;
|
||||||
|
if (regx.test(this.imgname)) {
|
||||||
|
var url = 'images/' + this.imgname;
|
||||||
|
editor.loadImg(url).then(function (img) {
|
||||||
|
editor.drawMapBg(img);
|
||||||
|
tip.whichShow = 10;
|
||||||
|
}).catch(function (err) {
|
||||||
|
console.log(err);
|
||||||
|
tip.whichShow = 9;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
tip.whichShow = 9;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
updatebg: function(){
|
|
||||||
tip.whichShow = 0;
|
|
||||||
var regx = /\S+\.(png|bmp|jpg|jpeg|gif)$/i;
|
|
||||||
if(regx.test(this.imgname)){
|
|
||||||
var url = 'images/'+this.imgname;
|
|
||||||
editor.loadImg(url).then(function(img){
|
|
||||||
editor.drawMapBg(img);
|
|
||||||
tip.whichShow = 10;
|
|
||||||
}).catch(function(err){
|
|
||||||
console.log(err);
|
|
||||||
tip.whichShow = 9;
|
|
||||||
});
|
|
||||||
}else{
|
|
||||||
tip.whichShow = 9;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
518
editor.html
518
editor.html
@ -1,229 +1,267 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<link href="_server/css/editor.css" rel="stylesheet">
|
<link href="_server/css/editor.css" rel="stylesheet">
|
||||||
<link href="_server/CodeMirror/codemirror.css" rel="stylesheet">
|
<link href="_server/CodeMirror/codemirror.css" rel="stylesheet">
|
||||||
<link href="_server/CodeMirror/show-hint.css" rel="stylesheet">
|
<link href="_server/CodeMirror/show-hint.css" rel="stylesheet">
|
||||||
<link href="_server/CodeMirror/lint.css" rel="stylesheet">
|
<link href="_server/CodeMirror/lint.css" rel="stylesheet">
|
||||||
<link href="_server/css/editor_mode.css" rel="stylesheet">
|
<link href="_server/css/editor_mode.css" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<div id="left" style="z-index:-1;opacity: 0;"><!-- map -->
|
<div id="left" style="z-index:-1;opacity: 0;"><!-- map -->
|
||||||
<div id="arrEditor">
|
<div id="arrEditor">
|
||||||
<table class="col" id='arrColMark'></table>
|
<table class="col" id='arrColMark'></table>
|
||||||
<table class="row" id='arrRowMark'></table>
|
<table class="row" id='arrRowMark'></table>
|
||||||
<div id="editArea" v-cloak>
|
<div id="editArea" v-cloak>
|
||||||
<textarea cols="10" rows="10" id="pout" v-model="mapArr"></textarea>
|
<textarea cols="10" rows="10" id="pout" v-model="mapArr"></textarea>
|
||||||
<p class="warnText" v-if="error">{{ errors[error-1] }}</p>
|
<p class="warnText" v-if="error">{{ errors[error-1] }}</p>
|
||||||
|
</div>
|
||||||
|
<div id="editTip">
|
||||||
|
<input type="button" value="新建空白地图" id='newMap'/>
|
||||||
|
<input id='newFileName' placeholder="输入新楼层id"/>
|
||||||
|
</div>
|
||||||
|
<div style="position: absolute;left: 10px;bottom:0; margin-bottom: 90px">
|
||||||
|
<input type="button" value="导出地图" id="exportMap" v-on:click="exportMap"/>
|
||||||
|
<input type="button" value="复制地图" id="copyMap" v-on:click="copyMap"/>
|
||||||
|
<input type="button" value="清除地图" id='clearMap' v-on:click="clearMap"/>
|
||||||
|
<input type="button" value="删除地图" id="deleteMap" v-on:click="deleteMap"/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="editTip" v-cloak>
|
<div id="objDataEditor">
|
||||||
<br>
|
|
||||||
<input type="button" value="新建空白地图" id='saveFloorAs'/>
|
|
||||||
<input id='saveAsName' placeholder="输入新楼层id"/>
|
|
||||||
<input class='btn' type="button" value="复制地图" v-on:click="copyMap"/>
|
|
||||||
</div>
|
|
||||||
<div style="position: absolute;right: 10px;bottom:70px;">
|
|
||||||
<input class='btn' id='clear' type="button" value="清除地图" v-on:click="clearMap"/>
|
|
||||||
<input class='btn' type="button" value="导出地图" id="exportM" v-on:click="exportMap"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="objDataEditor">
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div id="eventEditor">
|
<div id="eventEditor">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div id="left1" class='leftTab' style="z-index:-1;opacity: 0;"><!-- appendpic -->
|
<div id="left1" class='leftTab' style="z-index:-1;opacity: 0;"><!-- appendpic -->
|
||||||
<h3 class="leftTabHeader">追加素材</h3>
|
<h3 class="leftTabHeader">追加素材</h3>
|
||||||
<div class="leftTabContent">
|
<div class="leftTabContent">
|
||||||
<p>
|
<p>
|
||||||
<input id="selectFileBtn" type="button" value="导入文件到画板"/>
|
<input id="selectFileBtn" type="button" value="导入文件到画板"/>
|
||||||
<select id="selectAppend"></select><!-- ["terrains", "animates", "enemys", "enemy48", "items", "npcs", "npc48"] -->
|
<select id="selectAppend"></select>
|
||||||
<input id="appendConfirm" type="button" value="追加"/>
|
<!-- ["terrains", "animates", "enemys", "enemy48", "items", "npcs", "npc48"] -->
|
||||||
</p>
|
<input id="appendConfirm" type="button" value="追加"/>
|
||||||
<div id="appendPicCanvas" style="position:relative;overflow: auto;height:470px;">
|
</p>
|
||||||
<canvas style="position:absolute"></canvas><!-- 用于画出灰白相间背景 -->
|
<div id="appendPicCanvas" style="position:relative;overflow: auto;height:470px;">
|
||||||
<canvas style="position:absolute"></canvas><!-- 用于画出选中文件 -->
|
<canvas style="position:absolute"></canvas><!-- 用于画出灰白相间背景 -->
|
||||||
<canvas style="position:absolute;z-index:100"></canvas><!-- 用于响应鼠标点击 -->
|
<canvas style="position:absolute"></canvas><!-- 用于画出选中文件 -->
|
||||||
<canvas style="position:absolute;display:none;"></canvas><!-- 画出追加后的sprite用于储存 -->
|
<canvas style="position:absolute;z-index:100"></canvas><!-- 用于响应鼠标点击 -->
|
||||||
<div id="appendPicSelection">
|
<canvas style="position:absolute;display:none;"></canvas><!-- 画出追加后的sprite用于储存 -->
|
||||||
<div class="appendSelection"><span style="top: 0; left: 2px;">1</span></div>
|
<div id="appendPicSelection">
|
||||||
<div class="appendSelection"><span style="top: 0; left: 14px;">2</span></div>
|
<div class="appendSelection"><span style="top: 0; left: 2px;">1</span></div>
|
||||||
<div class="appendSelection"><span style="top: 12px; left: 2px;">3</span></div>
|
<div class="appendSelection"><span style="top: 0; left: 14px;">2</span></div>
|
||||||
<div class="appendSelection"><span style="top: 12px; left: 14px;">4</span></div>
|
<div class="appendSelection"><span style="top: 12px; left: 2px;">3</span></div>
|
||||||
|
<div class="appendSelection"><span style="top: 12px; left: 14px;">4</span></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div></div>
|
|
||||||
<div id="left2" class='leftTab' style="z-index:-1;opacity: 0;"><!-- loc -->
|
<div id="left2" class='leftTab' style="z-index:-1;opacity: 0;"><!-- loc -->
|
||||||
<h3 class="leftTabHeader">地图选点 <button onclick="editor.mode.onmode('save')">save</button></h3>
|
<h3 class="leftTabHeader">地图选点 <button onclick="editor.mode.onmode('save')">save</button>
|
||||||
<div class="leftTabContent">
|
</h3>
|
||||||
<p id='pos_a6771a78_a099_417c_828f_0a24851ebfce' style="margin-left: 15px">0,0</p>
|
<div class="leftTabContent">
|
||||||
<div class='etable'>
|
<p id='pos_a6771a78_a099_417c_828f_0a24851ebfce' style="margin-left: 15px">0,0</p>
|
||||||
<table>
|
<div class='etable'>
|
||||||
<tbody id='table_3d846fc4_7644_44d1_aa04_433d266a73df'>
|
<table>
|
||||||
<tr><td>条目</td><td>注释</td><td>值</td></tr>
|
<tbody id='table_3d846fc4_7644_44d1_aa04_433d266a73df'>
|
||||||
</tbody>
|
<tr>
|
||||||
</table>
|
<td>条目</td>
|
||||||
</div>
|
<td>注释</td>
|
||||||
</div></div>
|
<td>值</td>
|
||||||
<div id="left3" class='leftTab' style="z-index:-1;opacity: 0;"><!-- emenyitem -->
|
</tr>
|
||||||
<h3 class="leftTabHeader">图块属性 <button onclick="editor.mode.onmode('save')">save</button></h3>
|
</tbody>
|
||||||
<div class="leftTabContent">
|
</table>
|
||||||
<div id='newIdIdnum'><!-- id and idnum -->
|
</div>
|
||||||
<input placeholder="输入新id(唯一标识符)"/>
|
|
||||||
<input placeholder="输入新idnum(数字,1000以内)"/>
|
|
||||||
<button>save</button>
|
|
||||||
</div>
|
|
||||||
<div><!-- enemy and item -->
|
|
||||||
<div class='etable'>
|
|
||||||
<table>
|
|
||||||
<tbody id='table_a3f03d4c_55b8_4ef6_b362_b345783acd72'>
|
|
||||||
<tr><td>条目</td><td>注释</td><td>值</td></tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div></div>
|
<div id="left3" class='leftTab' style="z-index:-1;opacity: 0;"><!-- emenyitem -->
|
||||||
|
<h3 class="leftTabHeader">图块属性 <button onclick="editor.mode.onmode('save')">save</button>
|
||||||
|
</h3>
|
||||||
|
<div class="leftTabContent">
|
||||||
|
<div id='newIdIdnum'><!-- id and idnum -->
|
||||||
|
<input placeholder="输入新id(唯一标识符)"/>
|
||||||
|
<input placeholder="输入新idnum(数字,1000以内)"/>
|
||||||
|
<button>save</button>
|
||||||
|
</div>
|
||||||
|
<div><!-- enemy and item -->
|
||||||
|
<div class='etable'>
|
||||||
|
<table>
|
||||||
|
<tbody id='table_a3f03d4c_55b8_4ef6_b362_b345783acd72'>
|
||||||
|
<tr>
|
||||||
|
<td>条目</td>
|
||||||
|
<td>注释</td>
|
||||||
|
<td>值</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div id="left4" class='leftTab' style="z-index:-1;opacity: 0;"><!-- floor -->
|
<div id="left4" class='leftTab' style="z-index:-1;opacity: 0;"><!-- floor -->
|
||||||
<h3 class="leftTabHeader">楼层属性 <button onclick="editor.mode.onmode('save')">save</button></h3>
|
<h3 class="leftTabHeader">楼层属性 <button onclick="editor.mode.onmode('save')">save</button>
|
||||||
<div class="leftTabContent">
|
</h3>
|
||||||
<div class='etable'>
|
<div class="leftTabContent">
|
||||||
<table>
|
<div class='etable'>
|
||||||
<tbody id='table_4a3b1b09_b2fb_4bdf_b9ab_9f4cdac14c74'>
|
<table>
|
||||||
<tr><td>条目</td><td>注释</td><td>值</td></tr>
|
<tbody id='table_4a3b1b09_b2fb_4bdf_b9ab_9f4cdac14c74'>
|
||||||
</tbody>
|
<tr>
|
||||||
</table>
|
<td>条目</td>
|
||||||
</div>
|
<td>注释</td>
|
||||||
</div></div>
|
<td>值</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div id="left5" class='leftTab' style="z-index:-1;opacity: 0;"><!-- tower -->
|
<div id="left5" class='leftTab' style="z-index:-1;opacity: 0;"><!-- tower -->
|
||||||
<h3 class="leftTabHeader">全塔属性 <button onclick="editor.mode.onmode('save')">save</button></h3>
|
<h3 class="leftTabHeader">全塔属性 <button onclick="editor.mode.onmode('save')">save</button>
|
||||||
<div class="leftTabContent">
|
</h3>
|
||||||
<div class='etable'>
|
<div class="leftTabContent">
|
||||||
<table>
|
<div class='etable'>
|
||||||
<tbody id='table_b6a03e4c_5968_4633_ac40_0dfdd2c9cde5'>
|
<table>
|
||||||
<tr><td>条目</td><td>注释</td><td>值</td></tr>
|
<tbody id='table_b6a03e4c_5968_4633_ac40_0dfdd2c9cde5'>
|
||||||
</tbody>
|
<tr>
|
||||||
</table>
|
<td>条目</td>
|
||||||
</div>
|
<td>注释</td>
|
||||||
</div></div>
|
<td>值</td>
|
||||||
<div id="left6" class='leftTab' style="z-index:-1;opacity: 0;"><div style="position: relative; height: 95%"><!-- eventsEditor -->
|
</tr>
|
||||||
<h3>事件编辑器
|
</tbody>
|
||||||
<button onclick="editor_blockly.showXML()">Show XML</button>
|
</table>
|
||||||
<button onclick="editor_blockly.runCode()">console.log(obj=code)</button>
|
</div>
|
||||||
<select id="entryType" disabled="disabled">
|
</div>
|
||||||
<option value="event">event</option>
|
</div>
|
||||||
<option value="changeFloor">changeFloor</option>
|
<div id="left6" class='leftTab' style="z-index:-1;opacity: 0;">
|
||||||
<option value="point">point</option>
|
<div style="position: relative; height: 95%"><!-- eventsEditor -->
|
||||||
<option value="shop">shop</option>
|
<h3>事件编辑器
|
||||||
<option value="afterBattle">afterBattle</option>
|
<button onclick="editor_blockly.showXML()">Show XML</button>
|
||||||
<option value="afterGetItem">afterGetItem</option>
|
<button onclick="editor_blockly.runCode()">console.log(obj=code)</button>
|
||||||
<option value="afterOpenDoor">afterOpenDoor</option>
|
<select id="entryType" disabled="disabled">
|
||||||
<option value="firstArrive">firstArrive</option>
|
<option value="event">event</option>
|
||||||
</select>
|
<option value="changeFloor">changeFloor</option>
|
||||||
<button onclick="editor_blockly.parse()">parse</button>
|
<option value="point">point</option>
|
||||||
<button onclick="editor_blockly.confirm()">confirm</button>
|
<option value="shop">shop</option>
|
||||||
<button onclick="editor_blockly.cancel()">cancel</button>
|
<option value="afterBattle">afterBattle</option>
|
||||||
<xml id="toolbox" style="display:none">
|
<option value="afterGetItem">afterGetItem</option>
|
||||||
<category name="entry"></category>
|
<option value="afterOpenDoor">afterOpenDoor</option>
|
||||||
<category name="statement"></category>
|
<option value="firstArrive">firstArrive</option>
|
||||||
<category name="value"></category>
|
</select>
|
||||||
<category name="template"></category>
|
<button onclick="editor_blockly.parse()">parse</button>
|
||||||
</xml>
|
<button onclick="editor_blockly.confirm()">confirm</button>
|
||||||
</h3>
|
<button onclick="editor_blockly.cancel()">cancel</button>
|
||||||
<div style="position: relative;height: 100%">
|
<xml id="toolbox" style="display:none">
|
||||||
<div id="blocklyArea"><div id="blocklyDiv"></div></div>
|
<category name="entry"></category>
|
||||||
<textarea id="codeArea" spellcheck="false"></textarea>
|
<category name="statement"></category>
|
||||||
</div>
|
<category name="value"></category>
|
||||||
</div></div>
|
<category name="template"></category>
|
||||||
|
</xml>
|
||||||
|
</h3>
|
||||||
|
<div style="position: relative;height: 100%">
|
||||||
|
<div id="blocklyArea">
|
||||||
|
<div id="blocklyDiv"></div>
|
||||||
|
</div>
|
||||||
|
<textarea id="codeArea" spellcheck="false"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div id="left7" style="z-index:-1;opacity: 0;"><!-- 多行文本编辑器 -->
|
<div id="left7" style="z-index:-1;opacity: 0;"><!-- 多行文本编辑器 -->
|
||||||
<button onclick="editor_multi.confirm()">confirm</button>
|
<button onclick="editor_multi.confirm()">confirm</button>
|
||||||
<button onclick="editor_multi.cancel()">cancel</button>
|
<button onclick="editor_multi.cancel()">cancel</button>
|
||||||
<input type="checkbox" onclick="editor_multi.toggerLint()" id="lintCheckbox" style="vertical-align: bottom;margin-left:6px" />
|
<input type="checkbox" onclick="editor_multi.toggerLint()" id="lintCheckbox"
|
||||||
<span style="vertical-align: bottom; margin-left: -3px">Lint</span>
|
style="vertical-align: bottom;margin-left:6px"/>
|
||||||
<textarea id="multiLineCode" name="multiLineCode"></textarea>
|
<span style="vertical-align: bottom; margin-left: -3px">Lint</span>
|
||||||
|
<textarea id="multiLineCode" name="multiLineCode"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div id="left8" class='leftTab' style="z-index:-1;opacity: 0;"><!-- functions -->
|
<div id="left8" class='leftTab' style="z-index:-1;opacity: 0;"><!-- functions -->
|
||||||
<h3 class="leftTabHeader">脚本编辑 <button onclick="editor.mode.onmode('save')">save</button></h3>
|
<h3 class="leftTabHeader">脚本编辑 <button onclick="editor.mode.onmode('save')">save</button>
|
||||||
<div class="leftTabContent">
|
</h3>
|
||||||
<div class='etable'>
|
<div class="leftTabContent">
|
||||||
<table>
|
<div class='etable'>
|
||||||
<tbody id='table_e260a2be_5690_476a_b04e_dacddede78b3'>
|
<table>
|
||||||
<tr><td>条目</td><td>注释</td><td>值</td></tr>
|
<tbody id='table_e260a2be_5690_476a_b04e_dacddede78b3'>
|
||||||
</tbody>
|
<tr>
|
||||||
</table>
|
<td>条目</td>
|
||||||
</div>
|
<td>注释</td>
|
||||||
</div></div>
|
<td>值</td>
|
||||||
<div id="mid">
|
</tr>
|
||||||
<table class="col" id='mapColMark'></table>
|
</tbody>
|
||||||
<table class="row" id='mapRowMark'></table>
|
</table>
|
||||||
<div class="map" id="mapEdit">
|
|
||||||
<canvas class='gameCanvas' id='bg' width='416' height='416'></canvas>
|
|
||||||
<canvas class='gameCanvas' id='event' width='416' height='416'></canvas>
|
|
||||||
<canvas class='gameCanvas' id='event2' width='416' height='416'></canvas>
|
|
||||||
<canvas class='egameCanvas' id='eui' width='416' height='416' style='z-index:100'></canvas>
|
|
||||||
</div>
|
|
||||||
<div class="tools">
|
|
||||||
<div id="tip" v-cloak >
|
|
||||||
<div v-if="isSelectedBlock" >
|
|
||||||
<p v-if="isClearBlock" class="infoText">当前选择为清除块,可擦除地图上块</p>
|
|
||||||
<div v-else>
|
|
||||||
<p v-if="hasId">图块编号:<span class="infoText">{{ infos['idnum'] }}</span></p>
|
|
||||||
<p v-if="hasId">图块ID:<span class="infoText">{{ infos['id'] }}</span></p>
|
|
||||||
<p v-else class="warnText">该图块无对应的数字或ID存在,请先前往icons.js和maps.js中进行定义!</p>
|
|
||||||
<p>图块所在素材:<span class="infoText">{{ infos['images'] + (isAutotile ? '( '+infos['id']+' )' : '') }}</span></p>
|
|
||||||
<p>图块索引:<span class="infoText">{{ infos['y'] }}</span></p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div v-else>
|
|
||||||
<p v-if="whichShow" v-bind:class="[ (whichShow%2) ? 'warnText' : 'successText']">{{ mapMsg }}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="mid">
|
||||||
|
<table class="col" id='mapColMark'></table>
|
||||||
|
<table class="row" id='mapRowMark'></table>
|
||||||
|
<div class="map" id="mapEdit">
|
||||||
|
<canvas class='gameCanvas' id='bg' width='416' height='416'></canvas>
|
||||||
|
<canvas class='gameCanvas' id='event' width='416' height='416'></canvas>
|
||||||
|
<canvas class='gameCanvas' id='event2' width='416' height='416'></canvas>
|
||||||
|
<canvas class='egameCanvas' id='eui' width='416' height='416' style='z-index:100'></canvas>
|
||||||
|
</div>
|
||||||
|
<div class="tools">
|
||||||
|
<div id="tip" v-cloak>
|
||||||
|
<div v-if="isSelectedBlock">
|
||||||
|
<p v-if="isClearBlock" class="infoText">当前选择为清除块,可擦除地图上块</p>
|
||||||
|
<div v-else>
|
||||||
|
<p v-if="hasId">图块编号:<span class="infoText">{{ infos['idnum'] }}</span></p>
|
||||||
|
<p v-if="hasId">图块ID:<span class="infoText">{{ infos['id'] }}</span></p>
|
||||||
|
<p v-else class="warnText">该图块无对应的数字或ID存在,请先前往icons.js和maps.js中进行定义!</p>
|
||||||
|
<p>图块所在素材:<span class="infoText">{{ infos['images'] + (isAutotile ? '( '+infos['id']+' )' : '') }}</span>
|
||||||
|
</p>
|
||||||
|
<p>图块索引:<span class="infoText">{{ infos['y'] }}</span></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<p v-if="whichShow" v-bind:class="[ (whichShow%2) ? 'warnText' : 'successText']">{{ mapMsg }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<select id="editModeSelect">
|
|
||||||
<option value="map">地图编辑</option>
|
<select id="editModeSelect">
|
||||||
<option value="loc">地图选点</option>
|
<option value="map">地图编辑</option>
|
||||||
<option value="emenyitem">图块属性</option>
|
<option value="loc">地图选点</option>
|
||||||
<option value="floor">楼层属性</option>
|
<option value="emenyitem">图块属性</option>
|
||||||
<option value="tower">全塔属性</option>
|
<option value="floor">楼层属性</option>
|
||||||
<option value="functions">脚本编辑</option>
|
<option value="tower">全塔属性</option>
|
||||||
<option value="appendpic">追加素材</option>
|
<option value="functions">脚本编辑</option>
|
||||||
</select>
|
<option value="appendpic">追加素材</option>
|
||||||
<br><br><br><br>
|
</select>
|
||||||
<select id="selectFloor"></select>
|
<br><br><br><br>
|
||||||
<input type="button" value="保存地图" id='saveFloor'/>
|
<select id="selectFloor"></select>
|
||||||
<!-- -->
|
<input type="button" value="保存地图" id='saveFloor'/>
|
||||||
<div id="bgSelect" v-cloak style="display:none">
|
<!-- -->
|
||||||
<span>当前地板: </span>
|
<div id="bgSelect" v-cloak style="display:none">
|
||||||
<select v-model="selectedBg">
|
<span>当前地板: </span>
|
||||||
<option disabled value="">请选择地板</option>
|
<select v-model="selectedBg">
|
||||||
<option v-for="bg in bgs" v-bind:value="bg">
|
<option disabled value="">请选择地板</option>
|
||||||
{{ bg }}
|
<option v-for="bg in bgs" v-bind:value="bg">
|
||||||
</option>
|
{{ bg }}
|
||||||
</select>
|
</option>
|
||||||
<div class="selectpng">
|
</select>
|
||||||
<input class='input' id='pin' v-model="imgname" placeholder="请输入自定义背景文件名"/>
|
<div class="selectpng">
|
||||||
<input class='btn' type="button" value="确定" v-on:click="updatebg"/>
|
<input class='input' id='pin' v-model="imgname" placeholder="请输入自定义背景文件名"/>
|
||||||
</div>
|
<input class='btn' type="button" value="确定" v-on:click="updatebg"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- -->
|
||||||
</div>
|
</div>
|
||||||
<!-- -->
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="right">
|
<div id="right">
|
||||||
<div id="iconLib">
|
<div id="iconLib">
|
||||||
<canvas class='egameCanvas' id='edata' width='416' height='416' style='z-index:0'></canvas>
|
<canvas class='egameCanvas' id='edata' width='416' height='416' style='z-index:0'></canvas>
|
||||||
<div id="selectBox">
|
<div id="selectBox">
|
||||||
<div id='dataSelection' v-show="isSelected" v-cloak></div>
|
<div id='dataSelection' v-show="isSelected" v-cloak></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <script>/* -->
|
<!-- <script>/* -->
|
||||||
<div id='gameGroup' style='display:none'>
|
<div id='gameGroup' style='display:none'>
|
||||||
<p id='mainTips'>请稍后...</p>
|
<p id='mainTips'>请稍后...</p>
|
||||||
<div id='startPanel'>
|
<div id='startPanel'>
|
||||||
<div id='startTop'>
|
<div id='startTop'>
|
||||||
@ -320,26 +358,26 @@
|
|||||||
<canvas class='gameCanvas' id='weather' width='416' height='416'></canvas>
|
<canvas class='gameCanvas' id='weather' width='416' height='416'></canvas>
|
||||||
<canvas class='gameCanvas' id='ui' width='416' height='416'></canvas>
|
<canvas class='gameCanvas' id='ui' width='416' height='416'></canvas>
|
||||||
<canvas class='gameCanvas' id='data' width='416' height='416'>此浏览器不支持HTML5</canvas>
|
<canvas class='gameCanvas' id='data' width='416' height='416'>此浏览器不支持HTML5</canvas>
|
||||||
</div>
|
</div>
|
||||||
<!-- */</script> -->
|
<!-- */</script> -->
|
||||||
<script>
|
<script>
|
||||||
// 生成定位编号
|
// 生成定位编号
|
||||||
(function(){
|
(function () {
|
||||||
var colNum = ' ';
|
var colNum = ' ';
|
||||||
for(var i=0; i<13; i++){
|
for (var i = 0; i < 13; i++) {
|
||||||
var tpl = '<td>'+i+'<div class="colBlock" style="left:'+(i*32+1)+'px;"></div></td>';
|
var tpl = '<td>' + i + '<div class="colBlock" style="left:' + (i * 32 + 1) + 'px;"></div></td>';
|
||||||
colNum += tpl;
|
colNum += tpl;
|
||||||
}
|
}
|
||||||
arrColMark.innerHTML = '<tr>'+colNum+'</tr>';
|
arrColMark.innerHTML = '<tr>' + colNum + '</tr>';
|
||||||
mapColMark.innerHTML = '<tr>'+colNum+'</tr>';
|
mapColMark.innerHTML = '<tr>' + colNum + '</tr>';
|
||||||
var rowNum = ' ';
|
var rowNum = ' ';
|
||||||
for(var i=0; i<13; i++){
|
for (var i = 0; i < 13; i++) {
|
||||||
var tpl = '<tr><td>'+i+'<div class="rowBlock" style="top:'+(i*32+1)+'px;"></div></td></tr>';
|
var tpl = '<tr><td>' + i + '<div class="rowBlock" style="top:' + (i * 32 + 1) + 'px;"></div></td></tr>';
|
||||||
rowNum += tpl;
|
rowNum += tpl;
|
||||||
}
|
}
|
||||||
arrRowMark.innerHTML = rowNum;
|
arrRowMark.innerHTML = rowNum;
|
||||||
mapRowMark.innerHTML = rowNum;
|
mapRowMark.innerHTML = rowNum;
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- =========================================================== -->
|
<!-- =========================================================== -->
|
||||||
@ -353,38 +391,38 @@
|
|||||||
<script src='_server/vm.js'></script>
|
<script src='_server/vm.js'></script>
|
||||||
<script id='mainScript' src='main.js'></script>
|
<script id='mainScript' src='main.js'></script>
|
||||||
<script>
|
<script>
|
||||||
//所有全局量
|
//所有全局量
|
||||||
__all__=['Vue','fs','editor_file','editor_mode','main','core','hasOwnProp','printf','printe','editor','converter','ActionParser','MotaActionFunctions','MotaActionBlocks'];
|
__all__ = ['Vue', 'fs', 'editor_file', 'editor_mode', 'main', 'core', 'hasOwnProp', 'printf', 'printe', 'editor', 'converter', 'ActionParser', 'MotaActionFunctions', 'MotaActionBlocks'];
|
||||||
__id__=['editArea','arrRowMark','mapRowMark','data','bg','dataSelection','blocklyDiv','codeAreaHL','entryType'];
|
__id__ = ['editArea', 'arrRowMark', 'mapRowMark', 'data', 'bg', 'dataSelection', 'blocklyDiv', 'codeAreaHL', 'entryType'];
|
||||||
__Vue__=['exportM','editArea','editTip','clear','tip','selectBox'];
|
__Vue__ = ['editArea', 'exportMap', 'copyMap', 'clearMap', 'deleteMap', 'tip', 'selectBox'];
|
||||||
//var event = document.getElementById('event');
|
//var event = document.getElementById('event');
|
||||||
|
|
||||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||||
function hasOwnProp (obj, key) {
|
|
||||||
return hasOwnProperty.call(obj, key)
|
function hasOwnProp(obj, key) {
|
||||||
}
|
return hasOwnProperty.call(obj, key)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<script src='_server/editor.js'></script>
|
<script src='_server/editor.js'></script>
|
||||||
<script>
|
<script>
|
||||||
main.init('editor', function() {
|
main.init('editor', function () {
|
||||||
editor.init(function(){
|
editor.init(function () {
|
||||||
editor.pos={x: 0, y: 0};
|
editor.pos = {x: 0, y: 0};
|
||||||
editor.mode.loc();
|
editor.mode.loc();
|
||||||
editor.info=editor.ids[editor.indexs[201]];
|
editor.info = editor.ids[editor.indexs[201]];
|
||||||
editor.mode.emenyitem();
|
editor.mode.emenyitem();
|
||||||
editor.mode.floor();
|
editor.mode.floor();
|
||||||
editor.mode.tower();
|
editor.mode.tower();
|
||||||
editor.mode.functions();
|
editor.mode.functions();
|
||||||
editor.mode.showMode('floor');
|
editor.mode.showMode('floor');
|
||||||
editor.mode.listen();
|
editor.mode.listen();
|
||||||
editor_multi=editor_multi();
|
editor_multi = editor_multi();
|
||||||
editor_blockly=editor_blockly();
|
editor_blockly = editor_blockly();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//main.listen();
|
||||||
//main.listen();
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- hightlight textarea -->
|
<!-- hightlight textarea -->
|
||||||
|
|||||||
@ -301,7 +301,7 @@ utils.prototype.readFile = function (success, error, readType) {
|
|||||||
|
|
||||||
if (core.platform.fileInput==null) {
|
if (core.platform.fileInput==null) {
|
||||||
core.platform.fileInput = document.createElement("input");
|
core.platform.fileInput = document.createElement("input");
|
||||||
core.platform.fileInput.style.display = 'none';
|
core.platform.fileInput.style.opacity = 0;
|
||||||
core.platform.fileInput.type = 'file';
|
core.platform.fileInput.type = 'file';
|
||||||
core.platform.fileInput.onchange = function () {
|
core.platform.fileInput.onchange = function () {
|
||||||
var files = core.platform.fileInput.files;
|
var files = core.platform.fileInput.files;
|
||||||
|
|||||||
2
更新说明.txt
2
更新说明.txt
@ -13,7 +13,7 @@ APP端也能下载录像
|
|||||||
大数据魔塔的显示 √
|
大数据魔塔的显示 √
|
||||||
修改999999999的上界问题 √
|
修改999999999的上界问题 √
|
||||||
修复有时候无法输入ID的问题
|
修复有时候无法输入ID的问题
|
||||||
修复坐标等不能为负数的问题
|
修复坐标等不能为负数的问题 √
|
||||||
其他细节优化
|
其他细节优化
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user