// THIS FILE IS AUTO-GENERATED FROM permanode.js
// DO NOT EDIT.
package ui
import "time"
import "camlistore.org/pkg/fileembed"
func init() {
Files.Add("permanode.js", 20499, fileembed.String("/*\n"+
"Copyright 2011 Google Inc.\n"+
"\n"+
"Licensed under the Apache License, Version 2.0 (the \"License\");\n"+
"you may not use this file except in compliance with the License.\n"+
"You may obtain a copy of the License at\n"+
"\n"+
" http://www.apache.org/licenses/LICENSE-2.0\n"+
"\n"+
"Unless required by applicable law or agreed to in writing, software\n"+
"distributed under the License is distributed on an \"AS IS\" BASIS,\n"+
"WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"+
"See the License for the specific language governing permissions and\n"+
"limitations under the License.\n"+
"*/\n"+
"\n"+
"// Gets the |p| query parameter, assuming that it looks like a blobref.\n"+
"\n"+
"function getPermanodeParam() {\n"+
" var blobRef = Camli.getQueryParam('p');\n"+
" return (blobRef && Camli.isPlausibleBlobRef(blobRef)) ? blobRef : null;\n"+
"}\n"+
"\n"+
"function handleFormTitleSubmit(e) {\n"+
" e.stopPropagation();\n"+
" e.preventDefault();\n"+
"\n"+
" var inputTitle = document.getElementById(\"inputTitle\");\n"+
" inputTitle.disabled = true;\n"+
" var btnSaveTitle = document.getElementById(\"btnSaveTitle\");\n"+
" btnSaveTitle.disabled = true;\n"+
"\n"+
" var startTime = new Date();\n"+
"\n"+
" camliNewSetAttributeClaim(\n"+
" getPermanodeParam(),\n"+
" \"title\",\n"+
" inputTitle.value,\n"+
" {\n"+
" success: function() {\n"+
" var elapsedMs = new Date().getTime() - startTime.getTime();\n"+
" setTimeout(function() {\n"+
" inputTitle.disabled = false;\n"+
" btnSaveTitle.disabled = false;\n"+
" buildPermanodeUi();\n"+
" }, Math.max(250 - elapsedMs, 0));\n"+
" },\n"+
" fail: function(msg) {\n"+
" alert(msg);\n"+
" inputTitle.disabled = false;\n"+
" btnSaveTitle.disabled = false;\n"+
" }\n"+
" });\n"+
"}\n"+
"\n"+
"function handleFormTagsSubmit(e) {\n"+
" e.stopPropagation();\n"+
" e.preventDefault();\n"+
"\n"+
" var input = document.getElementById(\"inputNewTag\");\n"+
" var btn = document.getElementById(\"btnAddTag\");\n"+
"\n"+
" if (input.value == \"\") {\n"+
" return;\n"+
" }\n"+
"\n"+
" input.disabled = true;\n"+
" btn.disabled = true;\n"+
"\n"+
" var startTime = new Date();\n"+
"\n"+
" var tags = input.value.split(/\\s*,\\s*/);\n"+
" var nRemain = tags.length;\n"+
"\n"+
" var oneDone = function() {\n"+
" nRemain--;\n"+
" if (nRemain == 0) {\n"+
" var elapsedMs = new Date().getTime() - startTime.getTime();\n"+
" setTimeout(function() {\n"+
" input.value = '';\n"+
" input.disabled = false;\n"+
" btn.disabled = false;\n"+
" buildPermanodeUi();\n"+
" }, Math.max(250 - elapsedMs, 0));\n"+
" }\n"+
" };\n"+
" for (idx in tags) {\n"+
" var tag = tags[idx];\n"+
" camliNewAddAttributeClaim(\n"+
" getPermanodeParam(),\n"+
" \"tag\",\n"+
" tag,\n"+
" {\n"+
" success: oneDone,\n"+
" fail: function(msg) {\n"+
" alert(msg);\n"+
" oneDone();\n"+
" }\n"+
" });\n"+
" }\n"+
"}\n"+
"\n"+
"function handleFormAccessSubmit(e) {\n"+
" e.stopPropagation();\n"+
" e.preventDefault();\n"+
"\n"+
" var selectAccess = document.getElementById(\"selectAccess\");\n"+
" selectAccess.disabled = true;\n"+
" var btnSaveAccess = document.getElementById(\"btnSaveAccess\");\n"+
" btnSaveAccess.disabled = true;\n"+
"\n"+
" var operation = camliNewDelAttributeClaim;\n"+
" var value = \"\";\n"+
" if (selectAccess.value != \"private\") {\n"+
" operation = camliNewSetAttributeClaim;\n"+
" value = selectAccess.value;\n"+
" }\n"+
"\n"+
" var startTime = new Date();\n"+
"\n"+
" operation(\n"+
" getPermanodeParam(),\n"+
" \"camliAccess\",\n"+
" value,\n"+
" {\n"+
" success: function() {\n"+
" var elapsedMs = new Date().getTime() - startTime.getTime();\n"+
" setTimeout(function() {\n"+
" selectAccess.disabled = false;\n"+
" btnSaveAccess.disabled = false;\n"+
" }, Math.max(250 - elapsedMs, 0));\n"+
" },\n"+
" fail: function(msg) {\n"+
" alert(msg);\n"+
" selectAccess.disabled = false;\n"+
" btnSaveAccess.disabled = false;\n"+
" }\n"+
" });\n"+
"}\n"+
"\n"+
"function deleteTagFunc(tag, strikeEle, removeEle) {\n"+
" return function(e) {\n"+
" strikeEle.innerHTML = \"\" + strikeEle.innerHTML + \"\";\n"+
" camliNewDelAttributeClaim(\n"+
" getPermanodeParam(),\n"+
" \"tag\",\n"+
" tag,\n"+
" {\n"+
" success: function() {\n"+
" removeEle.parentNode.removeChild(removeEle);\n"+
" },\n"+
" fail: function(msg) {\n"+
" alert(msg);\n"+
" }\n"+
" });\n"+
" };\n"+
"}\n"+
"\n"+
"function onTypeChange() {\n"+
" var sel = document.getElementById(\"type\");\n"+
" var dnd = document.getElementById(\"dnd\");\n"+
" var btnGallery = document.getElementById(\"btnGallery\");\n"+
"\n"+
" if (sel.value == \"collection\" || sel.value == \"\") {\n"+
" dnd.style.display = \"block\";\n"+
" btnGallery.style.visibility = 'visible';\n"+
" } else {\n"+
" dnd.style.display = \"none\";\n"+
" btnGallery.style.visibility = 'hidden';\n"+
" }\n"+
"}\n"+
"\n"+
"function handleFiles(files) {\n"+
" for (var i = 0; i < files.length; i++) {\n"+
" var file = files[i];\n"+
" startFileUpload(file);\n"+
" }\n"+
"}\n"+
"\n"+
"function startFileUpload(file) {\n"+
" var dnd = document.getElementById(\"dnd\");\n"+
" var up = document.createElement(\"div\");\n"+
" up.className= 'camli-dnd-item';\n"+
" dnd.appendChild(up);\n"+
" var info = \"name=\" + file.name + \" size=\" + file.size + \"; type=\" + file.type"+
";\n"+
"\n"+
" var setStatus = function(status) {\n"+
" up.innerHTML = info + \" \" + status;\n"+
" };\n"+
" setStatus(\"(scanning)\");\n"+
"\n"+
" var onFail = function(msg) {\n"+
" up.innerHTML = info + \" fail: \";\n"+
" up.appendChild(document.createTextNode(msg));\n"+
" };\n"+
"\n"+
" var onGotFileSchemaRef = function(fileref) {\n"+
" setStatus(\" fileref: \" + fileref + \"\");\n"+
" camliCreateNewPermanode(\n"+
" {\n"+
" success: function(filepn) {\n"+
" var doneWithAll = function() {\n"+
" setStatus(\"- done\");\n"+
" buildPermanodeUi();\n"+
" };\n"+
" var addMemberToParent = function() {\n"+
" setStatus(\"adding member\");\n"+
" camliNewAddAttributeClaim(getPermanodeParam(), \"camliMember\","+
" filepn, { success: doneWithAll, fail: onFail });\n"+
" };\n"+
" var makePermanode = function() {\n"+
" setStatus(\"making permanode\");\n"+
" camliNewSetAttributeClaim(filepn, \"camliContent\", fileref, { "+
"success: addMemberToParent, fail: onFail });\n"+
" };\n"+
" makePermanode();\n"+
" },\n"+
" fail: onFail\n"+
" });\n"+
" };\n"+
"\n"+
" camliUploadFile(file, {\n"+
" onContentsRef: function(contentsRef) {\n"+
" setStatus(\"(checking for dup of \" + contentsRef + \")\");\n"+
" },\n"+
" success: onGotFileSchemaRef,\n"+
" fail: onFail\n"+
" });\n"+
"}\n"+
"\n"+
"function onFileFormSubmit(e) {\n"+
" e.stopPropagation();\n"+
" e.preventDefault();\n"+
" handleFiles(document.getElementById(\"fileInput\").files);\n"+
"}\n"+
"\n"+
"function $(id) { return document.getElementById(id) }\n"+
"\n"+
"function onFileInputChange(e) {\n"+
" var s = \"\";\n"+
" var files = $(\"fileInput\").files;\n"+
" for (var i = 0; i < files.length; i++) {\n"+
" var file = files[i];\n"+
" s += \"
\" + file.name + \"
\";\n"+ " }\n"+ " var fl = $(\"filelist\");\n"+ " fl.innerHTML = s;\n"+ "}\n"+ "\n"+ "function setupFilesHandlers() {\n"+ " var dnd = document.getElementById(\"dnd\");\n"+ " document.getElementById(\"fileForm\").addEventListener(\"submit\", onFileFormSubm"+ "it);\n"+ " document.getElementById(\"fileInput\").addEventListener(\"change\", onFileInputCh"+ "ange);\n"+ "\n"+ " var stop = function(e) {\n"+ " this.classList && this.classList.add('camli-dnd-over');\n"+ " e.stopPropagation();\n"+ " e.preventDefault();\n"+ " };\n"+ " dnd.addEventListener(\"dragenter\", stop, false);\n"+ " dnd.addEventListener(\"dragover\", stop, false);\n"+ "\n"+ "\n"+ " dnd.addEventListener(\"dragleave\", function() {\n"+ " this.classList.remove('camli-dnd-over');\n"+ " }, false);\n"+ "\n"+ " var drop = function(e) {\n"+ " this.classList.remove('camli-dnd-over');\n"+ " stop(e);\n"+ " var dt = e.dataTransfer;\n"+ " var files = dt.files;\n"+ " document.getElementById(\"info\").innerHTML = \"\";\n"+ " handleFiles(files);\n"+ " };\n"+ " dnd.addEventListener(\"drop\", drop, false);\n"+ "}\n"+ "\n"+ "\n"+ "// member: child permanode\n"+ "function deleteMember(member, strikeEle, removeEle) {\n"+ " return function(e) {\n"+ " strikeEle.innerHTML = \"