This commit is contained in:
parent
b6df14764c
commit
45084f1628
|
@ -22,44 +22,15 @@ var playground = {
|
||||||
playground.editor.setSize("auto", $("#editor").height() + "px");
|
playground.editor.setSize("auto", $("#editor").height() + "px");
|
||||||
},
|
},
|
||||||
_initShare: function () {
|
_initShare: function () {
|
||||||
if (!playground.editor) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var code = playground.editor.getValue();
|
|
||||||
|
|
||||||
var request = newWideRequest();
|
|
||||||
request.code = code;
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
type: 'POST',
|
|
||||||
url: config.context + '/playground/save',
|
|
||||||
data: JSON.stringify(request),
|
|
||||||
dataType: "json",
|
|
||||||
success: function (data) {
|
|
||||||
playground.editor.setValue(data.code);
|
|
||||||
|
|
||||||
if (!data.succ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#dialogShare").dialog({
|
$("#dialogShare").dialog({
|
||||||
"modal": true,
|
"modal": true,
|
||||||
"height": 460,
|
"height": 460,
|
||||||
"width": 800,
|
"width": 800,
|
||||||
"title": "Share",
|
"title": config.label.share,
|
||||||
"hideFooter": true,
|
"hideFooter": true,
|
||||||
"afterOpen": function () {
|
"afterOpen": function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var url = window.location.protocol + "//" + window.location.host + '/playground/' + data.fileName;
|
|
||||||
var html = 'URL: <a href="' + url + '" target="_blank">' + url + "</a><br/>";
|
|
||||||
html += "Embeded: xxxx";
|
|
||||||
|
|
||||||
$("#dialogShare").html(html);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
_initWideShare: function () {
|
_initWideShare: function () {
|
||||||
$(".share-panel .font-ico").click(function () {
|
$(".share-panel .font-ico").click(function () {
|
||||||
|
@ -189,6 +160,37 @@ var playground = {
|
||||||
console.log('[playground onerror] ' + JSON.parse(e));
|
console.log('[playground onerror] ' + JSON.parse(e));
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
share: function () {
|
||||||
|
if (!playground.editor) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var code = playground.editor.getValue();
|
||||||
|
|
||||||
|
var request = newWideRequest();
|
||||||
|
request.code = code;
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: config.context + '/playground/save',
|
||||||
|
data: JSON.stringify(request),
|
||||||
|
dataType: "json",
|
||||||
|
success: function (data) {
|
||||||
|
playground.editor.setValue(data.code);
|
||||||
|
|
||||||
|
if (!data.succ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var url = window.location.protocol + "//" + window.location.host + '/playground/' + data.fileName;
|
||||||
|
var html = 'URL: <a href="' + url + '" target="_blank">' + url + "</a><br/>";
|
||||||
|
html += "Embeded: xxxx";
|
||||||
|
|
||||||
|
$("#dialogShare").html(html);
|
||||||
|
$("#dialogShare").dialog("open");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
stop: function () {
|
stop: function () {
|
||||||
if (!playground.editor) {
|
if (!playground.editor) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
<button class="btn btn-red" id="stop" onclick="playground.stop();">{{.i18n.stop}}</button>
|
<button class="btn btn-red" id="stop" onclick="playground.stop();">{{.i18n.stop}}</button>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<button class="btn-white btn" id="share" onclick='$("#dialogShare").dialog("open");'>{{.i18n.share}}</button>
|
<button class="btn-white btn" id="share" onclick="playground.share();">{{.i18n.share}}</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="fn-right">
|
<div class="fn-right">
|
||||||
|
|
Loading…
Reference in New Issue