|
|
@@ -75,18 +75,18 @@ var $view = $('#preview'); |
|
|
|
editor.setTheme("ace/theme/chrome"); |
|
|
|
editor.session.setMode("ace/mode/html"); |
|
|
|
editor.getSession().on('change', updatePreview); |
|
|
|
{{if .ID}}{{else}}var saved = H.get('constructionSite', ''); |
|
|
|
var saved = H.get('{{if .ID}}house{{.ID}}{{else}}constructionSite{{end}}', ''); |
|
|
|
if (saved !== '') { |
|
|
|
editor.setValue(saved); |
|
|
|
}{{end}} |
|
|
|
} |
|
|
|
updatePreview(); |
|
|
|
|
|
|
|
{{if .ID}}{{else}}window.addEventListener('beforeunload', function(e) { |
|
|
|
window.addEventListener('beforeunload', function(e) { |
|
|
|
if (!justPublished) { |
|
|
|
H.set('constructionSite', editor.getSession().getValue()); |
|
|
|
H.set('{{if .ID}}house{{.ID}}{{else}}constructionSite{{end}}', editor.getSession().getValue()); |
|
|
|
} |
|
|
|
return null; |
|
|
|
});{{end}} |
|
|
|
}); |
|
|
|
|
|
|
|
if (hasBuilt) { |
|
|
|
$('header').append('<a href="/houses.html">my pages</a>'); |
|
|
@@ -122,7 +122,7 @@ $publishBtn.on('click', function(e) { |
|
|
|
houses.push({id: data.data.id, token: xhr.getResponseHeader('Authorization')}); |
|
|
|
H.set('neighborhood', JSON.stringify(houses));{{end}} |
|
|
|
justPublished = true; |
|
|
|
{{if .ID}}{{else}}H.remove('constructionSite');{{end}} |
|
|
|
H.remove('{{if .ID}}house{{.ID}}{{else}}constructionSite{{end}}'); |
|
|
|
window.location = '/' + data.data.id + '.html'; |
|
|
|
} else { |
|
|
|
alert(data.meta.error_msg); |
|
|
|