代码拉取完成,页面将自动刷新
在线HTMl编辑器
// 新建编辑器
var editor = ace.edit("editor")
// 开始配置编辑器
ace.config.set("basePath", 'js')
// 默认主题
editor.setTheme("ace/theme/chrome")
var htmlMode = ace.require("ace/mode/html").Mode
editor.session.setMode(new htmlMode())
ace.require("ace/ext/language_tools")
editor.setOptions({
enableBasicAutocompletion: true,
enableSnippets: true,
enableLiveAutocompletion: true
})
// 设置编辑器字体大小
var mr_setFontSize = localStorage.PonConHtmlEditorsetFontSize
if (!mr_setFontSize) {
mr_setFontSize = 18
}
editor.setFontSize(parseInt(mr_setFontSize))
$("label.label-fontsize").html('字号:' + mr_setFontSize)
$("#set-fontsize").val(mr_setFontSize)
if (localStorage.PonConHtmlEditorCode) {
editor.setValue(localStorage.PonConHtmlEditorCode)
}
// 消除文本选中状态
var His_row = localStorage.PonConHtmlEditorCursorRow
var His_column = localStorage.PonConHtmlEditorCursorColumn
if (!His_row) {
His_row = 0;
}
if (!His_column) {
His_column = 0;
}
editor.gotoLine(His_row - 1)
editor.moveCursorTo(His_row, His_column)
editor.setShowPrintMargin(true)
// 以上为编辑器配置
$('#viewer').html('<iframe id="iframe" name="iframe" style="width: 100%; height: 100%;"></iframe>')
var iframe = window.frames['iframe']
iframe.document.open()
iframe.document.write(editor.getValue())
iframe.document.close()
// 复制代码
$('.btn-group button.toCopy').click(function () {
$('button.copy').attr('data-clipboard-text', editor.getValue()).click().attr('data-clipboard-text', '')
})
// 清空代码
$('.btn-group button.clean').click(function () {
if (confirm('确定要清空?')) {
editor.setValue('')
}
})
// 下载代码
$('.btn-group button.download').click(function () {
var blob = new Blob([editor.getValue()], { type: "text/plain;charset=utf-8" })
saveAs(blob, new Date().getTime() + ".txt")
})
// HTML转文本
$('.btn-group button.toText').click(function () {
$('#toTextResult').html($(editor.getValue()).text().replace(/\n/g, '<br />'))
})
// 定时保存
setInterval(function () {
localStorage.PonConHtmlEditorCode = editor.getValue()
localStorage.PonConHtmlEditorCursorColumn = editor.selection.getCursor().column
localStorage.PonConHtmlEditorCursorRow = editor.selection.getCursor().row
}, 500)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。