createNoteX: function(aAsChild) {
sbSearchService.exit();
// create item
var newItem = sbCommonUtils.newItem(sbCommonUtils.getTimeStamp());
const now = new Date();
// ask for note page title, msel 20190318
var notextitle = prompt("Title", "New Note Page");
if (notextitle == null || notextitle == "") notextitle = "New Note Page";
newItem.id = sbDataSource.identify(newItem.id);
newItem.title = sbCommonUtils.lang("DEFAULT_NOTEX");
newItem.title = notextitle;
newItem.type = "notex";
newItem.chars = "UTF-8";
// check the template file, create one if not exist
var template = sbCommonUtils.getScrapBookDir().clone();
template.append("notex_template.html");
if ( !template.exists() ) sbCommonUtils.saveTemplateFile("chrome://scrapbook/skin/notex_template.html", template);
// create content
var dir = sbCommonUtils.getContentDir(newItem.id);
var html = dir.clone();
html.append("index.html");
//new variables NOTE_ID and NOTE_DATE, msel20190220
var tpl = {
NOTE_TITLE: newItem.title,
SCRAPBOOK_DIR: "../..",
DATA_DIR: ".",
NOTE_ID: newItem.id,
NOTE_DATE: now.toDateString(),
};
var content = sbCommonUtils.readFile(template, "UTF-8");
content = content.replace(/<%([\w_]+)%>/g, function(){
var label = arguments[1];
if (tpl[label]) return tpl[label];
return "";
});
sbCommonUtils.writeFile(html, content, newItem.chars);
sbCommonUtils.writeIndexDat(newItem);
// add resource
var newRes = this.addNewResource(newItem, null, aAsChild);
// open and edit the new notex
sbController.open(newRes, false);
},
Now, if you create a new note page your asked about a name for the note page. And in addition you can use the new variables NOTE_ID and NOTE_DATE in the notex_template.html.
I've have looked at the source code of ScrapBook X and I've made some additions for better working with New Note Pages.
Source: scrapbook.js Function: createNoteX: function(aAsChild)
Now, if you create a new note page your asked about a name for the note page. And in addition you can use the new variables NOTE_ID and NOTE_DATE in the notex_template.html.
Here is an example:
Perhaps you can add the code to scrapbook.js.