/***
|Name|[[InfoboxTablesPlugin]]|
|Source|http://infoboxes.tiddlyspot.com|
|Documentation|[[InfoboxTablesPluginInfo]]|
|Version|3.1.0|
|Author|Kristjan Brezovnik|
|License|[[Creative Commons Attribution-Share Alike 3.0 License|http://creativecommons.org/licenses/by-sa/3.0/]]|
|~CoreVersion|2.6.3|
|Type|plugin|
|Description|Provides customizable infoboxes for different types of articles.|
!Configuration
<<option txtInfoboxesMinViewportWidth>> Minimum viewport width for displaying the content (in 'px')
<<option txtInfoboxesMinTooNarrowWidth>> Minimum viewport width for displaying the "too narrow" error message (in 'px')
<<option txtInfoboxesMinPlaceholderWidth>> Minimum viewport width for displaying the placeholder (in 'px')
<<option chkInfoboxesHideInfoboxes>> Hide the infoboxes when opening a tiddler
<<option chkInfoboxesHideEmptyLines>> Hide the empty lines when opening an infobox in edit mode
<<option txtInfoboxesMaxMultipleSelections>> The maximum number of options to display in dropdowns where you can select multiple values (0 = all, which is the default) (the value is rounded to the nearest positive integer)
<<option chkInfoboxesHideShowTemplateListButton>> Hide the "show template list" button
<<option chkInfoboxesHideHideButton>> Hide the "hide" button
<<option chkInfoboxesHideHeader>> Hide the header
<<option chkInfoboxesHideFooter>> Hide the footer
<<option chkInfoboxesDisableEditOffline>> Disable offline editing
<<option chkInfoboxesEnableEditOnline>> Enable online editing (for example for [[TiddlySpot|http://www.tiddlyspot.com]])
<<option chkInfoboxesAllowModifyingTemplates>> Allow modifying templates from infobox edit mode
<<option txtInfoboxesNumberOfCheckboxesPerColumn>> The maximum number of module checkboxes per column (there are a maximum of four columns, so when the number of modules exceeds four times the value of this option, the number of module checkboxes per column keeps increasing) (the value is rounded to the nearest positive integer)
<<option chkInfoboxesShowImageCaption>> Show image caption
<<option chkInfoboxesDisplayImagesAsLinks>> Use images as links
<<option chkInfoboxesShowPreview>> Show image preview in edit mode
<<option chkInfoboxesShowUnitOfMeasure>> Show unit of measure
<<option chkInfoboxesShowModuleName>> Show module name before section name in view mode
<<option chkInfoboxesShowModulePrefix>> Show module prefix in edit mode
<<option chkInfoboxesShowDelimiterBetweenGlobalMainAndModule>> Show delimiter between global template, main template and first modules instance in edit mode
<<option chkInfoboxesShowDelimiterBetweenModuleInstances>> Show delimiter between module instances in edit mode
<<option chkInfoboxesShowBorderAroundInclude>> Show border around included sections
<<option chkInfoboxesPreserveParamsFromHiddenModules>> Preserve parameters from removed modules when saving
<<option chkInfoboxesUseEscapeToExitEditMode>> Use Escape to exit infobox edit mode
<<option chkInfoboxesSavePrompt>> Prompt if you really want to save
<<option chkInfoboxesSaveMode>> When editing the table, save the macro so each parameter is in its own line (default; enables using params as slices) or so that the entire macro is a single line
<<option chkInfoboxesIgnoreShorthands>> Ignore shorthands (converts them to longhands when saving the infobox from infobox edit mode)
<<option txtInfoboxesGlobalParametersTemplate>> Global parameters template
<<option chkInfoboxesBackupArticle>> Backup article tiddlers when making changes to an infobox from edit mode, including when deleting an infobox
<<option chkInfoboxesBackupInfoboxes>> Backup infobox tiddlers (regular, global, modules) when making changes from edit mode
<<option txtInfoboxesBackupsList>> List of all backed-up tiddlers
<<option chkInfoboxesExcludeLists>> Exclude backups from lists
<<option chkInfoboxesExcludeSearch>> Exclude backups from search
<<option chkInfoboxesDeleteBackupsPrompt>> Prompt if you really want to delete the backups
<<option chkInfoboxesEnableLogging>> Enable logging (only includes events triggered by this plugin in infobox edit mode)
<<option txtInfoboxesMessageLog>> Message log
<<option txtInfoboxesMessageLogDateFormat>> Message log date format
<<option chkInfoboxesPersistentLog>> Make log persistent
<<option chkInfoboxesLogArticleBackups>> Log when an article is backed up
<<option chkInfoboxesLogTemplateBackups>> Log when a template is backed up
<<option chkInfoboxesLogDeletions>> Log infobox deletions from articles
<<option chkInfoboxesLogInfoboxChanges>> Log infobox changes in articles
<<option chkInfoboxesLogTemplateChanges>> Log template changes
<<option txtInfoboxesTemplatesList>> Templates list
!!Special options
''Only change the following parameters before you start using the plugin and writing your own templates! Later changes will require you to fix all your templates and infobox calls. One reason for change would be if you wanted to localize the plugin.''
''System parameters''
><<option txtInfoboxesParamInfoboxType>> "Infobox type" parameter; specifies which template to use
><<option txtInfoboxesParamInfoboxTitle>> "Infobox title" parameter; if omitted, it uses the containing tiddler title
><<option txtInfoboxesParamInstanceID>> "Infobox instance ID" parameter; ID of an infobox instance
><<option txtInfoboxesParamColorScheme>> "Infobox color scheme" parameter; specifies which color scheme will be used
><<option txtInfoboxParamModules>> "Infobox modules" parameter; list of parameters to include
''Template sections''
><<option txtInfoboxesSectionContent>> Prefix for the content section
><<option txtInfoboxesSectionSchemes>> Prefix for the color schemes section
><<option txtInfoboxesSectionColors>> Prefix for the colors section
><<option txtInfoboxesSectionNotes>> Prefix for the notes section
''Slices''
><<option txtInfoboxesSliceText>> Slice for text color
><<option txtInfoboxesSliceTitle>> Slice for title background color
><<option txtInfoboxesSliceSubtitle>> Slice for subtitle background color
''Parameter prefixes''
><<option txtInfoboxesPrefixSection>> Prefix for section
><<option txtInfoboxesPrefixImage>> Prefix for image
><<option txtInfoboxesPrefixSingle>> Prefix for single
><<option txtInfoboxesPrefixSide>> Prefix for two-sided display
><<option txtInfoboxesPrefixThree>> Prefix for three-sided display
><<option txtInfoboxesPrefixFour>> Prefix for four-sided display
><<option txtInfoboxesPrefixInclude>> Prefix for includes
''Template prefixes''
><<option txtInfoboxesPrefixInfobox>> Prefix for main templates
><<option txtInfoboxesPrefixInfoboxModule>> Prefix for modules
><<option txtInfoboxesPrefixInfoboxInclude>> Prefix for includes
''Template delimiters''
><<option txtInfoboxesTemplateDelimiter>> Delimiter for main templates
><<option txtInfoboxesModuleDelimiter>> Delimiter for module instances
><<option txtInfoboxesIncludeDelimiterStart>> Delimiter for start of include
><<option txtInfoboxesIncludeDelimiterEnd>> Delimiter for end of include
''Special template parameter prefixes and suffix''
><<option txtInfoboxesPrefixGlobal>> Prefix for global parameters
><<option txtInfoboxesPrefixModules>> Prefix for module parameters (it also includes the module name without the module template prefix)
><<option txtInfoboxesPrefixIncludes>> Prefix for include parameters (it also includes the include name without the include template prefix)
><<option txtInfoboxesSuffixModules>> Instance suffix for module parameters (it also includes the module name without the module template prefix)
''Default tags''
><<option txtInfoboxesTagsArticle>> Articles are tagged
><<option txtInfoboxesTagsInfobox>> Infoboxes are tagged
><<option txtInfoboxesTagsInfoboxModule>> Infobox modules are tagged
><<option txtInfoboxesTagsInfoboxInclude>> Infobox includes are tagged
><<option txtInfoboxesTagsBackup>> Backed-up tiddlers are tagged
''Default and special values''
><<option txtInfoboxesDefaultValueUnknown>> Value when value is unknown
><<option txtInfoboxesDefaultValueDefaultID>> Default value for "Infobox instance ID" parameter
><<option txtInfoboxesSpecialValueOther>> Special value for dropdown lists, which triggers the appearance of an additional textarea
!Code
***/
//{{{
/*jslint browser: true, devel: true, bitwise: true, eval: true, for: true, multivar: true, this: true, white: true*/
/*global document version config wikify confirm prompt alert store story refreshStyles removeNode createTiddlyButton createTiddlyElement createTiddlyCheckbox createTiddlyDropDown createTiddlyLink window contentWrapper autoSaveChanges Popup event tiddler displayMessage getParam contentWrapper setStylesheet console readOnly place merge*/
if (!version.extensions.InfoboxTablesPlugin) { //Ensure that the plugin is only installed once
version.extensions.InfoboxTablesPlugin = {installed: true};
version.extensions.InfoboxTablesPlugin = {major: 3, minor: 1, revision: 0, date: new Date(2017,2,4)};
//Set options
if ((config.options.txtInfoboxesMinViewportWidth === undefined) || (isNaN(Math.abs(Math.round(config.options.txtInfoboxesMinViewportWidth))) === true)) {
config.options.txtInfoboxesMinViewportWidth = 800;
}
if ((config.options.txtInfoboxesMinTooNarrowWidth === undefined) || (isNaN(Math.abs(Math.round(config.options.txtInfoboxesMinTooNarrowWidth))) === true)) {
config.options.txtInfoboxesMinTooNarrowWidth = 600;
}
if ((config.options.txtInfoboxesMinPlaceholderWidth === undefined) || (isNaN(Math.abs(Math.round(config.options.txtInfoboxesMinPlaceholderWidth))) === true)) {
config.options.txtInfoboxesMinPlaceholderWidth = 470;
}
if (config.options.chkInfoboxesHideInfoboxes === undefined) {
config.options.chkInfoboxesHideInfoboxes = false;
}
if (config.options.chkInfoboxesHideEmptyLines === undefined) {
config.options.chkInfoboxesHideEmptyLines = false;
}
if ((config.options.txtInfoboxesMaxMultipleSelections === undefined) || (isNaN(Math.abs(Math.round(config.options.txtInfoboxesMaxMultipleSelections))) === true)) {
config.options.txtInfoboxesMaxMultipleSelections = 0;
}
if (config.options.chkInfoboxesHideShowTemplateListButton === undefined) {
config.options.chkInfoboxesHideShowTemplateListButton = false;
}
if (config.options.chkInfoboxesHideHideButton === undefined) {
config.options.chkInfoboxesHideHideButton = false;
}
if (config.options.chkInfoboxesHideHeader === undefined) {
config.options.chkInfoboxesHideHeader = false;
}
if (config.options.chkInfoboxesHideFooter === undefined) {
config.options.chkInfoboxesHideFooter = false;
}
if (config.options.chkInfoboxesDisableEditOffline === undefined) {
config.options.chkInfoboxesDisableEditOffline = false;
}
if (config.options.chkInfoboxesEnableEditOnline === undefined) {
config.options.chkInfoboxesEnableEditOnline = false;
}
if (config.options.chkInfoboxesAllowModifyingTemplates === undefined) {
config.options.chkInfoboxesAllowModifyingTemplates = true;
}
if ((config.options.txtInfoboxesNumberOfCheckboxesPerColumn === undefined) || (isNaN(Math.abs(Math.round(config.options.txtInfoboxesNumberOfCheckboxesPerColumn))) === true)) {
config.options.txtInfoboxesNumberOfCheckboxesPerColumn = 5;
}
if (config.options.chkInfoboxesShowImageCaption === undefined) {
config.options.chkInfoboxesShowImageCaption = true;
}
if (config.options.chkInfoboxesDisplayImagesAsLinks === undefined) {
config.options.chkInfoboxesDisplayImagesAsLinks = true;
}
if (config.options.chkInfoboxesShowPreview === undefined) {
config.options.chkInfoboxesShowPreview = true;
}
if (config.options.chkInfoboxesShowUnitOfMeasure === undefined) {
config.options.chkInfoboxesShowUnitOfMeasure = true;
}
if (config.options.chkInfoboxesShowModuleName === undefined) {
config.options.chkInfoboxesShowModuleName = true;
}
if (config.options.chkInfoboxesShowModulePrefix === undefined) {
config.options.chkInfoboxesShowModulePrefix = true;
}
if (config.options.chkInfoboxesShowDelimiterBetweenGlobalMainAndModule === undefined) {
config.options.chkInfoboxesShowDelimiterBetweenGlobalMainAndModule = true;
}
if (config.options.chkInfoboxesShowDelimiterBetweenModuleInstances === undefined) {
config.options.chkInfoboxesShowDelimiterBetweenModuleInstances = true;
}
if (config.options.chkInfoboxesShowBorderAroundInclude === undefined) {
config.options.chkInfoboxesShowBorderAroundInclude = true;
}
if (config.options.chkInfoboxesPreserveParamsFromHiddenModules === undefined) {
config.options.chkInfoboxesPreserveParamsFromHiddenModules = false;
}
if (config.options.chkInfoboxesUseEscapeToExitEditMode === undefined) {
config.options.chkInfoboxesUseEscapeToExitEditMode = true;
}
if (config.options.chkInfoboxesSavePrompt === undefined) {
config.options.chkInfoboxesSavePrompt = true;
}
if (config.options.chkInfoboxesSaveMode === undefined) {
config.options.chkInfoboxesSaveMode = true;
}
if (config.options.chkInfoboxesIgnoreShorthands === undefined) {
config.options.chkInfoboxesIgnoreShorthands = true;
}
if (config.options.txtInfoboxesGlobalParametersTemplate === undefined) {
config.options.txtInfoboxesGlobalParametersTemplate = "Infobox_Global_Parameters"; //The reason this shadow tiddler name format differs from the other shadow tiddlers generated by this plugin is that this is an infobox template and therefore its name follows the same convention as infobox template names
}
if (config.options.chkInfoboxesBackupArticle === undefined) {
config.options.chkInfoboxesBackupArticle = false;
}
if (config.options.chkInfoboxesBackupInfoboxes === undefined) {
config.options.chkInfoboxesBackupInfoboxes = false;
}
if (config.options.txtInfoboxesBackupsList === undefined) {
config.options.txtInfoboxesBackupsList = "InfoboxTablesBackupsList";
}
if (config.options.chkInfoboxesExcludeLists === undefined) {
config.options.chkInfoboxesExcludeLists = true;
}
if (config.options.chkInfoboxesExcludeSearch === undefined) {
config.options.chkInfoboxesExcludeSearch = true;
}
if (config.options.chkInfoboxesDeleteBackupsPrompt === undefined) {
config.options.chkInfoboxesDeleteBackupsPrompt = true;
}
if (config.options.chkInfoboxesEnableLogging === undefined) {
config.options.chkInfoboxesEnableLogging = true;
}
if (config.options.txtInfoboxesMessageLog === undefined) {
config.options.txtInfoboxesMessageLog = "InfoboxTablesMessageLog";
}
if (config.options.txtInfoboxesMessageLogDateFormat === undefined) {
config.options.txtInfoboxesMessageLogDateFormat = "YYYY.0MM.0DD 0hh:0mm:0ss";
}
if (config.options.chkInfoboxesPersistentLog === undefined) {
config.options.chkInfoboxesPersistentLog = false;
}
if (config.options.chkInfoboxesLogArticleBackups === undefined) {
config.options.chkInfoboxesLogArticleBackups = true;
}
if (config.options.chkInfoboxesLogTemplateBackups === undefined) {
config.options.chkInfoboxesLogTemplateBackups = true;
}
if (config.options.chkInfoboxesLogDeletions === undefined) {
config.options.chkInfoboxesLogDeletions = true;
}
if (config.options.chkInfoboxesLogInfoboxChanges === undefined) {
config.options.chkInfoboxesLogInfoboxChanges = true;
}
if (config.options.chkInfoboxesLogTemplateChanges === undefined) {
config.options.chkInfoboxesLogTemplateChanges = true;
}
if (config.options.txtInfoboxesTemplatesList === undefined) {
config.options.txtInfoboxesTemplatesList = "InfoboxTablesTemplatesList";
}
//System parameters
if (config.options.txtInfoboxesParamInfoboxType === undefined) {
config.options.txtInfoboxesParamInfoboxType = "Infobox type";
}
if (config.options.txtInfoboxesParamInfoboxTitle === undefined) {
config.options.txtInfoboxesParamInfoboxTitle = "Infobox title";
}
if (config.options.txtInfoboxesParamInstanceID === undefined) {
config.options.txtInfoboxesParamInstanceID = "Infobox instance ID";
}
if (config.options.txtInfoboxesParamColorScheme === undefined) {
config.options.txtInfoboxesParamColorScheme = "Infobox color scheme";
}
if (config.options.txtInfoboxParamModules === undefined) {
config.options.txtInfoboxParamModules = "Infobox modules";
}
//Template sections
if (config.options.txtInfoboxesSectionContent === undefined) {
config.options.txtInfoboxesSectionContent = "Content";
}
if (config.options.txtInfoboxesSectionSchemes === undefined) {
config.options.txtInfoboxesSectionSchemes = "Schemes";
}
if (config.options.txtInfoboxesSectionColors === undefined) {
config.options.txtInfoboxesSectionColors = "Colors";
}
if (config.options.txtInfoboxesSectionNotes === undefined) {
config.options.txtInfoboxesSectionNotes = "Notes";
}
//Slices
if (config.options.txtInfoboxesSliceText === undefined) {
config.options.txtInfoboxesSliceText = "Text";
}
if (config.options.txtInfoboxesSliceTitle === undefined) {
config.options.txtInfoboxesSliceTitle = "Title";
}
if (config.options.txtInfoboxesSliceSubtitle === undefined) {
config.options.txtInfoboxesSliceSubtitle = "Subtitle";
}
//Parameter prefixes
if (config.options.txtInfoboxesPrefixSection === undefined) {
config.options.txtInfoboxesPrefixSection = "Section";
}
if (config.options.txtInfoboxesPrefixImage === undefined) {
config.options.txtInfoboxesPrefixImage = "Image";
}
if (config.options.txtInfoboxesPrefixSingle === undefined) {
config.options.txtInfoboxesPrefixSingle = "Single";
}
if (config.options.txtInfoboxesPrefixSide === undefined) {
config.options.txtInfoboxesPrefixSide = "Side";
}
if (config.options.txtInfoboxesPrefixThree === undefined) {
config.options.txtInfoboxesPrefixThree = "Three";
}
if (config.options.txtInfoboxesPrefixFour === undefined) {
config.options.txtInfoboxesPrefixFour = "Four";
}
if (config.options.txtInfoboxesPrefixInclude === undefined) {
config.options.txtInfoboxesPrefixInclude = "Include";
}
//Template prefixes
if (config.options.txtInfoboxesPrefixInfobox === undefined) {
config.options.txtInfoboxesPrefixInfobox = "Infobox";
}
if (config.options.txtInfoboxesPrefixInfoboxModule === undefined) {
config.options.txtInfoboxesPrefixInfoboxModule = "Infobox Module";
}
if (config.options.txtInfoboxesPrefixInfoboxInclude === undefined) {
config.options.txtInfoboxesPrefixInfoboxInclude = "Infobox Include";
}
//Template delimiters
if (config.options.txtInfoboxesTemplateDelimiter === undefined) {
config.options.txtInfoboxesTemplateDelimiter = "Template";
}
if (config.options.txtInfoboxesModuleDelimiter === undefined) {
config.options.txtInfoboxesModuleDelimiter = "Module";
}
if (config.options.txtInfoboxesIncludeDelimiterStart === undefined) {
config.options.txtInfoboxesIncludeDelimiterStart = "Include Start";
}
if (config.options.txtInfoboxesIncludeDelimiterEnd === undefined) {
config.options.txtInfoboxesIncludeDelimiterEnd = "Include End";
}
//Special template parameter prefixes and suffix
if (config.options.txtInfoboxesPrefixGlobal === undefined) {
config.options.txtInfoboxesPrefixGlobal = "IG";
}
if (config.options.txtInfoboxesPrefixModules === undefined) {
config.options.txtInfoboxesPrefixModules = "IM";
}
if (config.options.txtInfoboxesPrefixIncludes === undefined) {
config.options.txtInfoboxesPrefixIncludes = "II";
}
if (config.options.txtInfoboxesSuffixModules === undefined) {
config.options.txtInfoboxesSuffixModules = "Instance";
}
//Default tags
if (config.options.txtInfoboxesTagsArticle === undefined) {
config.options.txtInfoboxesTagsArticle = "article";
}
if (config.options.txtInfoboxesTagsInfobox === undefined) {
config.options.txtInfoboxesTagsInfobox = "infobox";
}
if (config.options.txtInfoboxesTagsInfoboxModule === undefined) {
config.options.txtInfoboxesTagsInfoboxModule = "infoboxmodule";
}
if (config.options.txtInfoboxesTagsInfoboxInclude === undefined) {
config.options.txtInfoboxesTagsInfoboxInclude = "infoboxinclude";
}
if (config.options.txtInfoboxesTagsBackup === undefined) {
config.options.txtInfoboxesTagsBackup = "infoboxbackup";
}
//Default and special values
if (config.options.txtInfoboxesDefaultValueUnknown === undefined) {
config.options.txtInfoboxesDefaultValueUnknown = "unknown";
}
if (config.options.txtInfoboxesDefaultValueDefaultID === undefined) {
config.options.txtInfoboxesDefaultValueDefaultID = "DefaultID";
}
if (config.options.txtInfoboxesSpecialValueOther === undefined) {
config.options.txtInfoboxesSpecialValueOther = "other";
}
//}}}
/***
!!Generic Color Palette
***/
//{{{
var palette = store.getTiddler("InfoboxTablesColorPalette");
if (palette === null) {
config.shadowTiddlers.InfoboxTablesColorPalette =
"/***\nGeneric Color Palette\n***/\n/*{{{*/\n" +
"InfoboxTableBackground: whitesmoke\n" +
"InfoboxTableTopColor: whitesmoke\n" +
"InfoboxErrorMessage: red\n" +
"InfoboxErrorBoxBorder: black\n" +
"InfoboxErrorBoxBackground: red\n" +
"InfoboxErrorBoxText: black\n" +
"InfoboxHighlightDark: gray\n" +
"InfoboxHighlightLight: silver\n" +
"InfoboxBorderNormal: black\n" +
"InfoboxBorderHighlighted: red\n" +
"InfoboxSmallButtonOnHover: red\n" +
"InfoboxTemplateLink: cobalt\n" +
"InfoboxTemplateLinkOnHover: red\n" +
"InfoboxLogDeletion: maroon\n" +
"InfoboxLogBackup: green\n" +
"InfoboxLogValueAdd: dodgerblue\n" +
"InfoboxLogParamAdd: blue\n" +
"InfoboxLogParamRemove: coral\n" +
"InfoboxLogParamChange: darkgoldenrod\n" +
"InfoboxLogParamShortToLong: navy\n" +
"InfoboxLogParamLongToShort: darkslateblue\n" +
"InfoboxLogDelimiter: black\n" +
"InfoboxTemplateDelimiter: dimgray\n" +
"InfoboxModuleInstanceDelimiter: slategray\n" +
"InfoboxDelimiterText: ghostwhite\n" +
"InfoboxIncludeDelimiter: green\n" +
"/*}}}*/";
}
//}}}
/***
!!Generic Stylesheet
***/
//{{{
var stylesheet = store.getTiddler("InfoboxTablesStylesheet");
if (stylesheet === null) {
config.shadowTiddlers.InfoboxTablesStylesheet =
"/***\nGeneric Stylesheet\n***/\n/*{{{*/\n" +
".InfoboxOuterContainer {width: 33%; z-index: 10; padding: 0px; margin: 0px; overflow-wrap: hyphenate; word-break: normal!important; -ms-word-break: normal; -webkit-hyphens: auto; -moz-hyphens: auto; -ms-hyphens: auto; hyphens: auto;}\n" +
".InfoboxOuterContainer, .InfoboxInnerContainer, .InfoboxViewTableContainer, .InfoboxEditTableContainer, .InfoboxTemplateListOuterContainer, .InfoboxTemplateListButtonContainer, .InfoboxTemplateListInnerContainer {display: block; position: relative; float: right; clear: both;}\n" +
".InfoboxContainerDiv, .InfoboxInnerContainer, .InfoboxViewTableContainer, .InfoboxErrorsContainer, .InfoboxTooNarrowErrorContainer, .InfoboxPlaceholderContainer, .InfoboxTable, .InfoboxTableHeader, .InfoboxTableFooter, .InfoboxTableTop, .InfoboxTableBottom, .ContentSection, .InfoboxCellImage, .InfoboxCellSingle, .InfoboxError, .InfoboxTableEdit, .ContentSectionEdit, .InfoboxEditTableContainer, .InfoboxTemplateListOuterContainer, .InfoboxTemplateListButtonContainer, .InfoboxTemplateListInnerContainer, .InfoboxEditContainerDiv {width: 100%!important;}\n" +
".InfoboxTemplateListInnerContainer {background: [[InfoboxTablesColorPalette::InfoboxTableBackground]]; padding: 5px; border: 1px solid [[InfoboxTablesColorPalette::InfoboxBorderNormal]]; border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px; line-height: 100%; font-size: 10px; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box;}\n" +
".InfoboxTable, .InfoboxTableEdit {margin: 0px 1px!important; border-collapse: separate!important; border: none 0px!important; border-spacing: 0px!important;}\n" +
".InfoboxTableFixedLayout {table-layout: fixed;}\n" +
".InfoboxTableHeader, .InfoboxTableFooter {font-weight: bold; background: [[InfoboxTablesColorPalette::InfoboxTableBackground]];}\n" +
".InfoboxTableHeader {border-radius: 10px 10px 0px 0px; -moz-border-radius: 10px 10px 0px 0px; -webkit-border-radius: 10px 10px 0px 0px;} /* Header table */\n" +
".InfoboxTableFooter {border-radius: 0px 0px 10px 10px; -moz-border-radius: 0px 0px 10px 10px; -webkit-border-radius: 0px 0px 10px 10px;} /* Footer table */\n" +
".InfoboxTableTop, .InfoboxTableBottom {border: none 0px; text-align: center; line-height: 120%;} /* Top and bottom table */\n" +
".InfoboxTableTop {font-size: 14px; line-height: 120%; border-radius: 10px 10px 0px 0px; -moz-border-radius: 10px 10px 0px 0px; -webkit-border-radius: 10px 10px 0px 0px;} /* Header row */\n" +
".InfoboxTableBottom {line-height: 80%; border-radius: 0px 0px 10px 10px; -moz-border-radius: 0px 0px 10px 10px; -webkit-border-radius: 0px 0px 10px 10px;} /* Footer row */\n" +
".ContentSection, .ContentSectionEdit {border: none 0px; font-weight: bold; font-size: 12px; line-height: 120%;} /* Section header row */\n" +
".InfoboxEmptyDiv {}\n" +
".InfoboxRow {display: table-row; background: [[InfoboxTablesColorPalette::InfoboxTableBackground]];} /* Content row */\n" +
".InfoboxCellLeft, .InfoboxCellRight, .InfoboxCellSide, .InfoboxCellThree, .InfoboxCellFour, .InfoboxCellImage, .InfoboxCellSingle {border: 1px solid [[InfoboxTablesColorPalette::InfoboxBorderNormal]]; vertical-align: top!important;} /* Cells */\n" +
".InfoboxCellLeft {width: 33%!important;}\n" +
".InfoboxCellRight {width: 67%!important;}\n" +
".InfoboxCellSide {width: 50%!important;}\n" +
".InfoboxCellThree {width: 33%!important;}\n" +
".InfoboxCellFour {width: 25%!important;}\n" +
".InfoboxCellImage, .InfoboxImageContainer, .InfoboxTemplateDelimiter, .InfoboxModuleInstanceDelimiter {text-align: center!important;}\n" +
".InfoboxCellSingle {text-align: left;}\n" +
".InfoboxLogDelimiter {display: block; border: 1px solid [[InfoboxTablesColorPalette::InfoboxLogDelimiter]];}\n" +
".InfoboxTemplateDelimiter, .InfoboxModuleInstanceDelimiter {color: [[InfoboxTablesColorPalette::InfoboxDelimiterText]];}\n" +
".InfoboxTemplateDelimiter {background: [[InfoboxTablesColorPalette::InfoboxTemplateDelimiter]];}\n" +
".InfoboxModuleInstanceDelimiter {background: [[InfoboxTablesColorPalette::InfoboxModuleInstanceDelimiter]];}\n" +
".InfoboxIncludeRow {}\n" +
".InfoboxCellImage figure, img.InfoboxImage {margin: 0px; width: auto; max-width: 99%!important; object-fit: contain; -o-object-fit: contain; -moz-object-fit: contain; -ms-object-fit: contain; -webkit-object-fit: contain;} /* Image max width must be less than cell width */\n" +
".InfoboxSmallButton {display: inline; position: relative; float: right;}\n" +
"a.InfoboxSmallButton:hover {color: [[InfoboxTablesColorPalette::InfoboxSmallButtonOnHover]];}\n" +
".infoboxTemplateLinkGlobalText, .infoboxTemplateLinkMainText, .infoboxTemplateLinkModuleText {}\n" +
".infoboxTemplateLinkMainInclude, .infoboxTemplateLinkModule, .infoboxTemplateLinkModuleInclude {display: block;}\n" +
".infoboxTemplateLinkGlobal a, .infoboxTemplateLinkMain a, .infoboxTemplateLinkMainInclude a, .infoboxTemplateLinkModule a, .infoboxTemplateLinkModuleInclude a {color: [[InfoboxTablesColorPalette::InfoboxTemplateLink]]!important; font-weight: normal;}\n" +
".infoboxTemplateLinkGlobal a:hover, .infoboxTemplateLinkMain a:hover, .infoboxTemplateLinkMainInclude a:hover, .infoboxTemplateLinkModule a:hover, .infoboxTemplateLinkModuleInclude a:hover {background: inherit!important; color: [[InfoboxTablesColorPalette::InfoboxTemplateLinkOnHover]];}\n" +
".InfoboxSmallButton, .InfoboxSmallButtonBackups {border: 1px solid [[InfoboxTablesColorPalette::InfoboxBorderNormal]]!important; background: [[InfoboxTablesColorPalette::InfoboxTableBackground]]!important; padding: 1px; margin: 1px;}\n" +
".InfoboxSmallButton, .InfoboxCellLeft, .InfoboxCellRight, .InfoboxCellSide, .InfoboxCellThree, .InfoboxCellFour, .InfoboxCellImage, .InfoboxCellSingle, .InfoboxEditInputLabel, .InfoboxSmallButtonBackups {font-size: 10px; line-height: 120%;}\n" +
".InfoboxNoInfo {font-weight: bold; border: solid 2px [[InfoboxTablesColorPalette::InfoboxBorderNormal]]; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; padding: 5px 5px;} /* No Info */\n" +
".InfoboxError, .InfoboxTooNarrowErrorContainer, .InfoboxPlaceholderContainer {background: [[InfoboxTablesColorPalette::InfoboxErrorBoxBackground]]; color: [[InfoboxTablesColorPalette::InfoboxErrorBoxText]]; font-weight: bold; float: right;} /* Errors */\n" +
".InfoboxError, .InfoboxTooNarrowErrorContainer {border: solid 5px [[InfoboxTablesColorPalette::InfoboxErrorBoxBorder]]; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; padding: 2px 2px;}\n" +
".InfoboxPlaceholderContainer {border: solid 1px [[InfoboxTablesColorPalette::InfoboxErrorBoxBorder]]; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; padding: 1px 1px; text-align: center;}\n" +
".InfoboxColumns1 {-webkit-column-count: 1; -moz-column-count: 1; column-count: 1;}\n" +
".InfoboxColumns2 {-webkit-column-count: 2; -moz-column-count: 2; column-count: 2;}\n" +
".InfoboxColumns3 {-webkit-column-count: 3; -moz-column-count: 3; column-count: 3;}\n" +
".InfoboxColumns4 {-webkit-column-count: 4; -moz-column-count: 4; column-count: 4;}\n" +
".InfoboxColumns1, .InfoboxColumns2, .InfoboxColumns3, .InfoboxColumns4 {-webkit-column-gap: 40px; -moz-column-gap: 40px; column-gap: 40px; -webkit-column-rule: 1px solid [[InfoboxTablesColorPalette::InfoboxBorderNormal]]; -moz-column-rule: 1px solid [[InfoboxTablesColorPalette::InfoboxBorderNormal]]; column-rule: 1px solid [[InfoboxTablesColorPalette::InfoboxBorderNormal]];}\n" +
".InfoboxLinesHidden {border: 5px solid [[InfoboxTablesColorPalette::InfoboxBorderHighlighted]]!important;}\n" +
".InfoboxLinesHighlighted {background: [[InfoboxTablesColorPalette::InfoboxHighlightDark]]!important;}\n" +
".InfoboxEditDiv, .InfoboxEditInputContainer, .InfoboxTooNarrowErrorContainer, .InfoboxPlaceholderContainer, .InfoboxErrorsContainer {display: none;}\n" +
".InfoboxCheckboxContainer {display: inline-block;}\n" +
".InfoboxCheckboxLabel, .InfoboxCheckboxCounter {}\n" +
".InfoboxEditInput {width: 75%!important;}\n" +
".InfoboxEditInstanceCounterInput {width: 35px!important;}\n" +
".InfoboxEditTextarea, .InfoboxEditTextareaOnfocus, .InfoboxEditTextareaOnblur {width: 99%!important;}\n" +
".InfoboxEditTextarea {height: 20px; border: 1px solid [[InfoboxTablesColorPalette::InfoboxBorderNormal]]!important; padding: 0px!important; margin: 0px!important; overflow: auto; overflow-y: scroll!important; resize: vertical!important;}\n" +
".InfoboxEditTextareaOnfocus {height: 200px;}\n" +
".InfoboxEditTextareaOnblur {height: 20px;}\n" +
".InfoboxEditParamName, .InfoboxEditComment, .InfoboxImageContainer {display: block;}\n" +
".InfoboxCellLeft, .InfoboxEditParamName, .dropdownNoDependencyMessage, .InfoboxNoValueWarning, .InfoboxDependent, .InfoboxDependency, .InfoboxTemplateDelimiter, .InfoboxModuleInstanceDelimiter, .InfoboxHeaderParams, .InfoboxSubParams {font-weight: bold;}\n" +
".InfoboxSubParams {}\n" +
".InfoboxFigcaption {}\n" +
".InfoboxParamOnly {}\n" +
".InfoboxPrefixes {font-weight: lighter;}\n" +
".InfoboxEditComment {font-weight: normal!important; background: [[InfoboxTablesColorPalette::InfoboxTableBackground]]; color: [[InfoboxTablesColorPalette::InfoboxBorderNormal]];}\n" +
".InfoboxEditDropdownAltTextarea {display: none;}\n" +
".InfoboxNoValueWarning {color: [[InfoboxTablesColorPalette::InfoboxErrorMessage]];}\n" +
".InfoboxDependent, .InfoboxOnHover {background: [[InfoboxTablesColorPalette::InfoboxHighlightLight]];}\n" +
".InfoboxDependency {background: [[InfoboxTablesColorPalette::InfoboxHighlightDark]];}\n" +
".InfoboxListsFix ul, ol {margin-top: 0px; margin-bottom: 0px; display: inline-block;}\n" +
".InfoboxNoBackupsNotice, .InfoboxBackupsOuterContainer, .InfoboxBackupsListsHeader, .InfoboxBackupsListsContainer, .InfoboxBackupsListsList, .InfoboxBackupsListCountDiv, .InfoboxBackupsListCount {}\n" +
".InfoboxLogMessage, .InfoboxLogDeletion, .InfoboxLogBackup, .InfoboxLogValueAdd, .InfoboxLogParamAdd, .InfoboxLogParamRemove, .InfoboxLogParamChange, .InfoboxLogParamShortToLong, .InfoboxLogParamLongToShort, .InfoboxTemplateList {font-weight: bold;}\n" +
".InfoboxLogDeletion {color: [[InfoboxTablesColorPalette::InfoboxLogDeletion]]}\n" +
".InfoboxLogBackup {color: [[InfoboxTablesColorPalette::InfoboxLogBackup]]}\n" +
".InfoboxLogValueAdd {color: [[InfoboxTablesColorPalette::InfoboxLogValueAdd]]}\n" +
".InfoboxLogParamAdd {color: [[InfoboxTablesColorPalette::InfoboxLogParamAdd]]}\n" +
".InfoboxLogParamRemove {color: [[InfoboxTablesColorPalette::InfoboxLogParamRemove]]}\n" +
".InfoboxLogParamChange {color: [[InfoboxTablesColorPalette::InfoboxLogParamChange]]}\n" +
".InfoboxLogParamShortToLong {color: [[InfoboxTablesColorPalette::InfoboxLogParamShortToLong]]}\n" +
".InfoboxLogParamLongToShort {color: [[InfoboxTablesColorPalette::InfoboxLogParamLongToShort]]}\n" +
"[[InfoboxTablesStylesheetGenerated]]\n" +
"@media (max-width: "+config.options.txtInfoboxesMinViewportWidth+"px) {.InfoboxOuterContainer {width: 33%!important} .InfoboxErrorsContainer, .InfoboxInnerContainer {display: none!important;} .InfoboxTooNarrowErrorContainer {display: block;}}\n" +
"@media (max-width: "+config.options.txtInfoboxesMinTooNarrowWidth+"px) {.InfoboxErrorsContainer, .InfoboxInnerContainer {display: none!important;} .InfoboxTooNarrowErrorContainer {display: none;} .InfoboxPlaceholderContainer {display: block;}}\n" +
"@media (max-width: "+config.options.txtInfoboxesMinPlaceholderWidth+"px) {.InfoboxPlaceholderContainer {display: none;}}\n" +
"/*}}}*/";
}
//}}}
/***
!!Template-Specific Color Palette, Stylesheet
***/
//{{{
var TopContentSectionSchemes = config.options.txtInfoboxesSectionSchemes;
var TopInfoboxSlicesText = config.options.txtInfoboxesSliceText;
var TopInfoboxSlicesTitle = config.options.txtInfoboxesSliceTitle;
var TopInfoboxSlicesSubtitle = config.options.txtInfoboxesSliceSubtitle;
var TopInfoboxTagsInfobox = config.options.txtInfoboxesTagsInfobox;
var TopInfoboxTagsBackup = config.options.txtInfoboxesTagsBackup;
var list = store.getTaggedTiddlers(TopInfoboxTagsInfobox);
var TopInfoboxPrefixInfobox = config.options.txtInfoboxesPrefixInfobox;
var validTypes = [];
var ii, jj, listTitle, listTitleRE, validTypesRE, listColorsText, listColorsTitle, listColorsSubtitle, topSchemes, topSchemesSplit, scheme, listColorsSchemeText, listColorsSchemeTitle, listColorsSchemeSubtitle, topSchemesSplitLength;
var paletteGenerated = store.getTiddler("InfoboxTablesColorPaletteGenerated");
if (paletteGenerated === null) {
config.shadowTiddlers.InfoboxTablesColorPaletteGenerated =
"/***\nTemplate-Specific Color Palette\n***/\n/*{{{*/\n";
}
var stylesheetGenerated = store.getTiddler("InfoboxTablesStylesheetGenerated");
if (stylesheetGenerated === null) {
config.shadowTiddlers.InfoboxTablesStylesheetGenerated =
"/***\nTemplate-Specific Stylesheet\n***/\n/*{{{*/\n";
}
var listLength = list.length;
for (ii = 0; ii < listLength; ii+=1) {
if (!list[ii].isTagged(TopInfoboxTagsBackup)) {//If it is not a backup
listTitleRE = new RegExp(TopInfoboxPrefixInfobox+"|_| ","g");
listTitle = list[ii].title.replace(listTitleRE, "");
validTypesRE = new RegExp(TopInfoboxPrefixInfobox+"_","");
validTypes.push(list[ii].title.replace(validTypesRE, "").replace(/_/g, " "));
listColorsText = store.getTiddlerText(list[ii].title + "::"+TopInfoboxSlicesText);
listColorsTitle = store.getTiddlerText(list[ii].title + "::"+TopInfoboxSlicesTitle);
listColorsSubtitle = store.getTiddlerText(list[ii].title + "::"+TopInfoboxSlicesSubtitle);
if (listColorsText === null) {
listColorsText = "black";
}
if (listColorsTitle === null) {
listColorsTitle = "white";
}
if (listColorsSubtitle === null) {
listColorsSubtitle = "white";
}
//Color Palette - Template
//if (paletteGenerated === null) {//karamba
config.shadowTiddlers.InfoboxTablesColorPaletteGenerated +=
"Infobox" + listTitle + TopInfoboxSlicesText + ": " + listColorsText + "\n" +
"Infobox" + listTitle + TopInfoboxSlicesTitle + ": " + listColorsTitle + "\n" +
"Infobox" + listTitle + TopInfoboxSlicesSubtitle + ": " + listColorsSubtitle + "\n";
//}//karamba
//Stylesheet - Template
//if (stylesheetGenerated === null) {//karamba
config.shadowTiddlers.InfoboxTablesStylesheetGenerated +=
".Infobox" + listTitle + TopInfoboxSlicesTitle + " {background: [[InfoboxTablesColorPaletteGenerated::Infobox" + listTitle + TopInfoboxSlicesTitle + "]]; color: [[InfoboxTablesColorPaletteGenerated::Infobox" + listTitle + "Text]];}\n" +
".Infobox" + listTitle + TopInfoboxSlicesSubtitle + " {background: [[InfoboxTablesColorPaletteGenerated::Infobox" + listTitle + TopInfoboxSlicesSubtitle + "]]; color: [[InfoboxTablesColorPaletteGenerated::Infobox" + listTitle + TopInfoboxSlicesText + "]];}\n" +
".Infobox" + listTitle + "NoInfo {background: [[InfoboxTablesColorPaletteGenerated::Infobox" + listTitle + TopInfoboxSlicesTitle + "]]; color: [[InfoboxTablesColorPaletteGenerated::Infobox" + listTitle + TopInfoboxSlicesText + "]];}\n";
//".Infobox" + listTitle + "Error {background: [[InfoboxTablesColorPaletteGenerated::InfoboxError]]; color: [[InfoboxTablesColorPaletteGenerated::Infobox" + listTitle + TopInfoboxSlicesText + "]]; border: solid 5px [[InfoboxTablesColorPaletteGenerated::Infobox" + listTitle + TopInfoboxSlicesTitle + "]];}\n";//karamba
//".Infobox" + listTitle + "Error {background: [[InfoboxTablesColorPaletteGenerated::InfoboxError]]; color: [[InfoboxTablesColorPaletteGenerated::Infobox" + listTitle + TopInfoboxSlicesText + "]]; border: solid 5px [[InfoboxTablesColorPaletteGenerated::Infobox" + listTitle + TopInfoboxSlicesTitle + "]];}\n";
//}//karamba
//Alternative color schemes
topSchemes = store.getTiddlerText(list[ii].title+"##"+TopContentSectionSchemes);
if ((topSchemes !== null) && (topSchemes !== undefined) && (topSchemes.length > 0)) { //If there are schemes
topSchemesSplit = topSchemes.split(",");
topSchemesSplitLength = topSchemesSplit.length;
for (jj = 0; jj < topSchemesSplitLength; jj+=1) { //Go through schemes
scheme = topSchemesSplit[jj].trim().replace(/ /g, "");
listColorsSchemeText = store.getTiddlerText(list[ii].title + "::" + scheme + TopInfoboxSlicesText);
listColorsSchemeTitle = store.getTiddlerText(list[ii].title + "::" + scheme + TopInfoboxSlicesTitle);
listColorsSchemeSubtitle = store.getTiddlerText(list[ii].title + "::" + scheme + TopInfoboxSlicesSubtitle);
if (listColorsSchemeText === null) {
listColorsSchemeText = "black";
}
if (listColorsSchemeTitle === null) {
listColorsSchemeTitle = "white";
}
if (listColorsSchemeSubtitle === null) {
listColorsSchemeSubtitle = "white";
}
//Color Palette - Schemes
//if (paletteGenerated === null) {//karamba
config.shadowTiddlers.InfoboxTablesColorPaletteGenerated +=
"Infobox" + listTitle + scheme + TopInfoboxSlicesText + ": " + listColorsSchemeText + "\n" +
"Infobox" + listTitle + scheme + TopInfoboxSlicesTitle + ": " + listColorsSchemeTitle + "\n" +
"Infobox" + listTitle + scheme + TopInfoboxSlicesSubtitle + ": " + listColorsSchemeSubtitle + "\n";
//}//karamba
//Stylesheet - Schemes
//if (stylesheetGenerated === null) {//karamba
config.shadowTiddlers.InfoboxTablesStylesheetGenerated +=
".Infobox" + listTitle + scheme + TopInfoboxSlicesTitle + " {background: [[InfoboxTablesColorPaletteGenerated::Infobox" + listTitle + scheme + TopInfoboxSlicesTitle + "]]; color: [[InfoboxTablesColorPaletteGenerated::Infobox" + listTitle + scheme + TopInfoboxSlicesText + "]];}\n" +
".Infobox" + listTitle + scheme + TopInfoboxSlicesSubtitle + " {background: [[InfoboxTablesColorPaletteGenerated::Infobox" + listTitle + scheme + TopInfoboxSlicesSubtitle + "]]; color: [[InfoboxTablesColorPaletteGenerated::Infobox" + listTitle + scheme + TopInfoboxSlicesText + "]];}\n" +
".Infobox" + listTitle + scheme + "NoInfo {background: [[InfoboxTablesColorPaletteGenerated::Infobox" + listTitle + scheme + TopInfoboxSlicesTitle + "]]; color: [[InfoboxTablesColorPaletteGenerated::Infobox" + listTitle + scheme + TopInfoboxSlicesText + "]];}\n";
//".Infobox" + listTitle + scheme + "Error {background: [[InfoboxTablesColorPaletteGenerated::InfoboxError]]; color: [[InfoboxTablesColorPaletteGenerated::Infobox" + listTitle + scheme + TopInfoboxSlicesText + "]]; border: solid 5px [[InfoboxTablesColorPaletteGenerated::Infobox" + listTitle + scheme + TopInfoboxSlicesTitle + "]];}\n";
//}
} //End go through schemes
} //End if there are schemes
} //End if it is not backup
}
//Color Palette
if (paletteGenerated === null) {
config.shadowTiddlers.InfoboxTablesColorPaletteGenerated += "/*}}}*/\n";
}
//Stylesheet
if (stylesheetGenerated === null) {
config.shadowTiddlers.InfoboxTablesStylesheetGenerated += "/*}}}*/\n";
}
store.addNotification("InfoboxTablesStylesheet", refreshStyles); //Notify store now that all styles have been defined
//}}}
/***
!!Modules temp
***/
//{{{
config.shadowTiddlers.InfoboxTablesModulesTemp = "";
//}}}
/***
!!Global parameters shadow template
***/
//{{{
config.shadowTiddlers[config.options.txtInfoboxesGlobalParametersTemplate] = "!"+config.options.txtInfoboxesSectionContent+"\n"+config.options.txtInfoboxesPrefixSection+"-\n" +
"Single-Article domain **#''This article is about real life.'', ''This article is about fiction.''#";
//}}}
/***
!!Infobox Macro
***/
//{{{
config.macros.infobox = {};
//Texts
config.macros.infobox.texts = {
//Error messages
infoboxTooNarrow: "The display area is too narrow to properly display the results. Increase it by increasing the browser window width or by zooming out.",
infoboxPlaceholder: "I",
infoboxMandatoryType: "\nType is mandatory! Allowed types are: %0.\nInfobox edit mode is not available.", //%0 = list of infobox types
infoboxNonExistentType: "\nYou entered a non-existent type! Allowed types are: %0\nInfobox edit mode is not available.", //%0 = list of infobox types
infoboxNoTemplates: "\nNo infobox templates found.",
infoboxTooManyIDs: "\nThere are ''%0'' infoboxes of ''\"%1\"'' type, but only ''%2'' ~IDs. This infobox does not have an ''\"%3\"'' parameter.\nWhen using more than one infobox of the same type, you need to add ''\"%3\"'' parameter to all of them. This parameter can be a random ''alphanumeric'' string and must be different for each infobox of the same type.\nInfobox edit mode is not available.", //%0 = number of infoboxes, %1 = infobox type, %2 = number of infoboxes, %3 = parameter name (Infobox_instance_ID)
infoboxDuplicateParams: "\nThis infobox has the same ''\"%0\"'' parameter (''\"%1\"'') as another infobox of the same type (''\"%2\"'').\nInfoboxes of the same type must have ''unique ~IDs''.\nInfobox edit mode is not available.", // %0 = parameter name, %1 = parameter value, &2 = infobox type
infoboxNonExistentModule: "\nThe module ''\"%0\"'' does not exist. Available modules are: ''%1''.", //%0 = module name, %1 = list of modules
infoboxNonExistentInclude: "\nThe include ''\"%0\"'' does not exist. Available includes are: ''%1''.", //%0 = module name, %1 = list of modules
infoboxModuleInstanceNaN: "The value for the number of instances is not a number. Check the ''\"%0\"'' parameter. The correct format is: <module name A, number of instances, module name B, number of instances, ..., module name N, number of instances>.", //%0 = parameter name (Infobox_modules)
//Infobox UI texts, param messages/values and param validation errors
infoboxNoInformation: "No information available.",
infoboxDefaultColorScheme: "Default color scheme",
infoboxInfoboxHeader: "Infobox header",
infoboxInfoboxSystem: "Infobox system parameters",
infoboxInfoboxContent: "Infobox content parameters",
infoboxNoModules: "No modules available.",
infoboxUnnamedSection: "Unnamed section",
infoboxNoComment: "No comment available.",
infoboxDropdownNoDependencyValue: "The values for this parameter depend on the \"%0\" parameter. Select a value for that parameter first.", //%0 = parameter name
infoboxNewLimits: "New limits: ",
infoboxLimits: "Limits: ",
infoboxValueOutOfBounds: "The value is out of bounds!",
infoboxNaN: "Value is not a number!",
infoboxForbiddenChars: "Limits contain forbidden characters:\n%0.\nOnly the following characters are allowed:\n<, >, !, =, |, &, semi-colon, comma, dot, space and digits.", //%0 = list of detected forbidden characters
infoboxIncorrectLimits: "Limits are incorrectly formatted (%0).\nThe correct limit formatting is (([<>](=))|([!=]=))(-)[1-9]([|&](([<>](=))|([!=]=))(-)[1-9]). Limits are separated with a comma and a space.", //%0 = list of limits
infoboxCorrectYourTemplate: "You need to correct your template (template \"[[%0]]\", parameter \"%1\").", //%0 = template name
infoboxImageSrc: "Image src:",
infoboxImageAlt: "Image alt:",
infoboxImageTitle: "Image title:",
infoboxShowImageCaption: "Show image caption",
infoboxImageCaption: "Image caption:",
infoboxUseImageLink: "Use image Link",
infoboxImageLink: "Image link:",
infoboxPreview: "Preview:",
infoboxNoImage: "No image specified.",
//Buttons and tooltips
infoboxShowTemplateListButtonText: "show templates",
infoboxShowTemplateListButtonTooltip: "show template list",
infoboxHideTemplateListButtonText: "hide templates",
infoboxHideTemplateListButtonTooltip: "hide template list",
infoboxViewTemplates: "{{infoboxTemplateLinkGlobalText{Global template:}}} %0\n{{infoboxTemplateLinkMainText{Main template:}}} %1\n%2{{infoboxTemplateLinkModuleText{Active modules:}}} %3", //%0 = global template name, %1 = main template name followed by a list of includes, %2 = line break, %1 = list of active modules with includes
infoboxEditButtonText: "edit",
infoboxEditButtonTooltip: "edit infobox",
infoboxSaveButtonText: "save",
infoboxSaveButtonTooltip: "save infobox",
infoboxCancelButtonText: "cancel",
infoboxCancelButtonTooltip: "cancel editing infobox",
infoboxDeleteButtonText: "delete",
infoboxDeleteButtonTooltip: "delete infobox",
infoboxShowButtonText: "show",
infoboxShowButtonTooltip: "show infobox",
infoboxHideButtonText: "hide",
infoboxHideButtonTooltip: "hide infobox",
infoboxShowLinesButtonText: "show all",
infoboxShowLinesButtonTooltip: "show all lines",
infoboxHideLinesButtonText: "hide empty",
infoboxHideLinesButtonTooltip: "hide lines without values",
//Confirmation messages and alerts
infoboxConfirmDelete: "Do you really want to delete this infobox?\n%0: \"%1\"\n%2: \"%3\"\n%4: \"%5\"", //%0 = infobox title param, %1 = infobox title value, %2 = infobox type param, %3 = infobox type value, %4 = infobox instance ID param, %5 = infobox instance ID value
infoboxMissingDependentEntry: "You have selected \"%0\" in one of the dropdowns.\nYou need to enter values for all dependent fields.", //%0 = param special value
infoboxConfirmSave: "Do you really want to save changes to this infobox?\n%0: \"%1\"\n%2: \"%3\"\n%4: \"%5\"%6", //%0 = infobox title param, %1 = infobox title value, %2 = infobox type param, %3 = infobox type value, %4 = infobox instance ID param, %5 = infobox instance ID value, %6 = message text (infoboxNewInstanceID)
infoboxNewInstanceID: "(This is the default ID. The plugin will automatically generate a new one.)",
infoboxInfoboxBackupNotice: "Infobox templates (global, modules, regular) will also be backed up, if changed.",
infoboxArticleBackupNotice: "This article will also be backed up.",
//Backup list
infoboxArticleBackupListNoBackups: "No backups available.",
infoboxArticleBackupListDeleteSelectedButtonText: "Delete selected",
infoboxArticleBackupListDeleteSelectedButtonTooltip: "Delete selected backup tiddlers",
infoboxArticleBackupListDeleteAllButtonText: "Delete all",
infoboxArticleBackupListDeleteAllButtonTooltip: "Delete all backup tiddlers",
infoboxArticleBackupListArticlesTitle: "Articles",
infoboxArticleBackupListInfoboxesTitle: "Infoboxes",
infoboxArticleBackupListInfoboxModulesTitle: "Infobox modules",
infoboxArticleBackupListGlobalTemplateTitle: "Global template",
infoboxArticleBackupListNoneSelected: "No backups selected for deletion.",
infoboxArticleBackupListDeleteSelected: "Do you really want to delete all selected backup tiddlers?",
infoboxArticleBackupListDeleteAll: "Do you really want to delete all backup tiddlers?",
infoboxArticleBackupListNumberOfBackups: "Number of backups: %0", //%0 = number
//Log
infoboxLogNoMessages: "There are no messages.",
infoboxLogLoggingNotEnabled: "Logging is not enabled.",
infoboxLogMessageLogTitle: "InfoboxTablesPlugin message log\n",
infoboxLogInfoboxDeleted: "\n{{InfoboxLogMessage{\"%0\" - {{InfoboxLogDeletion{Deleted infobox \"%1\" with instance ID \"%2\" from article \"[[%3]]\".}}}}}}", //%0 = timestamp, %1 = infobox title, %2 = infobox instance ID, %3 = article title
infoboxLogArticleBackedUp: "\n{{InfoboxLogMessage{\"%0\" - {{InfoboxLogBackup{Backed up article \"[[%1]]\".}}}}}}", //%0 = timestamp, %1 = article title
infoboxLogTemplateBackedUp: "\n{{InfoboxLogMessage{\"%0\" - {{InfoboxLogBackup{Backed up template \"[[%1]]\".}}}}}}", //%0 = timestamp, %1 = article title
infoboxLogTemplateValueAdded: "\n{{InfoboxLogMessage{\"%0\" - {{InfoboxLogValueAdd{Added value \"{{{%1}}}\" to parameter \"{{{%2}}}\" in template \"[[%3]]\".}}}}}}", //%0 = timestamp, %1 = param value, %2 = param name, %3 = template title
infoboxLogInfoboxParamAdded: "\n{{InfoboxLogMessage{\"%0\" - {{InfoboxLogParamAdd{Added parameter \"{{{%1}}}\" with value \"{{{%2}}}\" to infobox \"{{{%3}}}\" with instance ID \"{{{%4}}}\" in article \"[[%5]]\".}}}}}}", //%0 = timestamp, %1 = param name, %2 = param value, %3 = infobox title, %4 = infobox instance ID, %5 = article title
infoboxLogInfoboxParamRemoved: "\n{{InfoboxLogMessage{\"%0\" - {{InfoboxLogParamRemove{Removed parameter \"{{{%1}}}\" with value \"{{{%2}}}\" from infobox \"{{{%3}}}\" with instance ID \"{{{%4}}}\" in article \"[[%5]]\".}}}}}}", //%0 = timestamp, %1 = param name, %2 = param value, %3 = infobox title, %4 = infobox instance ID, %5 = article title
infoboxLogInfoboxParamChanged: "\n{{InfoboxLogMessage{\"%0\" - {{InfoboxLogParamChange{Changed the value of parameter \"{{{%1}}}\" from \"{{{%2}}}\" to \"{{{%3}}}\" in infobox \"{{{%4}}}\" with instance ID \"{{{%5}}}\" in article \"[[%6]]\".}}}}}}", //%0 = timestamp, %1 = param name, %2 = old param value, %3 = new param value, %4 = infobox title, %5 = infobox instance ID, %6 = article title
infoboxLogInfoboxShortToLong: "\n{{InfoboxLogMessage{\"%0\" - {{InfoboxLogParamShortToLong{Changed shorthand parameters to longhand parameters in infobox \"{{{%1}}}\" with instance ID \"{{{%2}}}\" in article \"[[%3]]\".}}}}}}", //%0 = timestamp, %1 = infobox title, %2 = infobox instance ID, %3 = article title
infoboxLogInfoboxLongToShort: "\n{{InfoboxLogMessage{\"%0\" - {{InfoboxLogParamLongToShort{Changed longhand parameters to shorthand parameters in infobox \"{{{%1}}}\" with instance ID \"{{{%2}}}\" in article \"[[%3]]\".}}}}}}", //%0 = timestamp, %1 = infobox title, %2 = infobox instance ID, %3 = article title
infoboxLogBackupDeleted: "\n{{InfoboxLogMessage{\"%0\" - {{InfoboxLogDeletion{Deleted backup tiddler \"{{{%1}}}\".}}}}}}", //%0 = timestamp, %1 = backup title
//Template list
infoboxTemplateListHeader: "List of templates:",
infoboxTemplateListNoTemplates: "No templates available.",
//Annotations
InfoboxTablesColorPalette: "This is the global color palette for the ~InfoboxTablesPlugin. Feel free to modify it.",
InfoboxTablesColorPaletteGenerated: "This is the generated color palette for the ~InfoboxTablesPlugin. Do not modify!",
InfoboxTablesStylesheet: "This is the global stylesheet for the ~InfoboxTablesPlugin. Feel free to modify it.",
InfoboxTablesStylesheetGenerated: "This is the generated stylesheet for the ~InfoboxTablesPlugin. Do not modify!",
Infobox_Global_Parameters: "This is the template for global parameters for the ~InfoboxTablesPlugin. Feel free to modify it.",
InfoboxTablesBackupsList: "This is a list of backups generated by the ~InfoboxTablesPlugin. Do not modify!",
InfoboxTablesMessageLog: "This is a message log generated by the ~InfoboxTablesPlugin. Do not modify!",
InfoboxTablesModulesTemp: "This is a temporary storage for the ~InfoboxTablesPlugin. Do not modify!",
InfoboxTablesTemplatesList: "This is a list of templates generated by the ~InfoboxTablesPlugin. Do not modify!"
};
//Annotations for shadow tiddlers
merge(config.annotations,{
InfoboxTablesColorPalette: config.macros.infobox.texts.InfoboxTablesColorPalette,
InfoboxTablesColorPaletteGenerated: config.macros.infobox.texts.InfoboxTablesColorPaletteGenerated,
InfoboxTablesStylesheet: config.macros.infobox.texts.InfoboxTablesStylesheet,
InfoboxTablesStylesheetGenerated: config.macros.infobox.texts.InfoboxTablesStylesheetGenerated,
Infobox_Global_Parameters: config.macros.infobox.texts.Infobox_Global_Parameters,
InfoboxTablesBackupsList: config.macros.infobox.texts.InfoboxTablesBackupsList,
InfoboxTablesMessageLog: config.macros.infobox.texts.InfoboxTablesMessageLog,
InfoboxTablesTemplatesList: config.macros.infobox.texts.InfoboxTablesTemplatesList
});
//ID prefixes
config.macros.infobox.IDs = {
//Stylesheet elements
IDPrefixInfoboxTablesStyle: "InfoboxTablesStyle_",
IDPrefixIncludeTopRow: "IncludeTopRow_",
IDPrefixIncludeBottomRow: "IncludeBottomRow_",
IDPrefixIncludeFirstCell: "IncludeFirstCell_",
IDPrefixIncludeLastCell: "IncludeLastCell_",
//General DOM elements
IDPrefixEdit: "Edit_",
IDPrefixContent: "Content_",
IDPrefixErrorsDiv: "ErrorsDiv_",
IDPrefixTooNarrowDiv: "TooNarrowDiv_",
IDPrefixPlaceholderDiv: "PlaceholderDiv_",
IDPrefixOuterContainer: "OuterContainer_",
IDPrefixTableContainer: "TableContainer_",
IDPrefixInnerContainer: "InnerContainer_",
IDPrefixInfoboxContainer: "InfoboxContainer_",
IDPrefixEmptyDiv: "EmptyDiv_",
IDPrefixTemplateListOuterContainer: "TemplateListOuterContainer_",
IDPrefixTemplateListButtonContainer: "TemplateListButtonContainer_",
IDPrefixTemplateListInnerContainer: "TemplateListInnerContainer_",
IDPrefixHeaderTable: "HeaderTable_",
IDPrefixFooterTable: "FooterTable_",
IDPrefixInfoTable: "InfoTable_",
IDPrefixNoInfoTable: "NoInfoTable_",
IDPrefixSystemContent: "SystemContent_",
IDPrefixSectionTable: "SectionTable_",
IDPrefixSectionHeader: "SectionHeader_",
IDPrefixTemplateDelimiter: "TemplateDelimiter_",
IDPrefixTemplateDelimiterTable: "TemplateDelimiterTable_",
IDPrefixModuleDelimiter: "ModuleDelimiter_",
IDPrefixModuleDelimiterTable: "ModuleDelimiterTable_",
IDPrefixIncludeDelimiterStart: "IncludeDelimiterStart_",
IDPrefixIncludeDelimiterEnd: "IncludeDelimiterEnd_",
//Buttons
IDPrefixSmallButtonShowHide: "SmallButtonShowHide_",
IDPrefixSmallButtonDelete: "SmallButtonDelete_",
IDPrefixSmallButtonEdit: "SmallButtonEdit_",
IDPrefixSmallButtonSave: "SmallButtonSave_",
IDPrefixSmallButtonToggleEmptyLines: "SmallButtonToggleEmptyLines_",
IDPrefixSmallButtonShowTemplateList: "SmallButtonShowTemplateList_",
//Params
IDPrefixParamName: "ParamName_",
IDPrefixParamPrefix: "ParamPrefix_",
IDPrefixContentContainer: "ContentContainer_",
IDPrefixCommentContainer: "CommentContainer_",
IDPrefixFigure: "Figure_",
IDPrefixImage: "Image_",
IDPrefixNoImage: "NoImage_",
IDSuffixImageSrc: "_ImageSrc",
IDSuffixImageAlt: "_ImageAlt",
IDSuffixImageTitle: "_ImageTitle",
IDPrefixFigureCheckbox: "Checkbox_",
IDSuffixImageCaption: "_ImageCaption",
IDSuffixImageLink: "_ImageLink",
IDPrefixCaption: "Caption_",
IDPrefixColorSchemeSelect: "ColorSchemeSelect_",
IDPrefixModuleCheckbox: "ModuleCheckbox_",
IDPrefixModuleCheckboxCounter: "ModuleCheckboxCounter_",
IDPrefixComment: "Comment_",
IDPrefixNewLimit: "NewLimit_",
IDPrefixTextarea: "Textarea_",
IDPrefixSelect: "Select_",
IDPrefixNoValueWarning: "NoValueWarning_"
};
config.macros.infobox.handler = function (place,macroName,params,wikifier,paramString,tiddler) {
"use strict";
params = paramString.parseParams(null, null, true);
//Get template sections
var ContentSectionContent = config.options.txtInfoboxesSectionContent;
var ContentSectionSchemes = config.options.txtInfoboxesSectionSchemes;
//Get slices
var InfoboxSlicesTitle = config.options.txtInfoboxesSliceTitle;
var InfoboxSlicesSubtitle = config.options.txtInfoboxesSliceSubtitle;
//Get parameter prefixes
var prefixSection = config.options.txtInfoboxesPrefixSection;
var prefixImage = config.options.txtInfoboxesPrefixImage;
var prefixSingle = config.options.txtInfoboxesPrefixSingle;
var prefixSide = config.options.txtInfoboxesPrefixSide;
var prefixThree = config.options.txtInfoboxesPrefixThree;
var prefixFour = config.options.txtInfoboxesPrefixFour;
var prefixInclude = config.options.txtInfoboxesPrefixInclude;
//Get template prefixes and suffix
var InfoboxPrefixGlobal = config.options.txtInfoboxesPrefixGlobal;
var InfoboxPrefixModules = config.options.txtInfoboxesPrefixModules;
var InfoboxPrefixIncludes = config.options.txtInfoboxesPrefixIncludes;
var InfoboxSuffixModules = config.options.txtInfoboxesSuffixModules;
//Get special template parameter prefixes
var InfoboxPrefixInfobox = config.options.txtInfoboxesPrefixInfobox;
var InfoboxPrefixInfoboxModule = config.options.txtInfoboxesPrefixInfoboxModule;
var InfoboxPrefixInfoboxInclude = config.options.txtInfoboxesPrefixInfoboxInclude;
//Template delimiters
var templateDelimiter = config.options.txtInfoboxesTemplateDelimiter;
var moduleDelimiter = config.options.txtInfoboxesModuleDelimiter;
var includeDelimiterStart = config.options.txtInfoboxesIncludeDelimiterStart.replace(/ /g, "_");
var includeDelimiterEnd = config.options.txtInfoboxesIncludeDelimiterEnd.replace(/ /g, "_");
//Get default tags
var infoboxTagsInfoboxModule = config.options.txtInfoboxesTagsInfoboxModule;
var infoboxTagsInfoboxInclude = config.options.txtInfoboxesTagsInfoboxInclude;
var InfoboxTagsBackup = config.options.txtInfoboxesTagsBackup;
//Get default and special values
var InfoboxDefaultValueUnknown = config.options.txtInfoboxesDefaultValueUnknown;
var InfoboxDefaultValueDefaultID = config.options.txtInfoboxesDefaultValueDefaultID;
var InfoboxSpecialValueOther = config.options.txtInfoboxesSpecialValueOther;
//Get system parameters
var InfoboxTypeText = config.options.txtInfoboxesParamInfoboxType;
var InfoboxTypeParam = InfoboxTypeText.replace(/ /g, "_");
var InfoboxTitleText = config.options.txtInfoboxesParamInfoboxTitle;
var InfoboxTitleParam = InfoboxTitleText.replace(/ /g, "_");
var InfoboxInstanceIDText = config.options.txtInfoboxesParamInstanceID;
var InfoboxInstanceIDParam = InfoboxInstanceIDText.replace(/ /g, "_");
var InfoboxColorSchemeText = config.options.txtInfoboxesParamColorScheme;
var InfoboxColorSchemeParam = InfoboxColorSchemeText.replace(/ /g, "_");
var InfoboxParamModulesText = config.options.txtInfoboxParamModules;
var InfoboxParamModulesParam = InfoboxParamModulesText.replace(/ /g, "_");
//Get options
var hideInfoboxes = config.options.chkInfoboxesHideInfoboxes;
var hideEmptyLines = config.options.chkInfoboxesHideEmptyLines;
var showOnline = config.options.chkInfoboxesEnableEditOnline;
var hideOffline = config.options.chkInfoboxesDisableEditOffline;
var hideShowTemplateListButton = config.options.chkInfoboxesHideShowTemplateListButton;
var hideHideButton = config.options.chkInfoboxesHideHideButton;
var hideHeader = config.options.chkInfoboxesHideHeader;
var hideFooter = config.options.chkInfoboxesHideFooter;
var useEscape = config.options.chkInfoboxesUseEscapeToExitEditMode;
var maxMultipleSelections = (Math.abs(Math.round(config.options.txtInfoboxesMaxMultipleSelections)));
var allowModifyingTemplates = config.options.chkInfoboxesAllowModifyingTemplates;
var displayImagesAsLinks = config.options.chkInfoboxesDisplayImagesAsLinks;
var showPreview = config.options.chkInfoboxesShowPreview;
var showUnitOfMeasure = config.options.chkInfoboxesShowUnitOfMeasure;
var showModuleName = config.options.chkInfoboxesShowModuleName;
var showModulePrefix = config.options.chkInfoboxesShowModulePrefix;
var numberOfCheckboxesPerColumn = (Math.abs(Math.round(config.options.txtInfoboxesNumberOfCheckboxesPerColumn)));
var showImageCaption = config.options.chkInfoboxesShowImageCaption;
var showTemplateDelimiter = config.options.chkInfoboxesShowDelimiterBetweenGlobalMainAndModule;
var showInstanceDelimiter = config.options.chkInfoboxesShowDelimiterBetweenModuleInstances;
var showBorderAroundInclude = config.options.chkInfoboxesShowBorderAroundInclude;
var globalParametersTemplate = config.options.txtInfoboxesGlobalParametersTemplate;
//Get system parameter values
var Type = getParam(params, InfoboxTypeParam, InfoboxDefaultValueUnknown);
var Title = getParam(params, InfoboxTitleParam, tiddler.title);
var InstanceID = getParam(params, InfoboxInstanceIDParam, InfoboxDefaultValueDefaultID);
var TypeX = Type.replace(/[\W\s]/g, "");
var TitleX = Title.replace(/[\W\s]/g, "");
var InstanceIDX = InstanceID.replace(/[\W\s]/g, "");
var TTIX = TypeX + TitleX + InstanceIDX;
var InfoboxColorScheme = getParam(params, InfoboxColorSchemeParam, "").replace(/ /g, "");
var Modules, ModulesTemp;
var modulesTempRE = new RegExp(TTIX+":[\\w\\W\\s]*?(?:\n|$)", "g");
var TTIXRE = new RegExp(TTIX+":", "");
ModulesTemp = store.getShadowTiddlerText("InfoboxTablesModulesTemp").match(modulesTempRE);
if ((ModulesTemp !== null) && (ModulesTemp !== undefined) && ModulesTemp.length) { //First check the temp shadow tiddler for new modules/instances
Modules = ModulesTemp.toString().replace(TTIXRE, "");
}
else { //Otherwise get modules/instances from the parameter
Modules = getParam(params, InfoboxParamModulesParam, "");
}
var noEdit; //Set edit mode status
if (((document.location.protocol === "file:") && (hideOffline === false) && (readOnly === false)) || (((document.location.protocol === "http:") || (document.location.protocol === "https:")) && (showOnline === true))) { //If offline editing is disabled or online editing is not enabled, hide Edit button, hide Edit button
noEdit = false;
}
else {
noEdit = true;
}
//Create the outer container
var contentDiv = createTiddlyElement(place, "div", this.IDs.IDPrefixOuterContainer+TTIX, "InfoboxOuterContainer InfoboxListsFix");
//Create the container for the error message about display being too narrow
var tooNarrowDiv = createTiddlyElement(contentDiv, "div", this.IDs.IDPrefixTooNarrowDiv+TTIX, "InfoboxTooNarrowErrorContainer", this.texts.infoboxTooNarrow);
var placeholderDiv = createTiddlyElement(contentDiv, "div", this.IDs.IDPrefixPlaceholderDiv+TTIX, "InfoboxPlaceholderContainer", this.texts.infoboxPlaceholder);
//Create the container for other error messages
var errorsDiv = createTiddlyElement(contentDiv, "div", this.IDs.IDPrefixErrorsDiv+TTIX, "InfoboxErrorsContainer");
//Create the inner container
var infoboxDiv = createTiddlyElement(contentDiv, "div", this.IDs.IDPrefixInnerContainer+TTIX, "InfoboxInnerContainer");
setStylesheet("#" + this.IDs.IDPrefixOuterContainer + TTIX + " {width: 33%;}", this.IDs.IDPrefixInfoboxTablesStyle + this.IDs.IDPrefixOuterContainer + TTIX); //Reset the width if opening tiddler for edit while infobox is in edit mode
var saveButton, editButton, deleteButton, showHideEditModeButton, showHideLinesInEditModeButton, InfoboxTableDiv, InfoboxTableEditDiv, templateListOuterContainerDiv;
//Set initial values for the show/hide edit mode button
var closedtext = this.texts.infoboxShowButtonText;
var closedtip = this.texts.infoboxShowButtonTooltip;
var openedtext = this.texts.infoboxHideButtonText;
var openedtip = this.texts.infoboxHideButtonTooltip;
var showHideEditModeButtonText, showHideEditModeButtonTooltip;
if (hideInfoboxes === true) {
showHideEditModeButtonText = closedtext;
showHideEditModeButtonTooltip = closedtip;
}
else {
showHideEditModeButtonText = openedtext;
showHideEditModeButtonTooltip = openedtip;
}
//Create the show/hide edit mode button
showHideEditModeButton = createTiddlyButton(infoboxDiv, showHideEditModeButtonText, showHideEditModeButtonTooltip, function() {config.macros.infobox.toggleInfobox(noEdit,editButton,showHideEditModeButton,InfoboxTableDiv,templateListOuterContainerDiv);}, "InfoboxSmallButton", this.IDs.IDPrefixSmallButtonShowHide+TTIX);
if (hideHideButton === false) {
showHideEditModeButton.style.display = "block";
showHideEditModeButton.setAttribute("data-infobox-closedtext",closedtext);
showHideEditModeButton.setAttribute("data-infobox-closedtip",closedtip);
showHideEditModeButton.setAttribute("data-infobox-openedtext",openedtext);
showHideEditModeButton.setAttribute("data-infobox-openedtip",openedtip);
}
else {
showHideEditModeButton.style.display = "none";
}
//Set initial values for the edit/cancel button
var edittext = this.texts.infoboxEditButtonText;
var edittip = this.texts.infoboxEditButtonTooltip;
var canceltext = this.texts.infoboxCancelButtonText;
var canceltip = this.texts.infoboxCancelButtonTooltip;
//Create the delete button
deleteButton = createTiddlyButton(infoboxDiv, this.texts.infoboxDeleteButtonText, this.texts.infoboxDeleteButtonTooltip, function() {config.macros.infobox.deleteInfobox(tiddler.title,Type,Title,InstanceID);}, "InfoboxSmallButton", this.IDs.IDPrefixSmallButtonDelete+TTIX);
deleteButton.style.display = "none";
//Create the edit/cancel button
editButton = createTiddlyButton(infoboxDiv, edittext, edittip, function() {config.macros.infobox.editInfobox(saveButton,editButton,deleteButton,showHideEditModeButton,showHideLinesInEditModeButton,InfoboxTableDiv,templateListOuterContainerDiv,InfoboxTableEditDiv,TTIX);}, "InfoboxSmallButton", this.IDs.IDPrefixSmallButtonEdit+TTIX);
if (hideInfoboxes === true) {
editButton.style.display = "none";
}
else {
if (noEdit === false) {
editButton.style.display = "block";
}
else {
editButton.style.display = "none";
}
}
editButton.setAttribute("data-infobox-edittext",edittext);
editButton.setAttribute("data-infobox-edittip",edittip);
editButton.setAttribute("data-infobox-canceltext",canceltext);
editButton.setAttribute("data-infobox-canceltip",canceltip);
//Create the save button
var paramList; //Define this here, so it's called within the scope
saveButton = createTiddlyButton(infoboxDiv, this.texts.infoboxSaveButtonText, this.texts.infoboxSaveButtonTooltip, function() {config.macros.infobox.saveInfobox(saveButton,editButton,deleteButton,showHideEditModeButton,showHideLinesInEditModeButton,InfoboxTableDiv,InfoboxTableEditDiv,Type,Title,InstanceID,TTIX,tiddler.title,paramList,Modules);}, "InfoboxSmallButton", this.IDs.IDPrefixSmallButtonSave+TTIX);
saveButton.style.display = "none";
//Set initial values for the show/hide lines in edit mode button
var showtext = this.texts.infoboxShowLinesButtonText;
var showtip = this.texts.infoboxShowLinesButtonTooltip;
var hidetext = this.texts.infoboxHideLinesButtonText;
var hidetip = this.texts.infoboxHideLinesButtonTooltip;
var showHideLinesInEditModeButtonText, showHideLinesInEditModeButtonTooltip;
if (hideEmptyLines === true) {
showHideLinesInEditModeButtonText = showtext;
showHideLinesInEditModeButtonTooltip = showtip;
}
else {
showHideLinesInEditModeButtonText = hidetext;
showHideLinesInEditModeButtonTooltip = hidetip;
}
//Create the show/hide lines in edit mode button
showHideLinesInEditModeButton = createTiddlyButton(infoboxDiv, showHideLinesInEditModeButtonText, showHideLinesInEditModeButtonTooltip, function() {config.macros.infobox.toggleEmptyLines(this,InfoboxTableEditDiv);}, "InfoboxSmallButton", this.IDs.IDPrefixSmallButtonToggleEmptyLines+TTIX);
showHideLinesInEditModeButton.style.display = "none";
showHideLinesInEditModeButton.setAttribute("data-infobox-showtext",showtext);
showHideLinesInEditModeButton.setAttribute("data-infobox-showtip",showtip);
showHideLinesInEditModeButton.setAttribute("data-infobox-hidetext",hidetext);
showHideLinesInEditModeButton.setAttribute("data-infobox-hidetip",hidetip);
//Create the container for the table
InfoboxTableDiv = createTiddlyElement(infoboxDiv, "div", this.IDs.IDPrefixTableContainer+TTIX, "InfoboxViewTableContainer");
//Create outer container for the template list
templateListOuterContainerDiv = createTiddlyElement(infoboxDiv, "div", this.IDs.IDPrefixTemplateListOuterContainer+TTIX, "InfoboxTemplateListOuterContainer");
if (hideInfoboxes === true) {
templateListOuterContainerDiv.style.display = "none";
}
else {
templateListOuterContainerDiv.style.display = "block";
}
//Create na empty div at the end, so that multiple infoboxes are chained together when hiding lines in infobox edit mode
var emptyDiv = createTiddlyElement(place, "div", this.IDs.IDPrefixEmptyDiv+TTIX, "InfoboxEmptyDiv");
//Create container for the template list button
var templateListButtonContainerDiv = createTiddlyElement(templateListOuterContainerDiv, "div", this.IDs.IDPrefixTemplateListButtonContainer+TTIX, "InfoboxTemplateListButtonContainer");
templateListButtonContainerDiv.style.display = "block";
//Create inner container for the template list
var templateListInnerContainerDiv = createTiddlyElement(templateListOuterContainerDiv, "div", this.IDs.IDPrefixTemplateListInnerContainer+TTIX, "InfoboxTemplateListInnerContainer");
templateListInnerContainerDiv.style.display = "none";
//Create the button to show the template list
var showTemplateText = this.texts.infoboxShowTemplateListButtonText;
var showTemplateTip = this.texts.infoboxShowTemplateListButtonTooltip;
var hideTemplateText = this.texts.infoboxHideTemplateListButtonText;
var hideTemplateTip = this.texts.infoboxHideTemplateListButtonTooltip;
var showTemplateListButton = createTiddlyButton(templateListButtonContainerDiv, showTemplateText, showTemplateTip, function() {config.macros.infobox.toggleTemplateList(this,templateListInnerContainerDiv);}, "InfoboxSmallButton", this.IDs.IDPrefixSmallButtonShowTemplateList+TTIX);
showTemplateListButton.setAttribute("data-infobox-showTemplateText",showTemplateText);
showTemplateListButton.setAttribute("data-infobox-showTemplateTip",showTemplateTip);
showTemplateListButton.setAttribute("data-infobox-hideTemplateText",hideTemplateText);
showTemplateListButton.setAttribute("data-infobox-hideTemplateTip",hideTemplateTip);
if (hideShowTemplateListButton === true) {
showTemplateListButton.style.display = "none";
}
else {
showTemplateListButton.style.display = "block";
}
//Create container for the edit table
InfoboxTableEditDiv = createTiddlyElement(infoboxDiv, "div", this.IDs.IDPrefixEdit + this.IDs.IDPrefixInnerContainer+TTIX, "InfoboxEditTableContainer");
InfoboxTableEditDiv.style.display = "none";
if (hideEmptyLines === true) { //Empty lines are hidden
InfoboxTableEditDiv.classList.add("InfoboxLinesHidden");
}
else {
InfoboxTableEditDiv.classList.remove("InfoboxLinesHidden");
}
//Cancel edit by pressing escape
if (useEscape === true) { //If using Escape is enabled
contentDiv.onkeyup = function(e) { //Needs to be "infoboxDiv", because otherwise it closes all infoboxes in a tiddler
if ((e.keyCode === 27) && (jQuery(InfoboxTableDiv).css("display") === "none")) {
config.macros.infobox.editInfobox(saveButton,editButton,deleteButton,showHideEditModeButton,showHideLinesInEditModeButton,InfoboxTableDiv,templateListOuterContainerDiv,InfoboxTableEditDiv,TTIX);
setStylesheet("#" + config.macros.infobox.IDs.IDPrefixOuterContainer + TTIX + " {width: 33%;}", config.macros.infobox.IDs.IDPrefixInfoboxTablesStyle + config.macros.infobox.IDs.IDPrefixOuterContainer + TTIX); //Reset the width
}
};
}
//Output for beginning of table
var start = "<html><div id=\"" + this.IDs.IDPrefixInfoboxContainer + TTIX + "\" class=\"InfoboxContainerDiv\"><table id=\"" + this.IDs.IDPrefixHeaderTable + TTIX + "\" class=\"InfoboxTable InfoboxTableFixedLayout InfoboxTableHeader\">";
//Output for title
if (hideHeader === false) {
start += "<tr id=\"" + this.IDs.IDPrefixTitle + TTIX + "\"><td class=\"InfoboxTableTop Infobox" + TypeX + InfoboxColorScheme + InfoboxSlicesTitle + "\">" + Title + "</td></tr>";
}
//Output for content of table
var out = "";
//Output for end of table
var footer;
if (hideFooter === false) {
footer = "<table id=\"" + this.IDs.IDPrefixFooterTable + TTIX + "\" class=\"InfoboxTable InfoboxTableFixedLayout InfoboxTableFooter\"><tr id=\"" + this.IDs.IDPrefixInfoTable + TTIX + "\"><td class=\"InfoboxTableBottom Infobox" + TypeX + InfoboxColorScheme + InfoboxSlicesTitle + "\"> </td></tr></table>";
}
else {
footer = "";
}
var end = "</table>"+footer+"</div></html>";
var noInfo = "<html><div id=\"" + this.IDs.IDPrefixNoInfoTable + TTIX + "\" class=\"InfoboxNoInfo Infobox" + TypeX + InfoboxColorScheme + "NoInfo\">"+this.texts.infoboxNoInformation+"</div></html>";
//Output for beginning of edit mode table
var startEdit = "<html><div id=\"" + this.IDs.IDPrefixEdit + this.IDs.IDPrefixInfoboxContainer + TTIX + "\" class=\"InfoboxEditContainerDiv\"><table id=\"" + this.IDs.IDPrefixEdit + this.IDs.IDPrefixHeaderTable + TTIX + "\" class=\"InfoboxTableEdit\">";
if (noEdit === false) {
//Output for system header
if (showTemplateDelimiter === true) {
startEdit += "<tr id=\"" + this.IDs.IDPrefixEdit + this.IDs.IDPrefixTemplateDelimiter + TTIX + "_" + this.texts.infoboxInfoboxHeader.replace(/ /g, "_") + "\"><td class=\"InfoboxTemplateDelimiter\" colspan=\"2\">" + this.texts.infoboxInfoboxHeader +"</td></tr>";
}
startEdit += "<tr id=\"" + this.IDs.IDPrefixEdit + this.IDs.IDPrefixSectionTable + TTIX + "_" + this.texts.infoboxInfoboxSystem.replace(/ /g, "_") + "\"><td class=\"ContentSectionEdit Infobox" + TypeX + InfoboxColorScheme + InfoboxSlicesSubtitle + "\" colspan=\"2\">" + this.texts.infoboxInfoboxSystem +"</td></tr>";
//Output for type
startEdit += "<tr id=\"" + this.IDs.IDPrefixEdit + this.IDs.IDPrefixSystemContent + TTIX + "_" + InfoboxTypeText.replace(/ /g, "_") + "\" class=\"InfoboxRow\"><td class=\"InfoboxCellLeft\">"+ InfoboxTypeText +"</td><td class=\"InfoboxCellRight\"><span class=\"InfoboxHeaderParams\">" + Type + "</span></td></tr>";
//Output for title
startEdit += "<tr id=\"" + this.IDs.IDPrefixEdit + this.IDs.IDPrefixSystemContent + TTIX + "_" + InfoboxTitleText.replace(/ /g, "_") + "\" class=\"InfoboxRow\"><td class=\"InfoboxCellLeft\"> " + InfoboxTitleText + "</td><td class=\"InfoboxCellRight\"><div id=\"" + this.IDs.IDPrefixEdit + this.IDs.IDPrefixContentContainer + TTIX + InfoboxTitleText.replace(/ /g, "_") + "\" ><textarea id=\"" + this.IDs.IDPrefixEdit + this.IDs.IDPrefixTextarea + TTIX + InfoboxTitleText.replace(/ /g, "_") + "\" class=\"InfoboxEditTextarea\" onfocus=\"config.macros.infobox.toggleTextareaSize(this);\" onblur=\"config.macros.infobox.toggleTextareaSize(this);\">" + Title + "</textarea></div></td></tr>";
//Output for Infobox instance ID
startEdit += "<tr id=\"" + this.IDs.IDPrefixEdit + this.IDs.IDPrefixSystemContent + TTIX + "_" + InfoboxInstanceIDText.replace(/ /g, "_") + "\" class=\"InfoboxRow\"><td class=\"InfoboxCellLeft\">" + InfoboxInstanceIDText + "</td><td class=\"InfoboxCellRight\"><div id=\"" + this.IDs.IDPrefixEdit + this.IDs.IDPrefixContentContainer + TTIX + InfoboxInstanceIDText.replace(/ /g, "_") + "\" ><textarea id=\"" + this.IDs.IDPrefixEdit + this.IDs.IDPrefixTextarea + TTIX + InfoboxInstanceIDText.replace(/ /g, "_") + "\" class=\"InfoboxEditTextarea\" onfocus=\"config.macros.infobox.toggleTextareaSize(this);\" onblur=\"config.macros.infobox.toggleTextareaSize(this);\">" + InstanceID + "</textarea></div></td></tr>";
//Output for content header
startEdit += "<tr id=\"" + this.IDs.IDPrefixEdit + this.IDs.IDPrefixSectionTable + TTIX + "_" + this.texts.infoboxInfoboxContent.replace(/ /g, "_") + "\"><td class=\"ContentSectionEdit Infobox" + TypeX + InfoboxColorScheme + InfoboxSlicesSubtitle + "\" colspan=\"2\">" + this.texts.infoboxInfoboxContent + "</td></tr>";
}
//Output for color scheme
var d, schemeValue, schemeText, colorSchemeSelect, colorSchemeDefault;
var schemes = store.getTiddlerText(InfoboxPrefixInfobox+"_"+Type.replace(/ /g, "_")+"##"+ContentSectionSchemes);
if ((schemes !== null) && (schemes !== undefined) && (schemes.length > 0)) { //If there are schemes
var colorSchemeOptions = "<option value=\"\">"+this.texts.infoboxDefaultColorScheme+"</option>";
var schemesSplit = schemes.split(",");
var schemesSplitLength = schemesSplit.length;
for (d = 0; d < schemesSplitLength; d+=1) { //Go through schemes
schemeText = schemesSplit[d].trim();
schemeValue = schemeText.replace(/ /g, "");
colorSchemeOptions += "<option value=\""+schemeValue+"\">"+schemeText+"</option>";
} //End go through schemes
colorSchemeSelect = "<select id=\"" + this.IDs.IDPrefixEdit + this.IDs.IDPrefixColorSchemeSelect + TTIX + "\">" + colorSchemeOptions + "</select>";
colorSchemeDefault = false;
} //End if there are schemes
else {
colorSchemeSelect = "<span class=\"InfoboxHeaderParams\">"+this.texts.infoboxDefaultColorScheme+"</span>";
colorSchemeDefault = true;
}
if (noEdit === false) {
startEdit += "<tr id=\"" + this.IDs.IDPrefixEdit + this.IDs.IDPrefixSystemContent + TTIX + "_" + InfoboxColorSchemeText.replace(/ /g, "_") + "\" class=\"InfoboxRow\"><td class=\"InfoboxCellLeft\">" + InfoboxColorSchemeText + "</td><td class=\"InfoboxCellRight\"><div id=\"" + this.IDs.IDPrefixEdit + this.IDs.IDPrefixContentContainer + TTIX + InfoboxColorSchemeText.replace(/ /g, "_") + "\" >" + colorSchemeSelect + "</div></td></tr>";
//Output for modules list
var c, availableModulesList, moduleCheckboxTitle, moduleCheckboxTitleRE, moduleCheckboxName, moduleCheckboxValue, moduleCheckboxText, moduleCheckbox, checkedCheckbox, modulesSplit, counterIndex, counterValue, counter, colsNo;
var availableModulesCheckboxes = "";
var moduleCheckboxTitlePrefixRE = new RegExp(InfoboxPrefixInfoboxModule.replace(/ /g, "_")+"_","");
var InfoboxPrefixInfoboxModuleRE = new RegExp(InfoboxPrefixInfoboxModule.replace(/ /g, "_"),"");
var availableModules = store.getTaggedTiddlers(InfoboxPrefixInfobox+"_"+Type.replace(/ /g, "_")); //Get available modules
if (availableModules.length) { //If there are modules
var availableModulesLength = availableModules.length;
for (c = 0; c < availableModulesLength; c+=1) { //Go through available modules
if (!availableModules[c].isTagged(InfoboxTagsBackup)) { //If it is not a backup
moduleCheckboxTitle = availableModules[c].title;
moduleCheckboxName = moduleCheckboxTitle.replace(InfoboxPrefixInfoboxModuleRE, InfoboxPrefixModules);
moduleCheckboxValue = moduleCheckboxTitle;
moduleCheckboxText = moduleCheckboxValue.replace(moduleCheckboxTitlePrefixRE, "").replace(/_/g, " ");
moduleCheckboxTitleRE = new RegExp("(?:^|,)"+moduleCheckboxTitle+"(?:,|$)");
if (Modules.match(moduleCheckboxTitleRE)) { //Make sure the selected checkboxes are checked
modulesSplit = Modules.split(",");
counterIndex = modulesSplit.indexOf(moduleCheckboxTitle)+1;
counterValue = modulesSplit[counterIndex];
checkedCheckbox = " checked=\"checked\"";
counter = " value=\""+counterValue+"\"";
}
else {
checkedCheckbox = "";
counter = " value=\"0\" disabled=\"disabled\" style=\"display: none;\"";
}
moduleCheckbox = "<span class=\"InfoboxCheckboxContainer\"><span class=\"InfoboxCheckboxLabel\"><label for=\"" + this.IDs.IDPrefixModuleCheckbox + TTIX + "_"+ moduleCheckboxName + "\"><input type=\"checkbox\" id=\"" + this.IDs.IDPrefixModuleCheckbox + TTIX + "_"+ moduleCheckboxName + "\" name=\"" + this.IDs.IDPrefixModuleCheckbox + TTIX + "_"+ moduleCheckboxName + "\" value=\"" + moduleCheckboxValue + "\"" + checkedCheckbox + " onchange=\"config.macros.infobox.toggleInstanceCounter('" + this.IDs.IDPrefixModuleCheckboxCounter + TTIX + "_"+ moduleCheckboxName + "'); config.macros.infobox.toggleModule('"+moduleCheckboxText+"','"+Modules+"','"+saveButton.id+"','"+editButton.id+"','"+deleteButton.id+"','"+showHideEditModeButton.id+"','"+showHideLinesInEditModeButton.id+"','"+InfoboxTableDiv.id+"','"+templateListOuterContainerDiv.id+"','"+InfoboxTableEditDiv.id+"','"+tiddler.title+"','"+TTIX+"');\">" + moduleCheckboxText + "</label> </span><span class=\"InfoboxCheckboxCounter\"><input type=\"number\" class=\"InfoboxEditInstanceCounterInput\" id=\"" + this.IDs.IDPrefixModuleCheckboxCounter + TTIX + "_"+ moduleCheckboxName + "\" name=\"" + this.IDs.IDPrefixModuleCheckboxCounter + TTIX + "_"+ moduleCheckboxName + "\" min=\"1\"" + counter + " onchange=\"config.macros.infobox.changeNumberOfInstances(this,'"+Modules+"','"+counterIndex+"','"+saveButton.id+"','"+editButton.id+"','"+deleteButton.id+"','"+showHideEditModeButton.id+"','"+showHideLinesInEditModeButton.id+"','"+InfoboxTableDiv.id+"','"+templateListOuterContainerDiv.id+"','"+InfoboxTableEditDiv.id+"','"+tiddler.title+"','"+TTIX+"');\"></span></span><br/>"; //Generate the checkboxes
availableModulesCheckboxes += moduleCheckbox;
} //End if it is not a backup
} //End go through available modules
//Determine the number of columns for modules
if (availableModulesLength < (numberOfCheckboxesPerColumn+1)) {
colsNo = 1;
}
else if ((availableModulesLength > numberOfCheckboxesPerColumn) && (availableModulesLength < ((numberOfCheckboxesPerColumn*2)+1))) {
colsNo = 2;
}
else if ((availableModulesLength > (numberOfCheckboxesPerColumn*2)) && (availableModulesLength < ((numberOfCheckboxesPerColumn*3)+1))) {
colsNo = 3;
}
else if (availableModulesLength > (numberOfCheckboxesPerColumn*3)) {
colsNo = 4;
}
availableModulesList = "<div class=\"InfoboxColumns"+colsNo+"\">"+availableModulesCheckboxes+"</div>"; //Output the checkboxes
} //End if there are modules
else {
availableModulesList = "<span class=\"InfoboxHeaderParams\">"+this.texts.infoboxNoModules+"</span>"; //Message if there are no modules
}
startEdit += "<tr id=\"" + this.IDs.IDPrefixEdit + this.IDs.IDPrefixSystemContent + TTIX + "_" + InfoboxParamModulesText.replace(/ /g, "_") + "\" class=\"InfoboxRow\"><td class=\"InfoboxCellLeft\">" + InfoboxParamModulesText + "</td><td class=\"InfoboxCellRight\">" + availableModulesList + "</td></tr>";
}
//Output for content of edit mode table
var outEdit = "";
//Output for end of edit mode table
var endEdit = "</table></div></html>";
var validTypesList;
if (validTypes.length) { //Display valid types
validTypesList = validTypes.toString().replace(/,/g, ", ");
}
else { //Display message that no infobox templates were found
validTypesList = this.texts.infoboxNoTemplates;
}
//If Type is missing
if ((Type === InfoboxDefaultValueUnknown) || (Type === null) || !Type.length) {
wikify("{{InfoboxError{"+this.texts.infoboxMandatoryType.format([validTypesList])+"}}}", errorsDiv);
//editButton.style.display = "none";//karamba
contentDiv.style.width = "33%";
errorsDiv.style.display = "block";
infoboxDiv.style.display = "none";
noEdit = true;
}
//If Type is wrong
else if (validTypes.indexOf(Type) === -1) {
wikify("{{InfoboxError{"+this.texts.infoboxNonExistentType.format([validTypesList])+"}}}", errorsDiv);
//editButton.style.display = "none";//karamba
contentDiv.style.width = "33%";
errorsDiv.style.display = "block";
infoboxDiv.style.display = "none";
noEdit = true;
}
//If Type is okay
else if (validTypes.indexOf(Type) !== -1) {
//Check how many instances of the same type there are in a tiddler
var instanceCheck = store.getTiddlerText(tiddler.title);
var instanceInfobox = instanceCheck.match(/<<infobox/g); //Find all instances of the macro in the tiddler
if (instanceInfobox.length > 1) { //If there is more than one instance
var instanceInfoboxTypeAllRE = new RegExp("<<infobox[\\w\\W\\s]*?"+InfoboxTypeParam+":\"[\\w\\s]*?\"[\\w\\W\\s]*?>>", "g");
var instanceInfoboxTypeSingle;
var instanceInfoboxType = instanceCheck.match(instanceInfoboxTypeAllRE); //Get all infoboxes
var instanceInfoboxTypeResultEmpty = [];
var instanceInfoboxTypeResult = [];
var instanceInfoboxTypeLength = instanceInfoboxType.length;
var l;
for (l = 0; l < instanceInfoboxTypeLength; l+=1) {
instanceInfoboxTypeSingle = InfoboxTypeParam+":\"" + Type + "\"";
if ((instanceInfoboxType[l].indexOf(instanceInfoboxTypeSingle) !== -1) && (InstanceID === InfoboxDefaultValueDefaultID || InstanceID === null || InstanceID.length === 0) && (instanceInfoboxType[l].indexOf("\""+Type+"\"") !== -1)) { //If the infobox matches the type and does not have an InstanceID parameter, put it into array
instanceInfoboxTypeResultEmpty.push(instanceInfoboxType[l]);
}
if ((instanceInfoboxType[l].indexOf(instanceInfoboxTypeSingle) !== -1) && !(InstanceID === InfoboxDefaultValueDefaultID || InstanceID === null || InstanceID.length === 0) && (instanceInfoboxType[l].indexOf("\""+Type+"\"") !== -1)) { //If the infobox matches the type and has an InstanceID parameter, put it into array
instanceInfoboxTypeResult.push(instanceInfoboxType[l]);
}
}
if (instanceInfoboxTypeResultEmpty.length > 1) { //If there is more than one infobox without the InstanceID parameter
var InstanceIDCount = 0;
var m, instanceInfoboxTypeResultEmptyMatchInstanceIDRE;
var instanceInfoboxTypeResultEmptyLength = instanceInfoboxTypeResultEmpty.length;
for (m = 0; m < instanceInfoboxTypeResultEmptyLength; m+=1) { //Count the number or missing InstanceID parameters
instanceInfoboxTypeResultEmptyMatchInstanceIDRE = new RegExp(InfoboxInstanceIDParam+":\"[\\w\\s]*?\"", "g");
if (instanceInfoboxTypeResultEmpty[m].match(instanceInfoboxTypeResultEmptyMatchInstanceIDRE) !== null) {
InstanceIDCount = InstanceIDCount + 1;
}
}
if (instanceInfoboxType.length > InstanceIDCount) { //If there are more infoboxes than InstanceID parameters per type
if (InstanceID === InfoboxDefaultValueDefaultID || InstanceID === null || InstanceID.length === 0) { //Display error message for all infoboxes without an InstanceID parameter
wikify("{{InfoboxError Infobox" + TypeX + InfoboxColorScheme + "Error{"+this.texts.infoboxTooManyIDs.format([instanceInfoboxTypeResultEmpty.length,Type,InstanceIDCount,"~"+InfoboxInstanceIDParam])+"}}}", errorsDiv);
//editButton.style.display = "none";//karamba
contentDiv.style.width = "33%";
errorsDiv.style.display = "block";
infoboxDiv.style.display = "none";
noEdit = true;
return;
}
}
} //End missing InstanceID check
//Check for duplicate InstanceID parameters for a type
var InstanceIDs = [];
var n, InstanceIDMatch, instanceInfoboxTypeResultMatchInstaceIDRE;
if (instanceInfoboxTypeResult.length > 1) { //If there is more than one infobox with the InstanceID parameter
var instanceInfoboxTypeResultLength = instanceInfoboxTypeResult.length;
for (n = 0; n < instanceInfoboxTypeResultLength; n+=1) { //Count the number or InstanceID parameters
instanceInfoboxTypeResultMatchInstaceIDRE = new RegExp(InfoboxInstanceIDParam+":\"[\\w\\s]*?\"", "g");
if ((instanceInfoboxTypeResult[n].match(instanceInfoboxTypeResultMatchInstaceIDRE) !== null) && !(InstanceID === InfoboxDefaultValueDefaultID || InstanceID === null || InstanceID.length === 0)) {
InstanceIDMatch = instanceInfoboxTypeResult[n].match(instanceInfoboxTypeResultMatchInstaceIDRE);
InstanceIDs.push(InstanceIDMatch);
}
}
var InstanceIDsSorted = InstanceIDs.sort();
var duplicateIDs = [];
var o;
var InstanceIDsSortedLength1 = InstanceIDsSorted.length-1;
for (o = 0; o < InstanceIDsSortedLength1; o+=1) { //Find the duplicates
if (InstanceIDsSorted[o].toString() === InstanceIDsSorted[o+1].toString()) {
duplicateIDs.push(InstanceIDsSorted[o]);
}
}
if (duplicateIDs.length > 0) {
wikify("{{InfoboxError Infobox" + TypeX + InfoboxColorScheme + "Error{"+this.texts.infoboxDuplicateParams.format(["~"+InfoboxInstanceIDParam,InstanceID,Type])+"}}}", errorsDiv);
//editButton.style.display = "none";//karamba
contentDiv.style.width = "33%";
errorsDiv.style.display = "block";
infoboxDiv.style.display = "none";
noEdit = true;
return;
}
} //End duplicate check
} //End of checks when there's more than one instance
//Begin parsing parameters for output
//Global template
var globalParamList, globalTemplateDelimiter, getGlobalUnnamedSections, unnamedGlobalMatches;
var getGlobalUnnamedSectionsRE = new RegExp(prefixSection+"-\\n","");
var prefixInfoboxRE = new RegExp(InfoboxPrefixInfobox+"_", ""); //Remove global template prefix
if (store.getTiddlerText(globalParametersTemplate).match("!"+ContentSectionContent) !== null) { //Get global parameters
globalParamList = store.getTiddlerText(globalParametersTemplate+"##"+ContentSectionContent);
}
else {
globalParamList = store.getTiddlerText(globalParametersTemplate);
}
if ((globalParamList === null) || (globalParamList === undefined) || (!globalParamList.length)) {
globalParamList = "";
}
else {
getGlobalUnnamedSections = globalParamList.match(getGlobalUnnamedSectionsRE); //Get unnamed sections
unnamedGlobalMatches = 1;
if (getGlobalUnnamedSections !== null) { //If there are unnamed sections
while (globalParamList.match(getGlobalUnnamedSectionsRE) !== null) { //Replace all unnamed sections with the descriptor and a sequential number within the global parameters template
globalParamList = globalParamList.replace(getGlobalUnnamedSections, prefixSection+"-"+this.texts.infoboxUnnamedSection+" "+unnamedGlobalMatches+"\n");
unnamedGlobalMatches = unnamedGlobalMatches + 1;
}
}
if (showTemplateDelimiter === true) {
globalTemplateDelimiter = templateDelimiter+"-"+globalParametersTemplate.replace(prefixInfoboxRE, "").replace(/_/g, " ")+"\n"; //Template delimiter
}
else {
globalTemplateDelimiter = "";
}
globalParamList = globalTemplateDelimiter+InfoboxPrefixGlobal+"!"+globalParamList.replace(/\n/g, "\n"+InfoboxPrefixGlobal+"!").replace(/\+\+([\W\w\s]*?)\+\+/g, "\+\+"+InfoboxPrefixGlobal+"!$1\+\+").replace(/\(\(([\W\w\s]*?)\)\)/g, "\(\("+InfoboxPrefixGlobal+"!$1\)\)")+"\n----\n";
}
//Settings for includes (used by the modules and the main template)
var includedModulesRE, includedModuleIndex, includedModuleInstances, includeName, includeNameParam, includeParams, includeTid, includePrefixes, availableIncludes;
//var includePrefixRE = new RegExp(InfoboxPrefixInfoboxInclude.replace(/ /g, "_"),"g"); //Include template prefix//karamba
var includePrefixRE = new RegExp(InfoboxPrefixInfoboxInclude,"g"); //Include template prefix
var includeParamsRE = new RegExp(prefixInclude+"-[^\\n$]*?(?:\\n|$)", "");
var includeParamsPrefixedRE = new RegExp("(?:[^\\n]*?!)?"+prefixInclude+"-[^\\n$]*?(?:\\n|$)", "");
//var prefixIncludeRE = new RegExp(prefixInclude+"-|\\n", "g");//karamba
var prefixIncludeRE = new RegExp(prefixInclude+"-|(?:_\\(\\([^\\n]*?|_\\*\\*[^\\n]*?)?(?:\\n|$)", "g");
var allIncludes = store.getTaggedTiddlers(infoboxTagsInfoboxInclude); //Get available includes
var allIncludesLength = allIncludes.length;
//Modules
var e, g, h, ModulesSplit, ModulesSplitCleaned, delimiterModule, getModule, moduleName, moduleNameParam, moduleNameRE, unnamedModuleMatches, relevantModules, moduleIncludes, noModules;
var modulesParamsList = "";
var modulePrefixRE = new RegExp(InfoboxPrefixInfoboxModule.replace(/ /g, "_"),"g"); //Module prefix
var getModuleUnnamedSectionsRE = new RegExp(prefixSection+"-\\n",""); //Module unnamed sections
var modulesListInfoboxPrefixInfoboxModuleRE = new RegExp(InfoboxPrefixInfoboxModule.replace(/ /g, "_")+"_","");
var mainTemplate = InfoboxPrefixInfobox+"_" + Type.replace(/ /g, "_");
var allModules = store.getTaggedTiddlers(infoboxTagsInfoboxModule); //Get available modules
var allModulesLength = allModules.length;
var moduleListButtons = [];
if (Modules.length) { //If there are included modules
ModulesSplit = Modules.split(",");
var ModulesSplitLength = ModulesSplit.length;
for (e = 0; e < ModulesSplitLength; e+=2) { //Get module parameters
moduleListButtons.push("*{{infoboxTemplateLinkModule{[["+ModulesSplit[e].replace(modulesListInfoboxPrefixInfoboxModuleRE, "").replace(/_/g, " ")+"|"+ModulesSplit[e]+"]]}}}");
moduleIncludes = [];
if ((ModulesSplit[e+1] === undefined) || isNaN(Math.abs(Math.round(ModulesSplit[e+1])))) { //Check if the number of instances is set and valid
wikify("{{InfoboxError{"+this.texts.infoboxModuleInstanceNaN.format([InfoboxParamModulesParam])+"}}}", errorsDiv);
contentDiv.style.width = "33%";
errorsDiv.style.display = "block";
infoboxDiv.style.display = "none";
return;
}
if (!store.getTiddler(ModulesSplit[e])) { //Check if module exists
relevantModules = [];
for (g = 0; g < allModulesLength; g+=1) { //Get module parameters
if (allModules[g].isTagged(mainTemplate) && !allModules[g].isTagged(InfoboxTagsBackup)) { //If it is tagged with main template title and not a backup
relevantModules.push(allModules[g].title);
}
}
wikify("{{InfoboxError{"+this.texts.infoboxNonExistentModule.format([ModulesSplit[e],relevantModules.toString().replace(/,/g, ", ")])+"}}}", errorsDiv);
contentDiv.style.width = "33%";
errorsDiv.style.display = "block";
infoboxDiv.style.display = "none";
return;
} //End check if module exists
//if (store.getTiddler(ModulesSplit[e]).text.match("!"+ContentSectionContent) !== null) { //Get module parameters//karamba
if (store.getTiddlerText(ModulesSplit[e]).match("!"+ContentSectionContent) !== null) { //Get module parameters
getModule = store.getTiddlerText(ModulesSplit[e]+"##"+ContentSectionContent);
}
else {
getModule = store.getTiddlerText(ModulesSplit[e]);
}
moduleNameRE = new RegExp(InfoboxPrefixInfoboxModule.replace(/ /g, "_")+"_",""); //Module name
moduleNameParam = ModulesSplit[e].replace(moduleNameRE, ""); //Module name
moduleName = moduleNameParam.replace(/_/g, " ");
while (getModule.match(includeParamsRE) !== null) { //Process includes
includePrefixes = getModule.match(includeParamsPrefixedRE).toString().replace(includeParamsRE, "");
//includeName = getModule.match(includeParamsRE).toString().replace(prefixIncludeRE, "").replace(/ /g, "_").replace(/_\(\([\w\W\s]*?|_\*\*[\w\W\s]*?/g, ""); //Get include name//karamba
//includeNameParam = getModule.match(includeParamsRE).toString().replace(prefixIncludeRE, "").replace(/_\(\([\w\W\s]*?|_\*\*[\w\W\s]*?/g, ""); //Get include name//karamba
includeNameParam = getModule.match(includeParamsRE).toString().replace(prefixIncludeRE, ""); //Get include name
includeName = includeNameParam.replace(/_/g, " "); //Get include name
//if (!store.getTiddler(includeName)) { //Check if include exists//karamba
if (!store.getTiddler(includeNameParam)) { //Check if include exists
availableIncludes = [];
for (g = 0; g < allIncludesLength; g+=1) { //Get includes
if (!allIncludes[g].isTagged(InfoboxTagsBackup)) { //If it is not a backup
availableIncludes.push(allIncludes[g].title);
}
}
//wikify("{{InfoboxError{"+this.texts.infoboxNonExistentInclude.format([includeName,availableIncludes.toString().replace(/,/g, ", ")])+"}}}", errorsDiv);//karamba
wikify("{{InfoboxError{"+this.texts.infoboxNonExistentInclude.format([includeNameParam,availableIncludes.toString().replace(/,/g, ", ")])+"}}}", errorsDiv);
contentDiv.style.width = "33%";
errorsDiv.style.display = "block";
infoboxDiv.style.display = "none";
return;
} //End check if include exists
moduleIncludes.push("**"+includePrefixes.replace(/[^!]/g, "").replace(/!/g, "*")+includeName+"|"+includeNameParam+"]]}}}");
//if (store.getTiddler(includeName).text.match("!"+ContentSectionContent) !== null) { //Get included params//karamba
//if (store.getTiddler(includeNameParam).text.match("!"+ContentSectionContent) !== null) { //Get included params//karamba
if (store.getTiddlerText(includeNameParam).match("!"+ContentSectionContent) !== null) { //Get included params
//includeTid = store.getTiddlerText(includeName+"##"+ContentSectionContent);//karamba
includeTid = store.getTiddlerText(includeNameParam+"##"+ContentSectionContent);
}
else {
//includeTid = store.getTiddlerText(includeName);//karamba
includeTid = store.getTiddlerText(includeNameParam);
}
//if (includeTid.match("(?:^|\n)[^\n]*!"+prefixSection+"-") !== null) {
if (includeTid.match("^[^\n]*!"+prefixSection+"-") !== null) {
includeTid = "----\n"+includeTid; //Extra section separator for includes
}
includeParams = includeDelimiterStart+"-"+includeName.replace(includePrefixRE, InfoboxPrefixIncludes)+"\n"+includeTid.replace(/(^|\n)/g, "$1"+includePrefixes+includeName.replace(includePrefixRE, InfoboxPrefixIncludes).replace(modulePrefixRE, InfoboxPrefixModules)+"!").replace(/\+\+([\W\w\s]*?)\+\+/g, "\+\+"+includePrefixes+includeName.replace(includePrefixRE, InfoboxPrefixIncludes).replace(modulePrefixRE, InfoboxPrefixModules)+"!$1\+\+").replace(/\(\(([\W\w\s]*?)\)\)/g, "\(\("+includePrefixes+includeName.replace(includePrefixRE, InfoboxPrefixIncludes).replace(modulePrefixRE, InfoboxPrefixModules)+"!$1\)\)")+"\n"+includeDelimiterEnd+"-"+includeName.replace(includePrefixRE, InfoboxPrefixIncludes)+"\n";
// if (includeParams.match("(?:^|\n)[^\n]*!"+prefixSection+"-") !== null) {//karamba
// includeParams = "----\n"+includeParams; //Extra section separator for includes
//
getModule = getModule.replace(includeParamsPrefixedRE, includeParams).replace(/\n$/, ""); //The last line break needs to be removed, so it doesn't trigger a new section
} //End process includes
moduleListButtons.push(moduleIncludes.toString().replace(/((?:\*)+)/g, "$1{{infoboxTemplateLinkModuleInclude{[[").replace(/,/g, "\n"));
unnamedModuleMatches = 1; //Start numbering at one for each module/instance
while (getModule.match(getModuleUnnamedSectionsRE) !== null) { //Replace all unnamed sections with the descriptor and a sequential number within each module template
getModule = getModule.replace(getModuleUnnamedSectionsRE, prefixSection+"-"+this.texts.infoboxUnnamedSection+" "+unnamedModuleMatches+"\n");
unnamedModuleMatches = unnamedModuleMatches + 1;
}
for (h = 1; h < (+ModulesSplit[e+1]+1); h+=1) { //Make multiple instances
if ((h === 1) && (showTemplateDelimiter === true)) {
//delimiterModule = templateDelimiter+"-"+moduleName+"_"+h+"\n"; //Template delimiter//karamba
delimiterModule = templateDelimiter+"-"+moduleName+" "+h+"\n"; //Template delimiter
}
else if (showInstanceDelimiter === true) {
//delimiterModule = moduleDelimiter+"-"+moduleName+"_"+h+"\n"; //Module delimiter//karamba
delimiterModule = moduleDelimiter+"-"+moduleName+" "+h+"\n"; //Module delimiter
}
else {
delimiterModule = "";
}
//modulesParamsList += "\n----\n"+delimiterModule+InfoboxPrefixModules+"_"+moduleName+"_"+InfoboxSuffixModules+"_"+h+"!"+getModule.replace(/^[^\n]*?----\n/g, "").replace(/\n[^\n]*?----$/g, "").replace(/\n/g, "\n"+InfoboxPrefixModules+"_"+moduleName+"_"+InfoboxSuffixModules+"_"+h+"!").replace(/\+\+([\W\w\s]*?)\+\+/g, "\+\+"+InfoboxPrefixModules+"_"+moduleName+"_"+InfoboxSuffixModules+"_"+h+"!$1\+\+").replace(/\(\(([\W\w\s]*?)\)\)/g, "\(\("+InfoboxPrefixModules+"_"+moduleName+"_"+InfoboxSuffixModules+"_"+h+"!$1\)\)").replace(/([^\n]*?----\n)+/g, "----\n");//karamba
modulesParamsList += "\n----\n"+delimiterModule+InfoboxPrefixModules+" "+moduleName+" "+InfoboxSuffixModules+" "+h+"!"+getModule.replace(/^[^\n]*?----\n/g, "").replace(/\n[^\n]*?----$/g, "").replace(/\n/g, "\n"+InfoboxPrefixModules+" "+moduleName+" "+InfoboxSuffixModules+" "+h+"!").replace(/\+\+([\W\w\s]*?)\+\+/g, "\+\+"+InfoboxPrefixModules+" "+moduleName+" "+InfoboxSuffixModules+" "+h+"!$1\+\+").replace(/\(\(([\W\w\s]*?)\)\)/g, "\(\("+InfoboxPrefixModules+" "+moduleName+" "+InfoboxSuffixModules+" "+h+"!$1\)\)").replace(/([^\n]*?----\n)+/g, "----\n");}
} //End get module parameters
} //End if there are included modules
else {
noModules = this.texts.infoboxNoModules;
moduleListButtons.push(noModules);
}
//console.log(moduleIncludes);
/*karamba backup for modules
if (allModules.length) { //If there are modules
for (e = 0; e < allModulesLength; e+=1) { //Get module parameters
if (!allModules[e].isTagged(InfoboxTagsBackup)) { //If it is not a backup
if (Modules.length) { //Get the list of modules
includedModulesRE = new RegExp(ModulesSplitCleaned.toString().replace(/,/g, "|")); //Included modules
if (allModules[e].title.match(includedModulesRE)) { //Get included modules
includedModuleIndex = ModulesSplit.indexOf(allModules[e].title); //Get index of included module
includedModuleInstances = ModulesSplit[includedModuleIndex+1]; //Get the number of instance of included module
if (allModules[e].text.match("!"+ContentSectionContent) !== null) { //Get module parameters
getModule = store.getTiddlerText(allModules[e].title+"##"+ContentSectionContent);
}
else {
getModule = store.getTiddlerText(allModules[e].title);
}
moduleNameRE = new RegExp(InfoboxPrefixInfoboxModule.replace(/ /g, "_")+"_",""); //Module name
moduleName = allModules[e].title.replace(moduleNameRE, ""); //Module name
while (getModule.match(includeParamsRE) !== null) { //Include other modules
includePrefixes = getModule.match(includeParamsPrefixedRE).toString().replace(includeParamsRE, "");
includeName = getModule.match(includeParamsRE).toString().replace(prefixIncludeRE, "").replace(/ /g, "_").replace(/_\(\([\w\W\s]*?|_\*\*[\w\W\s]*?/g, ""); //Get included module name
//karamba do the existence check here
if (store.getTiddler(includeName).text.match("!"+ContentSectionContent) !== null) { //Get included module params
includeTid = store.getTiddlerText(includeName+"##"+ContentSectionContent);
}
else {
includeTid = store.getTiddlerText(includeName);
}
includeParams = includeTid.replace(/(^|\n)/g, "$1"+includePrefixes+includeName.replace(includePrefixRE, InfoboxPrefixIncludes).replace(modulePrefixRE, InfoboxPrefixModules)+"!").replace(/\+\+([\W\w\s]*?)\+\+/g, "\+\+"+includePrefixes+includeName.replace(includePrefixRE, InfoboxPrefixIncludes).replace(modulePrefixRE, InfoboxPrefixModules)+"!$1\+\+").replace(/\(\(([\W\w\s]*?)\)\)/g, "\(\("+includePrefixes+includeName.replace(includePrefixRE, InfoboxPrefixIncludes).replace(modulePrefixRE, InfoboxPrefixModules)+"!$1\)\)")+"\n----\n";
if (includeParams.match("(?:^|\n)[^\n]*!"+prefixSection+"-") !== null) {
includeParams = "----\n"+includeParams; //Extra section separator for includes
}
getModule = getModule.replace(includeParamsPrefixedRE, includeParams).replace(/\n$/, ""); //The last line break needs to be removed, so it doesn't trigger a new section
}
unnamedModuleMatches = 1; //Start numbering at one for each module/instance
while (getModule.match(getModuleUnnamedSectionsRE) !== null) { //Replace all unnamed sections with the descriptor and a sequential number within each module template
getModule = getModule.replace(getModuleUnnamedSectionsRE, prefixSection+"-"+this.texts.infoboxUnnamedSection+" "+unnamedModuleMatches+"\n");
unnamedModuleMatches = unnamedModuleMatches + 1;
}
for (h = 1; h < (+includedModuleInstances+1); h+=1) { //Make multiple instances
if ((h === 1) && (showTemplateDelimiter === true)) {
delimiterModule = templateDelimiter+"-"+moduleName+"_"+h+"\n"; //Template delimiter
}
else if (showInstanceDelimiter === true) {
delimiterModule = moduleDelimiter+"-"+moduleName+"_"+h+"\n"; //Module delimiter
}
else {
delimiterModule = "";
}
modulesParamsList += "\n----\n"+delimiterModule+InfoboxPrefixModules+"_"+moduleName+"_"+InfoboxSuffixModules+"_"+h+"!"+getModule.replace(/^[^\n]*?----\n/g, "").replace(/\n[^\n]*?----$/g, "").replace(/\n/g, "\n"+InfoboxPrefixModules+"_"+moduleName+"_"+InfoboxSuffixModules+"_"+h+"!").replace(/\+\+([\W\w\s]*?)\+\+/g, "\+\+"+InfoboxPrefixModules+"_"+moduleName+"_"+InfoboxSuffixModules+"_"+h+"!$1\+\+").replace(/\(\(([\W\w\s]*?)\)\)/g, "\(\("+InfoboxPrefixModules+"_"+moduleName+"_"+InfoboxSuffixModules+"_"+h+"!$1\)\)").replace(/([^\n]*?----\n)+/g, "----\n");
}
}
} //End get the list of modules
} //End if it is not a backup
} //End get module parameters
} //End if there are modules
*/
//Main template
var specificParamList = store.getTiddlerText(InfoboxPrefixInfobox+"_" + Type.replace(/[\s]/g, "_") + "##"+ContentSectionContent); //Get specific parameters
var getSpecificUnnamedSectionsRE = new RegExp(prefixSection+"-\\n","");
var infoboxIncludes = [];
while (specificParamList.match(includeParamsRE) !== null) { //Process includes
includePrefixes = specificParamList.match(includeParamsPrefixedRE).toString().replace(includeParamsRE, "");
//includeNameParam = specificParamList.match(includeParamsRE).toString().replace(prefixIncludeRE, "").replace(/_\(\([\w\W\s]*?|_\*\*[\w\W\s]*?/g, ""); //Get include name//karamba
includeNameParam = specificParamList.match(includeParamsRE).toString().replace(prefixIncludeRE, ""); //Get include name
includeName = includeNameParam.replace(/_/g, " "); //Get include name
//if (!store.getTiddler(includeName)) { //Check if include exists//karamba
if (!store.getTiddler(includeNameParam)) { //Check if include exists
availableIncludes = [];
for (g = 0; g < allIncludesLength; g+=1) { //Get includes
if (!allIncludes[g].isTagged(InfoboxTagsBackup)) { //If it is not a backup
availableIncludes.push(allIncludes[g].title);
}
}
wikify("{{InfoboxError{"+this.texts.infoboxNonExistentInclude.format([includeNameParam,availableIncludes.toString().replace(/,/g, ", ")])+"}}}", errorsDiv);
contentDiv.style.width = "33%";
errorsDiv.style.display = "block";
infoboxDiv.style.display = "none";
return;
} //End check if include exists
infoboxIncludes.push("*"+includePrefixes.replace(/[^!]/g, "").replace(/!/g, "*")+includeName+"|"+includeNameParam+"]]}}}");
//if (store.getTiddler(includeName).text.match("!"+ContentSectionContent) !== null) { //Get included params//karamba
//if (store.getTiddler(includeNameParam).text.match("!"+ContentSectionContent) !== null) { //Get included params//karamba
if (store.getTiddlerText(includeNameParam).match("!"+ContentSectionContent) !== null) { //Get included params
//includeTid = store.getTiddlerText(includeName+"##"+ContentSectionContent);//karamba
includeTid = store.getTiddlerText(includeNameParam+"##"+ContentSectionContent);
}
else {
//includeTid = store.getTiddlerText(includeName);//karamba
includeTid = store.getTiddlerText(includeNameParam);
}
//if (includeTid.match("(?:^|\n)[^\n]*!"+prefixSection+"-") !== null) {//karamba
if (includeTid.match("^[^\n]*!"+prefixSection+"-") !== null) {
includeTid = "----\n"+includeTid; //Extra section separator for includes
}
includeParams = includeDelimiterStart+"-"+includeName.replace(includePrefixRE, InfoboxPrefixIncludes)+"\n"+includeTid.replace(/(^|\n)/g, "$1"+includePrefixes+includeName.replace(includePrefixRE, InfoboxPrefixIncludes)+"!").replace(/\+\+([\W\w\s]*?)\+\+/g, "\+\+"+includePrefixes+includeName.replace(includePrefixRE, InfoboxPrefixIncludes)+"!$1\+\+").replace(/\(\(([\W\w\s]*?)\)\)/g, "\(\("+includePrefixes+includeName.replace(includePrefixRE, InfoboxPrefixIncludes)+"!$1\)\)")+"\n"+includeDelimiterEnd+"-"+includeName.replace(includePrefixRE, InfoboxPrefixIncludes)+"\n";
// if (includeParams.match("(?:^|\n)[^\n]*!"+prefixSection+"-") !== null) {//karamba
// includeParams = "----\n"+includeParams; //Extra section separator for includes
// }
specificParamList = specificParamList.replace(includeParamsPrefixedRE, includeParams).replace(/\n$/, ""); //The last line break needs to be removed, so it doesn't trigger a new section
} //End process includes
var getSpecificUnnamedSections = specificParamList.match(getSpecificUnnamedSectionsRE); //Get unnamed sections
var specificTemplateDelimiter;
var unnamedSpecificMatches = 1;
if (getSpecificUnnamedSections !== null) { //Replace all unnamed sections with the descriptor and a sequential number within the specific template
while (specificParamList.match(getSpecificUnnamedSectionsRE) !== null) { //Replace all unnamed sections with the descriptor and a sequential number within each module template
specificParamList = specificParamList.replace(getSpecificUnnamedSections, prefixSection+"-"+this.texts.infoboxUnnamedSection+" "+unnamedSpecificMatches+"\n");
unnamedSpecificMatches = unnamedSpecificMatches + 1;
}
}
if (showTemplateDelimiter === true) {
specificTemplateDelimiter = templateDelimiter+"-"+Type+"\n"; //Template delimiter
}
else {
specificTemplateDelimiter = "";
}
//Parse the parameters
paramList = globalParamList+specificTemplateDelimiter+specificParamList+modulesParamsList; //All parameters
var paramPrefixes = "(?:"+InfoboxPrefixGlobal+"!|"+InfoboxPrefixModules+"_[^\n\*]*!|"+InfoboxPrefixIncludes+"_[^\n\*]*!)?";
//var includePrefix = "(?:"+InfoboxPrefixIncludes+"_[^!]*!)";//karamba
//var includePrefixRE = new RegExp(includePrefix, "g");//karamba
var paramPrefixesRE = new RegExp(paramPrefixes,"");
var paramPrefixesEditRE = new RegExp("(^"+paramPrefixes.replace(/_/g, " ")+")([\\w\\W\\s]*?$)","g");
var paramListRE = new RegExp(paramPrefixes+"?----\\n","g"); //Question mark makes the string optional
var paramListParsed = paramList.replace(paramListRE, "").replace(/ /g, "_").split("\n");
var paramListParsedCleaned = [];
var paramCount = 0;
var prefixes = prefixSection+"-|"+prefixImage+"-|"+prefixSingle+"-|"+prefixSide+"\\d-|"+prefixThree+"\\d-|"+prefixFour+"\\d-";
var prefixesRE = new RegExp(prefixes, "");
var commentsRE = new RegExp("(?:"+prefixes+"|^)[\\w\\W\\s]*?\\*\\*", "g");
var ParamNameRE = new RegExp("_\\(\\([\\w\\W\\s]*?\\)\\)|_\\*\\*[\\w\\W\\s]*?$", "g");
var EditParamNameRE = new RegExp(prefixSection+"-|_\\(\\([\\w\\W\\s]*?\\)\\)|_\\*\\*[\\w\\W\\s]*?$", "g");
var RowIDReplaceRE = ParamNameRE;
var unnamedSectionRE = new RegExp(this.texts.infoboxUnnamedSection+" \\d\{1,\}","");
var selectArray; //Make array to ensure the correct value is selected in dropdowns when entering edit mode
if (colorSchemeDefault !== true) {
selectArray = this.IDs.IDPrefixEdit + this.IDs.IDPrefixColorSchemeSelect+TTIX+","+InfoboxColorScheme;
}
var onchangeStart = " onchange=\"";
var onchangeEnd = "\"";
var onmouseoverStart = " onmouseover=\"";
var onmouseoverEnd = "\"";
var onmouseoutStart = " onmouseout=\"";
var onmouseoutEnd = "\"";
var resetOtherValue = " config.macros.infobox.resetOtherValue(this);";
var templateDelimiterRE = new RegExp(templateDelimiter+"-", "");
var moduleDelimiterRE = new RegExp(moduleDelimiter+"-", "");
var forbiddenCharsRE = new RegExp("[^<>\\|&,;!=\\-\\.\\s\\d]", "g");
var moduleNameWithSuffixRE = new RegExp("^"+InfoboxPrefixModules+"_[\\w\\W\\s]*?_"+InfoboxSuffixModules+"_\\d+");
var moduleNameCleanupRE = new RegExp(InfoboxPrefixModules+"_|_"+InfoboxSuffixModules,"g");
var k, v, w, x, s, param, param2, param3, param4, delimiter, delimiterClass, getLimits, paramView, paramEdit, comment, image, preview, imageParam, imageSrc, imageAlt, imageTitle, imageCaption, figcaptionStart, figcaptionEnd, imageLink, showFigcaption, useImageLink, figcaption, figcaptionSelected, imageLinkStart, imageLinkEnd, imageLinkSelected, figureID, EditFigureID, figureIDRE, imageID, EditImageID, imageIDRE, imageLinkRE, captionID, EditCaptionID, captionIDRE, noImageID, ParamName, EditParamName, MultipleCellID, ViewModeMultipleContentID, EditModeMultipleContentID, RowIDReplace, RowIDReplaceNext, RowIDReplacePrevious, ViewModeSectionTableID, ViewModeSectionHeaderID, ViewModeContentID, EditModeSectionTableID, EditModeSectionHeaderID, EditModeContentID, EditCommentID, EditNewLimitID, EditTextareaID, EditFigureCheckboxID, EditSelectID, EditContentContainerID, EditNoValueWarningID, EditParamNameID, EditCommentContainerID, rowClass, highlightFilledRow, singleSideRowEdit, multiSideCell, multiSideCellEdit, dropdownOptions, dropdownOptionsCountRE, dropdownOptionsCount, noValueWarning, noValueWarningClass, paramCleaned, commentText, dropdownValues, dropdownValuesSplit, dropdownValue, containerID, paramListParsedRE, dependency, dependent, onchangeContent, dependencyOnchangeMatches, dependencyOnchange, altTextareaOnchange, normalParamHover, normalParamHoverOnmouseover, normalParamHoverOnmouseout, multiSideParamHover, multiSideParamHoverOnmouseover, multiSideParamHoverOnmouseout, dependencyParamHover, dropdownDependencyParam, dependencyParamHoverOnmouseover, dependencyParamHoverOnmouseout, dependencyHovers, dropdownDependentCategories, dropdownDependencyPosition, dropdownDependencyValues, dropdownDependencyValue, dropdownDependentValuesOnly, dropdownDependencyValuePosition, dropdownCategory, dropdownStatus, textareas, previewOnchange, headerColSpan, headerColSpanEdit, fixedLayout, limitValues, limitDependencyParam, limitDependentValuesOnly, limitDependentCategories, limitDependencyPosition, limitDependencyValues, limitDependencyValue, limitStatus, limitDependencyValuePosition, limitCategory, multipleSelect, multipleLength, multipleSize, unitOfMeasure, includeBorder, templateName, delimiterType, delimiterTypeTable, dropdownValuesSplitLength, moduleNamePrefixMatch, moduleNamePrefix, hideMultiRow, oldSectionTitleIndex, sectionTitleIndex, sectionLength, sectionTitle, sectionTable, hideSection, EditIncludeDelimiterStartID, EditIncludeDelimiterEndID, EditParamPrefixID, showTop, showBottom, EditModeSectionHeaderIDNext, EditModeContentIDNext, EditModeContentIDPrevious, prefixMatch213141, prefixMatch3141, prefixMatch41, prefixMatch31, prefixMatch21, prefixMatch324243, prefixMatch223344;
var includeDepth = 1; //The initial border width
var sectionParamsCounter = 0;
var paramListParsedLength = paramListParsed.length;
for (w = 0; w < paramListParsedLength; w+=1) { //Make an array of clean parameters to use when locating dependencies
if (paramListParsed[w].match(/%%/)) { //Check if limits contain forbidden characters
getLimits = paramListParsed[w].match(/%%[\w\W\s]*?%%/).toString().replace(/_/g, " ").replace(/\+\+[\w\W\s]*?\+\+|%%/g, "");
if (getLimits.match(forbiddenCharsRE)) {
wikify("{{InfoboxError Infobox" + TypeX + InfoboxColorScheme + "Error{"+this.texts.infoboxForbiddenChars.format([getLimits.match(forbiddenCharsRE).toString().replace(/,/g, ", ")])+"\n"+this.texts.infoboxCorrectYourTemplate.format([InfoboxPrefixInfobox + "_" + Type.replace(/ /g, "_"),paramListParsed[w].replace(/_/g, " ").replace(/\s\(\([\w\W\s]*?$|\s\*\*[\w\W\s]*?$/g, "")])+"}}}", errorsDiv);
contentDiv.style.width = "33%";
errorsDiv.style.display = "block";
infoboxDiv.style.display = "none";
return;
}
}
//paramCleaned = paramListParsed[w].replace(ParamNameRE, "").replace(prefixesRE, "");//karamba
paramCleaned = paramListParsed[w].replace(ParamNameRE, "");
paramListParsedCleaned.push(paramCleaned);
}
for (k = 0; k < paramListParsedLength; k+=1) {
//Get the param value
if (paramListParsed[k].indexOf("((") !== -1) { //Params when there is a shorthand definition
param = getParam(params, paramListParsed[k].replace(/^[\W\w\s]*?\(\(|\)\)[\W\w\s]*?$/g, ""), InfoboxDefaultValueUnknown);
if (param === InfoboxDefaultValueUnknown) { //If shorthands definition doesn't get a value, try the longhand definition (if shorthands are skipped, the macro gets written with longhands on save)
param = getParam(params, paramListParsed[k].replace(/_\(\([\W\w\s]*?$/g, ""), InfoboxDefaultValueUnknown);
}
}
else { //Params when there is no shorthand definition
param = getParam(params, paramListParsed[k].replace(/_\*\*[\W\w\s]*?$/g, ""), InfoboxDefaultValueUnknown);
}
//For multi-celled rows, check params for the other cells
//prefixMatch213141 = new RegExp("(?:^|!)(?:"+prefixSide+"|"+prefixThree+"|"+prefixFour+")1-[\\w\\W]*?(?:_\\(\\(|_\\*\\*|$)", ""); //First cells//karamba
prefixMatch213141 = new RegExp("(?:^|!)(?:"+prefixSide+"|"+prefixThree+"|"+prefixFour+")1-(?![^#]*\\+\\+)", ""); //First cells
prefixMatch3141 = new RegExp("(?:^|!)(?:"+prefixThree+"|"+prefixFour+")1-[\\w\\W]*?(?![^#]*\\+\\+)", ""); //First cells
prefixMatch41 = new RegExp("(?:^|!)"+prefixFour+"1-[\\w\\W]*?(?![^#]*\\+\\+)", ""); //First cells
prefixMatch31 = new RegExp("(?:^|!)"+prefixThree+"1-[\\w\\W]*?(?![^#]*\\+\\+)", ""); //First cells
prefixMatch21 = new RegExp("(?:^|!)"+prefixSide+"1-[\\w\\W]*?(?![^#]*\\+\\+)", ""); //First cells
prefixMatch324243 = new RegExp("(?:^|!)(?:"+prefixThree+"2|"+prefixFour+"(?:2|3))-(?![^#]*\\+\\+)", ""); //Middle cells
prefixMatch223344 = new RegExp("(?:^|!)(?:"+prefixSide+"2|"+prefixThree+"3|"+prefixFour+"4)-(?![^#]*\\+\\+)", ""); //End cells
//if ((paramListParsed[k].indexOf(prefixSide+"1-") !== -1) || (paramListParsed[k].indexOf(prefixThree+"1-") !== -1) || (paramListParsed[k].indexOf(prefixFour+"1-") !== -1)) {//karamba
if (paramListParsed[k].match(prefixMatch213141)) {
//if (((paramListParsed[k].indexOf(prefixSide+"1-") !== -1) && (paramListParsed[k].indexOf(prefixSide+"2-") === -1)) || (paramListParsed[k].indexOf(prefixThree+"1-") !== -1) || (paramListParsed[k].indexOf(prefixFour+"1-") !== -1)) {
if (paramListParsed[k+1].indexOf("((") !== -1) { //Params when there is a shorthand definition
param2 = getParam(params, paramListParsed[k+1].replace(/^[\W\w\s]*?\(\(|\)\)[\W\w\s]*?$/g, ""), InfoboxDefaultValueUnknown);
if (param2 === InfoboxDefaultValueUnknown) { //If shorthands definition doesn't get a value, try the longhand definition (if shorthands are skipped, the macro gets written with longhands on save)
param2 = getParam(params, paramListParsed[k+1].replace(/_\(\([\W\w\s]*?$/g, ""), InfoboxDefaultValueUnknown);
}
}
else { //Params when there is no shorthand definition
param2 = getParam(params, paramListParsed[k+1].replace(/_\*\*[\W\w\s]*?$/g, ""), InfoboxDefaultValueUnknown);
}
}
//if ((paramListParsed[k].indexOf(prefixThree+"1-") !== -1) || (paramListParsed[k].indexOf(prefixFour+"-") !== -1)) {//karamba
if (paramListParsed[k].match(prefixMatch3141)) {
if (paramListParsed[k+2].indexOf("((") !== -1) { //Params when there is a shorthand definition
param3 = getParam(params, paramListParsed[k+2].replace(/^[\W\w\s]*?\(\(|\)\)[\W\w\s]*?$/g, ""), InfoboxDefaultValueUnknown);
if (param3 === InfoboxDefaultValueUnknown) { //If shorthands definition doesn't get a value, try the longhand definition (if shorthands are skipped, the macro gets written with longhands on save)
param3 = getParam(params, paramListParsed[k+2].replace(/_\(\([\W\w\s]*?$/g, ""), InfoboxDefaultValueUnknown);
}
}
else { //Params when there is no shorthand definition
param3 = getParam(params, paramListParsed[k+2].replace(/_\*\*[\W\w\s]*?$/g, ""), InfoboxDefaultValueUnknown);
}
}
//if (paramListParsed[k].indexOf(prefixFour+"1-") !== -1) {//karamba
if (paramListParsed[k].match(prefixMatch41)) {
if (paramListParsed[k+3].indexOf("((") !== -1) { //Params when there is a shorthand definition
param4 = getParam(params, paramListParsed[k+3].replace(/^[\W\w\s]*?\(\(|\)\)[\W\w\s]*?$/g, ""), InfoboxDefaultValueUnknown);
if (param4 === InfoboxDefaultValueUnknown) { //If shorthands definition doesn't get a value, try the longhand definition (if shorthands are skipped, the macro gets written with longhands on save)
param4 = getParam(params, paramListParsed[k+3].replace(/_\(\([\W\w\s]*?$/g, ""), InfoboxDefaultValueUnknown);
}
}
else { //Params when there is no shorthand definition
param4 = getParam(params, paramListParsed[k+3].replace(/_\*\*[\W\w\s]*?$/g, ""), InfoboxDefaultValueUnknown);
}
}
//For multi-celled rows, determine whether the row should be hidden (if all params are unknown)
//if ((paramListParsed[k].indexOf(prefixSide+"1-") !== -1) || (paramListParsed[k].indexOf(prefixThree+"1-") !== -1) || (paramListParsed[k].indexOf(prefixFour+"1-") !== -1)) {//karamba
if (paramListParsed[k].match(prefixMatch213141)) {
//if ((paramListParsed[k].indexOf(prefixSide+"1-") !== -1) && (param === InfoboxDefaultValueUnknown) && (param2 === InfoboxDefaultValueUnknown)) {//karamba
if (paramListParsed[k].match(prefixMatch21) && (param === InfoboxDefaultValueUnknown) && (param2 === InfoboxDefaultValueUnknown)) {
hideMultiRow = true;
}
//else if ((paramListParsed[k].indexOf(prefixThree+"1-") !== -1) && (param === InfoboxDefaultValueUnknown) && (param2 === InfoboxDefaultValueUnknown) && (param3 === InfoboxDefaultValueUnknown)) {//karamba
else if (paramListParsed[k].match(prefixMatch31) && (param === InfoboxDefaultValueUnknown) && (param2 === InfoboxDefaultValueUnknown) && (param3 === InfoboxDefaultValueUnknown)) {
hideMultiRow = true;
}
//else if ((paramListParsed[k].indexOf(prefixFour+"1-") !== -1) && (param === InfoboxDefaultValueUnknown) && (param2 === InfoboxDefaultValueUnknown) && (param3 === InfoboxDefaultValueUnknown) && (param4 === InfoboxDefaultValueUnknown)) {//karamba
else if (paramListParsed[k].match(prefixMatch41) && (param === InfoboxDefaultValueUnknown) && (param2 === InfoboxDefaultValueUnknown) && (param3 === InfoboxDefaultValueUnknown) && (param4 === InfoboxDefaultValueUnknown)) {
hideMultiRow = true;
}
else {
hideMultiRow = false;
}
}
//paramView = param;//karambakaramba
paramView = param.replace(/\\([,;])/g, "$1"); //Unescape commas and semicolons
if (noEdit === false) {
paramEdit = param.replace(/<br>/g, "\n"); //Convert <br> to \n for edit mode
//Get comment
if (paramListParsed[k].indexOf("**") !== -1) {
comment = paramListParsed[k].replace(commentsRE, "").replace(/_/g, " ");
}
else {
comment = this.texts.infoboxNoComment;
}
}
//Generate IDs
if (paramListParsed[k].indexOf("1-") !== -1) { //Only define the following parameters when using multiple content cells in a row (Side, Three, Four)
MultipleCellID = TTIX + "_" + paramListParsed[k-1].replace(/_\(\([\w\s]*?\)\)|_\*\*[\w\W\s]*?$/g, "").replace(/!/g, "_");
ViewModeMultipleContentID = this.IDs.IDPrefixContent + MultipleCellID;
if (noEdit === false) {
EditModeMultipleContentID = this.IDs.IDPrefixEdit + ViewModeMultipleContentID;
}
}
RowIDReplace = TTIX + "_" + paramListParsed[k].replace(RowIDReplaceRE, "").replace(/!/g, "_").replace(/[^a-zA-Z0-9_\-]/g, "");
ViewModeSectionTableID = this.IDs.IDPrefixSectionTable + RowIDReplace;
ViewModeSectionHeaderID = this.IDs.IDPrefixSectionHeader + RowIDReplace;
ViewModeContentID = this.IDs.IDPrefixContent + RowIDReplace;
figureID = this.IDs.IDPrefixFigure + RowIDReplace;
imageID = this.IDs.IDPrefixImage + RowIDReplace;
captionID = this.IDs.IDPrefixCaption + RowIDReplace;
noImageID = this.IDs.IDPrefixNoImage + RowIDReplace;
if (noEdit === false) {
EditModeSectionTableID = this.IDs.IDPrefixEdit + ViewModeSectionTableID;
EditModeSectionHeaderID = this.IDs.IDPrefixEdit + ViewModeSectionHeaderID;
EditModeContentID = this.IDs.IDPrefixEdit + ViewModeContentID;
EditCommentID = this.IDs.IDPrefixEdit + this.IDs.IDPrefixComment + RowIDReplace;
EditNewLimitID = this.IDs.IDPrefixEdit + this.IDs.IDPrefixNewLimit + RowIDReplace;
EditContentContainerID = this.IDs.IDPrefixEdit + this.IDs.IDPrefixContentContainer + RowIDReplace;
EditTextareaID = this.IDs.IDPrefixEdit + this.IDs.IDPrefixTextarea + RowIDReplace;
EditFigureCheckboxID = this.IDs.IDPrefixEdit + this.IDs.IDPrefixFigureCheckbox + RowIDReplace;
EditSelectID = this.IDs.IDPrefixEdit + this.IDs.IDPrefixSelect + RowIDReplace;
EditNoValueWarningID = this.IDs.IDPrefixEdit + this.IDs.IDPrefixNoValueWarning + RowIDReplace;
EditParamNameID = this.IDs.IDPrefixEdit + this.IDs.IDPrefixParamName + RowIDReplace;
EditCommentContainerID = this.IDs.IDPrefixEdit + this.IDs.IDPrefixCommentContainer + RowIDReplace;
EditFigureID = this.IDs.IDPrefixEdit + this.IDs.IDPrefixFigure + RowIDReplace;
EditImageID = this.IDs.IDPrefixEdit + this.IDs.IDPrefixImage + RowIDReplace;
EditCaptionID = this.IDs.IDPrefixEdit + this.IDs.IDPrefixCaption + RowIDReplace;
EditIncludeDelimiterStartID = this.IDs.IDPrefixEdit + this.IDs.IDPrefixIncludeDelimiterStart + RowIDReplace;
EditIncludeDelimiterEndID = this.IDs.IDPrefixEdit + this.IDs.IDPrefixIncludeDelimiterEnd + RowIDReplace;
EditParamPrefixID = this.IDs.IDPrefixEdit + this.IDs.IDPrefixParamPrefix + RowIDReplace;
if (k < paramListParsedLength-1) { //Include delimiter top border
RowIDReplaceNext = TTIX + "_" + paramListParsed[k+1].replace(RowIDReplaceRE, "").replace(/!/g, "_").replace(/[^a-zA-Z0-9_\-]/g, "");
EditModeSectionHeaderIDNext = this.IDs.IDPrefixEdit + this.IDs.IDPrefixSectionHeader + RowIDReplaceNext;
EditModeContentIDNext = this.IDs.IDPrefixEdit + this.IDs.IDPrefixContent + RowIDReplaceNext;
}
if (k > 0) { //Include delimiter bottom border
RowIDReplacePrevious = TTIX + "_" + paramListParsed[k-1].replace(RowIDReplaceRE, "").replace(/!/g, "_").replace(/[^a-zA-Z0-9_\-]/g, "");
EditModeContentIDPrevious = this.IDs.IDPrefixEdit + this.IDs.IDPrefixContent + RowIDReplacePrevious;
}
}
ParamName = paramListParsed[k].replace(paramPrefixesRE, "").replace(ParamNameRE, "").replace(prefixesRE, "").replace(/_/g, " ").replace(unnamedSectionRE, "");
if (noEdit === false) {
EditParamName = paramListParsed[k].replace(EditParamNameRE, "").replace(/_/g, " ");
//Set up prefix formatting
if (paramListParsed[k].match(paramPrefixesRE)) {
EditParamName = "<nowiki>"+EditParamName.replace(paramPrefixesEditRE, "<span id=\""+EditParamPrefixID+"\" class=\"InfoboxPrefixes\">$1</span><span class=\"InfoboxParamOnly\">$2</span>")+"</nowiki>";
}
//On hover code
normalParamHoverOnmouseover = "document.getElementById('"+EditModeContentID+"').className = 'InfoboxOnHover';";
normalParamHoverOnmouseout = "document.getElementById('"+EditModeContentID+"').className = 'InfoboxRow';";
normalParamHover = onmouseoverStart + normalParamHoverOnmouseover + onmouseoverEnd + onmouseoutStart + normalParamHoverOnmouseout + onmouseoutEnd;
multiSideParamHoverOnmouseover = "document.getElementById('"+EditModeMultipleContentID+"').className = 'InfoboxOnHover';";
multiSideParamHoverOnmouseout = "document.getElementById('"+EditModeMultipleContentID+"').className = 'InfoboxRow';";
multiSideParamHover = onmouseoverStart + multiSideParamHoverOnmouseover + onmouseoverEnd + onmouseoutStart + multiSideParamHoverOnmouseout + onmouseoutEnd;
}
//Specify class for multiple content cells
if (paramListParsed[k].indexOf(prefixSide) !== -1) {
rowClass = "InfoboxCellSide";
}
else if (paramListParsed[k].indexOf(prefixThree) !== -1) {
rowClass = "InfoboxCellThree";
}
else if (paramListParsed[k].indexOf(prefixFour) !== -1) {
rowClass = "InfoboxCellFour";
}
if (noEdit === false) {
//Highlighting
if ((paramEdit !== InfoboxDefaultValueUnknown) && (paramEdit !== InfoboxDefaultValueDefaultID) && (paramEdit !== InfoboxSpecialValueOther)) { //Highlight if the value is not a default one
highlightFilledRow = " InfoboxLinesHighlighted";
}
else {
highlightFilledRow = "";
}
}
//Common rows and cells
multiSideCell = "<td class=\"" + rowClass + "\">" + paramView + "</td>";
//Define the image code, so the image can be previewed
if (paramListParsed[k].indexOf(prefixImage+"-") !== -1) {
imageParam = paramEdit.split("|");
imageSrc = imageParam[0];
imageAlt = imageParam[1];
if ((imageAlt === InfoboxDefaultValueUnknown) || (imageAlt === null) || (imageAlt === undefined)) {
imageAlt = imageSrc;
}
imageTitle = imageParam[2];
if ((imageTitle === InfoboxDefaultValueUnknown) || (imageTitle === null) || (imageTitle === undefined)) {
imageTitle = imageAlt;
}
showFigcaption = imageParam[3];
if (showFigcaption !== "false") {
showFigcaption = true;
}
imageCaption = imageParam[4];
if ((imageCaption === InfoboxDefaultValueUnknown) || (imageCaption === null) || (imageCaption === undefined)) {
imageCaption = imageTitle;
}
figcaptionStart = "<figcaption class=\"InfoboxFigcaption\" id=\""+captionID+"\">";
figcaptionEnd = "</figcaption>";
if ((showImageCaption === true) && (showFigcaption === true)) {
figcaption = figcaptionStart + imageCaption + figcaptionEnd;
}
else {
figcaption = figcaptionStart + figcaptionEnd;
}
if (showFigcaption === true) {
figcaptionSelected = " value=\"true\" checked=\"checked\"";
}
else {
figcaptionSelected = " value=\"false\"";
}
useImageLink = imageParam[5];
if (useImageLink !== "false") {
useImageLink = true;
}
imageLink = imageParam[6];
if ((imageLink === InfoboxDefaultValueUnknown) || (imageLink === null) || (imageLink === undefined)) {
imageLink = imageSrc;
}
if ((displayImagesAsLinks === true) && (useImageLink === true)) {
imageLinkStart = "<a href=\"" + imageLink + "\">";
imageLinkEnd = "</a>";
}
else {
imageLinkStart = "";
imageLinkEnd = "";
}
if (useImageLink === true) {
imageLinkSelected = " value=\"true\" checked=\"checked\"";
}
else {
imageLinkSelected = " value=\"false\"";
}
figureIDRE = new RegExp(figureID);
imageIDRE = new RegExp(imageID);
captionIDRE = new RegExp(captionID);
imageLinkRE = new RegExp(imageLinkStart+"|"+imageLinkEnd, "g");
image = "<figure id=\""+figureID+"\">"+imageLinkStart+"<img src=\"" + imageSrc + "\" alt=\"" + imageAlt + "\" title=\"" + imageTitle + "\" class=\"InfoboxImage\" id=\"" + imageID + "\"/>" + imageLinkEnd + figcaption + "</figure>";
if (showPreview === true) {
previewOnchange = " onchange=\"config.macros.infobox.changePreview(this);\"";
preview = "<hr/><span class=\"InfoboxSubParams\">"+this.texts.infoboxPreview+"<br/></span>"+image.replace(figureIDRE, EditFigureID).replace(imageIDRE, EditImageID).replace(captionIDRE, EditCaptionID).replace(imageLinkRE, "")+"<span class=\"InfoboxSubParams\" id=\""+noImageID+"\">"+this.texts.infoboxNoImage+"</span>";
if (imageSrc === InfoboxDefaultValueUnknown) {
setStylesheet("#" + EditFigureID + " {display: none;}", this.IDs.IDPrefixInfoboxTablesStyle + EditFigureID);
setStylesheet("#" + noImageID + " {display: block;}", this.IDs.IDPrefixInfoboxTablesStyle + noImageID);
}
else {
setStylesheet("#" + EditFigureID + " {display: block;}", this.IDs.IDPrefixInfoboxTablesStyle + EditFigureID);
setStylesheet("#" + noImageID + " {display: none;}", this.IDs.IDPrefixInfoboxTablesStyle + noImageID);
}
}
/*karamba
image = "<figure id=\""+figureID+"\">"+imageLinkStart+"<img src=\"" + imageSrc + "\" alt=\"" + imageAlt + "\" title=\"" + imageTitle + "\" class=\"InfoboxImage\" id=\"" + imageID + "\"/>" + imageLinkEnd + figcaption + "</figure>";
if (showPreview === true) {
previewOnchange = " onchange=\"config.macros.infobox.changePreview(this);\"";
preview = "<hr/><span class=\"InfoboxSubParams\">"+this.texts.infoboxPreview+"<br/></span>"+image.replace(figureIDRE, this.IDs.IDPrefixEdit + figureID).replace(imageIDRE, this.IDs.IDPrefixEdit+imageID).replace(captionIDRE, this.IDs.IDPrefixEdit+captionID).replace(imageLinkRE, "")+"<span class=\"InfoboxSubParams\" id=\""+noImageID+"\">"+this.texts.infoboxNoImage+"</span>";
if (imageSrc === InfoboxDefaultValueUnknown) {
setStylesheet("#" + this.IDs.IDPrefixEdit + figureID + " {display: none;}", this.IDs.IDPrefixInfoboxTablesStyle + this.IDs.IDPrefixEdit + figureID);
setStylesheet("#" + noImageID + " {display: block;}", this.IDs.IDPrefixInfoboxTablesStyle + noImageID);
}
else {
setStylesheet("#" + this.IDs.IDPrefixEdit + figureID + " {display: block;}", this.IDs.IDPrefixInfoboxTablesStyle + this.IDs.IDPrefixEdit + figureID);
setStylesheet("#" + noImageID + " {display: none;}", this.IDs.IDPrefixInfoboxTablesStyle + noImageID);
}
}
*/
else {
previewOnchange = "";
preview = "";
}
textareas = "<span class=\"InfoboxSubParams\">"+this.texts.infoboxImageSrc+"<br/></span><textarea id=\"" + EditTextareaID + this.IDs.IDSuffixImageSrc + "\" class=\"InfoboxEditTextarea" + highlightFilledRow + "\" onfocus=\"config.macros.infobox.toggleTextareaSize(this,true);\" onblur=\"config.macros.infobox.toggleTextareaSize(this,true);\"" + previewOnchange + ">" + imageSrc + "</textarea><span class=\"InfoboxSubParams\"><br/>"+this.texts.infoboxImageAlt+" <br/></span><textarea id=\"" + EditTextareaID + this.IDs.IDSuffixImageAlt + "\" class=\"InfoboxEditTextarea" + highlightFilledRow + "\" onfocus=\"config.macros.infobox.toggleTextareaSize(this,true);\" onblur=\"config.macros.infobox.toggleTextareaSize(this,true);\"" + previewOnchange + ">" + imageAlt + "</textarea><span class=\"InfoboxSubParams\"><br/>"+this.texts.infoboxImageTitle+"<br/></span><textarea id=\"" + EditTextareaID + this.IDs.IDSuffixImageTitle + "\" class=\"InfoboxEditTextarea" + highlightFilledRow + "\" onfocus=\"config.macros.infobox.toggleTextareaSize(this,true);\" onblur=\"config.macros.infobox.toggleTextareaSize(this,true);\"" + previewOnchange + ">" + imageTitle + "</textarea><label for=\"" + EditFigureCheckboxID + this.IDs.IDSuffixImageCaption + "\"><br/><input type=\"checkbox\" id=\"" + EditFigureCheckboxID + this.IDs.IDSuffixImageCaption + "\" name=\"" + EditFigureCheckboxID + this.IDs.IDSuffixImageCaption + "\""+figcaptionSelected+previewOnchange+"><span class=\"InfoboxSubParams\">"+this.texts.infoboxShowImageCaption+"<br/></span></label><span class=\"InfoboxSubParams\">"+this.texts.infoboxImageCaption+"<br/></span><textarea id=\"" + EditTextareaID + this.IDs.IDSuffixImageCaption + "\" class=\"InfoboxEditTextarea" + highlightFilledRow + "\" onfocus=\"config.macros.infobox.toggleTextareaSize(this,true);\" onblur=\"config.macros.infobox.toggleTextareaSize(this,true);\"" + previewOnchange + ">" + imageCaption + "</textarea><label for=\"" + EditFigureCheckboxID + this.IDs.IDSuffixImageLink + "\"><br/><input type=\"checkbox\" id=\"" + EditFigureCheckboxID + this.IDs.IDSuffixImageLink + "\" name=\"" + EditFigureCheckboxID + this.IDs.IDSuffixImageLink + "\"" + imageLinkSelected + previewOnchange + "><span class=\"InfoboxSubParams\">"+this.texts.infoboxUseImageLink+"<br/></span></label><span class=\"InfoboxSubParams\">"+this.texts.infoboxImageLink+"<br/></span><textarea id=\"" + EditTextareaID + this.IDs.IDSuffixImageLink + "\" class=\"InfoboxEditTextarea" + highlightFilledRow + "\" onfocus=\"config.macros.infobox.toggleTextareaSize(this,true);\" onblur=\"config.macros.infobox.toggleTextareaSize(this,true);\"" + previewOnchange + ">" + imageLink + "</textarea>";
}
else {
image = "";
preview = "";
textareas = "<textarea id=\"" + EditTextareaID + "\" class=\"InfoboxEditTextarea" + highlightFilledRow + "\" onfocus=\"config.macros.infobox.toggleTextareaSize(this,true);\" onblur=\"config.macros.infobox.toggleTextareaSize(this,true);\">" + paramEdit + "</textarea>";
}
if (noEdit === false) {
//Define the edit field for the normal display (textarea)
if ((comment.indexOf("#") === -1) && (comment.indexOf("%%") === -1)) { //If there are no dropdown or limit definitions
if ((paramListParsed[k].indexOf(templateDelimiter+"-") === -1) && (paramListParsed[k].indexOf(moduleDelimiter+"-") === -1)) {
singleSideRowEdit = "<tr id=\"" + EditModeContentID + "\" class=\"InfoboxRow\"" + normalParamHover + "><td class=\"InfoboxCellLeft\">" + EditParamName + "</td><td class=\"InfoboxCellRight\"><div id=\"" + EditCommentContainerID + "\" class=\"InfoboxEditDiv\"><span id=\"" + EditCommentID + "\" class=\"InfoboxEditComment\">" + comment + "</span></div><div id=\"" + EditContentContainerID + "\" >" + textareas + preview + "</div></td></tr>";
}
else { //Hide display for template/module delimiters
singleSideRowEdit = "";
}
multiSideCellEdit = "<td class=\"" + rowClass + "\"><div id=\"" + EditCommentContainerID + "\" class=\"InfoboxEditDiv\"><span id=\"" + EditParamNameID + "\" class=\"InfoboxEditParamName\">" + EditParamName + "</span><span id=\"" + EditCommentID + "\" class=\"InfoboxEditComment\">" + comment + "</span></div><textarea id=\"" + EditTextareaID + "\" class=\"InfoboxEditTextarea" + highlightFilledRow + "\" onfocus=\"config.macros.infobox.toggleTextareaSize(this,false);\" onblur=\"config.macros.infobox.toggleTextareaSize(this,false);\">" + paramEdit + "</textarea></td>";
}
else if (comment.indexOf("%%") !== -1) { //If there are limits definitions
dependencyOnchangeMatches = "";
dependencyParamHoverOnmouseover = " document.getElementById('"+EditModeContentID+"').className = 'InfoboxDependent';";
dependencyParamHoverOnmouseout = "document.getElementById('"+EditModeContentID+"').className = 'InfoboxRow';";
for (v = 0; v < paramListParsedLength; v+=1) { //Check param list for dependents
containerID = this.IDs.IDPrefixEdit + this.IDs.IDPrefixContentContainer + TTIX + "_" + paramListParsed[v].replace(EditParamNameRE, "").replace(/!/g, "_").replace(/[^a-zA-Z0-9_\-]/g, "");
paramListParsedRE = new RegExp("\\+\\+"+paramListParsedCleaned[k]+"\\+\\+", "g");
if (paramListParsed[v].match(paramListParsedRE)) {
dependency = encodeURIComponent(paramListParsed[k]); //Encode special characters
dependent = encodeURIComponent(paramListParsed[v]); //Encode special characters
dependencyOnchangeMatches += "config.macros.infobox.toggleDependencyValues(this,'"+dependency+"','"+dependent+"','"+containerID+"'); "; //Support for multiple dependents
dependencyParamHoverOnmouseover += " document.getElementById('"+this.IDs.IDPrefixEdit+this.IDs.IDPrefixContent+TTIX+"_"+paramListParsed[v].replace(EditParamNameRE, "").replace(/!/g, "_").replace(/[^a-zA-Z0-9_\-]/g, "")+"').className = 'InfoboxDependency';";
dependencyParamHoverOnmouseout += " document.getElementById('"+this.IDs.IDPrefixEdit+this.IDs.IDPrefixContent+TTIX+"_"+paramListParsed[v].replace(EditParamNameRE, "").replace(/!/g, "_").replace(/[^a-zA-Z0-9_\-]/g, "")+"').className = 'InfoboxRow';";
dependencyHovers = dependencyHovers + 1;
}
}
dependencyOnchange = dependencyOnchangeMatches;
if (dependencyOnchange === undefined) {
dependencyOnchange = "";
}
commentText = comment.replace(/\s*?%%[\w\W\s]*?%%\s*?| {2}/g, " ").replace(/ $/, ""); //Remove dropdown values from comment
if (commentText.length > 1) { //Add a break, if there's a comment
commentText = commentText+"<br/>";
}
limitValues = comment.match(/%%[\w\W\s]*?%%/).toString().replace(/%%/g, ""); //Remove dependency definition from dependent values;
if (limitValues.indexOf("++") === -1) { //If no dependency is defined
limitStatus = " style=\"display: block;\"";
noValueWarning = "";
if (dependencyHovers !== 0) { //If it is a dependency
dependencyParamHover = onmouseoverStart + dependencyParamHoverOnmouseover + onmouseoverEnd + onmouseoutStart + dependencyParamHoverOnmouseout + onmouseoutEnd;
}
else { //If it isn't a dependency
dependencyParamHover = "";
}
limitCategory = limitValues.trim();
}
else { //If dependency is defined
limitDependencyParam = limitValues.match(/\+\+[\w\W\s]*?\+\+/).toString().replace(/\+\+/g, "").trim().replace(/ /g, "_"); //Get dependency
dependencyParamHover = " onmouseover=\"document.getElementById('"+this.IDs.IDPrefixEdit+this.IDs.IDPrefixContent+TTIX+"_"+limitDependencyParam.replace(/!/g, "_").replace(/[^a-zA-Z0-9_\-]/g, "")+"').className = 'InfoboxDependent'; document.getElementById('"+EditModeContentID+"').className = 'InfoboxDependency';\" onmouseout=\"document.getElementById('"+this.IDs.IDPrefixEdit+this.IDs.IDPrefixContent+TTIX+"_"+limitDependencyParam.replace(/!/g, "_").replace(/[^a-zA-Z0-9_\-]/g, "")+"').className = 'InfoboxRow'; document.getElementById('"+EditModeContentID+"').className = 'InfoboxRow';\"";
limitDependentValuesOnly = limitValues.replace(/\+\+[\w\W\s]*?\+\+/, ""); //Remove dependency definition from limit values
limitDependentCategories = limitDependentValuesOnly.split(";"); //Split limit values to categories
limitDependencyPosition = paramListParsedCleaned.indexOf(limitDependencyParam); //Get the position of the dependency parameter in the parameter list
limitDependencyValues = paramListParsed[limitDependencyPosition].match(/#[\w\W\s]*?#/).toString().replace(/#/g, "").replace(/_/g, " ").replace(/\b\s*?,\s*?\b/g, ","); //Get dependency values
limitDependencyValue = getParam(params, limitDependencyParam, InfoboxDefaultValueUnknown); //Get the value of the dependency
if (limitDependencyValue === InfoboxDefaultValueUnknown) { //If dependency is unknown
//Display message about dependency
limitStatus = " style=\"display: none;\"";
noValueWarning = this.texts.infoboxDropdownNoDependencyValue.format([limitDependencyParam.replace(/_/g, " ")]);
noValueWarningClass = "InfoboxNoValueWarning";
}
else { //If dependency is known
limitStatus = " style=\"display: block;\"";
limitDependencyValuePosition = limitDependencyValues.replace(/\\,/g, "commaPlaceholder").split(",").indexOf(limitDependencyValue.replace(/\\,/g, "commaPlaceholder")); //Get the position of the dependency value in its own list
limitCategory = limitDependentCategories[limitDependencyValuePosition].trim(); //Use the correct category
noValueWarning = "";
noValueWarningClass = "InfoboxEditDiv";
} //End if dependency is known
}
onchangeContent = onchangeStart + dependencyOnchange + onchangeEnd;
singleSideRowEdit = "<tr id=\"" + EditModeContentID + "\" class=\"InfoboxRow\"" + dependencyParamHover + "><td class=\"InfoboxCellLeft\">" + EditParamName + "</td><td class=\"InfoboxCellRight\"><div id=\"" + EditCommentContainerID + "\" class=\"InfoboxEditDiv\"><span id=\"" + EditCommentID + "\" class=\"InfoboxEditComment\">" + commentText + this.texts.infoboxLimits + limitCategory + "</span></div><div id=\"" + EditContentContainerID + "\"" + limitStatus + "><textarea id=\"" + EditTextareaID + "\" class=\"InfoboxEditTextarea" + highlightFilledRow + "\" onfocus=\"config.macros.infobox.toggleTextareaSize(this,true);\" onblur=\"config.macros.infobox.toggleTextareaSize(this,true,'"+EditCommentID+"');\">" + paramEdit + "</textarea><div class=\"InfoboxEditInputContainer\"><span class=\"InfoboxEditInputLabel\">" + this.texts.infoboxNewLimits + "</span><input type=\"text\" class=\"InfoboxEditInput\" value=\""+InfoboxDefaultValueUnknown+"\" id=\"" + EditNewLimitID + "\" name=\"" + EditNewLimitID + "\" onfocus=\"config.macros.infobox.checkInputValue(this);\" onblur=\"config.macros.infobox.checkInputValue(this);\"/></div></div><div id=\"" + EditNoValueWarningID + "\" class=\"" + noValueWarningClass + "\">" + noValueWarning + "</div></td></tr>";
multiSideCellEdit = "<td class=\"" + rowClass + "\"><div id=\"" + EditCommentContainerID + "\" class=\"InfoboxEditDiv\"><span id=\"" + EditParamNameID + "\" class=\"InfoboxEditParamName\">" + EditParamName + "</span><span id=\"" + EditCommentID + "\" class=\"InfoboxEditComment\">" + commentText + this.texts.infoboxLimits + limitCategory + "</span></div><div id=\"" + EditContentContainerID + "\"" + limitStatus + "><textarea id=\"" + EditTextareaID + "\" class=\"InfoboxEditTextarea" + highlightFilledRow + "\" onfocus=\"config.macros.infobox.toggleTextareaSize(this,true);\" onblur=\"config.macros.infobox.toggleTextareaSize(this,true,'"+EditCommentID+"');\">" + paramEdit + "</textarea><div class=\"InfoboxEditInputContainer\"><span class=\"InfoboxEditInputLabel\">" + this.texts.infoboxNewLimits + "</span><input type=\"text\" class=\"InfoboxEditInput\" value=\""+InfoboxDefaultValueUnknown+"\" id=\"" + EditNewLimitID + "\" name=\"" + EditNewLimitID + "\" onfocus=\"config.macros.infobox.checkInputValue(this);\" onblur=\"config.macros.infobox.checkInputValue(this);\"/></div></div><div id=\"" + EditNoValueWarningID + "\" class=\"" + noValueWarningClass + "\">" + noValueWarning + "</div></td>";
}
else if (comment.indexOf("#") !== -1) { //If there are dropdown definitions
//Check if any parameter is dependent on this one
dependencyOnchangeMatches = "";
dependencyParamHoverOnmouseover = "document.getElementById('"+EditModeContentID+"').className = 'InfoboxDependent';";
dependencyParamHoverOnmouseout = "document.getElementById('"+EditModeContentID+"').className = 'InfoboxRow';";
for (v = 0; v < paramListParsedLength; v+=1) { //Check param list for dependents
containerID = this.IDs.IDPrefixEdit + this.IDs.IDPrefixContentContainer + TTIX + "_" + paramListParsed[v].replace(EditParamNameRE, "").replace(/!/g, "_").replace(/[^a-zA-Z0-9_\-]/g, "");
paramListParsedRE = new RegExp("\\+\\+"+paramListParsedCleaned[k]+"\\+\\+", "g");
if (paramListParsed[v].match(paramListParsedRE)) {
dependency = encodeURIComponent(paramListParsed[k]); //Encode special characters
dependent = encodeURIComponent(paramListParsed[v]); //Encode special characters
dependencyOnchangeMatches += "config.macros.infobox.toggleDependencyValues(this,'"+dependency+"','"+dependent+"','"+containerID+"'); "; //Support for multiple dependents
dependencyParamHoverOnmouseover += " document.getElementById('"+this.IDs.IDPrefixEdit+this.IDs.IDPrefixContent+TTIX+"_"+paramListParsed[v].replace(EditParamNameRE, "").replace(/!/g, "_").replace(/[^a-zA-Z0-9_\-]/g, "")+"').className = 'InfoboxDependency';";
dependencyParamHoverOnmouseout += " document.getElementById('"+this.IDs.IDPrefixEdit+this.IDs.IDPrefixContent+TTIX+"_"+paramListParsed[v].replace(EditParamNameRE, "").replace(/!/g, "_").replace(/[^a-zA-Z0-9_\-]/g, "")+"').className = 'InfoboxRow';";
dependencyHovers = dependencyHovers + 1;
}
}
dependencyOnchangeMatches += "config.macros.infobox.toggleSelectHighlight(this); ";
dependencyOnchange = dependencyOnchangeMatches;
if (dependencyOnchange === undefined) {
dependencyOnchange = "";
}
dropdownOptions = "<option value=\""+InfoboxDefaultValueUnknown+"\">"+InfoboxDefaultValueUnknown+"</option>";
commentText = comment.replace(/\s*?#[\w\W\s]*?#\s*?| {2}/g, " ").replace(/ $/, ""); //Remove dropdown values from comment
dropdownValues = comment.match(/#[\w\W\s]*?#/).toString().replace(/#/g, ""); //Get dropdown values
altTextareaOnchange = "config.macros.infobox.toggleAltTextarea(this);"; //Toggle alternative textarea
if (dropdownValues.indexOf("++") === -1) { //If no dependency is defined
dropdownStatus = " style=\"display: block;\"";
if (dependencyHovers !== 0) { //If it is a dependency
dependencyParamHover = onmouseoverStart + dependencyParamHoverOnmouseover + onmouseoverEnd + onmouseoutStart + dependencyParamHoverOnmouseout + onmouseoutEnd;
}
else { //If it isn't a dependency
dependencyParamHover = "";
}
//dropdownCategory = dropdownValues.trim();//karambakaramba
dropdownCategory = dropdownValues.trim().replace(/\\,/g, "commaPlaceholder").replace(/\\;/g, "semicolonPlaceholder");
dropdownValuesSplit = dropdownCategory.replace(/\=/, "").split(","); //Split the category
dropdownValuesSplitLength = dropdownValuesSplit.length;
for (x = 0; x < dropdownValuesSplitLength; x+=1) { //Make array for dropdown
//dropdownValue = dropdownValuesSplit[x].trim(); //karambakaramba
dropdownValue = dropdownValuesSplit[x].trim().replace(/commaPlaceholder/g, ",").replace(/semicolonPlaceholder/g, ";");
dropdownOptions += "<option value=\""+dropdownValue+"\">"+dropdownValue+"</option>";
}
if (allowModifyingTemplates === true) {
dropdownOptions += "<option value=\""+InfoboxSpecialValueOther+"\">"+InfoboxSpecialValueOther+"</option>";
}
if (dropdownCategory.indexOf("=") === 0) { //Allow selecting multiple values
multipleSelect = " multiple=\"multiple\"";
dropdownOptionsCountRE = new RegExp("</option>", "g");
dropdownOptionsCount = dropdownOptions.match(dropdownOptionsCountRE).length;
if (dropdownOptionsCount <= maxMultipleSelections) {
multipleLength = dropdownOptionsCount;
}
else {
multipleLength = maxMultipleSelections;
}
}
else { //Allow selecting only one value
multipleSelect = "";
multipleLength = 1;
}
multipleSize = " size=\"" + multipleLength + "\"";
noValueWarning = "";
noValueWarningClass = "InfoboxEditDiv";
}
else { //If dependency is defined
dropdownDependencyParam = dropdownValues.match(/\+\+[\w\W\s]*?\+\+/).toString().replace(/\+\+/g, "").trim().replace(/ /g, "_").replace(/[\(\)\[\]]/g, ""); //Get dependency
dependencyParamHover = " onmouseover=\"document.getElementById('"+this.IDs.IDPrefixEdit+this.IDs.IDPrefixContent+TTIX+"_"+dropdownDependencyParam.replace(/!/g, "_").replace(/[^a-zA-Z0-9_\-]/g, "")+"').className = 'InfoboxDependent'; document.getElementById('"+EditModeContentID+"').className = 'InfoboxDependency';\" onmouseout=\"document.getElementById('"+this.IDs.IDPrefixEdit+this.IDs.IDPrefixContent+TTIX+"_"+dropdownDependencyParam.replace(/!/g, "_").replace(/[^a-zA-Z0-9_\-]/g, "")+"').className = 'InfoboxRow'; document.getElementById('"+EditModeContentID+"').className = 'InfoboxRow';\"";
dropdownDependentValuesOnly = dropdownValues.replace(/\+\+[\w\W\s]*?\+\+/, ""); //Remove dependency definition from dependent values
//dropdownDependentCategories = dropdownDependentValuesOnly.split(";"); //Split dependent values to categories//karambakaramba
dropdownDependentCategories = dropdownDependentValuesOnly.replace(/\\;/g, "semicolonPlaceholder").split(";"); //Split dependent values to categories
dropdownDependencyPosition = paramListParsedCleaned.indexOf(dropdownDependencyParam); //Get the position of the dependency parameter in the parameter list
//dropdownDependencyValues = paramListParsed[dropdownDependencyPosition].match(/#[\w\W\s]*?#/).toString().replace(/#/g, "").replace(/_/g, " ").replace(/\b\s*?,\s*?\b/g, ",").split(",");//karambakaramba
dropdownDependencyValues = paramListParsed[dropdownDependencyPosition].match(/#[\w\W\s]*?#/).toString().replace(/#/g, "").replace(/_/g, " ").replace(/\b\s*?,\s*?\b/g, ",").replace(/\\,/g, "commaPlaceholder").replace(/\\;/g, "semicolonPlaceholder").split(",");
//Get dependency values
dropdownDependencyValue = getParam(params, dropdownDependencyParam, InfoboxDefaultValueUnknown); //Get the value of the dependency
if (dropdownDependencyValue === InfoboxDefaultValueUnknown) { //If dependency is unknown
//Display message about dependency
dropdownStatus = " style=\"display: none;\"";
dropdownOptions = "<option value=\""+InfoboxDefaultValueUnknown+"\">"+InfoboxDefaultValueUnknown+"</option>";
noValueWarning = this.texts.infoboxDropdownNoDependencyValue.format([dropdownDependencyParam.replace(/_/g, " ")]);
noValueWarningClass = "InfoboxNoValueWarning";
}
else { //If dependency is known
dropdownStatus = " style=\"display: block;\"";
dropdownDependencyValuePosition = dropdownDependencyValues.indexOf(dropdownDependencyValue.replace(/\\,/g, "commaPlaceholder").replace(/\\;/g, "semicolonPlaceholder")); //Get the position of the dependency value in its own list
//dropdownCategory = dropdownDependentCategories[dropdownDependencyValuePosition]; //Use the correct category //karambakaramba
dropdownCategory = dropdownDependentCategories[dropdownDependencyValuePosition].replace(/\\,/g, "commaPlaceholder").replace(/\\;/g, "semicolonPlaceholder"); //Use the correct category
if (dropdownDependentValuesOnly.indexOf("!") === 0) { //Strict dependency (only a single value allowed)
//console.log(k+"-7630x-"+ParamName+"-"+dropdownValue);//karamba
dropdownValue = dropdownCategory.replace(/!/, "").trim().replace(/commaPlaceholder/g, ",").replace(/semicolonPlaceholder/g, ";");
//console.log(k+"-7630-"+ParamName+"-"+dropdownValue);//karamba
dropdownOptions = "<option value=\""+dropdownValue+"\">"+dropdownValue+"</option>";
multipleSelect = "";
multipleLength = 0;
}
else { //Multiple values allowed
dropdownValuesSplit = dropdownCategory.replace(/\=/, "").split(","); //Split the category
for (x = 0; x < dropdownValuesSplit.length; x+=1) { //Make array for dropdown
//console.log(k+"-7639x-"+ParamName+"-"+dropdownValue);//karamba
dropdownValue = dropdownValuesSplit[x].trim().replace(/commaPlaceholder/g, ",").replace(/semicolonPlaceholder/g, ";");
//console.log(k+"-7639-"+ParamName+"-"+dropdownValue);//karamba
dropdownOptions += "<option value=\""+dropdownValue+"\">"+dropdownValue+"</option>";
}
if (allowModifyingTemplates === true) {
dropdownOptions += "<option value=\""+InfoboxSpecialValueOther+"\">"+InfoboxSpecialValueOther+"</option>";
}
if (dropdownValues.indexOf("=") === 0) { //Allow selecting multiple values
multipleSelect = " multiple=\"multiple\"";
dropdownOptionsCountRE = new RegExp("</option>", "g");
dropdownOptionsCount = dropdownOptions.match(dropdownOptionsCountRE).length;
if (dropdownOptionsCount <= maxMultipleSelections) {
multipleLength = dropdownOptionsCount;
}
else {
multipleLength = maxMultipleSelections;
}
}
else { //Allow selecting only one value
multipleSelect = "";
multipleLength = 0;
}
} //End multiple values allowed
noValueWarning = "";
noValueWarningClass = "InfoboxEditDiv";
} //End if dependency is known
multipleSize = " size=\"" + multipleLength + "\"";
} //End if dependency is defined
onchangeContent = onchangeStart + dependencyOnchange + altTextareaOnchange + resetOtherValue + onchangeEnd;
singleSideRowEdit = "<tr id=\"" + EditModeContentID + "\" class=\"InfoboxRow\"" + dependencyParamHover + "><td class=\"InfoboxCellLeft\">" + EditParamName + "</td><td class=\"InfoboxCellRight\"><div id=\"" + EditCommentContainerID + "\" class=\"InfoboxEditDiv\"><span id=\"" + EditCommentID + "\" class=\"InfoboxEditComment\">" + commentText + "</span></div><div id=\"" + EditContentContainerID + "\"" + dropdownStatus + "><select id=\"" + EditSelectID + "\" class=\"" + highlightFilledRow + "\" onfocus=\"config.macros.infobox.toggleComments(this);\" onblur=\"config.macros.infobox.toggleComments(this);\"" + onchangeContent + multipleSelect + multipleSize + ">" + dropdownOptions + "</select><textarea id=\"" + EditTextareaID + "\" class=\"InfoboxEditTextarea InfoboxEditDropdownAltTextarea\" onfocus=\"config.macros.infobox.toggleTextareaSize(this,true);\" onblur=\"config.macros.infobox.toggleTextareaSize(this,true);\">" + InfoboxDefaultValueUnknown + "</textarea></div><div id=\"" + EditNoValueWarningID + "\" class=\"" + noValueWarningClass + "\">" + noValueWarning + "</div></td></tr>";
multiSideCellEdit = "<td class=\"" + rowClass + "\"><div id=\"" + EditCommentContainerID + "\" class=\"InfoboxEditDiv\"><span id=\"" + EditParamNameID + "\" class=\"InfoboxEditParamName\">" + EditParamName + "</span><span id=\"" + EditCommentID + "\" class=\"InfoboxEditComment\">" + commentText + "</span></div><div id=\"" + EditContentContainerID + "\"" + dropdownStatus + "><select id=\"" + EditSelectID + "\" class=\"" + highlightFilledRow + "\" onfocus=\"config.macros.infobox.toggleComments(this);\" onblur=\"config.macros.infobox.toggleComments(this); config.macros.infobox.resetOtherValue(this);\"" + onchangeContent + multipleSelect + multipleSize + ">" + dropdownOptions + "</select><textarea id=\"" + EditTextareaID + "\" class=\"InfoboxEditTextarea InfoboxEditDropdownAltTextarea\" onfocus=\"config.macros.infobox.toggleTextareaSize(this,true);\" onblur=\"config.macros.infobox.toggleTextareaSize(this,true);\">" + InfoboxDefaultValueUnknown + "</textarea></div><div id=\"" + EditNoValueWarningID + "\" class=\"" + noValueWarningClass + "\">" + noValueWarning + "</div></td>";
selectArray += ";"+EditSelectID+","+paramEdit;
} //End if there are dropdown definitions
}
//Output for template delimiters (global, main, first module instance)
if (paramListParsed[k].indexOf(templateDelimiter+"-") !== -1) {
if (noEdit === false) {
outEdit += "</table><table id=\"" + this.IDs.IDPrefixEdit + this.IDs.IDPrefixTemplateDelimiterTable + this.IDs.IDPrefixTemplateDelimiter + TTIX + "_" + paramListParsed[k].replace(templateDelimiterRE, "") + "\" class=\"InfoboxTableEdit\"><tr id=\"" + this.IDs.IDPrefixEdit + this.IDs.IDPrefixTemplateDelimiter + TTIX + paramListParsed[k].replace(templateDelimiterRE, "") + "\"><td class=\"InfoboxTemplateDelimiter\">" + paramListParsed[k].replace(EditParamNameRE, "").replace(/_/g, " ") + "</td></tr>";
}
}
//Output for other module instance delimiters
else if (paramListParsed[k].indexOf(moduleDelimiter+"-") !== -1) {
if (noEdit === false) {
outEdit += "<table id=\"" + this.IDs.IDPrefixEdit + this.IDs.IDPrefixModuleDelimiterTable + this.IDs.IDPrefixModuleDelimiter + TTIX + "_" + paramListParsed[k].replace(moduleDelimiterRE, "") + "\" class=\"InfoboxTableEdit\"><tr id=\"" + this.IDs.IDPrefixEdit + this.IDs.IDPrefixModuleDelimiter + TTIX + paramListParsed[k].replace(moduleDelimiterRE, "") + "\"><td class=\"InfoboxModuleInstanceDelimiter\"" + headerColSpanEdit + ">" + paramListParsed[k].replace(EditParamNameRE, "").replace(/_/g, " ") + "</td></tr></table>";
}
}
//Output for include start delimiters
else if (paramListParsed[k].indexOf(includeDelimiterStart+"-") !== -1) {
includeDepth = includeDepth + 1;
if ((noEdit === false) && (showBorderAroundInclude === true) && (paramListParsed[k+1].indexOf(includeDelimiterStart+"-") === -1)) {
showTop = true;
}
}
//Output for include end delimiters
else if (paramListParsed[k].indexOf(includeDelimiterEnd+"-") !== -1) {
if ((noEdit === false) && (showBorderAroundInclude === true) && (paramListParsed[k-1].indexOf(includeDelimiterEnd+"-") === -1)) {
showBottom = true;
}
includeDepth = includeDepth - 1;
}
//Output for section titles
else if (paramListParsed[k].indexOf(prefixSection+"-") !== -1) {
//Determine how many columns the section header should span
if ((paramListParsed[k+1].indexOf(prefixImage+"-") !== -1) || (paramListParsed[k+1].indexOf(prefixSingle+"-") !== -1)) { //Images and singles
headerColSpan = " colspan=\"1\"";
headerColSpanEdit = " colspan=\"2\""; //There are two columns in edit mode, for param name and for textareas
fixedLayout = " InfoboxTableFixedLayout";
}
else if (paramListParsed[k+1].indexOf(prefixSide+"1-") !== -1) { //Two sides
headerColSpan = " colspan=\"2\"";
headerColSpanEdit = headerColSpan;
fixedLayout = " InfoboxTableFixedLayout";
}
else if (paramListParsed[k+1].indexOf(prefixThree+"1-") !== -1) { //Three sides
headerColSpan = " colspan=\"3\"";
headerColSpanEdit = headerColSpan;
fixedLayout = " InfoboxTableFixedLayout";
}
else if (paramListParsed[k+1].indexOf(prefixFour+"1-") !== -1) { //Four sides
headerColSpan = " colspan=\"4\"";
headerColSpanEdit = headerColSpan;
fixedLayout = " InfoboxTableFixedLayout";
}
else { //Normal output
headerColSpan = " colspan=\"2\"";
headerColSpanEdit = headerColSpan;
fixedLayout = ""; //The table layout cannot be fixed here, because it makes both columns the same width
}
out += "</table><table id=\"" + ViewModeSectionTableID + "\" class=\"InfoboxTable" + fixedLayout + "\">";
if (ParamName.length) { //Add end and beginning of table if section name is not empty
if (showModuleName === true) {
moduleNamePrefixMatch = paramListParsed[k].match(moduleNameWithSuffixRE);
if (moduleNamePrefixMatch) {
moduleNamePrefix = moduleNamePrefixMatch.toString().replace(moduleNameCleanupRE, "").replace(/_/g, " ")+": ";
}
else {
moduleNamePrefix = "";
}
}
else {
moduleNamePrefix = "";
}
out += "<tr id=\"" + ViewModeSectionHeaderID + "\"><td class=\"ContentSection Infobox" + TypeX + InfoboxColorScheme + InfoboxSlicesSubtitle + "\"" + headerColSpan + ">" + moduleNamePrefix + ParamName + "</td></tr>";
}
if (noEdit === false) {
outEdit += "</table><table id=\"" + EditModeSectionTableID + "\" class=\"InfoboxTableEdit\"><tr id=\"" + EditModeSectionHeaderID + "\"><td class=\"ContentSectionEdit Infobox" + TypeX + InfoboxColorScheme + InfoboxSlicesSubtitle + "\"" + headerColSpanEdit + ">" + EditParamName + "<span id=\"" + EditCommentID + "\" class=\"InfoboxEditComment\">" + comment + "</span></td></tr>";
}
}
//Output for images
else if (paramListParsed[k].indexOf(prefixImage+"-") !== -1) {
if (paramView !== InfoboxDefaultValueUnknown) {
out += "<tr id=\"" + ViewModeContentID + "\" class=\"InfoboxRow\"><td class=\"InfoboxCellImage\">" + image + "</td></tr>";
}
if (noEdit === false) {
outEdit += singleSideRowEdit;
}
}
//Output for single cells
else if (paramListParsed[k].indexOf(prefixSingle+"-") !== -1) {
if (paramView !== InfoboxDefaultValueUnknown) {
out += "<tr id=\"" + ViewModeContentID + "\" class=\"InfoboxRow\"><td class=\"InfoboxCellSingle\">" + paramView + "</td></tr>";
}
if (noEdit === false) {
outEdit += singleSideRowEdit;
}
}
//Output if using multiple sides (outer left cells)
//else if ((paramListParsed[k].indexOf(prefixSide+"1-") !== -1) || (paramListParsed[k].indexOf(prefixThree+"1-") !== -1) || (paramListParsed[k].indexOf(prefixFour+"1-") !== -1)) {//karamba
else if (paramListParsed[k].match(prefixMatch213141)) {
if (hideMultiRow === false) {
out += "<tr id=\"" + ViewModeMultipleContentID + "\" class=\"InfoboxRow\">" + multiSideCell;
}
if (noEdit === false) {
outEdit += "<tr id=\"" + EditModeMultipleContentID + "\" class=\"InfoboxRow\"" + multiSideParamHover + ">" + multiSideCellEdit;
}
}
//Output if using multiple sides (inner cells)
//else if ((paramListParsed[k].indexOf(prefixThree+"2-") !== -1) || (paramListParsed[k].indexOf(prefixFour+"2-") !== -1) || (paramListParsed[k].indexOf(prefixFour+"3-") !== -1)) {//karamba
else if (paramListParsed[k].match(prefixMatch324243)) {
if (hideMultiRow === false) {
out += multiSideCell;
}
if (noEdit === false) {
outEdit += multiSideCellEdit;
}
}
//Output if using multiple sides (outer right cells)
//else if ((paramListParsed[k].indexOf(prefixSide+"2-") !== -1) || (paramListParsed[k].indexOf(prefixThree+"3-") !== -1) || (paramListParsed[k].indexOf(prefixFour+"4-") !== -1)) {//karamba
else if (paramListParsed[k].match(prefixMatch223344)) {
if (hideMultiRow === false) {
out += multiSideCell + "</tr>";
}
if (noEdit === false) {
outEdit += multiSideCellEdit + "</tr>";
//console.log("RIGHT-"+paramListParsed[k]+"\n"+multiSideCellEdit + "</tr>");//karamba
}
}
//Normal output
else {
if (param !== InfoboxDefaultValueUnknown) {
if (showUnitOfMeasure === true) {
if (ParamName.match(/\[[\w\W]+?\]/)) { //Show unit of measure
unitOfMeasure = " "+ParamName.match(/\[[\w\W]+?\]/).toString().replace(/\[|\]/g, "");
}
else {
unitOfMeasure = "";
}
}
else {
unitOfMeasure = "";
}
out += "<tr id=\"" + ViewModeContentID + "\" class=\"InfoboxRow\"><td class=\"InfoboxCellLeft\">" + ParamName + "</td><td class=\"InfoboxCellRight\">" + paramView + unitOfMeasure + "</td></tr>";
}
if (noEdit === false) {
outEdit += singleSideRowEdit;
}
}
//Hide lines with no information
if ((param === InfoboxDefaultValueUnknown) && (paramListParsed[k].indexOf(prefixSection+"-") === -1)) {
if (hideEmptyLines === true) {
setStylesheet("#" + EditModeContentID + " {display: none;}", this.IDs.IDPrefixInfoboxTablesStyle + EditModeContentID);
}
else {
setStylesheet("#" + EditModeContentID + " {display: table-row;}", this.IDs.IDPrefixInfoboxTablesStyle + EditModeContentID);
}
}
//Show prefixes
if (showModulePrefix === true) {
setStylesheet("#" + EditParamPrefixID + " {display: inline;}", this.IDs.IDPrefixInfoboxTablesStyle + EditParamPrefixID);
}
else {
setStylesheet("#" + EditParamPrefixID + " {display: none;}", this.IDs.IDPrefixInfoboxTablesStyle + EditParamPrefixID);
}
//Add borders to includes
if ((noEdit === false) && (showBorderAroundInclude === true)) {
if (showTop === true) { //Top border
if (paramListParsed[k+1].indexOf(prefixSection+"-") !== -1) { //Section headers
setStylesheet("#" + EditModeSectionHeaderIDNext + " td {border-top: solid "+includeDepth+"px "+store.getTiddlerText('InfoboxTablesColorPalette::InfoboxIncludeDelimiter')+"!important;}", this.IDs.IDPrefixInfoboxTablesStyle + this.IDs.IDPrefixIncludeTopRow + EditModeSectionHeaderIDNext);
}
else { //Normal cells
setStylesheet("#" + EditModeContentIDNext + " td {border-top: solid "+includeDepth+"px "+store.getTiddlerText('InfoboxTablesColorPalette::InfoboxIncludeDelimiter')+"!important;}", this.IDs.IDPrefixInfoboxTablesStyle + this.IDs.IDPrefixIncludeTopRow + EditModeContentIDNext);
}
showTop = false;
}
if (includeDepth > 1) { //Side borders
if (paramListParsed[k].indexOf(prefixSection+"-") !== -1) { //Section headers
setStylesheet("#" + EditModeSectionHeaderID + " td:first-child {border-left: solid "+includeDepth+"px "+store.getTiddlerText('InfoboxTablesColorPalette::InfoboxIncludeDelimiter')+"!important;}", this.IDs.IDPrefixInfoboxTablesStyle + this.IDs.IDPrefixIncludeFirstCell + EditModeSectionHeaderID);
setStylesheet("#" + EditModeSectionHeaderID + " td:last-child {border-right: solid "+includeDepth+"px "+store.getTiddlerText('InfoboxTablesColorPalette::InfoboxIncludeDelimiter')+"!important;}", this.IDs.IDPrefixInfoboxTablesStyle + this.IDs.IDPrefixIncludeLastCell + EditModeSectionHeaderID);
}
else { //Normal cells
setStylesheet("#" + EditModeContentID + " td:first-child {border-left: solid "+includeDepth+"px "+store.getTiddlerText('InfoboxTablesColorPalette::InfoboxIncludeDelimiter')+"!important;}", this.IDs.IDPrefixInfoboxTablesStyle + this.IDs.IDPrefixIncludeFirstCell + EditModeContentID);
setStylesheet("#" + EditModeContentID + " td:last-child {border-right: solid "+includeDepth+"px "+store.getTiddlerText('InfoboxTablesColorPalette::InfoboxIncludeDelimiter')+"!important;}", this.IDs.IDPrefixInfoboxTablesStyle + this.IDs.IDPrefixIncludeLastCell + EditModeContentID);
}
}
if (showBottom === true) { //Bottom border
setStylesheet("#" + EditModeContentIDPrevious + " td {border-bottom: solid "+(includeDepth+1)+"px "+store.getTiddlerText('InfoboxTablesColorPalette::InfoboxIncludeDelimiter')+"!important;}", this.IDs.IDPrefixInfoboxTablesStyle + this.IDs.IDPrefixIncludeBottomRow + EditModeContentIDPrevious); //Needs to add 1px to border width, because the depth gets subtracted when showBottom is set to true
showBottom = false;
}
}
//Hide section title in view mode if all params in the section are unknown
if (paramListParsed[k].indexOf(prefixSection+"-") !== -1) {
oldSectionTitleIndex = sectionTitleIndex; //Set the index of the previous section title
if (oldSectionTitleIndex === undefined) {
oldSectionTitleIndex = 0;
}
sectionTitleIndex = k; //Set the index of the current section title
sectionTitle = paramListParsed[oldSectionTitleIndex]; //Get the previous section title
if (oldSectionTitleIndex !== sectionTitleIndex) { //Determine the length of the previous section
sectionLength = sectionTitleIndex-oldSectionTitleIndex-1;
}
else {
sectionLength = sectionParamsCounter;
}
if (sectionParamsCounter === sectionLength) { //Hide section if all params are unknown
hideSection = true;
}
else {
hideSection = false;
}
sectionParamsCounter = 0; //Reset the section counter
}
else {
if (param === InfoboxDefaultValueUnknown) { //Count the param, if it's unknown
sectionParamsCounter = sectionParamsCounter + 1;
}
if (k === paramListParsed.length-1) { //If it's the last parameter in the list
oldSectionTitleIndex = sectionTitleIndex; //Set the index of the previous section title
sectionTitleIndex = k+1; //Set the index of the current section title (here, it doesn't really exist, since it's the end of the list)
sectionTitle = paramListParsed[oldSectionTitleIndex]; //Get the previous section title
sectionLength = sectionTitleIndex-oldSectionTitleIndex-1; //Determine the length of the current section
if (sectionParamsCounter === sectionLength) { //Hide section if all params are unknown
hideSection = true;
}
else {
hideSection = false;
}
}
}
if (sectionTitle) { //Get the ID of the previous section title table
sectionTable = this.IDs.IDPrefixSectionTable + TTIX + "_" + sectionTitle.replace(RowIDReplaceRE, "").replace(/!/g, "_").replace(/[^a-zA-Z0-9_\-]/g, "");
}
if (hideSection === true) {
setStylesheet("#" + sectionTable + " {display: none;}", this.IDs.IDPrefixInfoboxTablesStyle + sectionTable);
if (hideEmptyLines === true) {
setStylesheet("#" + this.IDs.IDPrefixEdit + sectionTable + " {display: none;}", this.IDs.IDPrefixInfoboxTablesStyle + this.IDs.IDPrefixEdit + sectionTable);
}
else {
setStylesheet("#" + this.IDs.IDPrefixEdit + sectionTable + " {display: table;}", this.IDs.IDPrefixInfoboxTablesStyle + this.IDs.IDPrefixEdit + sectionTable);
}
}
else {
setStylesheet("#" + sectionTable + " {display: table;}", this.IDs.IDPrefixInfoboxTablesStyle + sectionTable);
}
//Count how many params are unknown
if (param === InfoboxDefaultValueUnknown) {
paramCount = paramCount + 1;
}
} //End parsing of parameters for output
//Final output
if (paramCount !== paramListParsedLength) { //If not all params are unknown
wikify(start + out + end, InfoboxTableDiv); //Show table
}
else {
wikify(noInfo, InfoboxTableDiv); //Show "No information available." message
}
if (noEdit === false) {
wikify(startEdit + outEdit + endEdit, InfoboxTableEditDiv);
}
//Output for template list
if (hideShowTemplateListButton === false) {
var globalTemplateButton = "{{infoboxTemplateLinkGlobal{[["+globalParametersTemplate.replace(/_/g, " ")+"|"+globalParametersTemplate+"]]}}}";
var mainTemplateButton = "{{infoboxTemplateLinkMain{[["+Type+"|" + InfoboxPrefixInfobox + "_" + Type.replace(/ /g, "_") + "]]}}}";
var infoboxIncludesButtons, extraLineBreakAfterInfobox, extraLineBreakAfterModuleText;
if (infoboxIncludes.length) {
infoboxIncludesButtons = infoboxIncludes.toString().replace(/((?:\*)+)/g, "$1{{infoboxTemplateLinkMainInclude{[[").replace(/,/g, "\n")+"\n";
extraLineBreakAfterInfobox = "\n";
}
else {
infoboxIncludesButtons = "";
extraLineBreakAfterInfobox = "";
}
var moduleButtons = moduleListButtons.toString().replace(/,/g, "\n");
if (Modules.length) {
extraLineBreakAfterModuleText = "\n";
}
else {
extraLineBreakAfterModuleText = "";
}
var ViewTemplateList = this.texts.infoboxViewTemplates.format([globalTemplateButton,mainTemplateButton,infoboxIncludesButtons+extraLineBreakAfterInfobox,extraLineBreakAfterModuleText+moduleButtons]);
wikify(ViewTemplateList,templateListInnerContainerDiv);
}
if (noEdit === false) {
//Make sure the correct value is selected in dropdowns
var selectArraySplit = selectArray.replace(/\\,/g, "commaPlaceholder").replace(/\\;/g, "semicolonPlaceholder").split(";");
var a, b, f, select, option, selectArraySplitOptions, selectArraySplitOptionsLength, selectOptionsLength;
var selectArraySplitLength = selectArraySplit.length;
for (a = 0; a < selectArraySplitLength; a+=1) { //Go through dropdowns
selectArraySplitOptions = selectArraySplit[a].split(",");
select = document.getElementById(selectArraySplitOptions[0]); //First entry is always the select
selectArraySplitOptionsLength = selectArraySplitOptions.length;
for (b = 1; b < selectArraySplitOptionsLength; b+=1) { //Go through selected values
selectOptionsLength = select.options.length;
for (f = 0; f < selectOptionsLength; f+=1) { //Go through options
option = select.options[f];
if (option.value === selectArraySplitOptions[b].replace(/commaPlaceholder/g, ",").replace(/semicolonPlaceholder/g, ";").trim()) { //If selected value matches the option, make it selected; need to trim, because values in the param are space-separated
option.setAttribute("selected", true);
option.selected = true;
}
} //End go through options
} //End go through selected values
} //End go through dropdowns
}
} //End if Type is okay
}; //End of Infobox macro
//Toggle display of infoboxes
config.macros.infobox.toggleInfobox = function(noEdit,editButton,showHideEditModeButton,place,templateListOuterContainerDiv) {
"use strict";
var hideInfoboxes = config.options.chkInfoboxesHideInfoboxes;
if (hideInfoboxes === true) { //If infoboxes are hidden on load
if (place.style.display === "block"){
place.style.display = "none";
templateListOuterContainerDiv.style.display = "none";
editButton.style.display = "none";
showHideEditModeButton.innerHTML = showHideEditModeButton.getAttribute("data-infobox-closedtext");
showHideEditModeButton.setAttribute("title",showHideEditModeButton.getAttribute("data-infobox-closedtip"));
} else {
place.style.display = "block";
templateListOuterContainerDiv.style.display = "block";
if (noEdit === false) {
editButton.style.display = "block";
}
showHideEditModeButton.innerHTML = showHideEditModeButton.getAttribute("data-infobox-openedtext");
showHideEditModeButton.setAttribute("title",showHideEditModeButton.getAttribute("data-infobox-openedtip"));
}
} else {
if (place.style.display === "none") {
place.style.display = "block";
templateListOuterContainerDiv.style.display = "block";
if (noEdit === false) {
editButton.style.display = "block";
}
showHideEditModeButton.innerHTML = showHideEditModeButton.getAttribute("data-infobox-openedtext");
showHideEditModeButton.setAttribute("title",showHideEditModeButton.getAttribute("data-infobox-openedtip"));
} else {
place.style.display = "none";
templateListOuterContainerDiv.style.display = "none";
editButton.style.display = "none";
showHideEditModeButton.innerHTML = showHideEditModeButton.getAttribute("data-infobox-closedtext");
showHideEditModeButton.setAttribute("title",showHideEditModeButton.getAttribute("data-infobox-closedtip"));
}
}
};
//End toggle display of infoboxes
//Edit infoboxes
config.macros.infobox.editInfobox = function(saveButton,editButton,deleteButton,showHideEditModeButton,showHideLinesInEditModeButton,place,templateListOuterContainerDiv,placeEdit,TTIX) {
"use strict";
//if (place.style.display === "block"){ //Switch from view to edit mode
if (jQuery(place).css("display") === "block"){ //Switch from view to edit mode
setStylesheet("#" + this.IDs.IDPrefixOuterContainer + TTIX + " {width: 100%;}", this.IDs.IDPrefixInfoboxTablesStyle + this.IDs.IDPrefixOuterContainer + TTIX);
deleteButton.style.display = "block";
saveButton.style.display = "block";
showHideEditModeButton.style.display = "none";
showHideLinesInEditModeButton.style.display = "block";
place.style.display = "none";
templateListOuterContainerDiv.style.display = "none";
placeEdit.style.display = "block";
editButton.innerHTML = editButton.getAttribute("data-infobox-canceltext");
editButton.setAttribute("title",editButton.getAttribute("data-infobox-canceltip"));
}
else { //Switch from edit to view mode
setStylesheet("#" + this.IDs.IDPrefixOuterContainer + TTIX + " {width: 33%;}", this.IDs.IDPrefixInfoboxTablesStyle + this.IDs.IDPrefixOuterContainer + TTIX);
deleteButton.style.display = "none";
saveButton.style.display = "none";
showHideEditModeButton.style.display = "block";
showHideLinesInEditModeButton.style.display = "none";
place.style.display = "block";
templateListOuterContainerDiv.style.display = "block";
placeEdit.style.display = "none";
editButton.innerHTML = editButton.getAttribute("data-infobox-edittext");
editButton.setAttribute("title",editButton.getAttribute("data-infobox-edittip"));
//Remove unsaved modules
var ModulesTempRE = new RegExp(TTIX+":[\\w\\W\\s]+?(?:\n|$)", "g");
var getModulesTemp = store.getShadowTiddlerText("InfoboxTablesModulesTemp");
var ModulesTemp = getModulesTemp.match(ModulesTempRE);
if (ModulesTemp !== null) {
var ModulesTempNew = getModulesTemp.replace(ModulesTempRE, "");
if (ModulesTempNew.length) {
config.shadowTiddlers.InfoboxTablesModulesTemp = ModulesTempNew;
}
else {
config.shadowTiddlers.InfoboxTablesModulesTemp = "";
}
}
else {
config.shadowTiddlers.InfoboxTablesModulesTemp = "";
}
window.scroll(0,0); //Scroll to top of the page (when pressing Escape instead of using the "cancel" button)
}
};
//End edit infoboxes
//Toggle template list
config.macros.infobox.toggleTemplateList = function(button,list) {
"use strict";
if (list.style.display === "none") {
list.style.display = "block";
button.innerHTML = button.getAttribute("data-infobox-hideTemplateText");
button.setAttribute("title",button.getAttribute("data-infobox-hideTemplateTip"));
}
else {
list.style.display = "none";
button.innerHTML = button.getAttribute("data-infobox-showTemplateText");
button.setAttribute("title",button.getAttribute("data-infobox-showTemplateTip"));
}
};
//Toggle module instance counter
config.macros.infobox.toggleInstanceCounter = function(counterID) {
"use strict";
var element = document.getElementById(counterID);
var disabled = element.disabled;
if ((disabled === true) || (disabled === undefined) || (disabled === null)) { //For some reason, the property gets ignored initially
element.disabled = false;
element.style.display = "inline";
element.value = "1";
}
else {
element.disabled = true;
element.style.display = "none";
element.value = "0";
}
};
//End toggle module instance counter
//Toggle modules
config.macros.infobox.toggleModule = function(moduleCheckboxText,Modules,saveButton,editButton,deleteButton,showHideEditModeButton,showHideLinesInEditModeButton,place,templateListOuterContainerDiv,placeEdit,article,TTIX) {
"use strict";
var InfoboxPrefixInfoboxModule = config.options.txtInfoboxesPrefixInfoboxModule.replace(/ /g, "_"); //Get module tiddler prefix
var ModulesTempRE = new RegExp(TTIX+":[\\w\\W\\s]*?(?:\n|$)", "g");
var ModulesTemp = store.getShadowTiddlerText("InfoboxTablesModulesTemp").match(ModulesTempRE);
var modulesSplit;
var moduleName = InfoboxPrefixInfoboxModule+"_"+moduleCheckboxText.replace(/ /g, "_"); //Get module name
if (Modules.length) { //If there are already activated modules
modulesSplit = Modules.split(","); //Turn modules string into array
var moduleIndex = modulesSplit.indexOf(moduleName); //Check if module is in the array
if (moduleIndex === -1) { //If module is not enabled, enable it (one instance only)
modulesSplit.push(moduleName);
modulesSplit.push("1");
}
else { //If module is enabled, disable it
modulesSplit.splice(moduleIndex,2);
}
}
else { //If there are no activated modules
modulesSplit = [];
modulesSplit.push(moduleName);
modulesSplit.push("1");
}
var ModulesNew = modulesSplit.toString(); //Turn the array back into string
if (!ModulesNew.length) { //If there are no modules
config.shadowTiddlers.InfoboxTablesModulesTemp = TTIX+":";
}
else { //If there are modules
if (ModulesTemp && ModulesTemp.toString().match(TTIX)) { //If there's a match in the temp shadow tiddler
var ModulesTempNew = ModulesTemp.toString().replace(ModulesTempRE, TTIX+":"+ModulesNew);
config.shadowTiddlers.InfoboxTablesModulesTemp = ModulesTempNew;
}
else {
config.shadowTiddlers.InfoboxTablesModulesTemp += "\n"+TTIX+":"+ModulesNew;
}
}
//Refresh display and open edit mode
story.refreshTiddler(article,null,true);
setStylesheet("#" + this.IDs.IDPrefixOuterContainer + TTIX + " {width: 100%!important;}", this.IDs.IDPrefixInfoboxTablesStyle + this.IDs.IDPrefixOuterContainer + TTIX);
document.getElementById(deleteButton).style.display = "block";
document.getElementById(saveButton).style.display = "block";
document.getElementById(editButton).innerHTML = document.getElementById(editButton).getAttribute("data-infobox-canceltext");
document.getElementById(editButton).setAttribute("title",document.getElementById(editButton).getAttribute("data-infobox-canceltip"));
document.getElementById(showHideEditModeButton).style.display = "none";
document.getElementById(showHideLinesInEditModeButton).style.display = "block";
document.getElementById(place).style.display = "none";
document.getElementById(templateListOuterContainerDiv).style.display = "none";
document.getElementById(placeEdit).style.display = "block";
};
//End toggle modules
//Change number of module instances
config.macros.infobox.changeNumberOfInstances = function(counter,Modules,counterIndex,saveButton,editButton,deleteButton,showHideEditModeButton,showHideLinesInEditModeButton,place,templateListOuterContainerDiv,placeEdit,article,TTIX) {
"use strict";
var ModulesTempRE = new RegExp(TTIX+":[\\w\\W\\s]*?(?:\n|$)", "g");
var ModulesTemp = store.getShadowTiddlerText("InfoboxTablesModulesTemp").match(ModulesTempRE);
var modulesSplit = Modules.split(","); //Turn modules string into array
modulesSplit[counterIndex] = counter.value; //Change the number of instances
var ModulesNew = modulesSplit.toString(); //Turn the array back into string
if (ModulesTemp && ModulesTemp.toString().match(TTIX)) {
var ModulesTempNew = ModulesTemp.toString().replace(ModulesTempRE, TTIX+":"+ModulesNew);
config.shadowTiddlers.InfoboxTablesModulesTemp = ModulesTempNew;
}
else {
config.shadowTiddlers.InfoboxTablesModulesTemp += "\n"+TTIX+":"+ModulesNew;
}
//Refresh display and open edit mode
story.refreshTiddler(article,null,true);
setStylesheet("#" + this.IDs.IDPrefixOuterContainer + TTIX + " {width: 100%!important;}", this.IDs.IDPrefixInfoboxTablesStyle + this.IDs.IDPrefixOuterContainer + TTIX);
document.getElementById(deleteButton).style.display = "block";
document.getElementById(saveButton).style.display = "block";
document.getElementById(editButton).innerHTML = document.getElementById(editButton).getAttribute("data-infobox-canceltext");
document.getElementById(editButton).setAttribute("title",document.getElementById(editButton).getAttribute("data-infobox-canceltip"));
document.getElementById(showHideEditModeButton).style.display = "none";
document.getElementById(showHideLinesInEditModeButton).style.display = "block";
document.getElementById(place).style.display = "none";
document.getElementById(templateListOuterContainerDiv).style.display = "none";
document.getElementById(placeEdit).style.display = "block";
};
//End change number of module instances
//Toggle empty lines in edit mode
config.macros.infobox.toggleEmptyLines = function(showHideLinesInEditModeButton,placeEdit) {
"use strict";
var InfoboxDefaultValueUnknown = config.options.txtInfoboxesDefaultValueUnknown;
var InfoboxSpecialValueOther = config.options.txtInfoboxesSpecialValueOther;
var templateDelimiter = config.options.txtInfoboxesTemplateDelimiter;
var moduleDelimiter = config.options.txtInfoboxesModuleDelimiter;
var delimitersRE = new RegExp("(?:"+templateDelimiter+"-|"+moduleDelimiter+"-)","");
var InfoboxPrefixGlobal = config.options.txtInfoboxesPrefixGlobal;
var InfoboxPrefixModules = config.options.txtInfoboxesPrefixModules;
var InfoboxPrefixIncludes = config.options.txtInfoboxesPrefixIncludes;
var InfoboxSuffixModules = config.options.txtInfoboxesSuffixModules;
var paramPrefixes = "("+InfoboxPrefixGlobal+"!|(?:"+InfoboxPrefixIncludes+"_[^\n\*]*!)|(?:"+InfoboxPrefixModules+"_[^\n\*]*!))?";
var paramPrefixesRE = new RegExp(paramPrefixes,"");
var prefixSection = config.options.txtInfoboxesPrefixSection;
var ParamNameRE = new RegExp("_\\(\\([\\w\\s]*?\\)\\)|_\\*\\*[\\w\\W\\s]*?$|[\\(\\)\\[\\]\\/<>]", "g");
var RowIDReplaceRE = ParamNameRE;
var i, j, RowIDReplace, EditModeContentID, cells, cell1, cell2, cell, emptyHiddenToggle, section, SectionTableID, cellsLength, sectionParamCount, sectionUnknownParamCount;
// var sectionParamCount = 0;//karamba
// var sectionUnknownParamCount = 0;//karamba
var cleanupRE = new RegExp("<\\/?span[^>]*?>|<\\/?a[^>]*?>|<\\/?nowiki>","g");
var cleanupSectionRE = new RegExp("<span(?![^<]*?(?:InfoboxPrefixes|InfoboxParamOnly))[^<]*?<\\/span>|<\\/?span[^>]*?>|<\\/?nowiki>","g"); //Needs to cleanup comments first
var emptyHiddenStatus = placeEdit.classList.contains("InfoboxLinesHidden");
if (emptyHiddenStatus === false) { //Toggle button and status
emptyHiddenToggle = true;
showHideLinesInEditModeButton.innerHTML = showHideLinesInEditModeButton.getAttribute("data-infobox-showtext");
showHideLinesInEditModeButton.setAttribute("title",showHideLinesInEditModeButton.getAttribute("data-infobox-showtip"));
}
else {
emptyHiddenToggle = false;
showHideLinesInEditModeButton.innerHTML = showHideLinesInEditModeButton.getAttribute("data-infobox-hidetext");
showHideLinesInEditModeButton.setAttribute("title",showHideLinesInEditModeButton.getAttribute("data-infobox-hidetip"));
}
placeEdit.classList.toggle("InfoboxLinesHidden"); //Toggle class
//var infobox = document.getElementById(this.IDs.IDPrefixEdit + this.IDs.IDPrefixInfoboxContainer + TTIX); //Needs to capture the actual values in the DOM object, not the parameters//karamba
var infobox = document.getElementById(placeEdit.id); //Needs to capture the actual values in the DOM object, not the parameters
var rows = infobox.getElementsByTagName("tr");
var rowsLength = rows.length;
for (i = 0; i < rowsLength; i+=1) { //Go through the rows
cells = rows[i].getElementsByTagName("td");
//if ((cells.length === 1) && (cells[0].innerHTML.match(delimitersRE) === null)) { //Get section titles, but ignore template and module delimiters, and reset the counters
if (cells.length === 1) { //Section headers and delimiters
if (cells[0].innerHTML.match(delimitersRE) === null) { //Get section titles, but ignore template and module delimiters, and reset the counters
if (cells[0].innerHTML.match(" ") === null) {
sectionParamCount = 0;
sectionUnknownParamCount = 0;
//section = cells[0].innerHTML.replace(cleanupSectionRE, "").replace(/ /g, "_").trim(); //Cleanup required because of http://www.TiddlyTools.com/#HTMLFormattingPlugin
//SectionTableID = this.IDs.IDPrefixEdit + this.IDs.IDPrefixSectionTable + TTIX + "_" + section.replace(paramPrefixesRE, "$1"+prefixSection+"-").replace(/!/g, "_").replace(/[^a-zA-Z0-9_\-]/g, ""); //Needs to add the section prefix
SectionTableID = cells[0].parentElement.parentElement.parentElement.id;
}
else { //Include delimiters
EditModeContentID = cells[0].parentElement.id;
if (emptyHiddenToggle === true) {
setStylesheet("#" + EditModeContentID + " {display: none;}", this.IDs.IDPrefixInfoboxTablesStyle + EditModeContentID);
//setStylesheet("#" + EditModeContentID + " {display: none;}", this.IDs.IDPrefixInfoboxTablesStyle + this.IDs.IDPrefixIncludeFirstCell + EditModeContentID);
//setStylesheet("#" + EditModeContentID + " {display: none;}", this.IDs.IDPrefixInfoboxTablesStyle + this.IDs.IDPrefixIncludeLastCell + EditModeContentID);
}
else {
setStylesheet("#" + EditModeContentID + " {display: table-row;}", this.IDs.IDPrefixInfoboxTablesStyle + EditModeContentID);
//setStylesheet("#" + EditModeContentID + " {display: table-row;}", this.IDs.IDPrefixInfoboxTablesStyle + this.IDs.IDPrefixIncludeFirstCell + EditModeContentID);
//setStylesheet("#" + EditModeContentID + " {display: table-row;}", this.IDs.IDPrefixInfoboxTablesStyle + this.IDs.IDPrefixIncludeLastCell + EditModeContentID);
}
}
} //End get section titles, but ignore template and module delimiters, and reset the counters
} //End section headers and delimiters
else if ((cells.length === 2) && (cells[0].innerHTML.indexOf("textarea") === -1)) { //Normal display
//cell1 = cells[0].innerHTML.replace(cleanupRE, "").trim().replace(/ /g, "_"); //Cleanup required because of http://www.TiddlyTools.com/#HTMLFormattingPlugin
//RowIDReplace = TTIX + "_" + cell1.replace(RowIDReplaceRE, "").replace(/!/g, "_").replace(/[^a-zA-Z0-9_\-]/g, ""); //karamba
//RowIDReplace = TTIX + "_" + cell1.replace(RowIDReplaceRE, "").replace(/!/g, "_").replace(/[^a-zA-Z0-9_\-]/g, "").replace(/ /g, "_").replace(paramPrefixesRE, "").replace(/!/g, "_").replace(/[^a-zA-Z0-9_\-]/g, ""); //karamba
//EditModeContentID = this.IDs.IDPrefixEdit + ViewModeContentID.replace(/ /g, "_").replace(paramPrefixesRE, "").replace(/!/g, "_").replace(/[^a-zA-Z0-9_\-]/g, ""); //karamba
//EditModeContentID = this.IDs.IDPrefixEdit + this.IDs.IDPrefixContent + RowIDReplace; //karamba
EditModeContentID = cells[0].parentElement.id;
if ((cells[1].innerHTML.indexOf("textarea") !== -1) && (cells[1].innerHTML.indexOf("select") === -1)) { //Normal textareas
cell2 = cells[1].getElementsByTagName("textarea")[0].value;
}
else if ((cells[1].innerHTML.indexOf("select") !== -1) && (cells[1].innerHTML.indexOf("textarea") === -1)) { //Plugin provided selects without alternative textareas
cell2 = cells[1].getElementsByTagName("select")[0].value;
}
else if ((cells[1].innerHTML.indexOf("select") !== -1) && (cells[1].innerHTML.indexOf("textarea") !== -1)) { //Selects with alternative textareas
cell2 = cells[1].getElementsByTagName("select")[0].value;
if (cell2 === InfoboxSpecialValueOther) { //If selected value is "other"
cell2 = cells[1].getElementsByTagName("textarea")[0].value;
}
}
else { //No selects or textareas, just display
cell2 = cells[1].innerHTML.replace(cleanupRE, "").trim(); //Cleanup required because of http://www.TiddlyTools.com/#HTMLFormattingPlugin
}
sectionParamCount = sectionParamCount + 1;
if (!cell2 || (cell2 === InfoboxDefaultValueUnknown)) { //If the cell is empty (or no value is selected for selects with multiple allowed values) or a default value
sectionUnknownParamCount = sectionUnknownParamCount + 1;
if (emptyHiddenToggle === true) {
setStylesheet("#" + EditModeContentID + " {display: none;}", this.IDs.IDPrefixInfoboxTablesStyle + EditModeContentID);
}
else {
setStylesheet("#" + EditModeContentID + " {display: table-row;}", this.IDs.IDPrefixInfoboxTablesStyle + EditModeContentID);
}
} //End if the cell is empty or a default value
} //End normal display
else if (((cells.length === 2) && (cells[0].innerHTML.indexOf("textarea") !== -1)) || (cells.length > 2)) { //Multiple sided display
cellsLength = cells.length;
for (j = 0; j < cellsLength; j+=1) { //Go through cells
if ((cells[j].innerHTML.indexOf("select") !== -1) && (cells[j].innerHTML.indexOf("textarea") !== -1)) { //Selects with alternative textareas
cell = cells[j].getElementsByTagName("select")[0].value;
if (cell === InfoboxSpecialValueOther) { //If selected value is "other"
cell = cells[j].getElementsByTagName("textarea")[0].value;
}
}
else { //Normal textareas
cell = cells[j].getElementsByTagName("textarea")[0].value;
}
sectionParamCount = sectionParamCount + 1;
if (cell === InfoboxDefaultValueUnknown) {
sectionUnknownParamCount = sectionUnknownParamCount + 1;
}
} //End go through cells
} //End multiple sided display
if (sectionParamCount === sectionUnknownParamCount) { //Hide the entire section if all parameters are unknown
if (emptyHiddenToggle === true) {
setStylesheet("#" + SectionTableID + " {display: none;}", this.IDs.IDPrefixInfoboxTablesStyle + SectionTableID);
}
else {
setStylesheet("#" + SectionTableID + " {display: table;}", this.IDs.IDPrefixInfoboxTablesStyle + SectionTableID);
}
}
else {
setStylesheet("#" + SectionTableID + " {display: table;}", this.IDs.IDPrefixInfoboxTablesStyle + SectionTableID);
}
} //End go through the rows
};
//End toggle empty lines in edit mode
//Change image preview
config.macros.infobox.changePreview = function(element) {
"use strict";
var InfoboxDefaultValueUnknown = config.options.txtInfoboxesDefaultValueUnknown;
element.defaultValue = element.value;
var value = element.defaultValue;
//Note: The reason why nextSibling is used so many times is because getting the image element by ID (getElementById()) and changing it directly doesn't trigger the change of preview
if (element.id.match(this.IDs.IDSuffixImageSrc)) {
element.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.src = value;
if ((value === InfoboxDefaultValueUnknown) || !value.length) {
element.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.style.display = "none";
element.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.style.display = "block";
}
else {
element.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.style.display = "block";
element.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.style.display = "none";
}
}
else if (element.id.match(this.IDs.IDSuffixImageAlt)) {
element.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.alt = value;
}
else if (element.id.match(this.IDs.IDSuffixImageTitle)) {
element.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.title = value;
}
else if (element.id.match(this.IDs.IDSuffixImageCaption)) {
if (element.id.match(this.IDs.IDPrefixEdit + this.IDs.IDPrefixFigureCheckbox)) {
if (element.getAttribute("checked") === "checked") {
element.defaultValue = false;
element.removeAttribute("checked");
element.parentElement.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.nextSibling.innerHTML = "";
}
else {
element.defaultValue = true;
element.setAttribute("checked","checked");
element.parentElement.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.nextSibling.innerHTML = element.parentElement.nextSibling.nextSibling.innerHTML;
}
}
}
else if ((element.id.match(this.IDs.IDSuffixImageLink)) && (element.id.match(this.IDs.IDPrefixEdit + this.IDs.IDPrefixFigureCheckbox))) {
if (element.getAttribute("checked") === "checked") {
element.defaultValue = false;
element.removeAttribute("checked");
}
else {
element.defaultValue = true;
element.setAttribute("checked","checked");
}
}
};
//End change image preview
//Toggle comments
config.macros.infobox.toggleComments = function(select) {
"use strict";
if (select.parentNode.previousSibling.style.display !== "block") {
select.parentNode.previousSibling.style.display = "block";
}
else {
select.parentNode.previousSibling.style.display = "none";
}
};
//End toggle comments
//Toggle select highlight
config.macros.infobox.toggleSelectHighlight = function(select) {
"use strict";
var InfoboxDefaultValueUnknown = config.options.txtInfoboxesDefaultValueUnknown;
if (select.selectedOptions && (select.selectedOptions.length === 1) && (select.selectedOptions[0].value === InfoboxDefaultValueUnknown)) { //selectedOptions is not supported in IE and Safari for Windows
select.classList.remove("InfoboxLinesHighlighted");
}
else {
select.classList.add("InfoboxLinesHighlighted");
}
};
//End toggle select highlight
//Toggle alternative textarea
config.macros.infobox.toggleAltTextarea = function(select) {
"use strict";
var InfoboxSpecialValueOther = config.options.txtInfoboxesSpecialValueOther;
var e, multipleOther;
var optionsLength = select.options.length;
for (e = 0; e < optionsLength; e+=1) { //Go through the select options and check if other option is selected
if (select.options[e].selected === true) {
if (select.options[e].value === InfoboxSpecialValueOther) {
multipleOther = true;
break;
}
}
}
if ((multipleOther === true) && (select.nextSibling.style.display !== "block")) {
select.nextSibling.style.display = "block";
select.nextSibling.focus();
}
else {
select.nextSibling.style.display = "none";
}
};
//End toggle alternative textarea
//Toggle textarea size
config.macros.infobox.toggleTextareaSize = function(textarea,textareaOnly,EditCommentID) {
"use strict";
var InfoboxDefaultValueUnknown = config.options.txtInfoboxesDefaultValueUnknown;
if (textarea.className !== "InfoboxEditTextareaOnfocus") { //On focus
textarea.className = "InfoboxEditTextareaOnfocus";
if (textarea.value === InfoboxDefaultValueUnknown) { //Empty the textarea if value is unknown
textarea.value = "";
}
if (textareaOnly === true) { //If there is no comments div
textarea.parentNode.previousSibling.style.display = "block";
}
else {
if (textarea.previousSibling) { //If comments div exists
textarea.previousSibling.style.display = "block";
}
}
}
else { //On blur
if (EditCommentID !== undefined) { //Check the limits
if ((textarea.value !== InfoboxDefaultValueUnknown) && (textarea.parentElement.previousSibling.firstChild.innerHTML.match(this.texts.infoboxLimits))) { //Clean up only the textareas with values
textarea.value = textarea.value.replace(/[^\d\.\-]/g, "");
}
var textareaValueClean = textarea.value;
var comment = document.getElementById(EditCommentID).innerHTML; //Get the comment
var limitRE = new RegExp(this.texts.infoboxLimits+"[\\w\\W\\s]*?$","");
var limitCleanRE = new RegExp(this.texts.infoboxLimits,"");
var limits = comment.match(limitRE).toString().replace(limitCleanRE, "").replace(/</g, "<").replace(/>/g, ">"); //Get limits
var limitSplit = limits.split(",");
var newLimits = textarea.nextSibling.firstChild.nextSibling;
var newLimitsSplit = newLimits.value.split(",");
var i, split, newLimitsSplitLength;
var count = 0;
if (textareaValueClean.length !== 0) { //If it contains a value
if (isNaN(textareaValueClean) === true) { //If the entered value is not a number
textarea.value = InfoboxDefaultValueUnknown;
textarea.className = "InfoboxEditTextareaOnblur";
textarea.parentNode.previousSibling.style.display = "none";
alert(this.texts.infoboxNaN);
return;
}
if ((limits !== null) && (limits !== undefined) && (limits !== "undefined")) { //If limits are defined
var limitSplitLength = limitSplit.length;
for (i = 0; i < limitSplitLength; i+=1) { //Go through the limits
if (limitSplit[i].indexOf("&") !== -1) { //If the limit is an inlusive interval
split = limitSplit[i].split("&");
if ((eval(textareaValueClean+split[0].trim()) === false) || (eval(textareaValueClean+split[1].trim()) === false)) {
count = count + 1;
}
}
else if (limitSplit[i].indexOf("|") !== -1) { //If the limit is an exclusive interval
split = limitSplit[i].split("|");
if ((eval(textareaValueClean+split[0].trim()) === false) && (eval(textareaValueClean+split[1].trim()) === false)) {
count = count + 1;
}
}
else { //If the limit is not an interval
if (eval(textareaValueClean+limitSplit[i].trim()) === false) {
count = count + 1;
}
}
} //End go through the limits
if (count === limitSplitLength) { //If the value doesn't match any limits
textarea.value = InfoboxDefaultValueUnknown;
textarea.className = "InfoboxEditTextareaOnblur";
textarea.parentNode.previousSibling.style.display = "none";
alert(this.texts.infoboxValueOutOfBounds+" "+this.texts.infoboxLimits+"\n"+limits.replace(/&/g, "&"));
return;
}
} //End if limits are defined
else if ((limits === "undefined") && ((newLimits.value !== "unknown") || (newLimits.length > 0))) { //If defining new limits
newLimitsSplitLength = newLimitsSplit.length;
for (i = 0; i < newLimitsSplitLength; i+=1) { //Go through the limits
if (newLimitsSplit[i].indexOf("&") !== -1) { //If the limit is an inlusive interval
split = limitSplit[i].split("&");
if ((eval(textareaValueClean+split[0].trim()) === false) || (eval(textareaValueClean+split[1].trim()) === false)) {
count = count + 1;
}
}
else if (newLimitsSplit[i].indexOf("|") !== -1) { //If the limit is an exclusive interval
split = newLimitsSplit[i].split("|");
if ((eval(textareaValueClean+split[0].trim()) === false) && (eval(textareaValueClean+split[1].trim()) === false)) {
count = count + 1;
}
}
else { //If the limit is not an interval
if (eval(textareaValueClean+newLimitsSplit[i].trim()) === false) {
count = count + 1;
}
}
} //End go through the limits
if (count === newLimitsSplitLength) {
textarea.value = InfoboxDefaultValueUnknown;
textarea.className = "InfoboxEditTextareaOnblur";
textarea.parentNode.previousSibling.style.display = "none";
alert(this.texts.infoboxValueOutOfBounds+" "+this.texts.infoboxLimits+"\n"+newLimitsSplit.toString().replace(/&/g, "&"));
return;
}
} //End if defining new limits
} //End if it contains a value
else { //If no value is entered
textarea.value = InfoboxDefaultValueUnknown;
}
}
else {
textarea.defaultValue = textarea.value;
if (textarea.value.length === 0) {
textarea.value = InfoboxDefaultValueUnknown;
}
}
if (textarea.value === InfoboxDefaultValueUnknown) {
textarea.className = "InfoboxEditTextareaOnblur";
}
else {
textarea.className = "InfoboxEditTextareaOnblur InfoboxLinesHighlighted";
}
if (textareaOnly === true) {
textarea.parentNode.previousSibling.style.display = "none";
}
else {
if (textarea.previousSibling) { //If comments div exists
textarea.previousSibling.style.display = "none";
}
}
}
};
//End toggle textarea size
//Check input value
config.macros.infobox.checkInputValue = function(input) {
"use strict";
var InfoboxDefaultValueUnknown = config.options.txtInfoboxesDefaultValueUnknown;
var correctFormattingRE = new RegExp("(?:[<>]=?|[!=]=)?-?\\d+(?:\\.\\d+)?(?:[\\|&](?:[<>]=?|[!=]=)?-?\\d+(?:\\.\\d+)?)?(?:, )?","g");
var wrongFormattingRE = new RegExp("(?:^|, )(?:!=|==)[\\d\\.<>]+[\\|&]|[\\|&](?:!=|==)[\\d\\.<>]+(?:,|$)","g");
var forbiddenCharsRE = new RegExp("[^<>\\|&,!=\\-\\.\\s\\d]", "g");
var textarea = input.parentNode.previousSibling;
if (input.value === InfoboxDefaultValueUnknown) { //Clear the input if value is unknown
input.value = "";
}
else if (input.value.length === 0) { //Set the value to unknown if the value is empty
input.value = InfoboxDefaultValueUnknown;
input.classList.remove("InfoboxLinesHighlighted");
}
else { //Check the value
input.value = input.value.replace(forbiddenCharsRE, "").replace(/(^| |\|)=?(-?\d)/g, "$1==$2"); //Remove all forbidden characters, replace missing or single = with double
var limits = input.value;
var parts = limits.match(/,/g); //Check if there are limits
if (parts === null) {
parts = "";
}
var correctFormatting = limits.match(correctFormattingRE);
var wrongFormatting = limits.match(wrongFormattingRE);
var formatting;
if ((correctFormatting === null) || (wrongFormatting !== null)) { //Check formatting
formatting = "";
}
else {
formatting = correctFormatting;
}
var partsLength1 = parts.length+1;
var formattingLength = formatting.length;
if (partsLength1 !== formattingLength) { //If the limits are not formatted correctly
alert(this.texts.infoboxIncorrectLimits.format([limits]));
input.value = InfoboxDefaultValueUnknown; //Reset the value to default
input.classList.remove("InfoboxLinesHighlighted");
return;
}
if ((textarea.value !== null) && (textarea.value !== undefined) && (textarea.value !== InfoboxDefaultValueUnknown)) { //If textarea is filled in
var limitSplit = limits.split(","); //Split the limit list
var limitSplitLength = limitSplit.length;
var i, split;
var count = 0; //Set/reset the failed limit check counter
for (i = 0; i < limitSplitLength; i+=1) { //Go through the limits
if (limitSplit[i].indexOf("&") !== -1) { //If the limit is an inlusive interval
split = limitSplit[i].split("&");
if ((eval(textarea.value+split[0].trim()) === false) || (eval(textarea.value+split[1].trim()) === false)) {
count = count + 1;
}
}
else if (limitSplit[i].indexOf("|") !== -1) { //If the limit is an exclusive interval
split = limitSplit[i].split("|");
if ((eval(textarea.value+split[0].trim()) === false) && (eval(textarea.value+split[1].trim()) === false)) {
count = count + 1;
}
}
else { //If the limit is not an interval
if (eval(textarea.value+limitSplit[i].trim()) === false) { //If the limit fails
if (limitSplit[i].indexOf("!") === -1) { //If the limit is not a prohibition
count = count + 1;
}
else { //If the limit is a prohibition
count = limitSplitLength; //Fail all conditions
break; //Stop processing further limits
}
}
}
} //End if textarea is filled in
if (count === limitSplitLength) { //If all conditions fail
alert(this.texts.infoboxValueOutOfBounds+" "+this.texts.infoboxLimits+"\n"+limits);
textarea.value = InfoboxDefaultValueUnknown; //Reset the value to default
textarea.className = "InfoboxEditTextareaOnblur"; //Reset the textarea class
return;
}
} //End go through the limits
input.defaultValue = limits; //Set the new value
if (input.value === InfoboxDefaultValueUnknown) {
input.classList.remove("InfoboxLinesHighlighted"); //Remove the highlighting if value is not unknown
}
else {
input.classList.add("InfoboxLinesHighlighted"); //Add the highlighting if value is set
}
}
};
//End check input value
//Reset other value
config.macros.infobox.resetOtherValue = function(select) {
"use strict";
var InfoboxDefaultValueUnknown = config.options.txtInfoboxesDefaultValueUnknown;
var InfoboxSpecialValueOther = config.options.txtInfoboxesSpecialValueOther;
if (select.value !== InfoboxSpecialValueOther) { //If the value is not other
select.nextSibling.value = InfoboxDefaultValueUnknown; //Alternative textarea; reset the value
select.nextSibling.style.display = "none"; //Hide the alternative textarea
}
};
//End reset other value
//Toggle dependency values
config.macros.infobox.toggleDependencyValues = function(dependencyObject,dependency,dependent,containerID) {
"use strict";
var allowModifyingTemplates = config.options.chkInfoboxesAllowModifyingTemplates;
var maxMultipleSelections = (Math.abs(Math.round(config.options.txtInfoboxesMaxMultipleSelections)));
var InfoboxDefaultValueUnknown = config.options.txtInfoboxesDefaultValueUnknown;
var InfoboxSpecialValueOther = config.options.txtInfoboxesSpecialValueOther;
var multiple = false;
var dropdownOptionsCountRE, dropdownOptionsCount;
var getDependency = decodeURIComponent(dependency); //Get dependency param
var getDependent = decodeURIComponent(dependent); //Get dependent param
//var dependencyNewValue = dependencyObject.value; //Get the new value of the dependency//karambakaramba
var dependencyNewValue = dependencyObject.value.replace(/,/g, "commaPlaceholder").replace(/;/g, "semicolonPlaceholder"); //Get the new value of the dependency
if (getDependent.indexOf("%%") !== -1) {
var limitDependentValues = getDependent.match(/%%[\w\W\s]*?%%/).toString().replace(/%%/g, "").replace(/_/g, " ").replace(/\+\+[\w\W\s]*?\+\+/, "").replace(/\b\s*?,\s*?\b/g, ",").replace(/\b\s*?;\s*?\b/g, ";"); //Get dependent values
var limitDependentCategories = limitDependentValues.split(";"); //Split dependent values into categories
var commentText = getDependent.replace(/_|[\w\W\s]*?\*\*|\s*?%%[\w\W\s]*?%%\s*?| {2}/g, " ").replace(/ $/, ""); //Remove values from comment
if (commentText.length > 1) { //Add a break, if there's a comment
commentText = commentText+"<br/>";
}
var textarea = document.getElementById(containerID);
var limitDependencyValuePosition, limitCategory;
if (dependencyNewValue === InfoboxDefaultValueUnknown) { //If dependency is unknown
//Display message about dependency and hide the textarea
textarea.nextSibling.innerHTML = this.texts.infoboxDropdownNoDependencyValue.format([getDependency.replace(/_/g, " ").replace(/ [\(\*][\w\W\s]*?$/, "")]); //Error message
textarea.nextSibling.className = "InfoboxNoValueWarning"; //Show error message
textarea.style.display = "none"; //Container with select and alternative textarea
textarea.firstChild.value = InfoboxDefaultValueUnknown; //Alternative textarea; reset the value to "unknown"
textarea.firstChild.className = "InfoboxEditTextareaOnblur"; //Alternative textarea; reset the class
textarea.firstChild.nextSibling.firstChild.nextSibling.value = InfoboxDefaultValueUnknown; //Input; reset the value to "unknown"
textarea.firstChild.nextSibling.firstChild.nextSibling.className = "InfoboxEditInput"; //Input; reset the class
}
else if (dependencyNewValue === InfoboxSpecialValueOther) { //If dependency is other
//Remove message about dependency and show the textarea
textarea.nextSibling.className = "InfoboxEditDiv"; //Hide error message
textarea.style.display = "block"; //Container with select and alternative textarea
textarea.firstChild.value = InfoboxDefaultValueUnknown; //Alternative textarea; reset the value to "unknown"
textarea.firstChild.className = "InfoboxEditTextareaOnblur"; //Alternative textarea; reset the class
textarea.firstChild.nextSibling.style.display = "block"; //Input
textarea.previousSibling.firstChild.innerHTML = commentText + this.texts.infoboxLimits + limitCategory; //Comment
}
else { //If dependency is known
var limitDependencyValues = getDependency.match(/#[\w\W\s]*?#/).toString().replace(/#/g, "").replace(/_/g, " ").replace(/\b\s*?,\s*?\b/g, ",").split(","); //Get dependency values
limitDependencyValuePosition = limitDependencyValues.indexOf(dependencyNewValue); //Get the position of the dependency value in its own list
limitCategory = limitDependentCategories[limitDependencyValuePosition]; //Use the correct category
//Remove message about dependency and show the dropdown
textarea.nextSibling.className = "InfoboxEditDiv"; //Hide error message
textarea.style.display = "block"; //Container with select and alternative textarea
textarea.firstChild.value = InfoboxDefaultValueUnknown; //Alternative textarea; reset the value to "unknown"
textarea.firstChild.className = "InfoboxEditTextareaOnblur"; //Alternative textarea; reset the class
textarea.firstChild.nextSibling.style.display = "none"; //Input
textarea.firstChild.nextSibling.firstChild.nextSibling.value = InfoboxDefaultValueUnknown; //Input; reset the value to "unknown"
textarea.firstChild.nextSibling.firstChild.nextSibling.className = "InfoboxEditInput"; //Input; reset the class
textarea.previousSibling.firstChild.innerHTML = commentText + this.texts.infoboxLimits + limitCategory; //Comment
} //End if dependency is known
}
else if (getDependent.indexOf("#") !== -1) {
var dropdownDependencyValues = getDependency.match(/#[\w\W\s]*?#/).toString().replace(/#/g, "").replace(/_/g, " ").replace(/\b\s*?,\s*?\b/g, ",").replace(/\\,/g, "commaPlaceholder").replace(/\\;/g, "semicolonPlaceholder").split(","); //Get dependency values
var dropdownDependentValues = getDependent.match(/#[\w\W\s]*?#/).toString().replace(/#/g, "").replace(/_/g, " ").replace(/\+\+[\w\W\s]*?\+\+\s*?\b/, "").replace(/\b\s*?,\s*?\b/g, ",").replace(/\b\s*?;\s*?\b/g, ";").replace(/\\,/g, "commaPlaceholder").replace(/\\;/g, "semicolonPlaceholder"); //Get dependent values
var dropdownDependentCategories = dropdownDependentValues.split(";"); //Split dependent values into categories
var dependentSelect = document.getElementById(containerID);
var x, dropdownOptions, dropdownDependencyValuePosition, dropdownCategory, dropdownValuesSplit, dropdownValue, optionOther, dropdownValuesSplitLength;
if (dependencyNewValue === InfoboxDefaultValueUnknown) { //If dependency is unknown
//Display message about dependency and hide the dropdown
dependentSelect.nextSibling.innerHTML = this.texts.infoboxDropdownNoDependencyValue.format([getDependency.replace(/_/g, " ").replace(/ [\(\*][\w\W\s]*?$/, "")]); //Error message
dependentSelect.nextSibling.className = "InfoboxNoValueWarning"; //Error message
dependentSelect.firstChild.nextSibling.value = InfoboxDefaultValueUnknown; //Alternative textarea; reset the value
dependentSelect.style.display = "none"; //Container with select and alternative textarea
}
else if (dependencyNewValue === InfoboxSpecialValueOther) { //If dependency is other
//Remove message about dependency and show the textarea
dependentSelect.nextSibling.className = "InfoboxEditDiv"; //Hide error message
dependentSelect.style.display = "block"; //Container with select and alternative textarea
dependentSelect.firstChild.style.display = "none"; //Select
optionOther = document.createElement("option");
optionOther.text = InfoboxSpecialValueOther;
optionOther.value = InfoboxSpecialValueOther;
dependentSelect.firstChild.add(optionOther); //Add the "other" option
dependentSelect.firstChild.value = InfoboxSpecialValueOther; //Select; reset dependent value to "other"
dependentSelect.firstChild.classList.remove("InfoboxLinesHighlighted"); //Select; reset the highlighting
dependentSelect.firstChild.nextSibling.style.display = "block"; //Textarea
}
else { //If dependency is known
dropdownDependencyValuePosition = dropdownDependencyValues.indexOf(dependencyNewValue); //Get the position of the dependency value in its own list
//dropdownCategory = dropdownDependentCategories[dropdownDependencyValuePosition]; //Use the correct category//karambakaramba
dropdownCategory = dropdownDependentCategories[dropdownDependencyValuePosition]; //Use the correct category
if (dropdownDependentValues.indexOf("!") === 0) { //Strict dependency (only a single value allowed)
dropdownValue = dropdownCategory.replace(/!/, "").trim().replace(/commaPlaceholder/g, ",").replace(/semicolonPlaceholder/g, ";");
dropdownOptions = "<option value=\""+dropdownValue+"\">"+dropdownValue+"</option>";
}
else { //Multiple selections
if (dropdownDependentValues.indexOf("\=") === 0) { //Multiple values allowed
multiple = true;
}
dropdownOptions = "<option value=\""+InfoboxDefaultValueUnknown+"\">"+InfoboxDefaultValueUnknown+"</option>";
dropdownValuesSplit = dropdownCategory.replace(/\=/, "").split(","); //Split the category
dropdownValuesSplitLength = dropdownValuesSplit.length;
for (x = 0; x < dropdownValuesSplitLength; x+=1) { //Make array for dropdown
dropdownValue = dropdownValuesSplit[x].trim().replace(/commaPlaceholder/g, ",").replace(/semicolonPlaceholder/g, ";");
dropdownOptions += "<option value=\""+dropdownValue+"\">"+dropdownValue+"</option>";
}
if (allowModifyingTemplates === true) {
dropdownOptions += "<option value=\""+InfoboxSpecialValueOther+"\">"+InfoboxSpecialValueOther+"</option>"; //Show other option, if it's allowed
}
}
//Remove message about dependency and show the dropdown
dependentSelect.nextSibling.className = "InfoboxEditDiv"; //Hide error message
dependentSelect.style.display = "block"; //Container with select and alternative textarea
dependentSelect.firstChild.style.display = "block"; //Select
dependentSelect.firstChild.innerHTML = dropdownOptions; //Select
dependentSelect.firstChild.nextSibling.value = InfoboxDefaultValueUnknown; //Alternative textarea; reset the value
dependentSelect.firstChild.nextSibling.classList.remove("InfoboxLinesHighlighted"); //Alternative textarea; reset the highlighting
if (multiple === true) {
dependentSelect.firstChild.setAttribute("multiple","multiple"); //Make sure the select supports multiple choices
dependentSelect.firstChild.value = InfoboxDefaultValueUnknown; //Select
dependentSelect.firstChild.options.selected = InfoboxDefaultValueUnknown; //Select
dropdownOptionsCountRE = new RegExp("</option>", "g");
dropdownOptionsCount = dropdownOptions.match(dropdownOptionsCountRE).length; //Get the size of the select
if ((maxMultipleSelections === 0) || (dropdownOptionsCount <= maxMultipleSelections)) {
dependentSelect.firstChild.setAttribute("size",dropdownOptionsCount); //Set the size of the select
}
else {
dependentSelect.firstChild.setAttribute("size",maxMultipleSelections); //Set the size of the select
}
}
if (!dependentSelect.firstChild.value || (dependentSelect.firstChild.value === InfoboxDefaultValueUnknown)) {
dependentSelect.firstChild.classList.remove("InfoboxLinesHighlighted"); //Remove the highlighting when value is unknown or empty
}
else {
dependentSelect.firstChild.classList.add("InfoboxLinesHighlighted"); //Add the highlighting when the value is set
}
dependentSelect.firstChild.nextSibling.style.display = "none"; //Textarea
}
}
};
//End toggle dependency values
//Delete infoboxes
config.macros.infobox.deleteInfobox = function(article,type,title,instance) {
"use strict";
//Settings for logging
var enableLogging = config.options.chkInfoboxesEnableLogging;
var messageLog = config.options.txtInfoboxesMessageLog;
var messageLogDateFormat = config.options.txtInfoboxesMessageLogDateFormat;
var getMessageLog = store.getTiddler(messageLog);
var persistentLog = config.options.chkInfoboxesPersistentLog;
var logTitle = this.texts.infoboxLogMessageLogTitle;
var noMessages = this.texts.infoboxLogNoMessages;
var logArticleBackups = config.options.chkInfoboxesLogArticleBackups;
var logDeletions = config.options.chkInfoboxesLogDeletions;
var infoboxDeleted = this.texts.infoboxLogInfoboxDeleted;
var articleBackedUp = this.texts.infoboxLogArticleBackedUp;
var logTitleRE = new RegExp(noMessages, "");
var messageLogText;
var messageLogTags = "";
if ((logArticleBackups === true) || (logDeletions === true)) {
if (getMessageLog === null) {
messageLogText = config.shadowTiddlers[messageLog].replace(logTitleRE, logTitle); //If message log is not persistent, use the shadow tiddler
}
else {
messageLogText = getMessageLog; //Use the persistent tiddler
}
}
//Settings for backups
var backupArticleNotice;
var backupArticle = config.options.chkInfoboxesBackupArticle;
if ((backupArticle === true) && (logArticleBackups === true)) { //Article backup notice
backupArticleNotice = "\n\n"+this.texts.infoboxArticleBackupNotice;
}
else {
backupArticleNotice = "";
}
var infoboxTagsBackup = " "+config.options.txtInfoboxesTagsBackup;
var infoboxExcludeLists = config.options.chkInfoboxesExcludeLists;
var infoboxExcludeSearch = config.options.chkInfoboxesExcludeSearch;
var excludeFromLists, excludeFromSearch;
if (infoboxExcludeLists === true) {
excludeFromLists = " excludeLists"; //Exclude from lists
}
else {
excludeFromLists = "";
}
if (infoboxExcludeSearch === true) {
excludeFromSearch = " excludeSearch"; //Exclude from search
}
else {
excludeFromSearch = "";
}
var InfoboxTypeText = config.options.txtInfoboxesParamInfoboxType;
var InfoboxTypeParam = InfoboxTypeText.replace(/ /g, "_");
var InfoboxTitleText = config.options.txtInfoboxesParamInfoboxTitle;
var InfoboxInstanceIDText = config.options.txtInfoboxesParamInstanceID;
var InfoboxInstanceIDParam = InfoboxInstanceIDText.replace(/ /g, "_");
var confirmDelete = confirm(this.texts.infoboxConfirmDelete.format([InfoboxTitleText,title,InfoboxTypeText,type,InfoboxInstanceIDText,instance])+backupArticleNotice); //Confirm deletion choice
if (confirmDelete === true) { //If deletion is confirmed
//Get macro
var articleText = store.getTiddlerText(article); //Get article text
var articleTextRE = new RegExp("<<infobox[\\w\\W\\s]*?"+InfoboxTypeParam+":\"[\\w\\s]*?\"[\\w\\W\\s]*?>>", "g");
var macros = articleText.match(articleTextRE); //Get all macros
var i, targetMacro, macroType, macroInstanceID;
var macrosLength = macros.length;
for (i = 0; i < macrosLength; i+=1) { //Get the correct macro
macroType = InfoboxTypeParam+":\""+type+"\"";
if (macros[i].match(macroType)) {
if (macros[i].match(instance)) {
macroInstanceID = InfoboxInstanceIDParam+":\""+instance+"\"";
if (macros[i].match(macroInstanceID)) {
targetMacro = macros[i];
}
}
else {
targetMacro = macros[i];
}
}
}
//Delete
var oldText, backupTitle, backupTags;
var user = config.options.txtUserName;
var tid = store.getTiddler(article);
var tags = tid.tags.toString().replace(/,/g, " ");
var saveDate = new Date().convertToYYYYMMDDHHMMSSMMM().replace(/\./, "-"); //Dots are not allowed in CSS classes
var oldTextCheck = articleText.match(targetMacro+"\n");
if (oldTextCheck === null) {
oldText = targetMacro;
}
else {
oldText = targetMacro+"\n";
}
if (backupArticle === true) { //Backup the article
backupTitle = article+"_"+saveDate;
backupTags = tags+infoboxTagsBackup+excludeFromLists+excludeFromSearch;
if (logArticleBackups === true) { //Log the backup
messageLogText += articleBackedUp.format([new Date().formatString(messageLogDateFormat), article]);
}
store.saveTiddler(backupTitle,backupTitle,articleText,user,new Date(),backupTags); //Save the backed up tiddler
}
if (logDeletions === true) {
messageLogText += infoboxDeleted.format([new Date().formatString(messageLogDateFormat), title, instance, article]);
}
var newText = articleText.replace(oldText, "");
store.saveTiddler(article,article,newText,user,new Date(),tags); //Save the article
//Logging
if (enableLogging === true) { //If logging is enabled
if (getMessageLog === null) { //If there is no persisten tiddler
if (persistentLog === true) { //If the log is persistent
store.saveTiddler(messageLog,messageLog,messageLogText,user,new Date(),messageLogTags); //Save the log
}
else {
config.shadowTiddlers[messageLog] = messageLogText; //Use the shadow tiddler
}
}
else {
store.saveTiddler(messageLog,messageLog,messageLogText,user,new Date(),messageLogTags); //Save the message log
}
} //End if logging is enabled
//autoSaveChanges();
}
else {
return;
}
};
//End delete infoboxes
//Save infoboxes
config.macros.infobox.saveInfobox = function(saveButton,editButton,deleteButton,showHideEditModeButton,showHideLinesInEditModeButton,place,placeEdit,type,title,instance,TTIX,article,paramList,Modules) {
"use strict";
//Get options
var user = config.options.txtUserName;
var preserveParams = config.options.chkInfoboxesPreserveParamsFromHiddenModules;
var savePrompt = config.options.chkInfoboxesSavePrompt;
var saveMode = config.options.chkInfoboxesSaveMode;
var ignoreShorthands = config.options.chkInfoboxesIgnoreShorthands;
var globalParametersTemplate = config.options.txtInfoboxesGlobalParametersTemplate;
var backupInfoboxes = config.options.chkInfoboxesBackupInfoboxes;
var backupArticle = config.options.chkInfoboxesBackupArticle;
//Get content section
var ContentSectionContent = config.options.txtInfoboxesSectionContent;
//Get default values
var InfoboxDefaultValueUnknown = config.options.txtInfoboxesDefaultValueUnknown;
var InfoboxDefaultValueDefaultID = config.options.txtInfoboxesDefaultValueDefaultID;
var InfoboxSpecialValueOther = config.options.txtInfoboxesSpecialValueOther;
//Get default tags
var infoboxTagsInfoboxModule = config.options.txtInfoboxesTagsInfoboxModule;
var infoboxTagsBackup = config.options.txtInfoboxesTagsBackup;
//Get parameter prefixes
var prefixSection = config.options.txtInfoboxesPrefixSection;
var prefixInclude = config.options.txtInfoboxesPrefixInclude;
//Get template prefixes
var InfoboxPrefixInfobox = config.options.txtInfoboxesPrefixInfobox;
var InfoboxPrefixInfoboxModule = config.options.txtInfoboxesPrefixInfoboxModule;
var InfoboxPrefixInfoboxInclude = config.options.txtInfoboxesPrefixInfoboxInclude;
//Get special template parameter prefixes and suffixes
var InfoboxPrefixGlobal = config.options.txtInfoboxesPrefixGlobal;
var InfoboxPrefixModules = config.options.txtInfoboxesPrefixModules;
var InfoboxPrefixIncludes = config.options.txtInfoboxesPrefixIncludes;
var InfoboxSuffixModules = config.options.txtInfoboxesSuffixModules;
//Get system parameters
var InfoboxTypeText = config.options.txtInfoboxesParamInfoboxType;
var InfoboxTypeParam = InfoboxTypeText.replace(/ /g, "_");
var InfoboxTitleText = config.options.txtInfoboxesParamInfoboxTitle;
var InfoboxTitleParam = InfoboxTitleText.replace(/ /g, "_");
var InfoboxInstanceIDText = config.options.txtInfoboxesParamInstanceID;
var InfoboxInstanceIDParam = InfoboxInstanceIDText.replace(/ /g, "_");
var InfoboxColorSchemeText = config.options.txtInfoboxesParamColorScheme;
var InfoboxColorSchemeParam = InfoboxColorSchemeText.replace(/ /g, "_");
var InfoboxParamModulesText = config.options.txtInfoboxParamModules;
var InfoboxParamModulesParam = InfoboxParamModulesText.replace(/ /g, "_");
//Settings for logging
var enableLogging = config.options.chkInfoboxesEnableLogging;
var messageLog = config.options.txtInfoboxesMessageLog;
var messageLogDateFormat = config.options.txtInfoboxesMessageLogDateFormat;
var getMessageLog = store.getTiddler(messageLog);
var persistentLog = config.options.chkInfoboxesPersistentLog;
var logArticleBackups = config.options.chkInfoboxesLogArticleBackups;
var logTemplateBackups = config.options.chkInfoboxesLogTemplateBackups;
var logInfoboxChanges = config.options.chkInfoboxesLogInfoboxChanges;
var logTemplateChanges = config.options.chkInfoboxesLogTemplateChanges;
var logTitle = this.texts.infoboxLogMessageLogTitle;
var noMessages = this.texts.infoboxLogNoMessages;
var articleBackedUp = this.texts.infoboxLogArticleBackedUp;
var templateBackedUp = this.texts.infoboxLogTemplateBackedUp;
var templateValueAdded = this.texts.infoboxLogTemplateValueAdded;
var infoboxParamAdded = this.texts.infoboxLogInfoboxParamAdded;
var infoboxParamRemoved = this.texts.infoboxLogInfoboxParamRemoved;
var infoboxParamChanged = this.texts.infoboxLogInfoboxParamChanged;
var infoboxShortToLong = this.texts.infoboxLogInfoboxShortToLong;
var infoboxLongToShort = this.texts.infoboxLogInfoboxLongToShort;
var logTitleRE = new RegExp(noMessages, "");
var messageLogText;
var paramMessages = "";
var valueMessages = "";
var backupMessages = "";
var convertMessages = "";
var messageLogTags = "";
if (getMessageLog === null) { //If there is no persistent log
messageLogText = config.shadowTiddlers[messageLog].replace(logTitleRE, logTitle);
}
else {
messageLogText = getMessageLog;
}
var doSave, backupArticleNotice, backupInfoboxNotice;
if (savePrompt === true) {
if (backupArticle === true) { //Article backup notice
backupArticleNotice = "\n\n"+this.texts.infoboxArticleBackupNotice;
}
else {
backupArticleNotice = "";
}
if (backupInfoboxes === true) { //Infobox backup notice
backupInfoboxNotice = "\n\n"+this.texts.infoboxInfoboxBackupNotice;
}
else {
backupInfoboxNotice = "";
}
var checkTitle = document.getElementById(this.IDs.IDPrefixEdit + this.IDs.IDPrefixTextarea + TTIX + InfoboxTitleText.replace(/ /g, "_")).value;
var newTitle;
if (checkTitle === InfoboxDefaultValueUnknown) {
newTitle = article;
}
else {
newTitle = checkTitle;
}
var checkInstance = document.getElementById(this.IDs.IDPrefixEdit + this.IDs.IDPrefixTextarea + TTIX + InfoboxInstanceIDText.replace(/ /g, "_")).value;
var newInstance, newIDWarning;
if ((checkInstance === InfoboxDefaultValueUnknown) || (checkInstance === InfoboxDefaultValueDefaultID)) {
newInstance = instance;
newIDWarning = " "+this.texts.infoboxNewInstanceID;
}
else {
newInstance = checkInstance;
newIDWarning = "";
}
var confirmSave = confirm(this.texts.infoboxConfirmSave.format([InfoboxTitleText,newTitle,InfoboxTypeText,type,InfoboxInstanceIDText,newInstance,newIDWarning])+backupArticleNotice+backupInfoboxNotice);
if (confirmSave === true) {
doSave = true;
}
else {
doSave = false;
}
}
else {
doSave = true;
}
if (doSave === true) { //Do the save
var d, e, f, g, h, i, j, k, v, matchRE, paramWithModulePrefix, matchShorthand, shorthand, imageSrc, imageAlt, imageTitle, showFigcaption, imageCaption, useImageLink, imageLink, cells, cell1, cell2, selectMultiple, multipleOther, multipleOptions, textarea, limits, spans, spanOriginal, span, cell, addOptions, categoryValues, moduleList, includedModulesRE, excludedModulesRE, moduleParamPrefix, moduleText, includeName, includeParams, cellsLength, selectMultipleOptionsLength, selectMultipleOptionsLength1, includedModules;
var timeStamp = Date.now().toString().replace(/[^\d]/g, "");
var modulesParamsList = ""; //Module parameters
var excludedModules = [];
//var includedModules = [];//karamba
//var checkboxesList = [];//karamba
var modulePrefixRE = new RegExp(InfoboxPrefixInfoboxModule,"g"); //Module prefix
var moduleSuffixRE = new RegExp(" "+InfoboxSuffixModules+" [\d]*?","g"); //Module suffix
var modulePrefixConverted = InfoboxPrefixInfoboxModule.replace(/ /g, "_")+"_";
var modulePrefixConvertedRE = new RegExp(modulePrefixConverted,"g");
var tid = store.getTiddler(article);
var addOther = [];
var categoryMatches = "";
var cleanupRE = new RegExp("<\\/?span[^>]*?>|<\\/?a[^>]*?>|<\\/?nowiki>","g");
var sanitize = { //Characters to replace with entities
"\n":"<br>",
"{":"{",
"}":"}",
"<<":"<<",
">>":">>",
"\"":"\""};
var sanitizeRE = new RegExp(Object.keys(sanitize).join("|"),"g");
var includePrefixRE = new RegExp(InfoboxPrefixInfoboxInclude,"g"); //Include template prefix
var template = InfoboxPrefixInfobox+"_" + type.replace(/ /g, "_"); //Get template name
var templateDefinition = store.getTiddlerText(template + "##" + ContentSectionContent).replace(includePrefixRE, InfoboxPrefixIncludes); //Get template definition
//kakaramba fix templateDefinition, it needs to include the includes - DO I? DON'T THE PARAMS GET PASSED FROM THE MAIN???
/*
while (templateDefinition.match(includeParamsRE) !== null) { //Include other includes
includePrefixes = templateDefinition.match(includeParamsPrefixedRE).toString().replace(includeParamsRE, "");
includeName = templateDefinition.match(includeParamsRE).toString().replace(prefixIncludeRE, "").replace(/ /g, "_").replace(/_\(\([\w\W\s]*?|_\*\*[\w\W\s]*?/g, ""); //Get include name
if (!store.getTiddler(includeName)) { //Check if include exists
availableIncludes = [];
for (g = 0; g < allIncludesLength; g+=1) { //Get includes
if (!allIncludes[g].isTagged(InfoboxTagsBackup)) { //If it is not a backup
availableIncludes.push(allIncludes[g].title);
}
}
wikify("{{InfoboxError{"+this.texts.infoboxNonExistentInclude.format([includeName,availableIncludes.toString().replace(/,/g, ", ")])+"}}}", errorsDiv);
return;
} //End check if include exists
if (store.getTiddler(includeName).text.match("!"+ContentSectionContent) !== null) { //Get included params
includeTid = store.getTiddlerText(includeName+"##"+ContentSectionContent);
}
else {
includeTid = store.getTiddlerText(includeName);
}
includeParams = includeTid.replace(/(^|\n)/g, "$1"+includePrefixes+includeName.replace(includePrefixRE, InfoboxPrefixIncludes)+"!").replace(/\+\+([\W\w\s]*?)\+\+/g, "\+\+"+includePrefixes+includeName.replace(includePrefixRE, InfoboxPrefixIncludes)+"!$1\+\+").replace(/\(\(([\W\w\s]*?)\)\)/g, "\(\("+includePrefixes+includeName.replace(includePrefixRE, InfoboxPrefixIncludes)+"!$1\)\)")+"\n----\n";
if (includeParams.match("(?:^|\n)[^\n]*!"+prefixSection+"-") !== null) {
includeParams = "----\n"+includeParams; //Extra section separator for includes
}
templateDefinition = templateDefinition.replace(includeParamsPrefixedRE, includeParams).replace(/\n$/, ""); //The last line break needs to be removed, so it doesn't trigger a new section
} //End include other includes
*/
var templateText = store.getTiddlerText(template); //Get template text
var templateTags = store.getTiddler(template).tags; //Get template tags
var globalTemplateText = store.getTiddlerText(globalParametersTemplate); //Get global template text
var globalParamList;
if (globalTemplateText === undefined) {
globalTemplateText = "";
}
if (globalTemplateText.length) { //Get global parameters
globalParamList = InfoboxPrefixGlobal+"!"+globalTemplateText.replace(/\n/g, "\n"+InfoboxPrefixGlobal+"!").replace(/\+\+([\W\w\s]*?)\+\+/g, "\+\+"+InfoboxPrefixGlobal+"!$1\+\+").replace(/\(\(([\W\w\s]*?)\)\)/g, "\(\("+InfoboxPrefixGlobal+"!$1\)\)");
}
var globalTemplateTid = store.getTiddler(globalParametersTemplate); //Get global template tiddler
var globalTemplateTags;
if (globalTemplateTid === null) {
globalTemplateTags = "";
}
else {
globalTemplateTags = globalTemplateTid.tags; //Get global template tags
}
/*
//karamba
var modulesList = store.getTaggedTiddlers(template); //Get module templates
var checkModules = document.getElementById(this.IDs.IDPrefixEdit + this.IDs.IDPrefixSystemContent + TTIX + "_"+ InfoboxParamModulesText.replace(/ /g, "_")); //Get the modules
var checkboxes = checkModules.getElementsByTagName("input");
var modulesListLength;
var checkboxesLength = checkboxes.length;
for (g = 0; g < checkboxesLength; g+=1) {
if ((checkboxes[g].type.toLowerCase() === "checkbox") && (checkboxes[g].checked === true)) { //Get checked checkboxes
checkboxesList.push(checkboxes[g].value);
checkboxesList.push(checkboxes[g].parentElement.parentElement.nextElementSibling.firstChild.value);
}
}
moduleList = checkboxesList.toString();
if (moduleList.length) {
modulesListLength = modulesList.length;
includedModulesRE = new RegExp("^(?:"+moduleList.replace(/,/g, "|")+")$");
for (f = 0; f < modulesListLength; f+=1) {
if (modulesList[f].isTagged(infoboxTagsInfoboxModule) && !modulesList[f].isTagged(infoboxTagsBackup)) { //Check if it is actually a module and that it is not a backup
if (!modulesList[f].title.match(includedModulesRE)) { //Get the list of excluded modules
excludedModules.push(modulesList[f].title);
}
else { //Get the list of included modules
includedModules.push(modulesList[f].title);
}
} //End check if it is actually a module and that it is not a backup
}
if (excludedModules.length) {
excludedModulesRE = new RegExp("^"+excludedModules.toString().replace(/,/g, "!|^").replace(/_/g, " ").replace(modulePrefixRE, InfoboxPrefixModules).replace(moduleSuffixRE, "")+"!");
}
}
*/
//var ModulesTemp;
//var modulesTempRE = new RegExp(TTIX+":[\\w\\W\\s]*?(?:\n|$)", "g");
//var TTIXRE = new RegExp(TTIX+":", "");
//karamba maybe skip TTIXRE and just use slices
//ModulesTemp = store.getShadowTiddlerText("InfoboxTablesModulesTemp").match(modulesTempRE);//karamba
//if ((ModulesTemp !== null) && (ModulesTemp !== undefined) && ModulesTemp.length) { //First check the temp shadow tiddler for new modules/instances//karamba
var includedModulesParam = store.getShadowTiddlerText("InfoboxTablesModulesTemp::"+TTIX);
if ((includedModulesParam === null) || (includedModulesParam === undefined) || (!includedModulesParam.length)) { //First check the temp shadow tiddler for new modules/instances
includedModulesParam = Modules;
}
if (includedModulesParam.length) {
var includedModulesParamSplit = includedModulesParam.split(",");
var includedModulesParamSplitLength = includedModulesParamSplit.length;
for (g = 0; g < includedModulesParamSplitLength.length; g+=1) {
includedModulesParamSplit.splice(g+1,1);
}
includedModules = includedModulesParamSplit.toString();
}
else {
includedModules = "";
}
var includeParamsRE = new RegExp(prefixInclude+"-[\\W\\w\\s]*?(?:\\n|$)", ""); //Included param
var prefixIncludeRE = new RegExp(prefixInclude+"-|\\n", "g"); //Include prefix
var includeParamsPrefixedRE = new RegExp("(?:[^\\n]*?!)?"+prefixInclude+"-[\\W\\w\\s]*?(?:\\n|$)", "");
var includedModulesSplit = includedModules.split(",");
var includedModulesSplitLength = includedModulesSplit.length;
//var checkboxesListLength = checkboxesList.length;//karamba
//var checkboxesListInstanceLength, includePrefixes, includeTid;//karamba
var includedModulesInstanceLength, includePrefixes, includeTid;
for (d = 0; d < includedModulesSplitLength; d = d + 2) { //Go through the modules
//checkboxesListInstanceLength = (+checkboxesList[d+1]+1);//karamba
includedModulesInstanceLength = (+includedModulesSplit[d+1]+1);
//for (f = 1; f < checkboxesListInstanceLength; f+=1) { //Make multiple instances//karamaba
for (f = 1; f < includedModulesInstanceLength; f+=1) { //Make multiple instances
moduleText = store.getTiddlerText(includedModulesSplit[d]);
moduleParamPrefix = includedModulesSplit[d].replace(modulePrefixConvertedRE, "").replace(/_/g, " ");
while (moduleText.match(includeParamsRE) !== null) { //Include other modules
includePrefixes = moduleText.match(includeParamsPrefixedRE).toString().replace(includeParamsRE, "");
includeName = moduleText.match(includeParamsRE).toString().replace(prefixIncludeRE, "").replace(/ /g, "_").replace(/_\(\([\w\W\s]*?|_\*\*[\w\W\s]*?/g, ""); //Get included module name
//if (store.getTiddler(includeName).text.match("!"+ContentSectionContent) !== null) { //Get included module params//karamba
if (store.getTiddlerText(includeName).match("!"+ContentSectionContent) !== null) { //Get included module params
includeTid = store.getTiddlerText(includeName+"##"+ContentSectionContent);
}
else {
includeTid = store.getTiddlerText(includeName);
}
includeParams = includeTid.replace(/(^|\n)/g, "$1"+includePrefixes+includeName.replace(/_/g, " ").replace(includePrefixRE, InfoboxPrefixIncludes).replace(modulePrefixRE, InfoboxPrefixModules)+"!").replace(/\+\+([\W\w\s]*?)\+\+/g, "\+\+"+includePrefixes+includeName.replace(/_/g, " ").replace(includePrefixRE, InfoboxPrefixIncludes).replace(modulePrefixRE, InfoboxPrefixModules)+"!$1\+\+").replace(/\(\(([\W\w\s]*?)\)\)/g, "\(\("+includePrefixes+includeName.replace(/_/g, " ").replace(includePrefixRE, InfoboxPrefixIncludes).replace(modulePrefixRE, InfoboxPrefixModules)+"!$1\)\)")+"\n";
if (includeParams.match("(?:^|\n)[^\n]*!"+prefixSection+"-") !== null) {
includeParams = "----\n"+includeParams; //Extra section separator for includes
}
moduleText = moduleText.replace(includeParamsPrefixedRE, includeParams).replace(/\n$/, ""); //The last line break needs to be removed, so it doesn't trigger a new section
}
modulesParamsList += "\n----\n"+InfoboxPrefixModules+" "+moduleParamPrefix+" "+InfoboxSuffixModules+" "+f+"!"+moduleText.replace(/\n/g, "\n"+InfoboxPrefixModules+" "+moduleParamPrefix+" "+InfoboxSuffixModules+" "+f+"!").replace(/\+\+([\W\w\s]*?)\+\+/g, "\+\+"+InfoboxPrefixModules+" "+moduleParamPrefix+" "+InfoboxSuffixModules+" "+f+"!$1\+\+").replace(/\(\(([\W\w\s]*?)\)\)/g, "\(\("+InfoboxPrefixModules+" "+moduleParamPrefix+" "+InfoboxSuffixModules+" "+f+"!$1\)\)");
}
}
// var allDefinitionsWithIncludePrefix = globalParamList+"\n----\n"+templateDefinition+modulesParamsList;//karamba
// var allDefinitionsx = allDefinitionsWithIncludePrefix.replace(includePrefixRE, InfoboxPrefixIncludes);//karamba
//var allDefinitions = globalParamList+"\n----\n"+templateDefinition+modulesParamsList;//karamba
var allDefinitions = paramList;
var allDefinitionsSplit = allDefinitions.split("\n");
var getNewMacro = ["<<infobox"];
//var infobox = document.getElementById(this.IDs.IDPrefixEdit + this.IDs.IDPrefixInfoboxContainer+TTIX);//karamba check what ID it needs and use placeEdit.parentElement.id if necessary - check in delete function as well
var infobox = document.getElementById(placeEdit.firstChild.firstChild.id);
var rows = infobox.getElementsByTagName("tr");
var rowsLength = rows.length;
for (i = 0; i < rowsLength; i+=1) { //Go through the rows
//checkboxesList = [];//karamba
addOptions = false;
categoryValues = [];
cells = rows[i].getElementsByTagName("td");
if ((cells.length === 2) && (cells[0].innerHTML.indexOf("textarea") === -1)) { //Normal two sided display
cell1 = cells[0].innerHTML.replace(cleanupRE, "").trim(); //Cleanup required because of http://www.TiddlyTools.com/#HTMLFormattingPlugin
if ((cells[1].innerHTML.indexOf("textarea") !== -1) && (cells[1].innerHTML.indexOf("select") === -1)) { //Textareas
if (cells[1].getElementsByTagName("textarea").length === 1) {
if (cells[1].innerHTML.indexOf("input") === -1) { //Normal textareas
cell2 = cells[1].getElementsByTagName("textarea")[0].value;
}
else if (cells[1].innerHTML.indexOf("input") !== -1) { //Textareas with limit inputs
cell2 = cells[1].getElementsByTagName("textarea")[0].value;
limits = cells[1].getElementsByTagName("input")[0].value;
if (limits !== InfoboxDefaultValueUnknown) { //If limits are not "unknown"
addOther.push(cell1);
addOther.push(limits);
}
}
}
else if (cells[1].getElementsByTagName("textarea").length === 5) { //Images
imageSrc = cells[1].getElementsByTagName("textarea")[0].value;
if (imageSrc === InfoboxDefaultValueUnknown) {
cell2 = InfoboxDefaultValueUnknown;
}
else {
imageAlt = cells[1].getElementsByTagName("textarea")[1].value;
if (imageAlt === InfoboxDefaultValueUnknown) {
imageAlt = imageSrc;
}
imageTitle = cells[1].getElementsByTagName("textarea")[2].value;
if (imageTitle === InfoboxDefaultValueUnknown) {
imageTitle = imageAlt;
}
showFigcaption = cells[1].getElementsByTagName("input")[0].value;
imageCaption = cells[1].getElementsByTagName("textarea")[3].value;
if (imageCaption === InfoboxDefaultValueUnknown) {
imageCaption = imageTitle;
}
useImageLink = cells[1].getElementsByTagName("input")[1].value;
imageLink = cells[1].getElementsByTagName("textarea")[4].value;
if (imageLink === InfoboxDefaultValueUnknown) {
imageLink = imageSrc;
}
cell2 = imageSrc+"|"+imageAlt+"|"+imageTitle+"|"+showFigcaption+"|"+imageCaption+"|"+useImageLink+"|"+imageLink;
}
}
}
else if ((cells[1].innerHTML.indexOf("select") !== -1) && (cells[1].innerHTML.indexOf("textarea") === -1)) { //System provided selects without alternative textareas
cell2 = cells[1].getElementsByTagName("select")[0].value;
}
else if ((cells[1].innerHTML.indexOf("input") !== -1) && (cells[1].innerHTML.indexOf("textarea") === -1)){ //Checkboxes
//cell2 = moduleList;//karamba
cell2 = includedModules;
}
else if ((cells[1].innerHTML.indexOf("select") !== -1) && (cells[1].innerHTML.indexOf("textarea") !== -1)) { //Selects with alternative textareas
multipleOptions = [];
selectMultiple = cells[1].getElementsByTagName("select")[0];
selectMultipleOptionsLength = selectMultiple.options.length;
for (e = 0; e < selectMultipleOptionsLength; e+=1) { //Go through the options and check if other option is selected
if (selectMultiple.options[e].selected === true) {
if (selectMultiple.options[e].value === InfoboxSpecialValueOther) {
multipleOther = true;
}
else {
multipleOther = false;
if (selectMultiple.options[e].value !== InfoboxDefaultValueUnknown) { //Get a list of selected options
//multipleOptions.push(selectMultiple.options[e].value);//karambakaramba
multipleOptions.push(selectMultiple.options[e].value.replace(/,/g, "commaPlaceholder").replace(/;/g, "semicolonPlaceholder"));
}
}
}
}
if (multipleOther === true) { //If selected value is "other" or "unknown"
//textarea = cells[1].getElementsByTagName("textarea")[0].value;//karambakaramba
textarea = cells[1].getElementsByTagName("textarea")[0].value.replace(/,/g, "commaPlaceholder").replace(/;/g, "semicolonPlaceholder");
if (textarea !== InfoboxDefaultValueUnknown) { //Add alt textarea value, if set
multipleOptions.push(textarea);
addOther.push(cell1);
addOther.push(textarea);
addOptions = true;
}
}
selectMultipleOptionsLength1 = selectMultiple.options.length-1;
for (h = 1; h < selectMultipleOptionsLength1; h+=1) {
categoryValues.push(selectMultiple.options[h].value); //Add options for the selected category to array
}
cell2 = multipleOptions.toString().replace(/,/g, ", ").replace(/commaPlaceholder/g, "\\,").replace(/semicolonPlaceholder/g, "\\;").replace(/ /g, " ");
}
else { //No selects or textareas, just display
cell2 = cells[1].innerHTML.replace(cleanupRE, "").trim(); //Cleanup required because of http://www.TiddlyTools.com/#HTMLFormattingPlugin
}
if (cell2.length) {
cell2 = cell2.replace(sanitizeRE, function(matched){return sanitize[matched];}); //Convert special characters to entities
}
if ((preserveParams === true) || ((preserveParams === false) && (!excludedModules.length || !cell1.match(excludedModulesRE)))) {
if (cell2.length && (cell2 !== InfoboxDefaultValueUnknown) && (cell2.match(this.texts.infoboxDefaultColorScheme) === null) && (cell2.match(this.texts.infoboxNoModules) === null)) { //If the cell has contents, the contents isn't "unknown" and doesn't match the text for the "default color scheme" or "no modules"
if (cell1 === InfoboxTypeText) { //Infobox_type
getNewMacro.push(InfoboxTypeParam+":\""+cell2+"\"");
}
else if ((cell1 === InfoboxTitleText) && (cell2 !== article)) { //Infobox_title
getNewMacro.push(InfoboxTitleParam+":\""+cell2+"\"");
}
else if (cell1 === InfoboxInstanceIDText) { //Infobox_instance_ID
if (cell2 === InfoboxDefaultValueDefaultID) {
cell2 = type.replace(/\W/g, "")+title.replace(/\W/g, "")+timeStamp; //Generate the instance ID, if none is specified
}
getNewMacro.push(InfoboxInstanceIDParam+":\""+cell2+"\"");
}
else if ((cell1 === InfoboxParamModulesText) && (cell2.match(this.texts.infoboxNoModules) === null)) { //Infobox_modules
getNewMacro.push(InfoboxParamModulesParam+":\""+cell2+"\"");
}
else if ((cell1 === InfoboxColorSchemeText) && (cell2 !== InfoboxDefaultValueUnknown)) { //Infobox_color_scheme
getNewMacro.push(InfoboxColorSchemeParam+":\""+cell2+"\"");
}
else if ((cell1 !== InfoboxTypeText) && (cell1 !== InfoboxTitleText) && (cell1 !== InfoboxInstanceIDText) && (cell1 !== InfoboxParamModulesText) && (cell1 !== InfoboxColorSchemeText)) { //Content params
if (ignoreShorthands === false) { //Check for shorthands
paramWithModulePrefix = cell1.replace(cleanupRE, "").escapeRegExp();
matchRE = new RegExp("(?:^|\\n)"+paramWithModulePrefix+"[\\w\\W\\s]*?(?:\\n|$)");
matchShorthand = allDefinitions.match(matchRE).toString();
if (matchShorthand.indexOf("((") !== -1) {
shorthand = matchShorthand.replace(/^[\W\w\s]*?\(\(|\)\)[\W\w\s]*?[\n$]/g, "");
getNewMacro.push(shorthand.replace(/ /g, "_")+":\""+cell2+"\"");
}
else {
getNewMacro.push(cell1.replace(/ /g, "_")+":\""+cell2+"\"");
}
}
else {
getNewMacro.push(cell1.replace(/ /g, "_")+":\""+cell2+"\"");
}
}
} //End if the cell has contents, the contents isn't "unknown" and doesn't match the text for the "default color scheme" or "no modules"
}
} //End normal two sided display
else if (((cells.length === 2) && (cells[0].innerHTML.indexOf("textarea") !== -1)) || (cells.length > 2)) { //Multiple sided display
cellsLength = cells.length;
for (j = 0; j < cellsLength; j+=1) {
if ((cells[j].innerHTML.indexOf("select") !== -1) && (cells[j].innerHTML.indexOf("textarea") !== -1)) { //Selects with alternative textareas
multipleOptions = [];
selectMultiple = cells[j].getElementsByTagName("select")[0]; //Go through the options and check if other option is selected
selectMultipleOptionsLength = selectMultiple.options.length;
for (v = 0; v < selectMultiple.options.length; v+=1) {
if (selectMultiple.options[v].selected === true) {
if (selectMultiple.options[v].value === InfoboxSpecialValueOther) {
multipleOther = true;
}
else {
multipleOther = false;
if (selectMultiple.options[v].value !== InfoboxDefaultValueUnknown) { //Get a list of selected options
multipleOptions.push(selectMultiple.options[v].value.replace(/,/g, "commaPlaceholder").replace(/;/g, "semicolonPlaceholder"));
}
}
}
}
if (multipleOther === true) { //If selected value is "other" or "unknown"
textarea = cells[j].getElementsByTagName("textarea")[0].value.replace(/,/g, "commaPlaceholder").replace(/;/g, "semicolonPlaceholder");
if (textarea !== InfoboxDefaultValueUnknown) { //Add alt textarea value, if set
multipleOptions.push(textarea);
addOther.push(cells[j].getElementsByTagName("textarea")[0].parentElement.previousSibling.firstChild.firstChild.innerHTML.replace(cleanupRE, "").trim());
addOther.push(textarea);
addOptions = true;
}
}
selectMultipleOptionsLength1 = selectMultiple.options.length-1;
for (v = 1; v < selectMultiple.options.length-1; v+=1) {
categoryValues.push(selectMultiple.options[v].value); //Add options for the selected category to array
}
cell = multipleOptions.toString().replace(/,/g, ", ").replace(/commaPlaceholder/g, "\\,").replace(/semicolonPlaceholder/g, "\\;").replace(/ /g, " ");
}
else if ((cells[j].innerHTML.indexOf("textarea") !== -1) && (cells[j].innerHTML.indexOf("input") !== -1)) { //Textareas with limit inputs
cell = cells[j].getElementsByTagName("textarea")[0].value;
limits = cells[j].getElementsByTagName("input")[0].value;
if (limits !== InfoboxDefaultValueUnknown) { //If limits are not "unknown"
addOther.push(cell);
addOther.push(limits);
}
}
else { //No selects or textareas, just display
cell = cells[j].getElementsByTagName("textarea")[0].value;
}
cell = cell.replace(sanitizeRE, function(matched){return sanitize[matched];}); //Convert special characters to entities
if (cell.length && (cell !== InfoboxDefaultValueUnknown)) { //If the cell has contents and the contents isn't "unknown"
spans = cells[j].getElementsByTagName("span");
spanOriginal = spans[0].innerHTML.replace(cleanupRE, "").trim(); //Cleanup required because of http://www.TiddlyTools.com/#HTMLFormattingPlugin
span = spanOriginal.replace(/ /g, "_");
if (ignoreShorthands === false) { //Check for shorthands
paramWithModulePrefix = spanOriginal.replace(cleanupRE, "").escapeRegExp();
matchRE = new RegExp("(?:^|\\n)"+paramWithModulePrefix+"[\\w\\W\\s]*?(?:\\n|$)");
matchShorthand = allDefinitions.match(matchRE).toString();
if (matchShorthand.indexOf("((") !== -1) {
shorthand = matchShorthand.replace(/^[\W\w\s]*?\(\(|\)\)[\W\w\s]*?[\n$]/g, "");
getNewMacro.push(shorthand.replace(/ /g, "_")+":\""+cell+"\"");
}
else {
getNewMacro.push(span+":\""+cell+"\"");
}
}
else {
getNewMacro.push(span+":\""+cell+"\"");
}
} //End if the cell has contents and the contents isn't "unknown"
}
} //End multiple sided display
if (addOptions === true) {
categoryMatches += categoryValues+"\n"; //Add all options arrays to a meta-array
}
} //End go through the rows
getNewMacro.push(">>");
//Save mode
var fullCode;
if (saveMode === true) { //Each parameter in its own line
fullCode = getNewMacro.toString().replace(/\",/g, "\"\n").replace(/infobox,/g, "infobox\n"); //The quotation mark is necessary, so it doesn't mess up commas in parameter values
}
else { //All parameters on the same line
fullCode = getNewMacro.toString().replace(/\",/g, "\" ").replace(/infobox,/g, "infobox ").replace(/ >>/g, ">>"); //The quotation mark is necessary, so it doesn't mess up commas in parameter values
}
//Get the correct macro
var articleText = store.getTiddlerText(article); //Get article text
var articleTextRE = new RegExp("<<infobox[\\w\\W\\s]*?"+InfoboxTypeParam+":\"[\\w\\W\\s]*?\"[\\w\\W\\s]*?>>", "g");
var macros = articleText.match(articleTextRE);
var macroType, targetMacro, macroInstanceID;
var macrosLength = macros.length;
for (k = 0; k < macrosLength; k+=1) { //Go through the macros
macroType = InfoboxTypeParam+":\""+type+"\"";
if (macros[k].match(macroType)) {
if (instance !== InfoboxDefaultValueDefaultID) {
if (macros[k].match(instance)) {
macroInstanceID = InfoboxInstanceIDParam+":\""+instance+"\"";
if (macros[k].match(macroInstanceID)) {
targetMacro = macros[k];
}
}
}
else {
targetMacro = macros[k];
}
}
}
if (targetMacro !== fullCode) { //If there are changes
//Settings for backups
var backupGlobalTitle, originalModuleTemplateText, backupModuleTitle, backupInfoboxTitle, backupArticleTitle, backupGlobalTemplateTags, backupModuleTemplateTags, backupTemplateTags, backupArticleTags;
var infoboxTagsBackupSpace = " "+infoboxTagsBackup;
var infoboxExcludeLists = config.options.chkInfoboxesExcludeLists;
var infoboxExcludeSearch = config.options.chkInfoboxesExcludeSearch;
var excludeFromLists, excludeFromSearch;
if (infoboxExcludeLists === true) {
excludeFromLists = " excludeLists";
}
else {
excludeFromLists = "";
}
if (infoboxExcludeSearch === true) {
excludeFromSearch = " excludeSearch";
}
else {
excludeFromSearch = "";
}
var saveDate = new Date().convertToYYYYMMDDHHMMSSMMM().replace(/\./, "-"); //Dots are not allowed in CSS classes
//Add new values
if (addOther.length) { //If there are new values
var iterationFactor, a, b, l, m, n, p, q, r, s, t, param, paramRE, globalTemplate, globalParamMatched, paramMatched, paramMatchedActual, paramMatchedNew, dependencySelected, dependencyRE, dependencyMatch, paramValue, dependentCategories, dependentCategory, dependentCategorySplit, dependentCategoryNew, dependentCategoriesNew, dependentCategoriesCleaned, dependentMatchRE, dependentParam, newGlobalTemplateText, newTemplateText, modules, modulePrefix, moduleTemplateTitle, moduleTemplateTitlePrefixRE, moduleTemplateText, newModuleTemplateText, moduleTemplateTags, moduleParamMatched, multiple, globalTemplateChangedParam, moduleTemplateChangedParam, templateChangedParam, includedModulesLength, dependentMatchLength, dependencyArrayLength, newGlobalTemplateTextSanitizeLength, newModuleTemplateTextSanitizeLength, newTemplateTextSanitizeLength, InfoboxSuffixModulesRE, actualModuleRE, paramIndex, existingParam, appendedModuleValue, repeatedValue, paramPrefixMatch, dependentCategoriesCleanedSplit, dependencyCaptureRE, paramMatchedActualPrefix, dependencyMatchActual, dependencyMatchActualRE, dependencyMatchActualParam, dependencyMatchActualParamCategories, dependencyMatchActualParamCategoriesIndex, dependencyTextarea, dependencyMatchActualParamRE, dependencyMatchActualParamNoPrefix, dependencyMatchActualParamNoPrefixMatch, dependencyMatchActualParamWithCommentRE, dependencyMatchActualParamWithComment, dependencyMatchActualParamWithCommentIndex, dependentMatchActualParamIndex, dependentCategoriesClean, dependencyMatchActualParamCategoriesExisting, dependentCategoriesRE, dependentCategoryRE, dependentCategoriesExisting, usedTemplate, usedArray, usedArrayLength, newValues, newValuesLength, newParamValue;
var addOtherLength = addOther.length;
var allDefinitionsSplitLength = allDefinitionsSplit.length;
var dependentMatch = [];
var dependencyArray = [];
var newTemplateTextSanitize = [];
var newGlobalTemplateTextSanitize = [];
var newModuleTemplateTextSanitize = [];
//var paramPrefixes = "("+InfoboxPrefixGlobal+"!|((?:"+InfoboxPrefixModules+"[\\w\\W][^\\n]*?(?:_"+InfoboxSuffixModules+"_\\d+?)?!)+))?";//karamba
//var paramPrefixes = "(?:"+InfoboxPrefixGlobal+"!|(?:"+InfoboxPrefixIncludes+"_[^\n!]*?!)*!|(?:"+InfoboxPrefixModules+"_[^\n!]*?(?:_"+InfoboxSuffixModules+"_\d+?)!(?:"+InfoboxPrefixIncludes+"_[^\n!]*?!)*?))?";
//var paramPrefixes = "(?:"+InfoboxPrefixGlobal+"!|(?:"+InfoboxPrefixModules+" [^\n]*?!)*!|(?:"+InfoboxPrefixIncludes+" [^\n]*!))?";
var paramPrefixes = "(?:"+InfoboxPrefixGlobal+"!|"+InfoboxPrefixModules+" [^\n\*]*!|"+InfoboxPrefixIncludes+" [^\n\*]*!)?";
var paramPrefixGlobal = new RegExp("^"+InfoboxPrefixGlobal+"!");
var paramPrefixModules = new RegExp("^"+InfoboxPrefixModules+"[^!]*!");
var paramPrefixIncludes = new RegExp("(?:^"+InfoboxPrefixModules+"[^!]*!)|(?:^|!)"+InfoboxPrefixIncludes+"[^!]*!");
var paramPrefixesRE = new RegExp(paramPrefixes,"");
for (l = 0; l < addOtherLength; l = l + 2) { //Go through new values
appendedModuleValue = false; //Reset the flag when multiple values are appended to the same parameter
repeatedValue = false; //Reset the flag when value already exists
newParamValue = [];
param = addOther[l]; //Get parameter from cell1
paramValue = addOther[l+1].replace(/, /g, ","); //Get selected value of dependent parameter/limit
paramRE = new RegExp("(?:^|\\n)"+param.replace(paramPrefixesRE, "").escapeRegExp()+"(?: \\(\\([\\w\\W\\s]*?| \\*\\*[\\W\\w\\s]*?)?(?:\\n|$)");
paramMatchedActualPrefix = param.match(/^[\w\W\s]*!/); //Get prefix
dependentMatchRE = new RegExp("\\+\\+"+param+"\\+\\+", "g");
dependencyRE = new RegExp("\\+\\+[\\W\\w\\s]*?[^\\+]\\+\\+");
dependencyCaptureRE = new RegExp("\\+\\+([\\W\\w\\s]*?[^\\+])\\+\\+");
//Check for global template
if ((globalTemplateText === null) || (globalTemplateText === undefined) || (!globalTemplateText.length) || !param.match(paramPrefixGlobal)) {
globalTemplate = false;
}
else {
globalParamMatched = globalTemplateText.match(paramRE); //Get global parameter line
if (globalParamMatched === null) {
globalTemplate = false;
}
else {
globalTemplate = true;
}
}
//Check for modules
//if ((!includedModules.length) || (globalTemplate === true) || (!param.match(paramPrefixModules) && !param.match(paramPrefixIncludes))) {
if ((!includedModules.length) || (globalTemplate === true) || !param.match(paramPrefixIncludes)) {
modules = false;
}
else {
/*karamba
includedModulesLength = includedModules.length;
for (s = 0; s < includedModulesLength; s+=1) {
moduleTemplateTitle = includedModules[s]; //Get module template title
moduleTemplateTitlePrefixRE = new RegExp(InfoboxPrefixInfoboxModule.replace(/ /g, "_"),"");
//includeTemplateTitlePrefixRE = new RegExp(InfoboxPrefixInfoboxInclude.replace(/ /g, "_"),"");
//moduleTemplateTitlePrefixRE = new RegExp(InfoboxPrefixInfoboxModule.replace(/ /g, "_"),"");
//moduleTemplateTitlePrefixRE = new RegExp("(?:!|\n|^)(?:"+InfoboxPrefixModules+"|"+InfoboxPrefixIncludes+") [^!]*?![^!]*?$","g");
InfoboxSuffixModulesRE = new RegExp(" "+InfoboxSuffixModules+" \\d+?", "g");
modulePrefix = moduleTemplateTitle.replace(moduleTemplateTitlePrefixRE, InfoboxPrefixModules)+"!";
//modulePrefix = moduleTemplateTitle.replace(includeTemplateTitlePrefixRE, InfoboxPrefixIncludes).replace(moduleTemplateTitlePrefixRE, InfoboxPrefixModules)+"!";
//actualModuleRE = new RegExp(InfoboxPrefixModules+"(?=[\\w\\W\\s]*?!(?:"+InfoboxPrefixModules+"|"+InfoboxPrefixIncludes+")?)","g");//karamba
// actualModuleRE = new RegExp(InfoboxPrefixModules+"(?=[\\w\\W\\s]*?!(?:"+InfoboxPrefixModules+"|"+InfoboxPrefixIncludes+")?)","g");
// actualModeulRE = new RegExp("(?:!"+InfoboxPrefixModules+"|"+InfoboxPrefixIncludes+"", "g");
actualModelRE = new RegExp("(?:!|\n|^)[^!]*?![^!]*?$","g");
//(?:_"+InfoboxSuffixModules+"_\d+?)?
//var paramPrefixes = "(?:"+InfoboxPrefixGlobal+"!|II!|(?:"+InfoboxPrefixModules+"_[^\n!]*?(?:_"+InfoboxSuffixModules+"_\d+?)!(?:"+InfoboxPrefixIncludes+"_[^\n!]*?!)*))?";
//globalParamList+"\n----\n"+templateDefinition+modulesParamsList //karamba - paramRE is looking for the param in the template itself, so it needs the actual (included) template, not the top template
//needs to check for prefixes first: if IG->global, if none or II->main, if IM->module; needs to take into account includes! no includes in global
//problem is, it goes through included modules and looks for param there (which works for normal modules), instead of in the actual includes
console.log("moduleTemplateTitle-"+moduleTemplateTitle);//karamba
//(?:!|\n|^)[^!]*?![^!]*?$
console.log("moduleTemplateTitlePrefixRE-"+moduleTemplateTitlePrefixRE);//karamba
console.log("modulePrefix-"+modulePrefix);//karamba
console.log("actualModuleRE-"+actualModuleRE);//karamba
console.log("param-"+param);//karamba
console.log("paramReplace-"+param.replace(actualModuleRE, "").replace(InfoboxSuffixModulesRE, ""));//karamba
if (param.replace(actualModuleRE, "").replace(InfoboxSuffixModulesRE, "").match(modulePrefix.replace(/_/g, " "))) {
moduleTemplateText = store.getTiddlerText(moduleTemplateTitle); //Get module template text
moduleTemplateTags = store.getTiddler(moduleTemplateTitle).tags; //Get module template tags
moduleParamMatched = moduleTemplateText.match(paramRE); //Get the parameter
break;
}
}
*/
//Don't go through included modules, get the actual module/include instead
modulePrefixRE = new RegExp(InfoboxPrefixModules.replace(/ /g, "_"),"");
includePrefixRE = new RegExp(InfoboxPrefixIncludes.replace(/ /g, "_"),"");
InfoboxSuffixModulesRE = new RegExp(" "+InfoboxSuffixModules+" \\d+?", "g");
moduleTemplateTitlePrefixRE = new RegExp("(?:!|\n|^)(?:"+InfoboxPrefixModules+"|"+InfoboxPrefixIncludes+") [^!]*?![^!]*?$","g");
moduleTemplateTitle = param.match(moduleTemplateTitlePrefixRE).toString().replace(/![^!\n]*?(?:$|\n)/, "").replace(/!/, "").replace(modulePrefixRE, InfoboxPrefixInfoboxModule).replace(includePrefixRE, InfoboxPrefixInfoboxInclude).replace(InfoboxSuffixModulesRE, "").replace(/ /g, "_");
moduleTemplateText = store.getTiddlerText(moduleTemplateTitle); //Get module template text
moduleTemplateTags = store.getTiddler(moduleTemplateTitle).tags; //Get module template tags
moduleParamMatched = moduleTemplateText.match(paramRE); //Get the parameter
//karamba
/*
while (getModule.match(includeParamsRE) !== null) { //Include other modules
includePrefixes = getModule.match(includeParamsPrefixedRE).toString().replace(includeParamsRE, "");
includeName = getModule.match(includeParamsRE).toString().replace(prefixIncludeRE, "").replace(/ /g, "_").replace(/_\(\([\w\W\s]*?|_\*\*[\w\W\s]*?/g, ""); //Get included module name
if (store.getTiddler(includeName).text.match("!"+ContentSectionContent) !== null) { //Get included module params
includeTid = store.getTiddlerText(includeName+"##"+ContentSectionContent);
}
else {
includeTid = store.getTiddlerText(includeName);
}
includeParams = includeTid.replace(/(^|\n)/g, "$1"+includePrefixes+includeName.replace(modulePrefixRE, InfoboxPrefixModules)+"!").replace(/\+\+([\W\w\s]*?)\+\+/g, "\+\+"+includePrefixes+includeName.replace(modulePrefixRE, InfoboxPrefixModules)+"!$1\+\+").replace(/\(\(([\W\w\s]*?)\)\)/g, "\(\("+includePrefixes+includeName.replace(modulePrefixRE, InfoboxPrefixModules)+"!$1\)\)")+"\n----\n";
if (includeParams.match("(?:^|\n)[^\n]*!"+prefixSection+"-") !== null) {
includeParams = "----\n"+includeParams; //Extra section separator for includes
}
getModule = getModule.replace(includeParamsPrefixedRE, includeParams).replace(/\n$/, ""); //The last line break needs to be removed, so it doesn't trigger a new section
}
while (moduleText.match(includeParamsRE) !== null) { //Include other modules
includePrefixes = moduleText.match(includeParamsPrefixedRE).toString().replace(includeParamsRE, "");
includeName = moduleText.match(includeParamsRE).toString().replace(prefixIncludeRE, "").replace(/ /g, "_").replace(/_\(\([\w\W\s]*?|_\*\*[\w\W\s]*?/g, ""); //Get included module name
if (store.getTiddler(includeName).text.match("!"+ContentSectionContent) !== null) { //Get included module params
includeTid = store.getTiddlerText(includeName+"##"+ContentSectionContent);
}
else {
includeTid = store.getTiddlerText(includeName);
}
includeParams = includeTid.replace(/(^|\n)/g, "$1"+includePrefixes+includeName.replace(/_/g, " ").replace(modulePrefixRE, InfoboxPrefixModules)+"!").replace(/\+\+([\W\w\s]*?)\+\+/g, "\+\+"+includePrefixes+includeName.replace(/_/g, " ").replace(modulePrefixRE, InfoboxPrefixModules)+"!$1\+\+").replace(/\(\(([\W\w\s]*?)\)\)/g, "\(\("+includePrefixes+includeName.replace(/_/g, " ").replace(modulePrefixRE, InfoboxPrefixModules)+"!$1\)\)")+"\n";
if (includeParams.match("(?:^|\n)[^\n]*!"+prefixSection+"-") !== null) {
includeParams = "----\n"+includeParams; //Extra section separator for includes
}
moduleText = moduleText.replace(includeParamsPrefixedRE, includeParams).replace(/\n$/, ""); //The last line break needs to be removed, so it doesn't trigger a new section
}
*/
if ((moduleParamMatched === null) || (moduleParamMatched === undefined)) {
modules = false;
}
else {
modules = true;
}
}
//Get the actual parameter
if (globalTemplate === false) {
if (modules === false) {
usedTemplate = templateDefinition;
usedArray = newTemplateTextSanitize;
iterationFactor = 3;
paramMatched = templateDefinition.match(paramRE).toString(); //Get main parameter line
paramMatchedActual = paramMatched;
}
else {
usedTemplate = moduleTemplateText;
usedArray = newModuleTemplateTextSanitize;
iterationFactor = 4;
paramMatched = moduleParamMatched.toString(); //Get module parameter line
paramMatchedActual = paramMatched.replace(/\n/, "\n"+paramMatchedActualPrefix.toString()).replace(dependencyCaptureRE, "\+\+"+paramMatchedActualPrefix.toString()+"$1\+\+");
}
}
else {
usedTemplate = globalTemplateText;
usedArray = newGlobalTemplateTextSanitize;
iterationFactor = 3;
paramMatched = globalParamMatched.toString(); //Get global parameter line
paramMatchedActual = paramMatched.replace(/\n/, "\n"+paramMatchedActualPrefix.toString()).replace(dependencyCaptureRE, "\+\+"+paramMatchedActualPrefix.toString()+"$1\+\+");
}
usedArrayLength = usedArray.length;
if (paramMatched.indexOf("++") !== -1) { //If it is a dependent
dependencyMatch = paramMatched.match(dependencyRE).toString().replace(/\+\+/g, ""); //Get dependency parameter name
dependencyArray.pushUnique(param); //Push dependent to array
if (((modules === true) && (newModuleTemplateTextSanitize.indexOf(moduleTemplateTitle) !== -1)) || (modules === false)) { //If the array contains the module title
for (a = 0; a < usedArrayLength; a = a + iterationFactor) {
if (((usedArray[a] === moduleTemplateTitle) && (usedArray[a+1] === paramMatched)) || (usedArray[a] === paramMatched)) { //If the original parameter in the array is the same as the current original parameter
paramIndex = a+iterationFactor-2; //Get index of the new parameter in the array
existingParam = usedArray[paramIndex]; //Use the value from the array as source
if (existingParam) {
appendedModuleValue = true;
break;
}
}
}
}
if (paramMatched.match(/%%/)) {
if (appendedModuleValue === true) {
dependentCategories = existingParam.match(/%%[\W\w\s]*?%%/).toString(); //Get limits
}
else {
dependentCategories = paramMatched.match(/%%[\W\w\s]*?%%/).toString(); //Get limits
}
dependentCategoriesCleaned = dependentCategories.replace(dependencyRE, "").replace(/%%/g, "").replace(/\s*(,|;)\s*/g, "$1").trim(); //Clean limits
dependentCategoriesCleanedSplit = dependentCategoriesCleaned.split(";");
}
else if (paramMatched.match(/#/)) {
if (appendedModuleValue === true) {
dependentCategories = existingParam.match(/#[\W\w\s]*?#/).toString(); //Get parameter categories
}
else {
dependentCategories = paramMatched.match(/#[\W\w\s]*?#/).toString(); //Get parameter categories
}
/*
//karamba issue when saving new values (other) with or without commas and semicolons
**Adds comma instead of semicolon for category delimiter
NEED TO ADD .replace(/\\,/g, "commaPlaceholder").replace(/\\;/g, "semicolonPlaceholder")
COPY! - paramRE = new RegExp("(?:^|\\n)"+param.replace(paramPrefixesRE, "").escapeRegExp()+"(?: \\(\\([\\w\\W\\s]*?| \\*\\*[\\W\\w\\s]*?)?(?:\\n|$)");
SIDE BY SIDE - dropdown without dependency
<span id="Edit_ParamPrefix_DummyTestInfoboxExampleshowcasetest5test5_IG_Side1-Dummy15a" class="InfoboxPrefixes">IG!</span><span class="InfoboxParamOnly">Side1-Dummy15a</span>
/(?:^|\n)<span id\="Edit_ParamPrefix_DummyTestInfoboxExampleshowcasetest5test5_IG_Side1-Dummy15a" class\="InfoboxPrefixes">IG\!<\/span><span class\="InfoboxParamOnly">Side1-Dummy15a<\/span>(?: \(\([\w\W\s]*?| \*\*[\W\w\s]*?)?(?:\n|$)/
SIDE BY SIDE - dropdown with dependency
<span id="Edit_ParamPrefix_DummyTestInfoboxExampleshowcasetest5test5_IM_Test_8_Instance_1_Side1-Simple_comma_test" class="InfoboxPrefixes">IM Test 8 Instance 1!</span><span class="InfoboxParamOnly">Side1-Simple comma test</span>
/(?:^|\n)<span id\="Edit_ParamPrefix_DummyTestInfoboxExampleshowcasetest5test5_IM_Test_8_Instance_1_Side1-Simple_comma_test" class\="InfoboxPrefixes">IM Test 8 Instance 1\!<\/span><span class\="InfoboxParamOnly">Side1-Simple comma test<\/span>(?: \(\([\w\W\s]*?| \*\*[\W\w\s]*?)?(?:\n|$)/
SINGLE SIDE - dropdown with dependency
IM Test 8 Instance 1!Dependent comma test
/(?:^|\n)Dependent comma test(?: \(\([\w\W\s]*?| \*\*[\W\w\s]*?)?(?:\n|$)/
Cannot read property 'replace' of undefined
Adds comma instead of semicolon for category delimiter <- issue for error
SINGLE SIDE - dropdown with dependency
works normally
*/
//dependentCategoriesCleaned = dependentCategories.replace(dependencyRE, "").replace(/[#!=]/g, "").replace(/\s*(,|;)\s*/g, "$1").trim(); //Clean parameter categories//karamba
dependentCategoriesCleaned = dependentCategories.replace(dependencyRE, "").replace(/[#!=]/g, "").replace(/\\,/g, "commaPlaceholder").replace(/\\;/g, "semicolonPlaceholder").replace(/\s*(,|;)\s*/g, "$1").trim(); //Clean parameter categories
dependentCategoriesCleanedSplit = dependentCategoriesCleaned.split(";");
if (dependentCategories.indexOf("=") === 1) {
multiple = "=";
}
else {
multiple = "";
}
}
if (param.match(/!/)) { //Modules and global params
paramPrefixMatch = param.replace(/![^\!]*?$/, "").replace(/[\! ]/g, "_")+"_";
}
else { //Main template
paramPrefixMatch = param.replace(/^[\w\W\s]*?$/, "");
}
dependencySelected = document.getElementById(this.IDs.IDPrefixEdit + this.IDs.IDPrefixSelect+TTIX+"_"+paramPrefixMatch+dependencyMatch.replace(/ /g, "_")).value; //Get value of the select
dependencyMatchActual = paramMatchedActual.match(dependencyRE).toString().replace(/\+\+/g, ""); //Get the actual dependency param name with prefixes
dependencyMatchActualRE = new RegExp("(?:^|\\n)"+dependencyMatchActual+"[\\w\\W\\s]*?(?:\\n|$)");
dependencyMatchActualParam = allDefinitions.match(dependencyMatchActualRE).toString(); //Get the entire actual dependency param with prefixes
dependencyMatchActualParamCategories = dependencyMatchActualParam.match(/#[\W\w\s]*?#/).toString().replace(/#/g, "").replace(/\\,/g, "commaPlaceholder").replace(/\\;/g, "semicolonPlaceholder").replace(/\s*,\s*/g, ",").split(","); //Get the actual dependency param categories
dependencyMatchActualParamRE = new RegExp("![^!]*?$", "");
dependencyMatchActualParamNoPrefixMatch = dependencyMatchActual.match(dependencyMatchActualParamRE); //Dependency param name without prefix
if (dependencyMatchActualParamNoPrefixMatch) {
dependencyMatchActualParamNoPrefix = dependencyMatchActualParamNoPrefixMatch.toString().replace(/!/, "");
}
else {
dependencyMatchActualParamNoPrefix = dependencyMatchActual;
}
dependencyMatchActualParamWithCommentRE = new RegExp(dependencyMatchActualParamNoPrefix+"[\\w\\W\\s]*?(?:\\n|$)");
dependencyMatchActualParamWithComment = "\n"+usedTemplate.match(dependencyMatchActualParamWithCommentRE);
dependencyMatchActualParamWithCommentIndex = usedArray.indexOf(dependencyMatchActualParamWithComment); //Get index of the paramater in the array to be added
if (dependencySelected === InfoboxSpecialValueOther) { //If the dependency value is "other"
dependencyTextarea = document.getElementById(this.IDs.IDPrefixEdit + this.IDs.IDPrefixTextarea+TTIX+"_"+paramPrefixMatch+dependencyMatch.replace(/ /g, "_")).value; //Get value of the textarea
dependencyMatchActualParamCategoriesIndex = dependencyMatchActualParamCategories.indexOf(dependencyTextarea);
if ((dependencyMatchActualParamWithCommentIndex !== -1) && (dependencyMatchActualParamCategoriesIndex === -1)) { //If the value in textarea is new, but the value already exists in the new values to be added
if (((modules === true) && (usedArray[dependencyMatchActualParamWithCommentIndex-1] === moduleTemplateTitle)) || (modules === false)) {
dependencyMatchActualParamCategoriesExisting = usedArray[dependencyMatchActualParamWithCommentIndex+1].match(/#[\W\w\s]*?#/).toString().replace(/#/g, "").replace(/\\,/g, "commaPlaceholder").replace(/\\;/g, "semicolonPlaceholder").replace(/\s*,\s*/g, ",").split(","); //Get the actual dependency param categories
dependencyMatchActualParamCategoriesIndex = dependencyMatchActualParamCategoriesExisting.indexOf(dependencyTextarea);
}
}
}
else {
dependencyMatchActualParamCategoriesIndex = dependencyMatchActualParamCategories.indexOf(dependencySelected);
}
if (dependencyMatchActualParamCategoriesIndex !== -1) { //If the dependency index exists
dependentCategory = dependentCategoriesCleanedSplit[dependencyMatchActualParamCategoriesIndex]; //Get category from definition params
if (dependentCategory === undefined) { //If the category doesn't exist in definition params
dependentMatchActualParamIndex = usedArray.indexOf(paramMatched); //Get index from the array to be added
if (dependentMatchActualParamIndex !== -1) { //If it exists in the array to be added
dependentCategoriesExisting = usedArray[dependentMatchActualParamIndex+1].match(/(?:#|%%)[\W\w\s]*?(?:#|%%)/).toString(); //Get the actual dependency param categories
}
else {
dependentCategoriesExisting = "";
}
if (dependentCategoriesExisting.length) {
dependentCategoriesClean = dependentCategoriesExisting.replace(/#|%%|\+\+[^\+]*?\+\+/g, "").replace(/\\,/g, "commaPlaceholder").replace(/\\;/g, "semicolonPlaceholder").replace(/\s*([,;])\s*/g, "$1").trim().split(";");
dependentCategory = dependentCategoriesClean[dependencyMatchActualParamCategoriesIndex];
if (dependentCategory === undefined) { //If the category doesn't exists in definition params
dependentCategory = "";
}
}
else {
dependentCategory = "";
}
}
}
else {
dependentCategory = "";
}
if (dependentCategory.length) { //If the category exists
dependentCategoriesRE = new RegExp(dependentCategories.escapeRegExp());
dependentCategoryRE = new RegExp(dependentCategory.escapeRegExp());
dependentCategorySplit = dependentCategory.replace(/\\,/g, "commaPlaceholder").replace(/\\;/g, "semicolonPlaceholder").split(",");
if (dependentCategorySplit.indexOf(paramValue) !== -1) {
repeatedValue = true;
}
if (dependentCategorySplit.indexOf(paramValue) === -1) { //If the value is new
dependentCategoryNew = dependentCategory+","+paramValue.replace(/\\,/g, "commaPlaceholder").replace(/\\;/g, "semicolonPlaceholder"); //Append the value
dependentCategoriesCleanedSplit.splice(dependencyMatchActualParamCategoriesIndex,1,dependentCategoryNew); //Replace the old value in the original stringified array, in case multiple values are added to the same param at once
if (paramMatched.match(/%%/)) {
dependentCategoriesNew = "%%++"+dependencyMatch+"++ "+dependentCategoriesCleanedSplit.join(";").replace(/([,;])/g, "$1 ")+"%%"; //Replace old category with new one
}
else if (paramMatched.match(/#/)) {
dependentCategoriesNew = "#"+multiple+"++"+dependencyMatch+"++ "+dependentCategoriesCleanedSplit.join(";").replace(/([,;])/g, "$1 ").replace(/commaPlaceholder/g, "\\,").replace(/semicolonPlaceholder/g, "\\;")+"#"; //Replace old category with new one
}
}
else {
repeatedValue = true;
}
if (repeatedValue === false) {
if ((modules === true) && (appendedModuleValue === true)) {
paramMatchedNew = existingParam.replace(dependentCategoriesRE, dependentCategoriesNew); //Get the new parameter
if (!newParamValue.length) {
newParamValue.push(usedArray[paramIndex+1]);
}
newParamValue.push(paramValue); //Add the new value
usedArray.splice(paramIndex,1,paramMatchedNew);
usedArray.splice(paramIndex+1,1,newParamValue);
}
else {
paramMatchedNew = paramMatched.replace(dependentCategoriesRE, dependentCategoriesNew); //Get the new parameter
}
}
if ((appendedModuleValue === false) && (repeatedValue === false)) {
if (globalTemplate === true) {
newGlobalTemplateTextSanitize.push(paramMatched);
newGlobalTemplateTextSanitize.push(paramMatchedNew);
newGlobalTemplateTextSanitize.push(paramValue);
}
//else if ((modules === true) && (appendedModuleValue === false) && (repeatedValue === false)) {
else if (modules === true) {
newModuleTemplateTextSanitize.push(moduleTemplateTitle);
newModuleTemplateTextSanitize.push(paramMatched);
newModuleTemplateTextSanitize.push(paramMatchedNew);
newModuleTemplateTextSanitize.push(paramValue);
}
else if (modules === false) {
newTemplateTextSanitize.push(paramMatched);
newTemplateTextSanitize.push(paramMatchedNew);
newTemplateTextSanitize.push(paramValue);
}
}
}
else { //If the category doesn't exist
dependentCategoryRE = new RegExp(dependentCategoriesCleaned.escapeRegExp());
dependentCategoriesRE = new RegExp(dependentCategories.escapeRegExp());
dependentCategoryNew = dependentCategoriesCleaned+";"+paramValue.replace(/\\,/g, "commaPlaceholder").replace(/\\;/g, "semicolonPlaceholder"); //Append the value
if (paramMatched.match(/%%/)) {
dependentCategoriesNew = "%%"+"++"+dependencyMatch+"++ "+dependentCategoriesCleaned.replace(dependentCategoryRE, dependentCategoryNew).replace(/([,;])/g, "$1 ")+"%%"; //Replace old category with new one
}
else if (paramMatched.match(/#/)) {
dependentCategoriesNew = "#"+multiple+"++"+dependencyMatch+"++ "+dependentCategoriesCleaned.replace(dependentCategoryRE, dependentCategoryNew).replace(/([,;])/g, "$1 ").replace(/commaPlaceholder/g, "\\,").replace(/semicolonPlaceholder/g, "\\;")+"#"; //Replace old category with new one
}
if ((modules === true) && (appendedModuleValue === true) && (repeatedValue === false)) {
paramMatchedNew = existingParam.replace(dependentCategoriesRE, dependentCategoriesNew); //Get the new parameter
if (!newParamValue.length) {
newParamValue.push(usedArray[paramIndex+1]);
}
newParamValue.push(paramValue); //Add the new value
usedArray.splice(paramIndex,1,paramMatchedNew);
usedArray.splice(paramIndex+1,1,newParamValue);
}
else {
paramMatchedNew = paramMatched.replace(dependentCategoriesRE, dependentCategoriesNew); //Get the new parameter
}
if ((appendedModuleValue === false) && (repeatedValue === false)) {
if (globalTemplate === true) {
newGlobalTemplateTextSanitize.push(paramMatched);
newGlobalTemplateTextSanitize.push(paramMatchedNew);
newGlobalTemplateTextSanitize.push(paramValue);
}
else if (modules === true) {
newModuleTemplateTextSanitize.push(moduleTemplateTitle);
newModuleTemplateTextSanitize.push(paramMatched);
newModuleTemplateTextSanitize.push(paramMatchedNew);
newModuleTemplateTextSanitize.push(paramValue);
}
else if (modules === false) {
newTemplateTextSanitize.push(paramMatched);
newTemplateTextSanitize.push(paramMatchedNew);
newTemplateTextSanitize.push(paramValue);
}
}
}
}
else { //If it is not a dependent
for (t = 0; t < allDefinitionsSplitLength; t+=1) { //Check if it has any dependents
if (allDefinitionsSplit[t].match(dependentMatchRE)) {
dependentMatch.push(allDefinitionsSplit[t]);
}
}
if (dependentMatch.length) {
dependencyArray.pushUnique(param); //Push dependent to array
dependentMatchLength = dependentMatch.length;
for (n = 0; n < dependentMatchLength; n+=1) {
dependentParam = dependentMatch[n].replace(/(?: \(\([\w\W\s]*?| \*\*[\W\w\s]*?)?$/, ""); //Get dependent parameter
dependencyArray.pushUnique(dependentParam.replace(/\+\+|\n/g, "")); //Push dependent to array
}
}
if (((modules === true) && (newModuleTemplateTextSanitize.indexOf(moduleTemplateTitle) !== -1)) || (modules === false)) { //If the array contains the module title
for (a = 0; a < usedArrayLength; a = a + iterationFactor) {
if (((newModuleTemplateTextSanitize[a] === moduleTemplateTitle) && (usedArray[a+1] === paramMatched)) || (usedArray[a] === paramMatched)) { //If the original parameter in the array is the same as the current original parameter
paramIndex = a+iterationFactor-2; //Get index of the new parameter in the array
existingParam = usedArray[paramIndex]; //Use the value from the array as source
if (existingParam) {
appendedModuleValue = true;
break;
}
}
}
if (appendedModuleValue === true) {
dependentCategories = existingParam.match(/#[\W\w\s]*?#/).toString(); //Get parameter categories
}
else {
dependentCategories = paramMatched.match(/#[\W\w\s]*?#/).toString(); //Get parameter categories
}
}
else {
dependentCategories = paramMatched.match(/#[\W\w\s]*?#/).toString(); //Get parameter categories
}
if (dependentCategories.indexOf("=") === 1) {
multiple = "=";
}
else {
multiple = "";
}
dependentCategoriesCleaned = dependentCategories.replace(/[#!=]/g, "").replace(/\b\s*?,\s*?\b/g, ",").replace(/\\,/g, "commaPlaceholder").replace(/\\;/g, "semicolonPlaceholder").replace(/\b\s*?;\s*?\b/g, ";").trim(); //Clean parameter categories
dependentCategoriesCleanedSplit = dependentCategoriesCleaned.split(",");
if (dependentCategoriesCleanedSplit.indexOf(paramValue) !== -1) {
repeatedValue = true;
}
dependentCategoriesRE = new RegExp(dependentCategories.escapeRegExp());
dependentCategoryRE = new RegExp(dependentCategoriesCleaned.escapeRegExp());
dependentCategoryNew = dependentCategoriesCleaned+","+paramValue.replace(/\\,/g, "commaPlaceholder").replace(/\\;/g, "semicolonPlaceholder"); //Append the value
dependentCategoriesNew = "#"+multiple+dependentCategoriesCleaned.replace(dependentCategoryRE, dependentCategoryNew).replace(/([,;])/g, "$1 ").replace(/commaPlaceholder/g, "\\,").replace(/semicolonPlaceholder/g, "\\;")+"#"; //Replace old category with new one
if (repeatedValue === false) {
if ((modules === true) && (appendedModuleValue === true)) {
paramMatchedNew = existingParam.replace(dependentCategoriesRE, dependentCategoriesNew); //Get the new parameter
if (!newParamValue.length) {
newParamValue.push(usedArray[paramIndex+1]);
}
newParamValue.push(paramValue); //Add the new value
usedArray.splice(paramIndex,1,paramMatchedNew);
usedArray.splice(paramIndex+1,1,newParamValue);
}
else {
paramMatchedNew = paramMatched.replace(dependentCategoriesRE, dependentCategoriesNew); //Get the new parameter
}
}
if ((appendedModuleValue === false) && (repeatedValue === false)) {
if (globalTemplate === true) {
newGlobalTemplateTextSanitize.push(paramMatched);
newGlobalTemplateTextSanitize.push(paramMatchedNew);
newGlobalTemplateTextSanitize.push(paramValue);
}
else if (modules === true) {
newModuleTemplateTextSanitize.push(moduleTemplateTitle);
newModuleTemplateTextSanitize.push(paramMatched);
newModuleTemplateTextSanitize.push(paramMatchedNew);
newModuleTemplateTextSanitize.push(paramValue);
}
else if (modules === false) {
newTemplateTextSanitize.push(paramMatched);
newTemplateTextSanitize.push(paramMatchedNew);
newTemplateTextSanitize.push(paramValue);
}
}
}
} //End go through new values
if (dependencyArray.length) {
dependencyArrayLength = dependencyArray.length;
for (m = 0; m < dependencyArrayLength; m+=1) {
if (addOther.indexOf(dependencyArray[m]) === -1) { //If the dependency and all the dependents aren't filled in
alert(this.texts.infoboxMissingDependentEntry.format([InfoboxSpecialValueOther]));
return;
}
}
}
//Only save global template if there were changes
if (newGlobalTemplateTextSanitize.length) {
newGlobalTemplateText = globalTemplateText;
newGlobalTemplateTextSanitizeLength = newGlobalTemplateTextSanitize.length;
for (p = 0; p < newGlobalTemplateTextSanitizeLength; p = p + 3) { //Do the final replace
newGlobalTemplateText = newGlobalTemplateText.replace(newGlobalTemplateTextSanitize[p], newGlobalTemplateTextSanitize[p+1]);
if (enableLogging === true) {
if (logTemplateChanges === true) { //Parameters with added values
globalTemplateChangedParam = newGlobalTemplateTextSanitize[p].replace(/ \(\([\W\w\s]*| \*\*[\W\w\s]*/, "").trim();
valueMessages += templateValueAdded.format([new Date().formatString(messageLogDateFormat), newGlobalTemplateTextSanitize[p+2].trim(), globalTemplateChangedParam, globalParametersTemplate]);
}
}
}
if (backupInfoboxes === true) { //Backup the global template
backupGlobalTitle = globalParametersTemplate+"_"+saveDate;
backupGlobalTemplateTags = globalTemplateTags.toString().replace(/,/g, " ")+infoboxTagsBackupSpace+excludeFromLists+excludeFromSearch;
if (enableLogging === true) { //If logging is enabled
if (logTemplateBackups === true) { //If logging is enabled for global template
backupMessages += templateBackedUp.format([new Date().formatString(messageLogDateFormat), globalParametersTemplate]);
}
}
store.saveTiddler(backupGlobalTitle,backupGlobalTitle,globalTemplateText,user,new Date(),backupGlobalTemplateTags); //Save backed up tiddler
}
store.saveTiddler(globalParametersTemplate,globalParametersTemplate,newGlobalTemplateText,user,new Date(),globalTemplateTags); //Save global template
}
//Only save module template if there were changes
if (newModuleTemplateTextSanitize.length) {
newModuleTemplateTextSanitizeLength = newModuleTemplateTextSanitize.length;
for (q = 0; q < newModuleTemplateTextSanitizeLength; q = q + 4) { //Do the final replace
originalModuleTemplateText = store.getTiddlerText(newModuleTemplateTextSanitize[q]);
newModuleTemplateText = originalModuleTemplateText.replace(newModuleTemplateTextSanitize[q+1], newModuleTemplateTextSanitize[q+2]);
if (newModuleTemplateTextSanitize[q] !== newModuleTemplateTextSanitize[q+4]) { //Only save when the next module name changes
if (backupInfoboxes === true) { //Backup the module template
backupModuleTitle = newModuleTemplateTextSanitize[q]+"_"+saveDate;
backupModuleTemplateTags = moduleTemplateTags.toString().replace(/,/g, " ")+infoboxTagsBackupSpace+excludeFromLists+excludeFromSearch;
if (logTemplateBackups === true) {
backupMessages += templateBackedUp.format([new Date().formatString(messageLogDateFormat), newModuleTemplateTextSanitize[q]]);
}
store.saveTiddler(backupModuleTitle,backupModuleTitle,originalModuleTemplateText,user,new Date(),backupModuleTemplateTags); //Save backed up tiddler
}
}
store.saveTiddler(newModuleTemplateTextSanitize[q],newModuleTemplateTextSanitize[q],newModuleTemplateText,user,new Date(),moduleTemplateTags); //Save module templates
if (enableLogging === true) { //If logging is enabled
if (logTemplateChanges === true) { //If logging is enabled for modules
moduleTemplateChangedParam = newModuleTemplateTextSanitize[q+1].replace(/ \(\([\W\w\s]*| \*\*[\W\w\s]*/, "").trim();
if ((newModuleTemplateTextSanitize[q] !== newModuleTemplateTextSanitize[q-4]) || ((newModuleTemplateTextSanitize[q] === newModuleTemplateTextSanitize[q-4]) && (newModuleTemplateTextSanitize[q+3] !== newModuleTemplateTextSanitize[q-1]))) {
if (typeof newModuleTemplateTextSanitize[q+3] === "string") { //If it's a string, it means it's only one value
valueMessages += templateValueAdded.format([new Date().formatString(messageLogDateFormat), newModuleTemplateTextSanitize[q+3].trim(), moduleTemplateChangedParam, newModuleTemplateTextSanitize[q]]);
}
else { //If it's not a string, it means it's an array of multiple values and it needs to log them separately
newValues = newModuleTemplateTextSanitize[q+3];
newValuesLength = newValues.length;
for (b = 0; b < newValuesLength; b+=1) {
valueMessages += templateValueAdded.format([new Date().formatString(messageLogDateFormat), newValues[b].trim(), moduleTemplateChangedParam, newModuleTemplateTextSanitize[q]]);
}
}
}
} //End if logging is enabled for modules
} //End if logging is enabled
} //End do the final replace
} //End if there are changes
//Only save infobox template if there were changes
if (newTemplateTextSanitize.length) {
newTemplateText = templateText;
newTemplateTextSanitizeLength = newTemplateTextSanitize.length;
for (r = 0; r < newTemplateTextSanitizeLength; r = r + 3) { //Do the final replace
newTemplateText = newTemplateText.replace(newTemplateTextSanitize[r], newTemplateTextSanitize[r+1]);
if (enableLogging === true) { //If logging is enabled
if (logTemplateChanges === true) { //If logging is enabled for infoboxes
templateChangedParam = newTemplateTextSanitize[r].replace(/ \(\([\W\w\s]*| \*\*[\W\w\s]*/, "").trim();
valueMessages += templateValueAdded.format([new Date().formatString(messageLogDateFormat), newTemplateTextSanitize[r+2].trim(), templateChangedParam, template]);
}
}
}
if (backupInfoboxes === true) { //Backup the infobox template
backupInfoboxTitle = template+"_"+saveDate;
backupTemplateTags = templateTags.toString().replace(/,/g, " ")+infoboxTagsBackupSpace+excludeFromLists+excludeFromSearch;
if (logTemplateBackups === true) {
backupMessages += templateBackedUp.format([new Date().formatString(messageLogDateFormat), template]);
}
store.saveTiddler(backupInfoboxTitle,backupInfoboxTitle,templateText,user,new Date(),backupTemplateTags); //Save backed up tiddler
}
store.saveTiddler(template,template,newTemplateText,user,new Date(),templateTags); //Save main infobox template
}
}//End if there are new values
//Save tiddler
var tags = tid.tags;
if (backupArticle === true) { //Backup the article
backupArticleTitle = article+"_"+saveDate;
backupArticleTags = tags.toString().replace(/,/g, " ")+infoboxTagsBackupSpace+excludeFromLists+excludeFromSearch;
if (logArticleBackups === true) { //If logging is enabled for articles
backupMessages += articleBackedUp.format([new Date().formatString(messageLogDateFormat), article]);
}
store.saveTiddler(backupArticleTitle,backupArticleTitle,articleText,user,new Date(),backupArticleTags); //Save backed up tiddler
}
var newArticleText = articleText.replace(targetMacro, fullCode);
store.saveTiddler(article,article,newArticleText,user,new Date(),tags); //Save article
} //End if there are changes
//Logging
if (enableLogging === true) { //If logging is enabled
if (logInfoboxChanges === true) { //If logging is enabled for changes
var w, x, y, z, locChange, getShorthand, getLonghand, newOriginalInfobox, newOriginalInfoboxBare, cleanupShortRE, cleanupLongRE, newInfoboxParamValue, originalInfoboxParamValue;
var cleanupShort = {};
var cleanupLong = {};
var originalInfobox = targetMacro.replace(/<<infobox[ \n]|[ \n]?>>/g, "").replace(/\n/g, ",").replace(/" \b/g, "\",").replace(/,$/, "").trim().replace(/",/g, "\"splitHere").split("splitHere"); //splitHere requred because some parameters contain multiple comma-separated values
var originalInfoboxBare = targetMacro.replace(/<<infobox[ \n]|[ \n]?>>/g, "").replace(/:"[^"]*?"[ \n]?/g, ",").replace(/,$/, "").trim().split(",");
var newInfobox = fullCode.replace(/<<infobox[ \n]|[ \n]?>>/g, "").replace(/\n/g, ",").replace(/" \b/g, "\",").replace(/,$/, "").trim().replace(/",/g, "\"splitHere").split("splitHere"); //splitHere requred because some parameters contain multiple comma-separated values
var newInfoboxBare = fullCode.replace(/<<infobox[ \n]|[ \n]?>>/g, "").replace(/:"[^"]*?"[ \n]?/g, ",").replace(/,$/, "").trim().split(",");
var shorthandsRE = new RegExp("\\n[^\\n]*?\\(\\([\\w\\W\\s]*?\\)\\)","g");
var shorthands = allDefinitions.match(shorthandsRE); //Get shorthands
var shorthandsLength = shorthands.length;
for (z = 0; z < shorthandsLength; z+=1) { //Go through shorthands
getShorthand = shorthands[z].match(/\(\([\w\W\s]+?\)\)/).toString().replace(/[\(\)]/g, "").replace(/ /g, "_"); //Get shorthands
getLonghand = shorthands[z].match(/^[\w\W\s]+?\(\(/).toString().replace(/\n| \(\(/g, "").replace(/ /g, "_"); //Get longhands
if (ignoreShorthands === true) {
cleanupShort[getShorthand] = getLonghand;
}
else {
cleanupLong[getLonghand] = getShorthand;
}
}
if (ignoreShorthands === true) { //If shorthands are ignored
if (Object.keys(cleanupShort).length) { //Replace shorthands with longhands for comparisson
cleanupShortRE = new RegExp(Object.keys(cleanupShort).join("|"),"g");
newOriginalInfobox = originalInfobox.toString().replace(cleanupShortRE, function(matched){return cleanupShort[matched];}).replace(/",/g, "\"splitHere").split("splitHere"); //splitHere requred because some parameters contain multiple comma-separated values
newOriginalInfoboxBare = originalInfoboxBare.toString().replace(cleanupShortRE, function(matched){return cleanupShort[matched];}).split(",");
}
else {
newOriginalInfobox = originalInfobox;
newOriginalInfoboxBare = originalInfoboxBare;
}
}
else {
if (Object.keys(cleanupLong).length) { //Replace longhands with shorthands for comparisson
cleanupLongRE = new RegExp(Object.keys(cleanupLong).join("|"),"g");
newOriginalInfobox = originalInfobox.toString().replace(cleanupLongRE, function(matched){return cleanupLong[matched];}).replace(/",/g, "\"splitHere").split("splitHere"); //splitHere requred because some parameters contain multiple comma-separated values
newOriginalInfoboxBare = originalInfoboxBare.toString().replace(cleanupLongRE, function(matched){return cleanupLong[matched];}).split(",");
}
else {
newOriginalInfobox = originalInfobox;
newOriginalInfoboxBare = originalInfoboxBare;
}
}
var newOriginalInfoboxBareLength = newOriginalInfoboxBare.length;
for (w = 0; w < newOriginalInfoboxBareLength; w+=1) { //Find removed values that are in fullCode (target) but not in targetMacro (source)
if (newInfoboxBare.indexOf(newOriginalInfoboxBare[w]) === -1) {
originalInfoboxParamValue = newOriginalInfobox[w].slice(0, -1).split(":\""); //Added value
paramMessages += infoboxParamRemoved.format([new Date().formatString(messageLogDateFormat), newOriginalInfoboxBare[w], originalInfoboxParamValue[1], title, instance, article]);
}
}
var newInfoboxBareLength = newInfoboxBare.length;
for (x = 0; x < newInfoboxBareLength; x+=1) { //Find added values that are in targetMacro (source) but not in fullCode (target)
if (newOriginalInfoboxBare.indexOf(newInfoboxBare[x]) === -1) {
newInfoboxParamValue = newInfobox[x].slice(0, -1).split(":\""); //Removed value
paramMessages += infoboxParamAdded.format([new Date().formatString(messageLogDateFormat), newInfoboxBare[x], newInfoboxParamValue[1], title, instance, article]);
}
}
var originalInfoboxLength = originalInfobox.length;
for (y = 0; y < originalInfoboxLength; y+=1) { //Find changed values in fullCode (target) that were changed from targetMacro (source)
if (newInfoboxBare.indexOf(newOriginalInfoboxBare[y]) !== -1) { //Compare new param list to old param list
locChange = newInfoboxBare.indexOf(newOriginalInfoboxBare[y]);
if (newOriginalInfobox[y] !== newInfobox[locChange]) {
originalInfoboxParamValue = newOriginalInfobox[y].slice(0, -1).split(":\""); //Original value
newInfoboxParamValue = newInfobox[locChange].slice(0, -1).split(":\""); //Changed value
paramMessages += infoboxParamChanged.format([new Date().formatString(messageLogDateFormat), newOriginalInfoboxBare[y], originalInfoboxParamValue[1], newInfoboxParamValue[1], title, instance, article]);
}
}
}
if (ignoreShorthands === true) {
if (Object.keys(cleanupShort).length && (originalInfobox.toString().match(cleanupShortRE) !== null)) { //Add message for converting shorthands to longhands
convertMessages += infoboxShortToLong.format([new Date().formatString(messageLogDateFormat), title, instance, article]);
}
}
else {
if (Object.keys(cleanupLong).length && (originalInfobox.toString().match(cleanupLongRE) !== null)) { //Add message for converting longhands to shorthands
convertMessages += infoboxLongToShort.format([new Date().formatString(messageLogDateFormat), title, instance, article]);
}
}
}
messageLogText += backupMessages+convertMessages+paramMessages+valueMessages; //Join messages
if (backupMessages.length+convertMessages.length+paramMessages.length+valueMessages.length > 0) {
messageLogText += "{{InfoboxLogDelimiter{----}}}"; //Add a separator to separate messages for different infoboxes, but only if something was logged
}
if (getMessageLog === null) {
if (persistentLog === true) { //Save message log to a tiddler
store.saveTiddler(messageLog,messageLog,messageLogText,user,new Date(),messageLogTags);
}
else {
config.shadowTiddlers[messageLog] = messageLogText;
}
}
else {
store.saveTiddler(messageLog,messageLog,messageLogText,user,new Date(),messageLogTags);
}
} //End if logging is enabled
//Toggle display
setStylesheet("#" + this.IDs.IDPrefixOuterContainer + TTIX + " {width: 33%!important;}", this.IDs.IDPrefixInfoboxTablesStyle + this.IDs.IDPrefixOuterContainer + TTIX); //Reset the size
deleteButton.style.display = "none";
saveButton.style.display = "none";
showHideEditModeButton.style.display = "block";
showHideLinesInEditModeButton.style.display = "none";
place.style.display = "block";
placeEdit.style.display = "none";
editButton.innerHTML = editButton.getAttribute("data-infobox-edittext");
editButton.setAttribute("title",editButton.getAttribute("data-infobox-edittip"));
//story.refreshTiddler(article,null,true);//karamba
//autoSaveChanges();
}
else {
return;
}
};
//End save of infoboxes
//}}}
/***
!!Backups List Macro
***/
//{{{
config.macros.infoboxBackupsList = {};
config.macros.infoboxBackupsList.handler = function (place,macroName,params,wikifier,paramString,tiddler) {
"use strict";
var noBackupsNotice = config.macros.infobox.texts.infoboxArticleBackupListNoBackups;
var backupsContainerDiv = createTiddlyElement(place, "div", config.macros.infobox.IDs.IDPrefixBackupsContainerDiv, "InfoboxBackupsOuterContainer");
var backupsHeaderDiv = createTiddlyElement(backupsContainerDiv, "div", config.macros.infobox.IDs.IDPrefixBackupsHeaderDiv, "InfoboxBackupsListsHeader");
var infoboxTagsBackup = config.options.txtInfoboxesTagsBackup;
var infoboxTagsArticle = config.options.txtInfoboxesTagsArticle;
var infoboxTagsInfobox = config.options.txtInfoboxesTagsInfobox;
var infoboxTagsInfoboxModule = config.options.txtInfoboxesTagsInfoboxModule;
var backups = store.getTaggedTiddlers(infoboxTagsBackup);
if (backups.length) { //If there are backups
var deleteSelectedButtonText = config.macros.infobox.texts.infoboxArticleBackupListDeleteSelectedButtonText;
var deleteSelectedButtonTooltip = config.macros.infobox.texts.infoboxArticleBackupListDeleteSelectedButtonTooltip;
var deleteAllButtonText = config.macros.infobox.texts.infoboxArticleBackupListDeleteAllButtonText;
var deleteAllButtonTooltip = config.macros.infobox.texts.infoboxArticleBackupListDeleteAllButtonTooltip;
var numberOfBackups = config.macros.infobox.texts.infoboxArticleBackupListNumberOfBackups;
var articlesTitle = config.macros.infobox.texts.infoboxArticleBackupListArticlesTitle;
var infoboxTitle = config.macros.infobox.texts.infoboxArticleBackupListInfoboxesTitle;
var infoboxModulesTitle = config.macros.infobox.texts.infoboxArticleBackupListInfoboxModulesTitle;
var globalTemplateTitle = config.macros.infobox.texts.infoboxArticleBackupListGlobalTemplateTitle;
var i, backup, articleHeader, infoboxHeader, infoboxModulesHeader, globalTemplateHeader, articleCountDiv, infoboxCountDiv, infoboxModulesCountDiv, globalTemplateCountDiv;
var articleBackups = 0;
var infoboxBackups = 0;
var infoboxModulesBackups = 0;
var infoboxGlobalBackups = 0;
var infoboxGlobalTemplate = config.options.txtInfoboxesGlobalParametersTemplate;
var backupsListsContainerDiv = createTiddlyElement(backupsContainerDiv, "div", config.macros.infobox.IDs.IDPrefixBackupsContainerDiv, "InfoboxBackupsListsContainer"); //Main container div
var backupsListsArticleDiv = createTiddlyElement(backupsListsContainerDiv, "div", config.macros.infobox.IDs.IDPrefixBackupsArticleDiv, "InfoboxBackupsListsList"); //Div container for article backups
var backupsListsInfoboxDiv = createTiddlyElement(backupsListsContainerDiv, "div", config.macros.infobox.IDs.IDPrefixBackupsInfoboxDiv, "InfoboxBackupsListsList"); //Div container for main template backups
var backupsListsInfoboxModuleDiv = createTiddlyElement(backupsListsContainerDiv, "div", config.macros.infobox.IDs.IDPrefixBackupsInfoboxModuleDiv, "InfoboxBackupsListsList"); //Div container for module template backups
var backupsListsGlobalTemplateDiv = createTiddlyElement(backupsListsContainerDiv, "div", config.macros.infobox.IDs.IDPrefixBackupsTemplateDiv, "InfoboxBackupsListsList"); //Div container for global template backups
var backupsLength = backups.length;
for (i = 0; i < backupsLength; i+=1) { //Go through the backups
if (backups[i].isTagged(infoboxTagsArticle)) { //If backup is an article
articleBackups = articleBackups + 1;
if (articleBackups === 1) { //Add a header
articleHeader = "!"+articlesTitle+"\n";
}
else {
articleHeader = "";
}
wikify(articleHeader,backupsListsArticleDiv); //Display the backups
if (articleBackups === 1) {
articleCountDiv = createTiddlyElement(backupsListsArticleDiv, "div", config.macros.infobox.IDs.IDPrefixArticleCountDiv, "InfoboxBackupsListCountDiv"); //Div for article backup count
}
backup = createTiddlyCheckbox(backupsListsArticleDiv, "[["+backups[i].title+"]]\n", false, null);
backup.setAttribute("name", "infoboxBackupCheckbox");
backup.setAttribute("data-infobox-backupTitle", backups[i].title);
}
if (backups[i].isTagged(infoboxTagsInfobox)) { //If backup is an infobox template
infoboxBackups = infoboxBackups + 1;
if (infoboxBackups === 1) { //Add a header
infoboxHeader = "!"+infoboxTitle+"\n";
}
else {
infoboxHeader = "";
}
wikify(infoboxHeader,backupsListsInfoboxDiv);
if (infoboxBackups === 1) {
infoboxCountDiv = createTiddlyElement(backupsListsInfoboxDiv, "div", config.macros.infobox.IDs.IDPrefixInfoboxCountDiv, "InfoboxBackupsListCountDiv"); //Div for infobox module backup count
}
backup = createTiddlyCheckbox(backupsListsInfoboxDiv, "[["+backups[i].title+"]]\n", false, null);
backup.setAttribute("data-infobox-name", "infoboxBackupCheckbox");
backup.setAttribute("backupTitle", backups[i].title);
}
if (backups[i].isTagged(infoboxTagsInfoboxModule)) { //If backup is a module template
infoboxModulesBackups = infoboxModulesBackups + 1;
if (infoboxModulesBackups === 1) { //Add a header
infoboxModulesHeader = "!"+infoboxModulesTitle+"\n";
}
else {
infoboxModulesHeader = "";
}
wikify(infoboxModulesHeader,backupsListsInfoboxModuleDiv);
if (infoboxModulesBackups === 1) {
infoboxModulesCountDiv = createTiddlyElement(backupsListsInfoboxModuleDiv, "div", config.macros.infobox.IDs.IDPrefixInfoboxModulesCountDiv, "InfoboxBackupsListCountDiv"); //Div for module template backup count
}
backup = createTiddlyCheckbox(backupsListsInfoboxModuleDiv, "[["+backups[i].title+"]]\n", false, null);
backup.setAttribute("name", "infoboxBackupCheckbox");
backup.setAttribute("data-infobox-backupTitle", backups[i].title);
}
if (backups[i].title.match(infoboxGlobalTemplate)) { //If backup is an global template
infoboxGlobalBackups = infoboxGlobalBackups + 1;
if (infoboxGlobalBackups === 1) { //Add a header
globalTemplateHeader = "!"+globalTemplateTitle+"\n";
}
else {
globalTemplateHeader = "";
}
wikify(globalTemplateHeader,backupsListsGlobalTemplateDiv);
if (infoboxGlobalBackups === 1) {
globalTemplateCountDiv = createTiddlyElement(backupsListsGlobalTemplateDiv, "div", config.macros.infobox.IDs.IDPrefixGlobalTemplateCountDiv, "InfoboxBackupsListCountDiv"); //Div for global template backup count
}
backup = createTiddlyCheckbox(backupsListsGlobalTemplateDiv, "[["+backups[i].title+"]]\n", false, null);
backup.setAttribute("name", "infoboxBackupCheckbox");
backup.setAttribute("data-infobox-backupTitle", backups[i].title);
}
}
var deleteSelectedButton = createTiddlyButton(backupsHeaderDiv,deleteSelectedButtonText,deleteSelectedButtonTooltip,function() {config.macros.infoboxBackupsList.deleteBackup("selected");} ,"InfoboxSmallButtonBackups",config.macros.infobox.IDs.IDPrefixDeleteSelectedBackupsButton); //Delete selected button
var deleteAllButton = createTiddlyButton(backupsHeaderDiv,deleteAllButtonText,deleteAllButtonTooltip,function() {config.macros.infoboxBackupsList.deleteBackup("all");},"InfoboxSmallButtonBackups",config.macros.infobox.IDs.IDPrefixDeleteAllBackupsButton); //Delete all button
if (articleBackups > 0) {
wikify("{{InfoboxBackupsListCount{"+numberOfBackups.format([articleBackups])+"}}}",articleCountDiv); //Display article backups
}
if (infoboxBackups > 0) {
wikify("{{InfoboxBackupsListCount{"+numberOfBackups.format([infoboxBackups])+"}}}",infoboxCountDiv); //Display infobox template backups
}
if (infoboxModulesBackups > 0) {
wikify("{{InfoboxBackupsListCount{"+numberOfBackups.format([infoboxModulesBackups])+"}}}",infoboxModulesCountDiv); //Display module template backups
}
if (infoboxGlobalBackups > 0) {
wikify("{{InfoboxBackupsListCount{"+numberOfBackups.format([infoboxGlobalBackups])+"}}}",globalTemplateCountDiv); //Display global template backups
}
} //End if there are backups
else {
wikify("{{InfoboxNoBackupsNotice{"+noBackupsNotice+"}}}",backupsHeaderDiv); //Message if there are no backups
}
}; //End of infoboxBackupsList macro
//Delete backups
config.macros.infoboxBackupsList.deleteBackup = function(mode) {
"use strict";
//Settings for logging
var user = config.options.txtUserName;
var enableLogging = config.options.chkInfoboxesEnableLogging;
var messageLog = config.options.txtInfoboxesMessageLog;
var messageLogDateFormat = config.options.txtInfoboxesMessageLogDateFormat;
var getMessageLog = store.getTiddler(messageLog);
var persistentLog = config.options.chkInfoboxesPersistentLog;
var logTitle = config.macros.infobox.texts.infoboxLogMessageLogTitle;
var noMessages = config.macros.infobox.texts.infoboxLogNoMessages;
var backupDeleted = config.macros.infobox.texts.infoboxLogBackupDeleted;
var logTitleRE = new RegExp(noMessages, "");
var messageLogText;
var messageLogTags = "";
if (enableLogging === true) { //If logging is enabled
if (getMessageLog === null) { //If there is no persistent log
messageLogText = config.shadowTiddlers[messageLog].replace(logTitleRE, logTitle);
}
else {
messageLogText = getMessageLog;
}
}
var backupsList = config.options.txtInfoboxesBackupsList;
var deleteBackupsPrompt = config.options.chkInfoboxesDeleteBackupsPrompt;
var deleteSelectedNotice = config.macros.infobox.texts.infoboxArticleBackupListDeleteSelected;
var deleteAllNotice = config.macros.infobox.texts.infoboxArticleBackupListDeleteAll;
var deleteNoneSelectedNotice = config.macros.infobox.texts.infoboxArticleBackupListNoneSelected;
var i, confirmDelete, backupTitle;
var backupCheckboxes = document.getElementsByName("infoboxBackupCheckbox");
var backupCheckboxesLength = backupCheckboxes.length;
if (mode === "selected") { //Delete selected
if (deleteBackupsPrompt === true) { //Confirm deletion
confirmDelete = confirm(deleteSelectedNotice);
}
else {
confirmDelete = true;
}
if (confirmDelete === true) {
if (document.querySelectorAll('input[name="infoboxBackupCheckbox"]:checked').length === 0) { //If no backups are selected
alert(deleteNoneSelectedNotice);
return;
}
for (i = 0; i < backupCheckboxes.length; i+=1) { //Go through backups
backupTitle = backupCheckboxes[i].getAttribute("data-infobox-backupTitle");
if (backupCheckboxes[i].checked === true) { //If backup is selected
store.deleteTiddler(backupTitle);
if (enableLogging === true) { //If logging is enabled
messageLogText += backupDeleted.format([new Date().formatString(messageLogDateFormat), backupTitle]); //Add message to log
}
}
}
story.refreshTiddler(backupsList,null,true); //Refresh tiddler
}
}
else if (mode === "all") { //Delete all
if (deleteBackupsPrompt === true) { //Prompt for confirmation
confirmDelete = confirm(deleteAllNotice);
}
else {
confirmDelete = true;
}
if (confirmDelete === true) { //Confirm deletion
for (i = 0; i < backupCheckboxesLength; i+=1) { //Go through backups
backupTitle = backupCheckboxes[i].getAttribute("data-infobox-backupTitle");
store.deleteTiddler(backupTitle);
if (enableLogging === true) { //If logging is enabled
messageLogText += backupDeleted.format([new Date().formatString(messageLogDateFormat), backupTitle]); //Add message to log
}
}
story.refreshTiddler(backupsList,null,true); //Refresh tiddler
}
}
else {
return;
}
//Logging
if (enableLogging === true) { //If logging is enabled
if (getMessageLog === null) { //If there is no persistent log
if (persistentLog === true) { //If persistent logging is enabled
store.saveTiddler(messageLog,messageLog,messageLogText,user,new Date(),messageLogTags); //Save persistent log
}
else {
config.shadowTiddlers[messageLog] = messageLogText; //Use the shadow tiddler
}
}
else {
store.saveTiddler(messageLog,messageLog,messageLogText,user,new Date(),messageLogTags); //Save persistent log
}
} //End if logging is enabled
};
//End delete backups
config.shadowTiddlers[config.options.txtInfoboxesBackupsList] = "<<infoboxBackupsList>>";
//}}}
/***
!!Message log
***/
//{{{
var messageLog = config.options.txtInfoboxesMessageLog;
var enableLogging = config.options.chkInfoboxesEnableLogging;
if (enableLogging === true) { //If logging is enabled
config.shadowTiddlers[messageLog] = "{{InfoboxLogMessage{"+config.macros.infobox.texts.infoboxLogNoMessages+"}}}"; //Message that there are no messages in the log
}
else {
config.shadowTiddlers[messageLog] = "{{InfoboxLogMessage{"+config.macros.infobox.texts.infoboxLogLoggingNotEnabled+"}}}"; //Message that logging is not enabled
}
//}}}
/***
!!Templates list
***/
//{{{
config.macros.infoboxTemplatesList = {};
config.macros.infoboxTemplatesList.handler = function (place,macroName,params,wikifier,paramString,tiddler) {
"use strict";
var infoboxes = config.options.txtInfoboxesTagsInfobox;
var modules = config.options.txtInfoboxesTagsInfoboxModule;
var includeTemplatePrefix = config.options.txtInfoboxesPrefixInfoboxInclude;
var includePrefix = config.options.txtInfoboxesPrefixInclude;
var includePrefixRE = new RegExp(includePrefix+"-|(?:_\\(\\([^\\n]*?|_\\*\\*[^\\n]*?)?\\n|,|\\*", "g");
var includeParamsRE = new RegExp("(\\**?)"+includePrefix+"-[^\\n$]*?(?:\\n|$)", "");
var includeRE = new RegExp("(?:\\*)*?"+includeTemplatePrefix.replace(/ /g, "_")+"_[^\\n$]*?(?:\\n|$)", "g");
var includeDepthRE = new RegExp("(\\**?)([^\\*\\n$]*?)(\\n|$)", "");
var ContentSectionContent = config.options.txtInfoboxesSectionContent;
var backups = config.options.txtInfoboxesTagsBackup;
var i, j, k, l, infoboxTidsLength, infoboxTitle, moduleTids, moduleTidsLength, moduleTitle, moduleTidsText, moduleIncludes, moduleIncludesLength, moduleIncludeTitle, moduleIncludeText, infoboxTidsText, infoboxIncludeTitle, infoboxIncludeText, infoboxIncludes, infoboxIncludesLength;
var templatesList = "";
var infoboxTids = store.getTaggedTiddlers(infoboxes);
if (infoboxTids.length) { //If there are infoboxes
templatesList = "{{InfoboxTemplateList{"+config.macros.infobox.texts.infoboxTemplateListHeader+"}}}\n";
infoboxTidsLength = infoboxTids.length;
for (i = 0; i < infoboxTidsLength; i+=1) { //Go through infoboxes
if (!infoboxTids[i].isTagged(backups)) { //If infobox isn't a backup
infoboxTitle = infoboxTids[i].title;
templatesList += "*[["+infoboxTitle+"]]\n";
moduleTids = store.getTaggedTiddlers(infoboxTitle);
if (moduleTids.length) { //End if there are modules
moduleTidsLength = moduleTids.length;
for (j = 0; j < moduleTidsLength; j+=1) { //Go through modules
if (moduleTids[j].isTagged(modules) && !moduleTids[j].isTagged(backups)) { //If the module is tagged as a module and it isn't a backup
moduleTitle = moduleTids[j].title;
templatesList += "**[["+moduleTitle+"]]\n";
//if (store.getTiddler(moduleTitle).text.match("!"+ContentSectionContent) !== null) { //Get included params//karamba
if (store.getTiddlerText(moduleTitle).match("!"+ContentSectionContent) !== null) { //Get included params
moduleTidsText = store.getTiddlerText(moduleTitle+"##"+ContentSectionContent);
}
else {
moduleTidsText = store.getTiddlerText(moduleTitle);
}
while (moduleTidsText.match(includeParamsRE) !== null) { //Process includes
moduleIncludeTitle = moduleTidsText.match(includeParamsRE).toString().replace(includePrefixRE, ""); //Get include name
if (store.getTiddler(moduleIncludeTitle)) { //If include exists
//if (store.getTiddler(moduleIncludeTitle).text.match("!"+ContentSectionContent) !== null) { //Get included params//karamba
if (store.getTiddlerText(moduleIncludeTitle).match("!"+ContentSectionContent) !== null) { //Get included params
moduleIncludeText = store.getTiddlerText(moduleIncludeTitle+"##"+ContentSectionContent);
}
else {
moduleIncludeText = store.getTiddlerText(moduleIncludeTitle);
}
} //End if include exists
else {
moduleIncludeText = "";
}
moduleTidsText = moduleTidsText.replace(includeParamsRE, "$1"+moduleIncludeTitle+"\n$1\*"+moduleIncludeText.replace(/\n/g, "\n\*")+"\n");
} //End process includes
moduleIncludes = moduleTidsText.match(includeRE);
if (moduleIncludes) { //If the module contains includes
moduleIncludesLength = moduleIncludes.length;
for (k = 0; k < moduleIncludesLength; k+=1) { //Go through module includes
moduleIncludeTitle = moduleIncludes[k];
templatesList += "***"+moduleIncludeTitle.replace(includeDepthRE, "$1\[\[$2")+"]]\n";
} //End go through module includes
} //End if the module contains includes
} //End if the module is tagged as a module and it isn't a backup
} //End go through modules
} //End if there are modules
infoboxTidsText = store.getTiddlerText(infoboxTitle+"##"+ContentSectionContent);
while (infoboxTidsText.match(includeParamsRE) !== null) { //Process includes
infoboxIncludeTitle = infoboxTidsText.match(includeParamsRE).toString().replace(includePrefixRE, ""); //Get include name
if (store.getTiddler(infoboxIncludeTitle)) { //If include exists
//if (store.getTiddler(infoboxIncludeTitle).text.match("!"+ContentSectionContent) !== null) { //Get included params//karamba
if (store.getTiddlerText(infoboxIncludeTitle).match("!"+ContentSectionContent) !== null) { //Get included params
infoboxIncludeText = store.getTiddlerText(infoboxIncludeTitle+"##"+ContentSectionContent);
}
else {
infoboxIncludeText = store.getTiddlerText(infoboxIncludeTitle);
}
} //End if include exists
else {
infoboxIncludeText = "";
}
infoboxTidsText = infoboxTidsText.replace(includeParamsRE, "$1"+infoboxIncludeTitle+"\n$1\*"+infoboxIncludeText.replace(/\n/g, "\n\*")+"\n");
} //End process includes
infoboxIncludes = infoboxTidsText.match(includeRE);
if (infoboxIncludes) { //If the infobox contains includes
infoboxIncludesLength = infoboxIncludes.length;
for (l = 0; l < infoboxIncludesLength; l+=1) { //Go through infobox includes
infoboxIncludeTitle = infoboxIncludes[l];
templatesList += "**"+infoboxIncludeTitle.replace(includeDepthRE, "$1\[\[$2")+"]]\n";
} //End go through module includes
} //End of the infobox contains includes
} //End if infobox isn't a backup
} //End go through infoboxes
} //End if there are infoboxes
else {
templatesList = "{{InfoboxTemplateList{"+config.macros.infobox.texts.infoboxTemplateListNoTemplates+"}}}";
}
wikify(templatesList,place);
}; //End of infoboxTemplatesList macro
config.shadowTiddlers[config.options.txtInfoboxesTemplatesList] = "<<infoboxTemplatesList>>";
//}}}
//karamba END OF PLUGIN, BELOW IS THE BACKUP
//{{{
} //End of install only once
//}}}