// This file is provided to you under the Freeware license.
// All rights to this file belong to AXMA Soft https://axmasoft.com.
// You agree not to distribute this file in any way, and also not to modify and do not change it. Also, you cannot delete or change the ownership information in copies of this file.

// Этот файл предоставляется вам по лицензии Freeware.
// Все права на этот файл принадлежат компании АКСМА Софт https://axmajs.ru.
// Вы соглашаетесь не распространять этот файл никаким способом, а также не модифицировать и не изменять его. Также Вы не можете удалять или изменять сведения о правах собственности в копиях этого файла.
(function () { // начало безымянной функции
function GetURLHashVar(name) {
name = name.trim();
var str = window.location.hash.substr(1);
str = str.split('&');
for (var key in str) {
var arr = str[key].split('=');
arr[0] = arr[0].trim();
if (arr[0] && arr[1] && arr[0]==name) {
arr[1] = arr[1].trim();
if (arr[1].toLowerCase()=='true') {
return true;
} else if (arr[1].toLowerCase()=='false') {
return false;
} else if (!isNaN(+arr[1])) {
return parseInt(arr[1],10);
} else {
return arr[1];
}
}
}
return undefined;
}
var LangCode;
LangCode = GetURLHashVar('LangCode');
if (!LangCode) {
if (window.location.pathname.toLowerCase()=='/en') {
LangCode = 'en';
} else {
var str = window.location.search.toLowerCase().substr(1).split('&');
for (var key in str) {
if (str[key].trim()=='en') {
LangCode = 'en';
} else {
LangCode = 'ru';
}
}
}
}
if (!LangCode) {
LangCode = 'ru';
}
var Lang = {
Server: function() {
return "https://axmajs.ru";
}
}
Lang.AppName = 'AXMA Story Maker JS';
if (LangCode=='ru') {
Lang.Navigator = 'Навигатор';
Lang.ToolButtons = [ 'Добавить', 'Действия', 'Вид', 'Сохранить', 'Загрузить', 'Запустить', 'Новая', 'Экспорт', Lang.Navigator, 'Помощь' ];
Lang.EditorButtons = [ 'Закрыть и сохранить', 'Вставить ссылку', 'Вставить функцию или оператор', 'Отформатировать текст', 'Закомментировать текст', 'Установить цвет параграфа' ];
Lang.SmallButtons = [ 'Вернуться назад', 'Тестировать', 'Искать далее', 'Табуляция/Автодополнение', 'Соединительные линии', 'Вид соединительных линий' ];
Lang.HTMLSave = 'Сохранить';
Lang.HTMLLoad = 'Восстановить';
Lang.HTMLSaveSure = 'Хотите сохранить состояние?';
Lang.HTMLLoadSure = 'Хотите восстановить состояние?';
Lang.Error = 'Произошла ошибка кода';
Lang.Audio = 'Аудио';
Lang.StartAgain = 'Хотите начать заново?';
Lang.HTMLRestart = 'Начать заново';
Lang.HTMLStart = 'Начать';
Lang.Console = 'Консоль';
Lang.ViewButton = 'Просмотр';
Lang.HTMLMenu = 'Меню';
Lang.HTMLPrefs = 'Настройки';
Lang.HTMLTextSize = 'Размер текста';
Lang.HTMLAnimOn = 'Включить анимацию';
Lang.HTMLAnimOff = 'Отключить анимацию';
Lang.HTMLSoundOn = 'Включить звуки';
Lang.HTMLSoundOff = 'Отключить звуки';
Lang.CreatedBy = 'использована&nbsp;платформа';
Lang.JSrequires = 'Для работы файла требуется, чтобы Javascript был включен в Вашем браузере';
Lang.Location = 'Параграф';
Lang.NotFound = 'не найден';
Lang.License = '<!DOCTYPE html>\n<!--\nиспользована платформа '+Lang.AppName+'\nhttps://sm.axmasoft.com/\nВы соглашаетесь ни коим образом не модифицировать и не изменять этот файл. Также Вы не можете удалять или изменять сведения о правах собственности в копиях этого файла.\n-->\n';
Lang.NotFound2 = 'Ничего не найдено';
Lang.Found = 'Найдено';
Lang.Replaced = 'Заменено';
Lang.Passages = 'Параграфов';
Lang.PassagesUpper = 'Параграфы';
Lang.PassagesErrors = 'С битыми ссылками';
Lang.Chars = 'символов';
Lang.NoPassages = 'Параграфы отсутствуют';
Lang.NoPassage = 'Не выбран параграф';
Lang.BadPassageTitle = 'Недопустимое название параграфа!';
Lang.PleaseWait = 'Подождите, пожалуйста...';
Lang.Create = 'создать';
Lang.PassagesGroup = 'Группа параграфов';
Lang.SplitAll = 'Разъединить все';
Lang.Back = 'Назад';
Lang.Grouped = 'Соединены';
Lang.Saved = 'Сохранено';
Lang.Saving = 'Сохраняется...';
Lang.StorySaved = 'Состояние сохранено';
Lang.StoryNotSaved = 'Ошибка при сохранении!';
Lang.StoryNotLoaded = 'Не удалось восстановить состояние!';
Lang.Loading = 'Загрузка...';
Lang.ListLoading = 'Загрузка списка...';
Lang.Loaded = 'Загружено';
Lang.AreYouSure = 'Вы уверены?';
Lang.No = 'нет';
Lang.LinesOn = 'Линии включены';
Lang.LinesOff = 'Линии выключены';
Lang.ArcsOn = 'Кривые';
Lang.ArcsOff = 'Прямые';
Lang.NO = 'Нет';
Lang.YES = 'Да';
Lang.FindInPassages = 'Поиск';
Lang.MenuEdit = 'Редактировать';
Lang.MenuDelete = 'Удалить';
Lang.MenuDuplicate = 'Дублировать';
Lang.MenuLinked = 'Связанные';
Lang.MenuTest = 'Тестировать';
Lang.MenuFindNReplace = 'Поиск и замена';
Lang.MenuGotoLink = 'Перейти по ссылке';
Lang.MenuUndo = 'Отменить изменения';
Lang.MenuOutLinks = 'Исходящие';
Lang.MenuInLinks = 'Входящие';
Lang.MenuArrangeByTitle = 'Расставить по названию';
Lang.MenuArrangeByColor = 'Расставить по цвету';
Lang.MenuArrangeBySize = 'Расставить по размеру';
Lang.MenuArrangeZoomOut = 'Уменьшить';
Lang.MenuArrangeZoomIn = 'Увеличить';
Lang.MenuSelectStory = 'Выбрать файл';
Lang.MenuMergeStory = 'Добавить к текущему';
Lang.MenuFromBackUp = 'Из резервной копии';
Lang.NoBackUp = 'Нет резервной копии';
Lang.MenuNewStandart = 'Шаблон примера';
Lang.MenuNewCompact = 'Пустой шаблон';
Lang.MenuNewClipboard = 'Из буфера обмена';
Lang.MenuNewClipboardMess = 'Скопируйте исходный текст в буфер обмена и вставьте его в это поле';
Lang.MenuPublishFile = 'Сохранить как HTML файл';
Lang.MenuPublishInet = 'Отправить в библиотеку';
Lang.MenuPublishApk = 'Сохранить как APK файл для Android';
Lang.MenuPublishInetSure = 'Вы уверены, что всё готово к публикации?';
Lang.MenuQuickStart = 'Быстрый старт';
Lang.MenuRestart = 'Перезагрузить';
Lang.MenuUserManual = 'Руководство пользователя';
Lang.MenuProfile = 'Мой аккаунт';
Lang.MenuModules = 'Внешние модули';
Lang.NoModules = 'Нет доступных модулей';
Lang.LoadModule = 'Установить модуль';
Lang.BuyModule = 'Купить модуль';
Lang.ExampleModule = 'Посмотреть пример';
Lang.DownloadModule = 'Скачать архив';
Lang.MenuToLibrary = 'Библиотека';
Lang.MenuDesktopVersion = 'Скачать программу';
Lang.AYSRemoveThisPassage = 'Вы действительно хотите удалить этот параграф?';
Lang.AYSRemovePassage = 'Вы действительно хотите удалить параграф';
Lang.AYSSaveNewStory = 'Вы действительно хотите создать новый файл?';
Lang.AYSCreateNewStory = 'Вы действительно хотите создать новую игру?';
Lang.AYSUndoChanges = 'Вы действительно хотите отменить все изменения, сделанные в параграфе?';
Lang.AYSExitSourceEditor = 'Вы действительно хотите выйти из редактора исходного кода?';
Lang.NotAvailEditPass = 'Недоступно при редактировании параграфа';
Lang.NotAvailInBeta = 'Недоступно в бета-версии';
Lang.NotAvailInPassage = 'Недоступно в этом параграфе';
Lang.FindLinkPlease = 'Установите курсор на ссылке';
Lang.ArrangeByTitle = 'Отсортировать параграфы по названию?';
Lang.DontForgetSave = 'Не забудьте сохранить сделанные изменения!';
Lang.UnableRemoveGroup = 'Невозможно удалить группу параграфов';
Lang.NoSavedFiles = 'Нет сохранённых файлов';
Lang.UpdateFound = 'Доступно обновление!';
Lang.ReloadApp = 'Перегрузить редактор?';
Lang.SourceCode = 'Исходный код';
Lang.FoundDuplicates = 'Найдены и объединены дубликаты';
Lang.FoundDuplicates2 = 'Найден дубликат параграфа';
Lang.FindFind = 'Найти';
Lang.FindCount = 'Подсчитать';
Lang.FindCase = 'С учётом регистра';
Lang.FindSelected = 'В выделенном';
Lang.FindRegEx = 'Регулярное выражение';
Lang.FindReplaceTo = 'Заменить на';
Lang.FindReplace = 'Заменить';
Lang.FindReplaceAll = 'Заменить все';
Lang.Object = 'переменная';
Lang.MacroElement = 'Элемент DOM';
Lang.MacroUpdate = 'Обновить текст';
Lang.MacroSprite = 'Создать и вывести спрайт';
Lang.MacroCopy = 'Создать копию спрайта/объекта';
Lang.MacroDisplay = 'Вставить параграф';
Lang.MacroPicture = 'Фоновая иллюстрация';
Lang.MacroFilter = 'Фильтры на иллюстрацию';
Lang.MacroVideo = 'Фоновое видео (mp4)';
Lang.MacroMenu = 'Изменить меню';
Lang.MacroEffect = 'Эффект для спрайтов';
Lang.MacroTextEffect = 'Эффект показа страниц';
Lang.MacroTitle = 'Заголовок страницы';
Lang.MacroClrScr = 'Очистить текстовую область';
Lang.ChoiceMacro = 'Выбор из вариантов';
Lang.SelectMacro = 'Выпадающий список';
Lang.MacroFade = 'Скорость листания';
Lang.MacroBackAudio = 'Фоновая музыка (mp3)';
Lang.MacroNoAudio = 'Выключить музыку';
Lang.MacroRow = 'Строка таблицы';
Lang.MacroSet = 'Присвоить значение';
Lang.MacroPrint = 'Вывести выражение';
Lang.MacroRandom = 'Случайное целое число';
Lang.MacroInput = 'Ввести данные';
Lang.MacroIf = 'Проверка условия';
Lang.MacroGoto = 'Перейти к параграфу';
Lang.MacroLoop = 'Обычный цикл';
Lang.MacroWhile = 'Цикл &laquo;пока&raquo;';
Lang.MacroDo = 'Цикл &laquo;делать, пока&raquo;';
Lang.MacroSwitch = 'Переключатель по значению';
Lang.MacroFunction = 'Глобальная функция';
Lang.MacroFunctionLocal = 'Локальная функция';
Lang.MacroFunctionParam = 'Функция как параметр';
Lang.MacroRepeat = 'Повторять параграф';
Lang.MacroStop = 'Остановить параграф';
Lang.MacroClass = 'Установить класс';
Lang.MacroSound = 'Звуковой эффект';
Lang.MacroImage = 'Вставить спрайт в текст';
Lang.MacroButton = 'Создать кнопку';
Lang.MacroLink = 'Создать ссылку';
Lang.MacroLog = 'Вывести в консоль';
Lang.MacroMessage = 'Окно с сообщением';
Lang.MacroPopup = 'Параграф в окне';
Lang.MacroScript = 'Внешний файл Javascript';
Lang.MacroStyle = 'Внешняя таблица стилей';
Lang.MacroVisited = 'Посещения параграфа';
Lang.MacroEither = 'Случайное из списка';
Lang.LinkSimple = 'Обычная ссылка';
Lang.LinkAdd = 'Добавляющая ссылка';
Lang.LinkMulti = 'Ссылка с открытием окна';
Lang.LinkNo = 'Невозвратная ссылка';
Lang.LinkObj = 'Установить значения в ссылке';
Lang.LinkBack = 'Ссылка &laquo;назад&raquo;';
Lang.LinkReturn = 'Ссылка &laquo;вернуться&raquo;';
Lang.LinkRestart = 'Ссылка &laquo;начать заново&raquo;';
Lang.LinkFile = 'Ссылка на изображение, музыку или видео (YouTube&nbsp;/&nbsp;Vimeo)';
Lang.LinkFileLocal = 'Изображение, музыка или видео';
Lang.FormatHTML = 'В сущности HTML';
Lang.FormatLink = 'Ссылка';
Lang.FormatItalic = 'Наклонный';
Lang.FormatBold = 'Жирный';
Lang.FormatUnderline = 'Подчёркнутый';
Lang.FormatHeader = 'Заголовок';
Lang.FormatMonospace = 'Моно<wbr>ширинный';
Lang.FormatCode = 'Код';
Lang.FormatCenter = 'По центру';
Lang.FormatRight = 'По правому краю';
Lang.FormatBreak = 'Разрыв<br>строки';
Lang.FormatTab = 'Табуляция';
Lang.FormatTire = 'Тире';
Lang.FormatQuotes = '&laquo;Кавычки&raquo;';
Lang.FormatAsterisk = 'Разбивка текста';
Lang.FormatHorline = 'Линия';
Lang.FormatImg = 'Изображение в тексте';
Lang.FormatSub = 'Нижний <sub>индекс</sub>';
Lang.FormatSup = 'Верхний <sup>индекс</sup>';
Lang.FormatLi = '• Строка списка';
Lang.SignIn = 'Авторизация';
Lang.Login = 'Логин (адрес e-mail)';
Lang.Password = 'Пароль';
Lang.Close = 'Закрыть';
Lang.GraphicMode = 'Визуальный режим';
Lang.SwitchTheme = 'Переключить тему';
Lang.NeedOnline = 'Необходимо подключение к интернету';
Lang.SaveToCloud = 'Экспортировать в облако';
Lang.LoadFromCloud = 'Импортировать из облака';
Lang.OnColorMode = 'Включить подсветку';
Lang.OffColorMode = 'Выключить подсветку';
Lang.Register = 'Зарегистрироваться';
Lang.Error2 = 'Произошла ошибка';
Lang.InText = 'В параграфах';
Lang.RestoreStoryStyle = 'Восстановить';
Lang.ThemeEdit = 'Изменить тему игры';
Lang.CloseWindow = 'Закрыть окно?';
Lang.Show = 'Показывать';
Lang.ChangeButton = 'Изменить кнопку';
Lang.Body = 'Основной фон';
Lang.PrintBlock = 'Текстовый блок';
Lang.PrintAddBlock = 'Всплывающий блок';
Lang.PrintImage = 'Иллюстрация';
Lang.PrintMenu = 'Игровое меню';
Lang.Toolbar = 'Панель инструментов';
Lang.PathToImage = 'путь/к/изображению';
Lang.StoryMenu = 'Нет доступных действий';
Lang.GlobalSettings = 'Настройки';
Lang.ChangeTheme = 'Выбрать тему';
Lang.Font = 'Шрифт';
Lang.MainColor = 'Цвет основного фона';
Lang.ShadowsStatBlocks = 'Тени у статичных блоков';
Lang.SetTexture = 'Установить фон';
Lang.RemoveTexture = 'Удалить фон';
Lang.ColorBack = 'Цвет фона';
Lang.ColorText = 'Цвет текста';
Lang.ColorLink = 'Цвет ссылок';
Lang.ColorHeader = 'Цвет заголовков';
Lang.ButtonRadius = 'Закругление кнопок';
Lang.FrameWidth = 'Ширина рамки';
Lang.FrameSet = 'Изменить рамку';
Lang.FrameRemove = 'Удалить рамку';
Lang.NoProperties = 'Нет доступных свойств';
Lang.SelectImageSize = 'Выберите изображение размером';
Lang.NeedPaidAccount = 'Для совершения этой операции необходим профессиональный аккаунт';
Lang.BuyPaidAccount = 'Купить профессиональный аккаунт';
Lang.ChangeLang = 'Переключить язык';
Lang.CreateStoryStyle = 'Параграф стилей';
Lang.StoryStyleAlready = 'Параграф стилей уже создан';
Lang.PassageTitle = 'Название параграфа';
Lang.FileSound = 'Звук';
Lang.FileImage = 'Спрайт';
Lang.FileImageDelete = 'Удалить спрайт';
Lang.FileImageDeleteAll = 'Удалить все спрайты';
Lang.PurePassage = 'Обычный параграф';
Lang.InputFileName = 'Введите имя файла!';
Lang.FileNameExists = 'Файл с таким именем уже существует!';
Lang.FileAnother = 'Другой';
Lang.FileSelect = 'Выбрать файл';
Lang.FileName = 'Название файла';
Lang.FileTooLarge = 'Слишком большой файл';
Lang.FilesList = 'Спрайты и звуки';
Lang.FilesNo = 'Нет файлов';
Lang.FilesAll = 'Все';
Lang.FilesImages = 'Спрайты';
Lang.FilesSounds = 'Звуки';
Lang.FileRename = 'Переименовать';
Lang.FileRemove = 'Удалить';
Lang.EditNo = 'Недоступно для редактирования';
Lang.Overwrite = 'Перезаписать';
Lang.Empty = 'Пусто';
Lang.ShowSize = 'Показать размер';
Lang.WantNewPub = 'Вы действительно хотите создать <span class=accent>новую</span> публикацию?';
Lang.WantUpdPub = 'Вы действительно хотите <span class=accent>обновить</span> публикацию?';
Lang.SaveFirst = 'Сохраните игру перед публикацией!';
Lang.ErrorPub = 'При публикации произошла ошибка';
Lang.SuccessPub = 'Успешно отправлено в библиотеку';
Lang.MissReqPass = 'Отсутствует или пустой обязательный параграф';
Lang.ErrorLoadFile = 'Ошибка загрузки файла';
Lang.MultiView = 'Интерактивная история';
Lang.ClassicView = 'Книга-игра';
Lang.InterABook = 'Интерактивная аудиокнига';
Lang.InterQuest = 'Графический квест';
Lang.InterVisual = 'Интерактивная новелла';
Lang.BaseType = 'Приключение';
Lang.InterTVOS = 'Игра для Apple TV';
Lang.NotForABook = 'Недоступно для аудиокниг';
Lang.GameType = 'Тип игры';
Lang.GameTheme = 'Тема оформления';
Lang.DefaultFileName = 'Новая игра';
Lang.AppWillBeRestarted = 'Приложение будет перезапущено. Продолжить?';
Lang.NeedSignIn = 'Для сохранения необходимо авторизироваться';
Lang.MenuSetFilesDir = 'Указать папку для медиафайлов';
Lang.Images = 'Изображения';
Lang.Videos = 'Видео mp4';
Lang.AudioMP3 = 'mp3';
Lang.RecentFiles = 'Последние файлы';
Lang.Send = 'Отправить';
Lang.PubNew = 'Новая публикация';
Lang.AboutPub = 'Вы можете создать новую публикацию или обновить существующую';
Lang.ReadMedia = 'Чтение медиафайла';
Lang.ErrorReadMedia = 'Ошибка чтения файла';
Lang.ErrorReadCode = 'Код ошибки';
Lang.ErrorTotalSize = 'Общий размер медиафайлов не может быть больше';
Lang.ErrorFileSize = 'Размер медиафайла не может быть больше 10 Мб';
Lang.Sending = 'Отправка';
Lang.Version = 'Версия';
Lang.GotoDownload = 'Открыть страницу скачивания?';
Lang.SaveNotComp = 'Извините, это сохранение из другой версии';
Lang.SaveAXMAKey = 'Подписать ключом АКСМА Софт';
Lang.SelectAppIcon = 'Выбрать иконку приложения (PNG 192х192)';
Lang.Play = 'Играть';
Lang.Continue = 'Продолжить';
Lang.Untitled = 'Без названия';
Lang.BadExt = 'Недопустимое имя файла';
Lang.OldFormat = 'Файл создан в предыдущем формате и был автоматически преобразован';
Lang.QuickStart = "Перед вами квадратики, соединённые между собой стрелками. Так выглядит стандартный шаблон, который генерируется при создании новой игры. Каждый квадратик — это параграф, т.е. небольшая порция текста вашей игры. <p></p>Кликните (тапните) дважды на любом параграфе — и Вы сможете отредактировать его текст.<p></p>Расставьте параграфы так, как вам удобно. Стрелки, соединяющие их, отображают ссылки, ведущие из одних параграфов в другие.<p></p>Ссылки позволяют читателю переходить от одного параграфа к другому, совершая придуманное вами путешествие по игре. А ссылка — это просто название другого параграфа, заключённое в двойные квадратные скобки. Вот так:<p><tt>[[Какой-то параграф]]</tt></p>Нажав на эту ссылку, читатель попадёт в параграф <i>Какой-то параграф</i>, если, конечно, он есть в вашей игре. Но как же его добавить?<p></p>Сделать это очень просто. Кликните на кнопку <i>Добавить</i>, введите имя параграфа, нажмите Ввод и введите текст параграфа. И это всё.&nbsp;:) Теперь Вы можете закрыть окно редактирования нажатием на крестик и увидеть, что новый параграф появился на рабочем столе.<p></p>Таким образом Вы можете создавать и изменять любые параграфы, расширяя и усложняя сюжет вашей игры.<p></p>Самый главный параграф имеет имя <i>Start</i>. С него для читателя начинается придуманная вами игра. Не менее важный параграф имеет в себе имя автора игры (конечно, ваше!). Он называется <i>StoryAuthor</i>. А параграфы <i>StoryTitle</i> и  <i>StorySubtitle</i> содержат название и краткое введение в игру, соответственно.<p></p>Ну вот, Вы отредактировали стандартные параграфы, добавили несколько новых... Пора посмотреть на результат вашего труда! Для этого нажмите на кнопку <i>Запустить</i> и через секунду игра откроется во всей своей красе!<p></p>Конечно, потом вам захочется ещё более усложнить и расширить свою работу, добавив в игру предметы и персонажей, а потом и опубликовать её в интернете для своих друзей.<p></p>Пожалуйста, всё это возможно! Но для начала придётся ознакомиться с <span class='plink' id='item1'>Руководством пользователя</span>. Если возникнут вопросы, не стесняйтесь их задавать на <span class='plink' id='item2'>форуме</span> нашего сайта.<p></p>Так что удачи! Придумайте свой уникальный игровой мир и станьте его властелином!<p></p><i>Примечание</i>. Обратите внимание, что для сохранения игры и публикации её в библиотеку, вам необходимо <span class='plink' id='item3'>зарегистрироваться</span> на сайте.<h3>Горячие клавиши</h3><b>F1</b> — вызвать меню помощи<br><b>F4</b> — редактор исходного кода<br><b>Esc</b> — закрыть редактор и сохранить параграф или закрыть меню<br><b>Курсор (вверх/вниз)</b> — перемещение по пунктам меню<br><b>Tab</b> — вывести список всех параграфов или перемещение по пунктам меню<br><b>Tab</b> — автодополнение ссылок, функций и переменных или вызов меню форматирования выделенного текста (в редакторе)<br><b>Shift+Tab</b> — выбрать следующий параграф<br><b>Пробел (Space)</b> — редактировать выбранный параграф<br><b>Ввод (Enter)</b> — выбор пункта меню<br><b>Del (Backspace)</b> — удалить выбранный параграф<br><b>Ctrl+R (F5)</b> — запустить игру или тестировать открытый параграф<br><b>Ctrl+Shift+R (Ctrl+Shift+F5)</b> — запустить игру (в редакторе)<br><b>Ctrl+P</b> — добавить параграф<br><b>Ctrl+A</b> — показать меню &laquo;Вид&raquo;<br><b>Ctrl+O</b> — загрузить игру<br><b>Ctrl+S</b> — сохранить игру<br><b>Ctrl+N</b> — создать новую игру<br><b>Ctrl+B</b> — опубликовать игру<br><b>Ctrl+K</b> — комментировать выделенные строки (в редакторе)<br><b>Ctrl+F</b> — искать в параграфах (поиск и замена в редакторе)<br><b>Ctrl+G (F3)</b> — искать далее (в редакторе)<br><b>Ctrl+H</b> — заменить далее (в редакторе)<br><b>Ctrl+L</b> — перейти по ссылке (в редакторе)<br><b>Ctrl+Backspace</b> — вернуться обратно после перехода по ссылке (в редакторе)<br><b>Ctrl+M</b> — вызвать меню вставки встроенных функций (в редакторе)<br><b>Ctrl+]</b> — сдвинуть текст вправо (в редакторе)<br><b>Ctrl+[</b> — сдвинуть текст влево (в редакторе)<br><b>Ctrl+D</b> — дублировать выбранный параграф или выделенные строки в редакторе<br><b>Ctrl+/-</b> — масштабировать параграфы или изменить размер шрифта<br><b>Ctrl+I</b> — вставить иллюстрацию (в редакторе)<br><b>Shift+Enter</b> — вставка тега переноса строки (в редакторе)<p align='center'><i>Это окно всегда можно вызвать через меню &laquo;Помощь&raquo;</i></p>";
} else {
Lang.Navigator = 'Navigator';
Lang.ToolButtons = [ 'Add', 'Actions', 'View', 'Save', 'Open', 'Run', 'New', 'Export', Lang.Navigator, 'Help' ];
Lang.EditorButtons = [ 'Close and Save', 'Insert a Link', 'Insert a Function', 'Format Text', 'Comment Text', 'Set Color' ];
Lang.SmallButtons = [ 'Come Back', 'Test', 'Find Next', 'Tab/Autocompletion', 'Connecting Lines', 'Type of Connecting Lines' ];
Lang.HTMLSave = 'Save';
Lang.HTMLLoad = 'Restore';
Lang.HTMLSaveSure = 'Do you want to save?';
Lang.HTMLLoadSure = 'Do you want to restore?';
Lang.Error = 'An error in the code';
Lang.Audio = 'Audio';
Lang.StartAgain = 'Start from the beginning?';
Lang.HTMLRestart = 'Restart';
Lang.HTMLStart = 'Start';
Lang.Console = 'Console';
Lang.ViewButton = 'View';
Lang.HTMLMenu = 'Menu';
Lang.HTMLPrefs = 'Preferences';
Lang.HTMLTextSize = 'Change Text Size';
Lang.HTMLAnimOn = 'Enable Animation';
Lang.HTMLAnimOff = 'Disable Animation';
Lang.HTMLSoundOn = 'Enable Sound';
Lang.HTMLSoundOff = 'Disable Sound';
Lang.MacrosDescTHEMEdefault = 'Default style';
Lang.MacrosDescTHEMEdark = 'Dark style';
Lang.MacrosDescTHEMEsepia = 'Sepia style';
Lang.CreatedBy = 'created&nbsp;with';
Lang.JSrequires = 'This file requires Javascript. Please enable it in your browser';
Lang.Location = 'Passage';
Lang.NotFound = 'not found';
Lang.License = '<!DOCTYPE html>\n<!--\ncreated with '+Lang.AppName+'\nhttps://sm.axmasoft.com/\nYou agree not to modify or alter this File in any way. You may not remove or alter any copyright notices or other proprietary notices on any copies of this File.\n-->\n';
Lang.NotFound2 = 'Not found';
Lang.Found = 'Found';
Lang.Replaced = 'Replaced';
Lang.Passages = 'Passages';
Lang.PassagesUpper = 'Passages';
Lang.PassagesErrors = 'With broken links';
Lang.Chars = 'characters';
Lang.NoPassages = 'No passages';
Lang.NoPassage = 'No selected passage';
Lang.BadPassageTitle = 'Bad title!';
Lang.PleaseWait = 'Please Wait...';
Lang.Create = 'create';
Lang.PassagesGroup = 'Group of passages';
Lang.SplitAll = 'Ungroup All';
Lang.Back = 'Back';
Lang.Grouped = 'Grouped';
Lang.Saved = 'Saved';
Lang.Saving = 'Saving...';
Lang.StorySaved = 'State Stored';
Lang.StoryNotSaved = 'Failed save!';
Lang.StoryNotLoaded = 'Failed restore!';
Lang.Loading = 'Loading...';
Lang.ListLoading = 'Loading list...';
Lang.Loaded = 'Loaded';
Lang.AreYouSure = 'Are you sure?';
Lang.No = 'no';
Lang.LinesOn = 'Lines On';
Lang.LinesOff = 'Lines Off';
Lang.ArcsOn = 'Arcs';
Lang.ArcsOff = 'Lines';
Lang.NO = 'No';
Lang.YES = 'Yes';
Lang.FindInPassages = 'Search';
Lang.MenuEdit = 'Edit';
Lang.MenuDelete = 'Remove';
Lang.MenuDuplicate = 'Duplicate';
Lang.MenuLinked = 'Linked';
Lang.MenuTest = 'Test';
Lang.MenuFindNReplace = 'Find and Replace';
Lang.MenuGotoLink = 'Go to Link';
Lang.MenuUndo = 'Cancel Changes';
Lang.MenuOutLinks = 'Outgoing';
Lang.MenuInLinks = 'Incoming';
Lang.MenuArrangeByTitle = 'Arrange By Title';
Lang.MenuArrangeByColor = 'Arrange By Color';
Lang.MenuArrangeBySize = 'Arrange By Size';
Lang.MenuArrangeZoomOut = 'Zoom Out';
Lang.MenuArrangeZoomIn = 'Zoom In';
Lang.MenuSelectStory = 'Select Story';
Lang.MenuMergeStory = 'Add Story';
Lang.MenuFromBackUp = 'From Backup Copy';
Lang.NoBackUp = 'No backup';
Lang.MenuNewStandart = 'Example';
Lang.MenuNewCompact = 'Empty Template';
Lang.MenuNewClipboard = 'From Clipboard';
Lang.MenuNewClipboardMess = 'Copy the source code to the clipboard and paste it into this field';
Lang.MenuPublishFile = 'Save as HTML file';
Lang.MenuPublishInet = 'Send to Library';
Lang.MenuPublishApk = 'Save as APK file for Android';
Lang.MenuPublishInetSure = 'Are you sure that the story<br>ready for publication?';
Lang.MenuQuickStart = 'Quick Start';
Lang.MenuRestart = 'Restart';
Lang.MenuUserManual = 'Online User Manual';
Lang.MenuProfile = 'My Account';
Lang.MenuModules = 'External modules';
Lang.NoModules = 'No modules available';
Lang.LoadModule = 'Install module';
Lang.BuyModule = 'Buy module';
Lang.ExampleModule = 'View example';
Lang.DownloadModule = 'Download zip';
Lang.MenuToLibrary = 'Library';
Lang.MenuDesktopVersion = 'Download';
Lang.AYSRemoveThisPassage = 'Do you really want to remove this passage?';
Lang.AYSRemovePassage = 'Do you really want to remove';
Lang.AYSSaveNewStory = 'Do you really want to create the new file?';
Lang.AYSCreateNewStory = 'Do you really want to create the new story?';
Lang.AYSUndoChanges = 'Do you really want to cancel all changes?';
Lang.AYSExitSourceEditor = 'Do you really want to close the source code editor?';
Lang.NotAvailEditPass = 'Not available now';
Lang.NotAvailInBeta = 'Not available in beta version';
Lang.NotAvailInPassage = 'Not available in this passage';
Lang.FindLinkPlease = 'Place the cursor on a link';
Lang.ArrangeByTitle = 'Sort passages by title?';
Lang.DontForgetSave = 'Do not forget to save your changes!';
Lang.UnableRemoveGroup = 'Unable to remove a group of passages';
Lang.NoSavedFiles = 'There are no saved stories';
Lang.UpdateFound = 'Update is available!';
Lang.ReloadApp = 'Reload app?';
Lang.SourceCode = 'Source Code';
Lang.FoundDuplicates = 'Found duplicates and merged';
Lang.FoundDuplicates2 = 'Found duplicate';
Lang.FindFind = 'Find';
Lang.FindCount = 'Count';
Lang.FindCase = 'Case sensitive';
Lang.FindSelected = 'Selected text only';
Lang.FindRegEx = 'Regular expressions';
Lang.FindReplaceTo = 'Replace';
Lang.FindReplace = 'Replace';
Lang.FindReplaceAll = 'Replace All';
Lang.Object = 'variable';
Lang.MacroElement = 'DOM element';
Lang.MacroUpdate = 'Update text';
Lang.MacroSprite = 'Create and display a sprite';
Lang.MacroCopy = 'Create a copy of the sprite/object';
Lang.MacroDisplay = 'Insert passage';
Lang.MacroPicture = 'Main picture';
Lang.MacroFilter = 'Set picture filters';
Lang.MacroVideo = 'Background video (mp4)';
Lang.MacroMenu = 'Change menu';
Lang.MacroEffect = 'Sprites effect';
Lang.MacroTextEffect = 'Pages effect';
Lang.MacroTitle = 'Page title';
Lang.MacroClrScr = 'Clear text area';
Lang.MacroFade = 'Page speed';
Lang.MacroBackAudio = 'Background music (mp3)';
Lang.MacroNoAudio = 'Stop music playback';
Lang.MacroRow = 'Table row';
Lang.MacroSet = 'Assign a value to a variable';
Lang.MacroPrint = "Output the expression";
Lang.MacroRandom = 'Random number';
Lang.MacroInput = "Input a data";
Lang.MacroIf = 'Check condition';
Lang.MacroGoto = 'Go to passage';
Lang.MacroLoop = 'Simple loop';
Lang.MacroSwitch = 'Code by value';
Lang.MacroFunction = 'Global function';
Lang.MacroFunctionLocal = 'Local function';
Lang.MacroFunctionParam = 'Function as parameter';
Lang.MacroWhile = 'Loop \"while\"';
Lang.MacroDo = 'Loop \"do, while\"';
Lang.MacroRepeat = 'Repeat passage';
Lang.MacroStop = 'Stop the passage';
Lang.MacroClass = 'Define a class';
Lang.MacroSound = 'Sound effect';
Lang.MacroImage = 'Insert sprite into text';
Lang.MacroButton = 'Create button';
Lang.MacroLink = 'Create link';
Lang.MacroLog = 'Output to console';
Lang.MacroMessage = 'Message window';
Lang.MacroPopup = 'Passage in the pop-up';
Lang.MacroScript = 'External Javascript file';
Lang.MacroStyle = 'External style sheet';
Lang.MacroVisited = 'Number of visits to passage';
Lang.MacroEither = 'Random from the list';
Lang.LinkSimple = 'Simple link';
Lang.LinkAdd = 'Adds link';
Lang.LinkMulti = 'Popup window';
Lang.LinkNo = 'One way link';
Lang.LinkObj = 'Set variables in the link';
Lang.LinkBack = 'Back';
Lang.LinkReturn = 'Return';
Lang.LinkRestart = 'Restart link';
Lang.LinkFile = 'Insert media from Internet';
Lang.LinkFileLocal = 'Insert local media file';
Lang.FormatHTML = 'Text to HTML Entities';
Lang.FormatLink = 'Link';
Lang.FormatItalic = 'Italic';
Lang.FormatBold = 'Bold';
Lang.FormatUnderline = 'Underline';
Lang.FormatHeader = 'Header';
Lang.FormatMonospace = 'Monospace';
Lang.FormatCode = 'Code';
Lang.FormatCenter = 'Center Text';
Lang.FormatRight = 'Align Text Right';
Lang.FormatBreak = 'Line<br>Break';
Lang.FormatTab = 'Tabulation';
Lang.FormatTire = 'Dash';
Lang.FormatQuotes = '“Quotes”';
Lang.FormatAsterisk = 'Text Break';
Lang.FormatHorline = 'Line';
Lang.FormatImg = 'Insert image into text';
Lang.FormatSub = 'Subscript <sub>Text</sub>';
Lang.FormatSup = 'Superscript <sup>Text</sup>';
Lang.FormatLi = '• List Item';
Lang.SignIn = 'Sign In';
Lang.Login = 'Login (email address)';
Lang.Password = 'Password';
Lang.Close = 'Close';
Lang.GraphicMode = 'Visual Mode';
Lang.SwitchTheme = 'Switch Theme';
Lang.NeedOnline = 'Need Connection of Internet';
Lang.SaveToCloud = 'Export to Cloud';
Lang.LoadFromCloud = 'Import from Cloud';
Lang.OnColorMode = 'Turn on Color Mode';
Lang.OffColorMode = 'Turn off Color Mode';
Lang.Register = 'Register';
Lang.Error2 = 'Error';
Lang.InText = 'In contents';
Lang.RestoreStoryStyle = 'Defaults';
Lang.ThemeEdit = 'Change Theme';
Lang.CloseWindow = 'Close Window?';
Lang.Show = 'Show';
Lang.ChangeButton = 'Change Button';
Lang.Body = 'Main Background';
Lang.PrintBlock = 'Content Block';
Lang.PrintAddBlock = 'Popup Block';
Lang.PrintImage = 'Picture';
Lang.PrintMenu = 'Story Menu';
Lang.Toolbar = 'Toolbar';
Lang.PathToImage = 'path/to/image';
Lang.StoryMenu = 'No actions available';
Lang.GlobalSettings = 'Main Settings';
Lang.ChangeTheme = 'Select Theme';
Lang.Font = 'Font';
Lang.MainColor = 'Main Background Color';
Lang.ShadowsStatBlocks = 'Show shadows of static blocks';
Lang.SetTexture = 'Set Background';
Lang.RemoveTexture = 'Remove Background';
Lang.ColorBack = 'Background Color';
Lang.ColorText = 'Text Color';
Lang.ColorLink = 'Link Color';
Lang.ColorHeader = 'Header Color';
Lang.ButtonRadius = 'Button Radius';
Lang.FrameWidth = 'Frame Width';
Lang.FrameSet = 'Set Frame';
Lang.FrameRemove = 'Remove Frame';
Lang.NoProperties = 'No properties';
Lang.SelectImageSize = 'The image must be';
Lang.NeedPaidAccount = 'To execute the operation needs a professional account';
Lang.BuyPaidAccount = 'Buy a professional account';
Lang.ChangeLang = 'Change Language';
Lang.CreateStoryStyle = 'StoryStyle';
Lang.StoryStyleAlready = 'StoryStyle already exists';
Lang.PassageTitle = 'Passage Title';
Lang.FileSound = 'Sound';
Lang.FileImage = 'Sprite';
Lang.FileImageDelete = 'Delete sprite';
Lang.FileImageDeleteAll = 'Delete all sprites';
Lang.ChoiceMacro = 'Choice of options';
Lang.SelectMacro = 'Drop-down list';
Lang.PurePassage = 'Passage';
Lang.InputFileName = 'Enter the file name!';
Lang.FileNameExists = 'A file with this name already exists!';
Lang.FileAnother = 'Another';
Lang.FileSelect = 'Select the file';
Lang.FileName = 'File Name';
Lang.FileTooLarge = 'File too large';
Lang.FilesList = 'Sprites and Sounds';
Lang.FilesNo = 'No files';
Lang.FilesAll = 'All';
Lang.FilesImages = 'Sprites';
Lang.FilesSounds = 'Sounds';
Lang.FileRename = 'Rename';
Lang.FileRemove = 'Remove';
Lang.EditNo = 'Non editable';
Lang.Overwrite = 'Overwrite';
Lang.Empty = 'Empty';
Lang.ShowSize = 'Show size';
Lang.WantNewPub = 'Do you really want to create the new publication?';
Lang.WantUpdPub = 'Do you really want to update the publication?';
Lang.SaveFirst = 'Save the game before publishing!';
Lang.ErrorPub = 'An error has occurred publication';
Lang.SuccessPub = 'Successfully sent to the library';
Lang.MissReqPass = 'Missing or empty required passage';
Lang.ErrorLoadFile = 'Error loading file';
Lang.MultiView = 'Interactive fiction';
Lang.ClassicView = 'CYOA book';
Lang.InterABook = 'Interactive audiobook';
Lang.InterQuest = 'Graphic quest';
Lang.InterVisual = 'Interactive novel';
Lang.BaseType = 'Adventure';
Lang.InterTVOS = 'Apple TV game';
Lang.NotForABook = 'Not available for audiobooks';
Lang.GameType = 'Type of game';
Lang.GameTheme = 'Theme';
Lang.DefaultFileName = 'New game';
Lang.AppWillBeRestarted = 'The application will be restarted. Continue?';
Lang.NeedSignIn = 'To save please sign in';
Lang.MenuSetFilesDir = 'Set a folder for local media';
Lang.Images = 'Images';
Lang.Videos = 'Videos mp4';
Lang.AudioMP3 = 'Audio mp3';
Lang.RecentFiles = 'Recent Files';
Lang.Send = 'Send';
Lang.PubNew = 'New publication';
Lang.AboutPub = 'You can create a new publication or update an existing one';
Lang.ReadMedia = 'Reading a media file';
Lang.ErrorReadMedia = 'Error reading file';
Lang.ErrorReadCode = 'Error code';
Lang.ErrorTotalSize = 'The total size of media files can not be larger than';
Lang.ErrorFileSize = 'The size of a media file can not be larger than 10 MB';
Lang.Sending = 'Sending';
Lang.Version = 'Version';
Lang.GotoDownload = 'Open the download page?';
Lang.SaveNotComp = 'The save game from other version, sorry';
Lang.SaveAXMAKey = 'Sign the app with AXMA Soft key';
Lang.SelectAppIcon = 'Select the application icon (PNG 192x192)';
Lang.Play = 'Play';
Lang.Continue = 'Continue';
Lang.Untitled = 'Untitled';
Lang.BadExt = 'Invalid file name';
Lang.OldFormat = 'The file was created in the previous format and automatically converted';
Lang.QuickStart = "<h1>Hotkeys</h1><b>F1</b> — show Help menu<br><b>F4</b> — source code editor<br><b>Esc</b> — close editor and save passage / close window<br><b>Arrow keys</b> — move the selected passage<br><b>Arrow keys (up/down)</b> — navigating the menu<br><b>Tab</b> — show the Navigator / navigating the menu<br><b>Tab</b> — autocompletion / show format menu of the selected text (editor)<br><b>Shift+Tab</b> — select next passage<br><b>Space bar</b> — edit selected passage<br><b>Enter</b> — activate menu item<br><b>Del (Backspace)</b> — remove selected passage<br><b>Ctrl+R (F5)</b> — run story / test passage<br><b>Ctrl+Shift+R (Ctrl+Shift+F5)</b> — run story (editor)<br><b>Ctrl+P</b> — add a new passage<br><b>Ctrl+A</b> — show view menu<br><b>Ctrl+O</b> — open a story file<br><b>Ctrl+S</b> — save a story file<br><b>Ctrl+N</b> — create a new story<br><b>Ctrl+B</b> — publish the story<br><b>Ctrl+K</b> —  comment/uncomment selection (editor)<br><b>Ctrl+F</b> — find / find and replace (editor)<br><b>Ctrl+G (F3)</b> — find next (editor)<br><b>Ctrl+H</b> — replace next (editor)<br><b>Ctrl+L</b> — go to the link (editor)<br><b>Ctrl+Backspace</b> — go back (editor)<br><br><b>Ctrl+M</b> — show functions menu (editor)<br><b>Ctrl+]</b> — shift right (editor)<br><b>Ctrl+[</b> — shift left (editor)<br><b>Ctrl+D</b> — duplicate selected passage or lines<br><b>Ctrl+/-</b> — change zoom or font size<br><b>Ctrl+I</b> — insert a main picture (editor)<br><b>Shift+Enter</b> — insert a new line (editor)";
}
function $(id) {
return document.getElementById(id);
}
function toTop()
{
top.document.body.scrollTop = 0;
}
function GetKeyCode(event)
{
return event.keyCode ? event.keyCode : event.charCode ? event.charCode : event.which;
}
function getElementsByClass(classList,node)
{
var node = node || document,
list = node.getElementsByTagName('*'),
length = list.length,
classArray = classList.split(/\s+/),
classes = classArray.length,
result = [],i,j;
for (var i=0; i<length; i++) {
for(var j=0; j<classes; j++)  {
if(list[i].className.search('\\b' + classArray[j] + '\\b') != -1) {
result.push(list[i]);
break;
}
}
}
return result;
}
function ScrollToPos(obj,pos)
{
var text;
if (obj.value!==undefined)
{
text = obj.value;
obj.value = text.substr(0,pos);
obj.scrollTop = obj.scrollHeight;
obj.value = text;
}
else
{
var anchor = 'ASM_view33245';
text = GetEditorText();
SetEditorText(text.substr(0,pos)+"<span id='"+anchor+"'></span>"+text.substr(pos));
obj.innerHTML = obj.innerHTML.replace("&lt;span id='"+anchor+"'&gt;","<span id='"+anchor+"'>");
obj.innerHTML = obj.innerHTML.replace("&lt;/span&gt;","</span>");
$(anchor).scrollIntoView(false);
}
}
function RTrim(str)
{
if (!str) {return '';}
return str.replace(/\s+$/g,'');
}
function LTrim(str)
{
if (!str) {return '';}
return str.replace(/^\s+/g,'');
}
function getInputSelection(obj)
{
var start = 0, end = 0, normalizedValue, range, textInputRange, len, endRange;
if (typeof obj.selectionStart == 'number' && typeof obj.selectionEnd == 'number')
{
start = obj.selectionStart;
end = obj.selectionEnd;
}
else
{
range = document.selection.createRange();
if (range && range.parentElement() == obj)
{
len = obj.value.length;
normalizedValue = obj.value.replace(/\\r\\n/g, '\\n');
textInputRange = obj.createTextRange();
textInputRange.moveToBookmark(range.getBookmark());
endRange = obj.createTextRange();
endRange.collapse(false);
if (textInputRange.compareEndPoints('StartToEnd', endRange) > -1)
{
start = end = len;
}
else
{
start = -textInputRange.moveStart('character', -len);
start += normalizedValue.slice(0, start).split('\\n').length - 1;
if (textInputRange.compareEndPoints('EndToEnd', endRange) > -1)
{
end = len;
}
else
{
end = -textInputRange.moveEnd('character', -len);
end += normalizedValue.slice(0, end).split('\\n').length - 1;
}
}
}
}
len = end - start;
return {
start: start,
end: end,
len: len,
};
}
function getTextNodesIn(node)
{
var textNodes = [];
if (node.nodeType == 3)
{
textNodes.push(node);
}
else
{
var children = node.childNodes;
for (var i = 0, len = children.length; i < len; ++i)
{
textNodes.push.apply(textNodes, getTextNodesIn(children[i]));
}
}
return textNodes;
}
function SelectText(obj,SelStart,SelLength)
{
if (obj.value===undefined)
{
var SelEnd = SelStart + SelLength;
if (document.createRange && window.getSelection)
{
var range = document.createRange();
range.selectNodeContents(obj);
var textNodes = getTextNodesIn(obj);
var foundStart = false;
var foundEnd = false;
var charCount = 0, endCharCount;
for (var i = 0, textNode; textNode = textNodes[i++]; )
{
endCharCount = charCount + textNode.length;
if (!foundStart && SelStart >= charCount && (SelStart < endCharCount || (SelStart == endCharCount && i < textNodes.length)))
{
range.setStart(textNode, SelStart - charCount);
foundStart = true;
}
if (foundStart && SelEnd <= endCharCount)
{
range.setEnd(textNode, SelEnd - charCount);
foundEnd = true;
break;
}
charCount = endCharCount;
}
if (!foundEnd)
{
range.selectNodeContents(obj);
range.collapse(false);
}
var sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
}
else if (document.selection && document.body.createTextRange)
{
var textRange = document.body.createTextRange();
textRange.moveToElementText(obj);
textRange.collapse(true);
textRange.moveEnd("character", SelEnd);
textRange.moveStart("character", SelStart);
textRange.select();
}
}
else
{
if ('selectionStart' in obj)
{
obj.selectionStart = SelStart;
obj.selectionEnd = SelStart+SelLength;
obj.focus();
}
else
{
var inputRange = obj.createTextRange();
inputRange.moveStart ("character", SelStart);
inputRange.collapse();
inputRange.moveEnd ("character", SelStart+SelLength);
inputRange.select();
}
RefreshText();
}
}
function GetSelection(obj)
{
if (obj.value===undefined)
{
obj.focus();
var start = getCaretCharacterOffsetWithin(obj);
var end = start + window.getSelection().toString().length;
var len = end - start;
return {
start: start,
end: end,
len: len,
};
}
else
{
return getInputSelection(obj);
}
}
function getCaretCharacterOffsetWithin(obj)
{
var caretOffset = 0;
var doc = obj.ownerDocument || obj.document;
var win = doc.defaultView || doc.parentWindow;
var sel;
if (typeof win.getSelection != 'undefined')
{
sel = win.getSelection();
var range = sel.getRangeAt(0);
var preCaretRange = range.cloneRange();
preCaretRange.selectNodeContents(obj);
preCaretRange.setEnd(range.endContainer, range.endOffset);
caretOffset = preCaretRange.toString().length - sel.toString().length;
}
else if ((sel = doc.selection) && sel.type != 'Control')
{
sel = doc.selection;
var textRange = sel.createRange();
var preCaretTextRange = doc.body.createTextRange();
preCaretTextRange.moveToobjText(obj);
preCaretTextRange.setEndPoint('EndToEnd', textRange);
caretOffset = preCaretTextRange.text.length - sel.createRange().text.length;
}
return caretOffset;
}
function fixEvent(e)
{
e = e || window.event;
if ( e.pageX == null && e.clientX != null )
{
var html = document.documentElement;
var body = document.body;
e.pageX = e.clientX + (html && html.scrollLeft || body && body.scrollLeft || 0) - (html.clientLeft || 0);
e.pageY = e.clientY + (html && html.scrollTop || body && body.scrollTop || 0) - (html.clientTop || 0);
}
if (!e.which && e.button)
{
e.which = e.button & 1 ? 1 : ( e.button & 2 ? 3 : ( e.button & 4 ? 2 : 0 ) );
}
return e;
}
function array_multisort (arr)
{
var argl = arguments.length,
sal = 0,
flags = {
'SORT_REGULAR': 16,
'SORT_NUMERIC': 17,
'SORT_STRING': 18,
'SORT_ASC': 32,
'SORT_DESC': 40
},
sortArrs = [
[]
],
sortFlag = [0],
sortKeys = [
[]
],
g = 0,
i = 0,
j = 0,
k = '',
l = 0,
thingsToSort = [],
vkey = 0,
zlast = null,
args = arguments,
nLastSort = [],
lastSort = [],
lastSorts = [],
tmpArray = [],
elIndex = 0,
sortDuplicator = function (a, b) {
return nLastSort.shift();
},
sortFunctions = [
[function (a, b) {
lastSort.push(a > b ? 1 : (a < b ? -1 : 0));
return a > b ? 1 : (a < b ? -1 : 0);
}, function (a, b) {
lastSort.push(b > a ? 1 : (b < a ? -1 : 0));
return b > a ? 1 : (b < a ? -1 : 0);
}],
[function (a, b) {
lastSort.push(a - b);
return a - b;
}, function (a, b) {
lastSort.push(b - a);
return b - a;
}],
[function (a, b) {
lastSort.push((a + '') > (b + '') ? 1 : ((a + '') < (b + '') ? -1 : 0));
return (a + '') > (b + '') ? 1 : ((a + '') < (b + '') ? -1 : 0);
}, function (a, b) {
lastSort.push((b + '') > (a + '') ? 1 : ((b + '') < (a + '') ? -1 : 0));
return (b + '') > (a + '') ? 1 : ((b + '') < (a + '') ? -1 : 0);
}]
];
if (Object.prototype.toString.call(arr) === '[object Array]') {
sortArrs[0] = arr;
}
else if (arr && typeof arr === 'object') {
for (i in arr) {
if (arr.hasOwnProperty(i)) {
sortKeys[0].push(i);
sortArrs[0].push(arr[i]);
}
}
}
else {
return false;
}
var arrMainLength = sortArrs[0].length,
sortComponents = [0, arrMainLength];
for (j = 1; j < argl; j++) {
if (Object.prototype.toString.call(arguments[j]) === '[object Array]') {
sortArrs[j] = arguments[j];
sortFlag[j] = 0;
if (arguments[j].length !== arrMainLength) {
return false;
}
} else if (arguments[j] && typeof arguments[j] === 'object') {
sortKeys[j] = [];
sortArrs[j] = [];
sortFlag[j] = 0;
for (i in arguments[j]) {
if (arguments[j].hasOwnProperty(i)) {
sortKeys[j].push(i);
sortArrs[j].push(arguments[j][i]);
}
}
if (sortArrs[j].length !== arrMainLength) {
return false;
}
} else if (typeof arguments[j] === 'string') {
var lFlag = sortFlag.pop();
if (typeof flags[arguments[j]] === 'undefined' || ((((flags[arguments[j]]) >>> 4) & (lFlag >>> 4)) > 0)) {
return false;
}
sortFlag.push(lFlag + flags[arguments[j]]);
} else {
return false;
}
}
for (i = 0; i !== arrMainLength; i++) {
thingsToSort.push(true);
}
for (i in sortArrs) {
if (sortArrs.hasOwnProperty(i)) {
lastSorts = [];
tmpArray = [];
elIndex = 0;
nLastSort = [];
lastSort = [];
if (sortComponents.length === 0) {
if (Object.prototype.toString.call(arguments[i]) === '[object Array]') {
args[i] = sortArrs[i];
} else {
for (k in arguments[i]) {
if (arguments[i].hasOwnProperty(k)) {
delete arguments[i][k];
}
}
sal = sortArrs[i].length;
for (j = 0, vkey = 0; j < sal; j++) {
vkey = sortKeys[i][j];
args[i][vkey] = sortArrs[i][j];
}
}
delete sortArrs[i];
delete sortKeys[i];
continue;
}
var sFunction = sortFunctions[(sortFlag[i] & 3)][((sortFlag[i] & 8) > 0) ? 1 : 0];
for (l = 0; l !== sortComponents.length; l += 2) {
tmpArray = sortArrs[i].slice(sortComponents[l], sortComponents[l + 1] + 1);
tmpArray.sort(sFunction);
lastSorts[l] = [].concat(lastSort); // Is there a better way to copy an array in Javascript?
elIndex = sortComponents[l];
for (g in tmpArray) {
if (tmpArray.hasOwnProperty(g)) {
sortArrs[i][elIndex] = tmpArray[g];
elIndex++;
}
}
}
sFunction = sortDuplicator;
for (j in sortArrs) {
if (sortArrs.hasOwnProperty(j)) {
if (sortArrs[j] === sortArrs[i]) {
continue;
}
for (l = 0; l !== sortComponents.length; l += 2) {
tmpArray = sortArrs[j].slice(sortComponents[l], sortComponents[l + 1] + 1);
nLastSort = [].concat(lastSorts[l]); // alert(l + ':' + nLastSort);
tmpArray.sort(sFunction);
elIndex = sortComponents[l];
for (g in tmpArray) {
if (tmpArray.hasOwnProperty(g)) {
sortArrs[j][elIndex] = tmpArray[g];
elIndex++;
}
}
}
}
}
for (j in sortKeys) {
if (sortKeys.hasOwnProperty(j)) {
for (l = 0; l !== sortComponents.length; l += 2) {
tmpArray = sortKeys[j].slice(sortComponents[l], sortComponents[l + 1] + 1);
nLastSort = [].concat(lastSorts[l]);
tmpArray.sort(sFunction);
elIndex = sortComponents[l];
for (g in tmpArray) {
if (tmpArray.hasOwnProperty(g)) {
sortKeys[j][elIndex] = tmpArray[g];
elIndex++;
}
}
}
}
}
zlast = null;
sortComponents = [];
for (j in sortArrs[i]) {
if (sortArrs[i].hasOwnProperty(j)) {
if (!thingsToSort[j]) {
if ((sortComponents.length & 1)) {
sortComponents.push(j - 1);
}
zlast = null;
continue;
}
if (!(sortComponents.length & 1)) {
if (zlast !== null) {
if (sortArrs[i][j] === zlast) {
sortComponents.push(j - 1);
} else {
thingsToSort[j] = false;
}
}
zlast = sortArrs[i][j];
} else {
if (sortArrs[i][j] !== zlast) {
sortComponents.push(j - 1);
zlast = sortArrs[i][j];
}
}
}
}
if (sortComponents.length & 1) {
sortComponents.push(j);
}
if (Object.prototype.toString.call(arguments[i]) === '[object Array]') {
args[i] = sortArrs[i];
}
else {
for (j in arguments[i]) {
if (arguments[i].hasOwnProperty(j)) {
delete arguments[i][j];
}
}
sal = sortArrs[i].length;
for (j = 0, vkey = 0; j < sal; j++) {
vkey = sortKeys[i][j];
args[i][vkey] = sortArrs[i][j];
}
}
delete sortArrs[i];
delete sortKeys[i];
}
}
return true;
}
function setCookie(name,value)
{
var expires = new Date();
expires.setTime(expires.getTime()+31536000000);
document.cookie = name + '=' + escape(value) + '; expires=' + expires.toGMTString() + '; path=/';
}
function getCookie(name)
{
var cookie = ' ' + document.cookie;
var search = ' ' + name + '=';
var setStr = null;
var offset = 0;
var end = 0;
if (cookie.length>0) {
offset = cookie.indexOf(search);
if (offset != -1) {
offset += search.length;end = cookie.indexOf(';',offset);
if (end == -1) {
end = cookie.length;
}
try {
setStr = decodeURIComponent(cookie.substring(offset,end));
} catch (err) {
setStr = '';
}
}
}
if (setStr==null) {
setStr = '';
}
return(setStr);
}
function getXmlHttp()
{
var xmlhttp;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function loadData(url,callback)
{
var xmlhttp = getXmlHttp();
if (!callback)
{
xmlhttp.open('GET', url, false);
xmlhttp.send(null);
return xmlhttp.responseText;
}
else
{
xmlhttp.open('GET', url, true);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4)
{
if(xmlhttp.status == 200)
{
callback(xmlhttp.responseText);
}
}
};
xmlhttp.send(null);
}
}
function saveData(url,data,callback)
{
var xmlhttp = getXmlHttp();
if (!callback)
{
xmlhttp.open('POST', url, false);
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.send(data);
if(xmlhttp.status == 200)
{
return xmlhttp.responseText;
}
else
{
return '';
}
}
else
{
xmlhttp.open('POST', url, true);
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4)
{
if(xmlhttp.status == 200)
{
callback(xmlhttp.responseText);
}
}
};
xmlhttp.send(data);
}
}
function DrawOtr(arc,x1,y1,x2,y2) {
var x3, y3, x4, y4, xp, yp, xb, yb;
ctx.lineWidth = 1;
var k = pixel_ratio;
var close = 15*k;
if (arc) {
close = 85*k;
}
if (Math.abs(x2 - x1) > LocSize * 2 || Math.abs(y2 - y1) < LocSize) {
x3 = Math.min(x1, x2) + (Math.max(x1, x2) - Math.min(x1, x2)) / 2;
y3 = y1;
x4 = x3;
y4 = y2;
yp = y1;
if (Math.abs(x2 - x1) > (LocSize + close)) {
if (x2 < x1) {
xp = x1 - LocSize / 2;
ctx.beginPath();
ctx.moveTo(xp - 10*k, yp - 3*k);
ctx.lineTo(xp - 10*k, yp + 5*k);
ctx.lineTo(xp + 2*k, yp + 1*k);
ctx.fill();
ctx.stroke();
ctx.closePath();
} else {
xp = x1 + LocSize / 2;
ctx.beginPath();
ctx.moveTo(xp + 10*k, yp - 3*k);
ctx.lineTo(xp + 10*k, yp + 5*k);
ctx.lineTo(xp - 2*k, yp + 1*k);
ctx.fill();
ctx.stroke();
ctx.closePath();
}
} else {
if (x2 < x1) {
xp = x1 - LocSize / 2;
ctx.fillRect(xp - 8*k, yp - 3*k, 8*k, 8*k);
} else {
xp = x1 + LocSize / 2;
ctx.fillRect(xp, yp - 3*k, 8*k, 8*k);
}
}
yb = y2;
if (x2 < x1) {
xb = x2 + LocSize / 2;
ctx.fillRect(xb, yb - 3*k, 2*k, 8*k);
} else {
xb = x2 - LocSize / 2;
ctx.fillRect(xb - 2*k, yb - 3*k, 2*k, 8*k);
}
} else {
x3 = x1;
y3 = Math.min(y1, y2) + (Math.max(y1, y2) - Math.min(y1, y2)) / 2;
x4 = x2;
y4 = y3;
xp = x1;
if (Math.abs(y2 - y1) > (LocSize + close)) {
if (y2 < y1) {
yp = y1 - LocSize / 2;
ctx.beginPath();
ctx.moveTo(xp - 3*k, yp - 10*k);
ctx.lineTo(xp + 5*k, yp - 10*k);
ctx.lineTo(xp + 1*k, yp + 2*k);
ctx.fill();
ctx.stroke();
ctx.closePath();
} else {
yp = y1 + LocSize / 2;
ctx.beginPath();
ctx.moveTo(xp - 3*k, yp + 10*k);
ctx.lineTo(xp + 5*k, yp + 10*k);
ctx.lineTo(xp + 1*k, yp - 2*k);
ctx.fill();
ctx.stroke();
ctx.closePath();
}
} else {
if (y2 < y1) {
yp = y1 - LocSize / 2;
ctx.fillRect(xp - 3*k, yp - 8*k, 8*k, 8*k);
} else {
yp = y1 + LocSize / 2;
ctx.fillRect(xp - 3*k, yp, 8*k, 8*k);
}
}
xb = x2;
if (y2 < y1) {
yb = y2 + LocSize / 2;
ctx.fillRect(xb - 3*k, yb, 8*k, 2*k);
} else {
yb = y2 - LocSize / 2;
ctx.fillRect(xb - 3*k, yb - 2*k, 8*k, 2*k);
}
}
ctx.lineWidth = 2*k;
ctx.beginPath();
ctx.moveTo(xp+k,yp+k);
if (!arc) {
ctx.lineTo(x3+k,y3+k);
ctx.lineTo(x4+k,y4+k);
ctx.lineTo(xb+k,yb+k);
} else {
ctx.bezierCurveTo(x3,y3,x4,y4,xb+k,yb+k);
}
ctx.stroke();
}
function getFocusedId()
{
var elem = document.activeElement;
if (elem)
{
return elem.id;
}
else
{
return undefined;
}
}
function getFocusedTag()
{
var elem = document.activeElement;
if (elem)
{
return elem.tagName.toLowerCase();
}
else
{
return '';
}
}
function ArrayUnique(myarray)
{
myarray.sort();
for (var i=myarray.length-1; i>=1; i--)
{
if (myarray[i].toLowerCase()==myarray[i-1].toLowerCase())
{
myarray.splice(i,1);
}
}
return myarray;
}
function ArraySortLen(myarray)
{
var lenVars = [];
for (var i=0; i<myarray.length; i++)
{
lenVars.push(myarray[i].length);
}
array_multisort(lenVars, myarray,'SORT_NUMERIC');
return myarray;
}
function Mid(str,start,len)
{
start = start-1;
if (start<0)
{
len = len + start;
start = 0;
}
if (len<0)
{
len = 0;
}
return str.substr(start,len);
}
function Left(str,len)
{
return str.substr(0,len);
}
function Right(str,len)
{
if (len<1)
{
return '';
}
return str.substr(-len);
}
function ReplaceLineEndings(str)
{
str =  str.replace(/\r\n/g,'\n');
str =  str.replace(/\n\r/g,'\n');
return str.replace(/\r/g,'\n');
}
function NthField(str,delim,n,caseSens)
{
var cs = 'i';
if (caseSens)
{
cs = '';
}
n--;
var arr = str.split(new RegExp(EscapeRegExp(delim),cs));
if (n>(arr.length-1))
{
return '';
}
else
{
return arr[n];
}
}
function CountFields(str,delim,caseSens)
{
var cs = 'i';
if (caseSens)
{
cs = '';
}
return str.split(new RegExp(EscapeRegExp(delim),cs)).length;
}
function EscapeRegExp(str)
{
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");
}
function Replace(str,find,replace)
{
return str.replace(new RegExp(EscapeRegExp(find),'i'),replace);
}
function ReplaceB(str,find,replace)
{
return str.replace(new RegExp(EscapeRegExp(find),''),replace);
}
function ReplaceAll(str,find,replace)
{
return str.replace(new RegExp(EscapeRegExp(find),'gi'),replace);
}
function ReplaceAllB(str,find,replace)
{
return str.replace(new RegExp(EscapeRegExp(find),'g'),replace);
}
function ReplaceInText(Input,Find,Replace,BegText,EndText)
{
var nl = '[[Temp554#ёNewline233e]]';
if (Find=='\n')
{
Find = nl;
}
Input = Input.replace(/\n/g,nl);
var inner;
var start, start2;
var myMatch;
var rg = new RegExp(BegText+"(.*?(?!"+BegText+").*?)("+EndText+")",'gi');
while ((myMatch = rg.exec(Input)) != null)
{
start = Input.indexOf(myMatch[1],myMatch.index);
start2 = Input.indexOf(myMatch[2],myMatch.index);
inner = myMatch[1];
inner = inner.replace(new RegExp(EscapeRegExp(Find),'gi'),Replace);
Input = Input.substr(0,start)+inner+Input.substr(start2);
rg.lastIndex = start;
}
Input = Input.replace(new RegExp(EscapeRegExp(nl),'g'),'\n');
return Input;
}
function Split(str,delimiter)
{
if (delimiter===undefined)
{
delimiter = ' ';
}
if (str.indexOf(delimiter)==-1)
{
return [str];
}
else
{
return str.split(delimiter);
}
}
function CompareRegEx(str,pattern)
{
var re = new RegExp("^"+pattern+"$",'im');
if (str.match(re)!=null)
{
return true;
}
else
{
return false;
}
}
function InStr(str,find)
{
return str.indexOf(find)+1;
}
function isLocalStorageAvailable()
{
if (!window.localStorage)
{
return false;
}
else
{
return true;
}
}
function urlencode(str)
{
str = (str+'').toString();
return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
}
function random(min,max)
{
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function SetEvent(id,func,event)
{
var elem = $(id);
if (elem) {
if (!event) {
event = 'click';
}
elem.addEventListener(event,func);
return true;
}
return false;
}
(function () {
if ( typeof window.CustomEvent === "function" ) return false;
function CustomEvent ( event, params ) {
params = params || { bubbles: false, cancelable: false, detail: undefined };
var evt = document.createEvent( 'CustomEvent' );
evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
return evt;
}
CustomEvent.prototype = window.Event.prototype;
window.CustomEvent = CustomEvent;
})();
var editor;
var editorColor;
var editorBlock;
var editorTitle;
var editorTop;
var backdrop;
var navPanel, navPanel2;
var message;
var maincanvas;
var maincanvas_w;
var maincanvas_h;
var maincanvasWidth = 2600;
var maincanvasHeight = 3000;
var canvasWrap;
var canvasWrap_w;
var canvasWrap_h;
var ClickOnLoc;
var LocationArr = []; // главный массив локаций
var GroupArr = {}; // объект координат Loc.Left+':'+Loc.Top, хранит индексы локаций (создаются в Paint())
var MouseX = 0;
var MouseY = 0;
var mouseOffsetX = 0;
var mouseOffsetY = 0;
var SelectedLocation = -1;
var ctx;
var pixel_ratio = 1;
var Cell = 8;
var MinimalWidth = 640;
var LocSizeDefault = 112;
var LocSize = LocSizeDefault;
var LocSizeSmall = 48;
var LocSizeMin = LocSizeSmall + Cell;
var LocSizeMax = 144;
var toolbar;
var toolbarH;
var footer, footer_status;
var mywindow;
var mywindow_inner;
var EditorVisible = false;
var WindowVisible = false;
var isMouseDown = false;
var editNewLoc = false;
var LocTitleH = 19;
var selectedColor = 0;
var buffer = document.createElement('canvas');
var fileNum = 0; // номер текущего файла
var isTouchDevice = false;
var previewWin;
var closePreview;
var PreviewVisible = false;
var mainDiv;
var LoadMerge = false;
var MenuItemsList = [];
var SelectedMenuItemNum = 0;
var EditrCaseField = false;
var EditrSelectedField = false;
var EditrRegExField = false;
var EditrFindField = '';
var EditrReplaceField = '';
var editor_buttons;
var show_lines, show_arcs;
var DarkMode = false;
var ColorMode = true;
var buttonBack;
var PrevTitle = '';
var isShowLines = true;
var isShowArcs = true;
var prevLastLocGroup = '';
var AuthLogin = '';
var AuthPassword = '';
var fontSize = 0;
var PlateVisible = false;
var myplate, platecontent, platetitle;
var isWebKit = 'WebkitAppearance' in document.documentElement.style;
var ua = window.navigator.userAgent.toLowerCase();
var isIE = !!ua.match(/msie|trident\/7|edge/);
var isWinPhone = ua.indexOf('windows phone') !== -1;
var isIOS = !isWinPhone && !!ua.match(/ipad|iphone|ipod/);
var lastSearchQuery = '';
var navPanelScrollPos;
var LocTextBak = '';
var previewTheme;
var EmptyImageDataURL = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
var colorbutton;
var SelLocColor = 'rgba(255,255,255,1)';
var Colors = [
'rgba(41,128,185,1)', // синий
'rgba(103,128,159,1)', //серо-синий
'rgba(110,110,110,1)', // серый
'rgba(231,76,60,1)', // красный
'rgba(155,89,182,1)', // сиреневый
'rgba(230,126,34,1)', // оранжевый
'rgba(22,160,133,1)', // зелёный
];
var BadVarsSymbs = "$!?.,:;<>{}|\(\)\\[\\]'\"@\^&/\\§`~±+\\-*%#=\\s";
var LinksPattern = /\[\[[\+\-\*]?[^"]*?\|*([^|]*?)\]\]/g;
var PrepinPattern = "'`\"»§@#<>\\[\\]()<>{}\\s:.;,=!?\\-+*/&|%\\^~";
var DisplayPattern = "(^|["+PrepinPattern+"])((display|repeat|stop|input|goto|popup)\\s*?\\(\\s*?['\"]\\s*?)([^'\"]*?)(\\s*?['\"])";
var EditrTitlesRegExp = /^[ \t]*?::[ \t]?([ \t\S]+?)$/mg;
var SpriteEffects = ['fade','zoom','flip','fly','jump','left','right','up','down','random'];
var SysVars = ['choice','select','input','online','test','time','title','from','storytitle','storysubtitle','storyauthor'];
SysVars.sort();
var asmProps = {
click: true,
grammar: false,
save: false,
};
if (LangCode=='ru') {
var MacrosArr = [
{name:'$',syntax:'("id_элемента")',title:Lang.MacroElement},
{name:'button',syntax:'("текст кнопки","имя параграфа","*/+",function(){});\nprint(кнопка);',title:Lang.MacroButton,before:'var кнопка = '},
{name:'back',syntax:'("текст ссылки",кнопка:true/false);',title:Lang.LinkBack,before:'var назад = '},
{name:'choice',syntax:'(false,"вариант1","вариант2","вариант3",function(n){});',title:Lang.ChoiceMacro},
{name:'clear',syntax:'();',title:Lang.MacroClrScr},
{name:'copy',syntax:'(имя_спрайта,"название/URL спрайта");',title:Lang.MacroCopy,before:'копия_спрайта = '},
{name:'display',syntax:'("имя параграфа");',title:Lang.MacroDisplay},
{name:'effect',syntax:'("название эффекта");',title:Lang.MacroEffect},
{name:'either',syntax:'("один","два","три");',title:Lang.MacroEither,before:'var случайное = '},
{name:'filter',syntax:'("CSS фильтры через пробел");',title:Lang.MacroFilter},
{name:'flip',syntax:'(0-1000);',title:Lang.MacroFade},
{name:'goto',syntax:'("имя параграфа");',title:Lang.MacroGoto},
{name:'image',syntax:'("название/URL спрайта");',title:Lang.MacroImage},
{name:'input',syntax:'("имя параграфа или функция (результат в $$input)");',title:Lang.MacroInput},
{name:'link',syntax:'("текст ссылки","имя параграфа","*/+",function(){});\nprint(ссылка);',title:Lang.MacroLink,before:'var ссылка = '},
{name:'log',syntax:'(выражение);',title:Lang.MacroLog},
{name:'menu',syntax:'("текст")',title:Lang.MacroMenu},
{name:'message',syntax:'(выражение);',title:Lang.MacroMessage},
{name:'music',syntax:'("адрес mp3 файла");',title:Lang.MacroBackAudio},
{name:'print',syntax:'(выражение);',title:Lang.MacroPrint},
{name:'picture',syntax:'("адрес изображения");',title:Lang.MacroPicture},
{name:'popup',syntax:'("имя параграфа");',title:Lang.MacroPopup},
{name:'random',syntax:'(min,max);',title:Lang.MacroRandom,before:'var случайное = '},
{name:'repeat',syntax:'("имя параграфа",секунды);',title:Lang.MacroRepeat},
{name:'restart',syntax:'("текст ссылки",кнопка:true/false);',title:Lang.LinkRestart,before:'var заново = '},
{name:'select',syntax:'(1,"элемент1","элемент2","элемент3",function(n){});',title:Lang.SelectMacro},
{name:'sprite',syntax:'("название/URL спрайта");\n//спрайт.width = true; // ширина 0-100, true - автоматически\n//спрайт.height = 30; // высота 0-100\n//спрайт.left = 0; // расстояние слева 0-100\n//спрайт.right = 0; // расстояние справа 0-100\n//спрайт.top = 0; // расстояние от верха 0-100\n//спрайт.bottom = 0; // расстояние от низа 0-100\n//спрайт.opacity = 100; // прозрачность 0-100\n//спрайт.filter = "CSS фильтры через пробел"; // "grayscale(20%) sepia(50%)"\n//спрайт.flipX = true; // отразить по горизонтали\n//спрайт.flipY = true; // отразить по вертикали\n//спрайт.rotate = 90; // повернуть на указанный градус\n//спрайт.action = "имя параграфа" или function(спрайт,координаты){}; // действие при нажатии\n//спрайт.drag = function(спрайт){}; // перетаскивание\n//спрайт.path = "название/URL спрайта"; // изменить адрес спрайта\nспрайт.show(1000); // показать спрайт, время в мс\n//спрайт.hide(1000); // скрыть спрайт, время в мс\n//показан = спрайт.visible; // показан ли спрайт (true/false)\n//спрайт.order = false; // перемещать спрайт наверх при нажатии\n',title:Lang.MacroSprite,before:'спрайт = '},
{name:'sprites',syntax:'(true);\n// спрайты = sprites();',title:Lang.FileImageDeleteAll},
{name:'sound',syntax:'("имя звука");',title:Lang.MacroSound},
{name:'script',syntax:'("путь к js-файлу");',title:Lang.MacroScript},
{name:'style',syntax:'("путь к css-файлу");',title:Lang.MacroStyle},
{name:'stop',syntax:'("имя параграфа");',title:Lang.MacroStop},
{name:'texteffect',syntax:'("название эффекта");',title:Lang.MacroTextEffect},
{name:'title',syntax:'("текст");',title:Lang.MacroTitle},
{name:'tab',syntax:'(целое_число);',title:Lang.FormatTab},
{name:'update',syntax:'();',title:Lang.MacroUpdate},
{name:'video',syntax:'("адрес mp4 файла");',title:Lang.MacroVideo},
{name:'visited',syntax:'();',title:Lang.MacroVisited,before:'var посещений = '},
];
} else {
var MacrosArr = [
{name:'$',syntax:'("element_id")',title:Lang.MacroElement},
{name:'button',syntax:'("caption","passage","*/+",function(){});\nprint(mybutton);',title:Lang.MacroButton,before:'var mybutton = '},
{name:'back',syntax:'("text",button:true/false);',title:Lang.LinkBack,before:'var backbutton = '},
{name:'choice',syntax:'(false,"choice1","choice2","choice3",function(){});',title:Lang.ChoiceMacro},
{name:'clear',syntax:'();',title:Lang.MacroClrScr},
{name:'copy',syntax:'(spr_var,"name/URL");',title:Lang.MacroCopy,before:'spr_copy = '},
{name:'display',syntax:'("passage");',title:Lang.MacroDisplay},
{name:'effect',syntax:'("effect name");',title:Lang.MacroEffect},
{name:'either',syntax:'("one","two","three");',title:Lang.MacroEither,before:'var rand = '},
{name:'filter',syntax:'("CSS filters");',title:Lang.MacroFilter},
{name:'flip',syntax:'(0-1000);',title:Lang.MacroFade},
{name:'goto',syntax:'("passage");',title:Lang.MacroGoto},
{name:'image',syntax:'("name/URL");',title:Lang.MacroImage},
{name:'input',syntax:'("passage or func (result == $$input)");',title:Lang.MacroInput},
{name:'link',syntax:'("test","passage","*/+",function(){});\nprint(mylink);',title:Lang.MacroLink,before:'var mylink = '},
{name:'log',syntax:'(expression);',title:Lang.MacroLog},
{name:'menu',syntax:'("text")',title:Lang.MacroMenu},
{name:'message',syntax:'(expression);',title:Lang.MacroMessage},
{name:'music',syntax:'("path to mp3 file");',title:Lang.MacroBackAudio},
{name:'print',syntax:'(expression);',title:Lang.MacroPrint},
{name:'picture',syntax:'("path");',title:Lang.MacroPicture},
{name:'popup',syntax:'("passage");',title:Lang.MacroPopup},
{name:'random',syntax:'(min,max);',title:Lang.MacroRandom,before:'var rand = '},
{name:'repeat',syntax:'("passage",sec);',title:Lang.MacroRepeat},
{name:'restart',syntax:'("text",button:true/false);',title:Lang.LinkRestart,before:'var rst = '},
{name:'select',syntax:'(1,"option1","option2","option3",function(n){});',title:Lang.SelectMacro},
{name:'sprite',syntax:'("name/path");\n//mysprite.width = true; // width 0-100, true - auto\n//mysprite.height = 30; // height 0-100\n//mysprite.left = 0; // left 0-100\n//mysprite.right = 0; // right 0-100\n//mysprite.top = 0; // top 0-100\n//mysprite.bottom = 0; // bottom 0-100\n//mysprite.opacity = 100; // opacity 0-100\n//mysprite.filter = "CSS filters"; // "grayscale(20%) sepia(50%)"\n//mysprite.flipX = true; // flip horizontally\n//mysprite.flipY = true; // flip vertically\n//mysprite.rotate = 90; // rotate by specified degree\n//mysprite.action = "passage" or function(sprite,coordinates){}; // click action\n//mysprite.drag = function(sprite){}; // drag sprite\n//mysprite.path = "name/URL"; // set sprite address\nmysprite.show(1000); // show sprite, ms\n//mysprite.hide(1000); // hide sprite, ms\n//visible = mysprite.visible; // is visible sprite (true/false)\n//mysprite.order = false; // sprite to front when pressed\n',title:Lang.MacroSprite,before:'mysprite = '},
{name:'sprites',syntax:'(true);\n// mysprites = sprites();',title:Lang.FileImageDeleteAll},
{name:'sound',syntax:'("name");',title:Lang.MacroSound},
{name:'script',syntax:'("path to js file");',title:Lang.MacroScript},
{name:'style',syntax:'("path to css file");',title:Lang.MacroStyle},
{name:'stop',syntax:'("passage");',title:Lang.MacroStop},
{name:'texteffect',syntax:'("effect name");',title:Lang.MacroTextEffect},
{name:'title',syntax:'("text");',title:Lang.MacroTitle},
{name:'tab',syntax:'(integer);',title:Lang.FormatTab},
{name:'update',syntax:'();',title:Lang.MacroUpdate},
{name:'video',syntax:'("path to mp4 file");',title:Lang.MacroVideo},
{name:'visited',syntax:'();',title:Lang.MacroVisited,before:'var n = '},
];
}
var MacrosArrNames = [];
for (var i in MacrosArr) {
MacrosArrNames.push(MacrosArr[i].name);
}
if (LangCode=='ru') {
var OperatorsArr = [
{name:'if',syntax:'(i==1) {\n\t// код 1\n} else if(i==2) {\n\t// код 2\n} else {\n\t// другой код\n}\n',title:Lang.MacroIf},
{name:'switch',syntax:'(x) {\n\tcase 1:\n\t\t// код, если x=1\n\t\tbreak;\n\tcase 2:\n\t\t// код, если x=2\n\t\tbreak;\n\tdefault:\n\t\t// код, если иное значение\n}\n',title:Lang.MacroSwitch},
{name:'for',syntax:'(var i=0; i<n; i++) {\n\t//break;\n\t//continue;\n}\n',title:Lang.MacroLoop},
{name:'while',syntax:'(i<n) {\n\t// код;\n\ti++;\n}\n',title:Lang.MacroWhile},
{name:'do',syntax:' {\n\t// код;\n\ti++;\n} while(i<n);\n',title:Lang.MacroDo},
{name:'function',syntax:'() {\n\t// код\n};\n',title:Lang.MacroFunction,before:'имя_функции = '},
{name:'function',syntax:' имя_функции() {\n\t// код\n}\n',title:Lang.MacroFunctionLocal},
{name:'function',syntax:'(){}\n',title:Lang.MacroFunctionParam},
];
} else {
var OperatorsArr = [
{name:'if',syntax:'(i==1) {\n\t// code 1\n} else if(i==2) {\n\t// code 2\n} else {\n\t// other code\n}\n',title:Lang.MacroIf},
{name:'switch',syntax:'(x) {\n\tcase 1:\n\t\t// code, if x=1\n\t\tbreak;\n\tcase 2:\n\t\t// code, if x=2\n\t\tbreak;\n\tdefault:\n\t\t// code, if different value\n}\n',title:Lang.MacroSwitch},
{name:'for',syntax:'(var i=0; i<n; i++) {\n\t//break;\n\t//continue;\n}\n',title:Lang.MacroLoop},
{name:'while',syntax:'(i<n) {\n\t// code;\n\ti++;\n}\n',title:Lang.MacroWhile},
{name:'do',syntax:' {\n\t// code;\n\ti++;\n} while(i<n);\n',title:Lang.MacroDo},
{name:'function',syntax:'() {\n\t// code\n};\n',title:Lang.MacroFunction,before:'function_name = '},
{name:'function',syntax:' function_name() {\n\t// code\n}\n',title:Lang.MacroFunctionLocal},
{name:'function',syntax:'(){}\n',title:Lang.MacroFunctionParam},
];
}
var style_current_theme = 0;
var style_view = GetURLHashVar('StyleView'); if (style_view===undefined) {style_view = 'bt';}
var style_themes = [];
var StyleText = '';
var html = '';
var tire = '—';
var FilesLinks = [];
var StoryPath = '';
var maxFileSizeStoryData = 1024*1024;
var TargetWindows  = GetURLHashVar('TargetWindows');  if (TargetWindows===undefined)  {TargetWindows = false;}
var TargetMacOS    = GetURLHashVar('TargetMacOS');    if (TargetDesktop===undefined)  {TargetDesktop = false;}
var TargetLinux    = GetURLHashVar('TargetLinux');    if (TargetLinux===undefined)    {TargetLinux = false;}
var TargetChromeApp= GetURLHashVar('TargetChromeApp');if (TargetChromeApp===undefined){TargetChromeApp = false;}
var TargetDesktop  = false; if (TargetWindows || TargetMacOS || TargetLinux || TargetChromeApp) {TargetDesktop = true;}
var TargetAndroid  = GetURLHashVar('TargetAndroid');  if (TargetAndroid===undefined)  {TargetAndroid = false;}
var TargetIOS      = GetURLHashVar('TargetIOS');      if (TargetIOS===undefined)      {TargetIOS = false;}
var TargetBrowser  = true; if (TargetDesktop || TargetAndroid || TargetIOS) {TargetBrowser = false;}
var TargetNovels   = false; if (window.location.hostname=='novels.ru') {TargetNovels = true;}
var TargetFormat   = 'html';
var TargetFormatBak= TargetFormat;
function Locations(Title,Text,Left,Top,ColorNum,ErrorLocation,Links,Vars) {
this.Title = Title;
this.Text = Text;
this.Left = Left;
this.Top = Top;
this.ColorNum = ColorNum;
this.ErrorLocation = ErrorLocation;
Links = [];
this.Links = Links;
Vars = [];
this.Vars = Vars;
}
function RemoveComments(str) {
str = str.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*|<!--[\s\S]*?-->$/gm,'');
return str.trim();
}
function ParseLocation(LocIndex) {
if (SimpleLocation(LocationArr[LocIndex].Title)) {
return;
}
var Loc = LocationArr[LocIndex];
var s = Loc.Text;
s = RemoveComments(s);
var myRe, myMatch, Link, Var;
Loc.Links = [];
myRe = LinksPattern;
myRe.lastIndex = 0;
while ((myMatch = myRe.exec(s)) != null) {
Link = myMatch[1].toLowerCase();
Link = Link.replace(/\{[^{}]*?\}/g,''); // игнорируем установки переменных в ссылках
Link = Link.trim();
if (Link.toLowerCase()!=Loc.Title.toLowerCase().trim() && !(/^https?:\/\//.test(Link))) {
Loc.Links.push(Link);
}
}
myRe = new RegExp(DisplayPattern,'g');
while ((myMatch = myRe.exec(s)) != null) {
Link = myMatch[4].toLowerCase().trim();
if (Link.toLowerCase()!=Loc.Title.toLowerCase().trim()) {
Loc.Links.push(Link);
}
}
Loc.Links = ArrayUnique(Loc.Links);
var GoodLinks = 0;
for (var j=0; j<Loc.Links.length; j++) {
var link = Loc.Links[j];
if (GetLocByTitle(link) || link.substr(0,2)=='$$') {
GoodLinks++; // кол-во ссылок, ведущих на существующие локации
}
}
if (GoodLinks==Loc.Links.length) {
Loc.ErrorLocation = false;
} else {
Loc.ErrorLocation = true;
}
}
function ParseAll() {
for (var i=0; i<LocationArr.length; i++) {
ParseLocation(i);
}
}
function SimpleLocation(LocTitle) {
LocTitle = LocTitle.toLowerCase().trim();
if (LocTitle=="storytitle" || LocTitle=="storyauthor" || LocTitle=="storysubtitle" || LocTitle=="storystyle" || LocTitle=="storystyle.bak" || LocTitle=="storydata") {
return true;
} else {
return false;
}
}
function ForbiddenLocation(LocTitle) {
if (LocTitle) {
LocTitle = LocTitle.toLowerCase().trim();
if (LocTitle=="storystyle.bak" || LocTitle=="storydata") {
return true;
} else {
return false;
}
}
}
function startApp()
{
document.body.onload = function() {
Paint();
};
document.addEventListener('dragstart', function(e) {e.preventDefault();});
if ('ontouchmove' in window) {
isTouchDevice = true;
}
window.addEventListener('message', function(e) {
var com = e.data;
if (com=='ClosePreview') {
ClosePreview();
} else if (com=='CompilePassage') {
CompilePassage();
} else if (com=='CloseThemeEditor') {
if (WindowVisible) {
ShowWind(false);
} else {
ShowPlate(false);
}
} else if (/^PropertyEditor=/.test(com)) {
var id = com.replace(/^[^=]+?=/,'');
PropertyEditor(id);
} else {
if (TargetChromeApp) {
chrome_Message(com);
}
}
}, false);
if (TargetBrowser || TargetAndroid) {
window.onbeforeunload = confirmExit;
}
if (!TargetDesktop) {
var fn = GetPrefValue('fileNum');
if (fn!='' && fn!='0')
{
fileNum = parseInt(fn,10);
}
}
if (TargetBrowser) {
AuthLogin = GetPrefValue('login');
AuthPassword = GetPrefValue('password');
} else if (TargetChromeApp) {
GetPrefValue('login',function(value) {
AuthLogin = value;
});
GetPrefValue('password',function(value) {
AuthPassword = value;
});
} else if (!TargetDesktop) {
AuthLogin = GetPrefValue('AuthLogin');
AuthPassword = GetPrefValue('AuthPassword');
}
$('toolbutton_add').onclick = function() {NewLocation(false,true);};
$('toolbutton_act').onclick = function() {ActionsMenu();};
$('toolbutton_arr').onclick = function() {ArrangeButton();};
$('toolbutton_save').onclick = function() {SaveStoryButton(true);};
$('toolbutton_load').onclick = function() {SelectStory(true);};
$('toolbutton_new').onclick = function() {NewGameButton();};
$('toolbutton_run').onclick = function() {CompileButton();};
$('toolbutton_publ').onclick = function() {Publish();};
$('toolbutton_nav').onclick = function() {Navigator();};
$('toolbutton_help').onclick = function() {Help();};
$('closebuttonBig').onclick = function() {CloseEditorButton();};
$('linksbutton').onclick = function() {InsertLink();};
$('macrosbutton').onclick = function() {InsertMacro();};
$('formatbutton').onclick = function() {FormatText();};
$('commentbutton').onclick = function() {CommentText();};
$('colorbutton').onclick = function() {SelectColor();};
$('closebutton_wind').onclick = function() {ShowWind(false);};
$('maincanvas').onclick = function() {ShowWind(false);};
$('buttonBack').onclick = function() {EditrBack();};
$('buttonCompPass').onclick = function() {CompilePassage();};
$('buttonFindNext').onclick = function() {EditorFindNext();};
$('buttonAutoDop').onclick = function() {AutoDop();};
$('show_lines').onclick = function() {ShowLines();};
$('show_arcs').onclick = function() {ShowArcs();};
$('closePreview').onclick = function() {ClosePreview();};
mainDiv = $('mainDiv');
closePreview = $('closePreview');
message = $('message');
toolbar = $('toolbar');
mywindow = $('wind');
mywindow_inner = $('windcontent');
footer = $('footer');
footer.style.display = 'block';
footer_status = $('footer_status');
footer_status.innerHTML = 'AXMA Soft'; // так надо (чтобы footer был уже чем-то заполнен)
maincanvas = $('maincanvas');
canvasWrap = $('canvasWrap');
canvasWrap.style.overflow = 'auto';
editorBlock = $('editorBlock');
editor = $('editor');
editor.onclick = function(e) {e.stopPropagation();ShowWind(false);};
backdrop = $('backdrop');
editorColor = $('editorColor');
navPanel = $('navPanel'); navPanel2 = $('navPanel2');
if (isIOS) {
editor.style.marginLeft = '-3px';
}
if (!isTouchDevice) {
editor.onmousedown = function(event) { ShowWind(false); };
} else {
editor.ontouchstart = function(event) { ShowWind(false); };
}
if (TargetChromeApp) {
GetPrefValue('FontSize',function(value) {
fontSize = value;
SetFontEditor();
});
} else if (!TargetDesktop) {
fontSize = GetPrefValue('FontSize');
SetFontEditor();
} else {
GetPrefValue('FontSize');
}
editorTop = $('editorTop');
editorTop.onclick = function(e) {e.stopPropagation();};
editorTitle = $('editorTitle');
editorTitle.onclick = function() {ShowWind(false);};
editorTitle.placeholder = Lang.PassageTitle;
colorbutton = $('colorbutton');
editor_buttons = $('editor_buttons');
show_lines = $('show_lines');
show_arcs = $('show_arcs');
buttonBack = $('buttonBack');
ctx = maincanvas.getContext('2d');
buffer.ctx = buffer.getContext('2d');
pixel_ratio = (window.devicePixelRatio || 1) / (ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1);
maincanvas.width = maincanvasWidth;
maincanvas.height = maincanvasHeight;
maincanvas.style.width = maincanvas.width / pixel_ratio + 'px';
maincanvas.style.height = maincanvas.height / pixel_ratio + 'px';
if (pixel_ratio>1) {
LocTitleH = LocTitleH * pixel_ratio;
Cell = Cell* pixel_ratio;
MinimalWidth = MinimalWidth * pixel_ratio;
LocSizeDefault = LocSizeDefault * pixel_ratio;
LocSize = LocSizeDefault * pixel_ratio;
LocSizeSmall = LocSizeSmall * pixel_ratio;
LocSizeMin = LocSizeMin * pixel_ratio;
LocSizeMax = LocSizeMax * pixel_ratio;
}
if (!myplate) {
myplate = document.createElement('div');
document.body.appendChild(myplate);
myplate.id = 'myplate';
myplate.className = 'plate';
myplate.oncontextmenu = function() { return false; };
myplate.innerHTML = "<table id='platetop' border='0' cellpadding='0' cellspacing='0'><tr><td width='5%' align='left'><div id='plateclose' class='closebutton'></div></td><td width='90%' align='center'><div id='platetitle'></div></td><td width='5%'>&nbsp;</td></tr></table><div id='platecontent'></div>";
SetEvent('plateclose',function(){ShowPlate(false);});
platecontent = $('platecontent');
platetitle = $('platetitle');
}
var tbList = getElementsByClass('tooltext',toolbar);
for (var i=0;i<tbList.length;i++) {
tbList[i].innerHTML = Lang.ToolButtons[i];
}
tbList = getElementsByClass('editor_button',footer);
for (var i=0;i<tbList.length;i++) {
tbList[i].title = Lang.SmallButtons[i];
}
tbList = getElementsByClass('closebuttonBig linkbutton color',editorTop);
for (var i=0;i<tbList.length;i++) {
tbList[i].title = Lang.EditorButtons[i];
}
if (TargetChromeApp)
{
GetPrefValue('ShowLines',function(value) {
if (value=='false') {
isShowLines = false;
}
});
GetPrefValue('ShowArcs',function(value) {
if (value=='false') {
isShowArcs = false;
}
});
}
else
{
if (GetPrefValue('ShowLines')=='false') {
isShowLines = false;
}
if (GetPrefValue('ShowArcs')=='false') {
isShowArcs = false;
}
}
ResizeEvent();
CanvasToTop();
if (TargetChromeApp)
{
chrome_LoadRecent();
}
else if (!TargetDesktop && (fileNum==0 || LoadStory(fileNum)==false))
{
NewGame();
}
window.onkeydown = function (e) { keys(e,''); };
if (!isTouchDevice)
{
window.onkeypress = function (e) { keysPress(e,''); };
}
window.onkeyup = function (e) { keysUp(e,''); };
window.addEventListener('resize', ResizeEvent, false);
window.addEventListener('orientationchange', ResizeEvent, false);
VisualEventsStart();
setInterval(UpdateFooter, 1500);
if (TargetBrowser)
{
var vdate = 0;
loadData(CommandServer('com=versiondate'),function(vdate) {
setInterval(function(){CheckUpdates(vdate.trim());},3600000); // проверяем обновление раз в 60 минут
});
}
if (TargetDesktop || isLocalStorageAvailable)
{
setInterval(ToBackup, 300000); // сохраняем backup раз в 5 минут
}
if (TargetChromeApp)
{
GetPrefValue('ColorMode',function(value) {
if (value=='false') {
ColorModeSwitch();
}
});
GetPrefValue('DarkMode',function(value) {
if (value=='true') {
DarkModeSwitch();
}
});
}
else if (TargetDesktop)
{
GetPrefValue('ColorMode');
GetPrefValue('DarkMode');
}
else
{
if (GetPrefValue('ColorMode')=='false')
{
ColorModeSwitch();
}
if (GetPrefValue('DarkMode')=='true')
{
DarkModeSwitch();
}
}
if (GetURLHashVar('QuickStart'))
{
QuickStart();
}
if (TargetChromeApp) {
window.ondragover = function(e) { e.preventDefault(); return false };
window.ondrop = function (e) {
e.preventDefault();
var fileDragName = e.dataTransfer.files[0].path;
if (fileDragName.substr(-3).toLowerCase()=='.sm') {
chrome_LoadFile(fileDragName);
}
return false;
};
var gui = require('nw.gui');
gui.App.on('open', function(path) {
path = decodeURIComponent(path).replace(/^file:\/\//,'');
chrome_LoadFile(path);
});
}
}
function selectTypeGame(type)
{
TargetFormat = 'html';
style_view = type;
if (type=='vis') {
style_current_theme = 10;
} else {
if (style_current_theme==10) {
style_current_theme = 0;
}
}
BackupStoryStyle();
NewGameButton();
}
function NewGameButton()
{
var selected = ' selected';
var selected1='', selected2='', selected3='', selected4='', selected5='';
if (style_view=='mw') {
selected3 = selected;
} else if (style_view=='sw') {
selected5 = selected;
} else if (style_view=='rpg') {
selected4 = selected;
} else if (style_view=='vis') {
selected2 = selected;
} else {
selected1 = selected;
}
var str = "";
if (!TargetNovels) {
str += "<div>"+Lang.GameType+"</div>";
str += "<div><select id='item1' style='margin:6px 0;font-size:13px;'>";
str += "<option"+selected1+" value='bt'>"+Lang.BaseType+"</option>";
str += "<option"+selected2+" value='vis'>"+Lang.InterVisual+"</option>";
str += "<option"+selected3+" value='mw'>"+Lang.MultiView+"</option>";
str += "<option"+selected4+" value='rpg'>"+Lang.InterQuest+"</option>";
str += "<option"+selected5+" value='sw'>"+Lang.ClassicView+"</option>";
str += "</select></div>";
}
if (TargetFormat=='html' && style_view!='vis') {
str += "<div style='margin-top:6px;'>"+Lang.GameTheme+"</div>";
str += "<div><select id='item2' style='margin:6px 0;font-size:13px;'>";
for (var i=0; i<style_themes.length; i++) {
selected1 = '';
if (i==style_current_theme) {
selected1 = selected;
}
str += "<option"+selected1+" value='"+i+"'>"+style_themes[i]+"</option>";
}
str += "</select></div>";
}
if (TargetFormat=='html') {
str += "<div class='menu_item' id='item3'>"+Lang.MenuNewStandart+"</div>";
}
str += "<div class='menu_item' id='item4'>"+Lang.MenuNewCompact+"</div>";
str += "<div class='menu_item' id='item5'>"+Lang.MenuNewClipboard+"</div>";
mywindow_inner.innerHTML = str;
SetEvent('item1',function(){selectTypeGame(this.value);},'change');
SetEvent('item2',function(){style_current_theme=parseInt(this.value);},'change');
SetEvent('item3',function(){AreYouSure(newGame,Lang.AYSCreateNewStory+' '+Lang.DontForgetSave);});
SetEvent('item4',function(){AreYouSure(newGameCompact,Lang.AYSCreateNewStory+' '+Lang.DontForgetSave);});
SetEvent('item5',function(){NewGameClipboard();});
ShowWind(true);
}
function newGameCompact()
{
NewGame(true);
}
function newGame()
{
NewGame();
}
function NewGame(compact)
{
if (TargetDesktop)
{
chrome_SetCurrentEntry('');
}
if (EditorVisible)
{
OpenEditor(false,false,true);
}
if (LocSize>LocSizeSmall)
{
LocSize = LocSizeDefault;
}
SelectedLocation = -1;
LocationArr = [];
if (LangCode=='ru') {
LocationArr.push(new Locations("StoryTitle","Название игры",328,Cell,2,false));
LocationArr.push(new Locations("StorySubtitle","Вставьте сюда краткое описание игры или её фабулу, уведомление пользователям или любой текст, который должен быть виден при запуске игры.",328,240,2,false));
LocationArr.push(new Locations("StoryAuthor","Автор игры",488,Cell,5,false));
LocationArr.push(new Locations("StoryMenu","// В этом параграфе можно установить ссылки, которые будут доступны в верхней правой части экрана\n\\ [[*Вступление|StorySubtitle]]\n\n// Можно устанавливать ссылки в виде картинок\n\\ [[<img src='https://online.axmajs.ru/examples/logo.png'>|https://axmajs.ru/ru/manual/]]\n\n// Если Вы хотите динамически изменять меню из других параграфов, то используйте функцию menu, например:\n//var ссылка1 = link('Описание игры','StorySubtitle');\n//var ссылка2 = link('Автор игры','StoryAuthor','*');\n//menu(ссылка1 + ссылка2);",488,240,6,false));
if (!compact) {
LocationArr.push(new Locations("Следующая сцена","\\ Это следующая сцена. Здесь мы добавили спрайт единорога.\n\n// Установка эффекта появления спрайтов по умолчанию (нажмите Tab внутри пустых кавычек, чтобы выбрать нужный эффект)\neffect(\"fade\");\n\n// Создание спрайта\nединорог = sprite(\"https://online.axmajs.ru/examples/sprite.png\");\n\n// Установка размеров и местоположения спрайта\nединорог.height = 50; // высота - 50% от размера окна\nединорог.width = true; // ширина - пропорциональная\nединорог.top = true; // расстояние от верха окна - автоматическое\nединорог.bottom = 5; // расстояние от низа окна - 5% от его размера\nединорог.action = \"StorySubtitle\"; // при нажатии параграф открывается в окне\n\n// Вывод спрайта за 1 секунду\nединорог.show(1000);\n\n\\ Можно добавлять спрайты из интернета, указав их адрес, либо со своего компьютера, воспользовавшись кнопкой «Добавить/Спрайт».\n\n\\ Добавляем фоновую музыку. Обратите внимание на появившуюся кнопку в панели инструментов.\nmusic(\"https://online.axmajs.ru/examples/music.mp3\");\n\n\\ Если ссылок в сцене несколько, то игроку будет предложен выбор действия. Кстати, ссылка, которая находится [[внутри текста|Несколько приёмов]], не превращается в кнопку.\n\n\\ [[*Всплывающее окно|StorySubtitle]]\n\\ [[Несколько приёмов]]",Cell,240,0,false));
LocationArr.push(new Locations("Несколько приёмов","// Удаляем спрайт за 1 секунду\nединорог.hide(1000);\n\n// Останавливаем музыку\nmusic();\n\n\\ Накладываем [[фильтры CSS|https://www.w3schools.com/cssref/css3_pr_filter.asp]] на фоновую иллюстрацию.\nfilter(\"sepia(50%) grayscale(20%)\");\n// Для последующего удаления фильтров используйте функцию без параметров: filter();\n\n\\ Объявляем глобальную переменную «ключ» и выводим «Да», если ключ есть, или «Нет», если ключ отсутствует:\nключ = true; // для локальной переменной: var ключ = true;\nif(ключ) {\n	print(\"Да\");\n} else {\n	print(\"Нет\");\n}\n\n\\ Ссылка на параграф, содержимое которого будет выведено на этой же странице: [[+вывести текст начала игры|Start]].\n\n\\ Текст, вставленный из другого параграфа:\ndisplay(\"StorySubtitle\");\n\n\\ Случайное целое число от 1 до 10:\nслучайное = random(1,10);\nprint(случайное);\n\n\\ Выбор варианта:\n// Номер выбранного варианта, начиная с 1, сохраняется в системной переменной $$choice. Если ничего не выбрано, то $$choice равна 0\nchoice(false,\"Вариант 1\",\"Вариант 2\",function(n) {\n	message(\"Выбран вариант \"+n);\n});\n\n\\ После выбора этой ссылки игрок сможет вернуться на предыдущую страницу:\nprint(back(\"\",false))",168,80,0,false));
}
var start = '';
if (style_view=='vis') {
start = "// Вставка фоновой иллюстрации (нажмите Ctrl+I для быстрой вставки)\npicture(\"https://online.axmajs.ru/examples/back.jpg\");\n\ntitle(\"Заголовок сцены\");\n\n// Вывод текста сцены\n\\ Поздравляем! Это первая сцена вашей новой интерактивной новеллы.\n\\ Если ссылка одна, как в этой сцене, то переход по ней произойдёт после нажатия на пробел или на этот текст.\n\n\\ [[Далее|Следующая сцена]]";
} else {
start = "\\ Это первый параграф и первое, что увидит пользователь после краткого описания. Отсюда начинается написанная Вами игра.\n\n\\ Разместив здесь ссылки на другие созданные параграфы, Вы дадите возможность пользователю [[продолжить|Следующая сцена]] его приключение.\n\npicture(\"https://online.axmajs.ru/examples/back.jpg\");";
}
if (style_view=='vis' || style_view=='bt') {
start += "\n\n\\ Нажмите на изображение глаза в левом верхнем углу, чтобы временно скрыть элементы интерфейса.";
}
LocationArr.push(new Locations("Start",start,Cell,Cell,3,false));
} else {
LocationArr.push(new Locations("StoryTitle","Story Title",328,Cell,2,false));
LocationArr.push(new Locations("StorySubtitle","Here you can place a brief introduction, a summary of the plot, a disclaimer/warning, etc.",328,240,2,false));
LocationArr.push(new Locations("StoryAuthor","Story Author",488,Cell,5,false));
LocationArr.push(new Locations("StoryMenu","// In this passage, you can set links that will be available in the upper right part of the screen.\n\\ [[*Introduction|StorySubtitle]]\n\n// You can set links to the images\n\\ [[<img src='https://online.axmajs.ru/examples/logo.png'>|https://axmajs.ru/ru/manual/]]\n\n// If you want to dynamically change the menu from other passages, use the menu function, for example:\n//var link1 = link('Introduction','StorySubtitle');\n//var link2 = link('Story author','StoryAuthor','*');\n//menu(link1 + link2);",488,240,6,false));
if (!compact) {
LocationArr.push(new Locations("Next scene","\\ This is the next scene. Here we added a sprite of a unicorn.\n\n// Setting the default sprites appearance effect (press Tab inside empty quotes to select the desired effect)\neffect(\"fade\");\n\n// Sprite creation\nunicorn = sprite(\"https://online.axmajs.ru/examples/sprite.png\");\n\n// Set the size and location of the sprite\nunicorn.height = 50; // height - 50% from window size\nunicorn.width = true; // width - proportional\nunicorn.top = true; // automatic distance from the top of the window\nunicorn.bottom = 5; // distance from the bottom of the window - 5% from its size\nunicorn.action = \"StorySubtitle\"; // when clicked, the passage opens in the window\n\n// Sprite output in 1 second\nunicorn.show(1000);\n\n\\ You can add sprites from the internet by entering URL, or from your computer using the button \"Add/Sprite\".\n\n\\ Add background music. Notice the toolbar button that appears.\nmusic(\"https://online.axmajs.ru/examples/music.mp3\");\n\n\\ If there are several links in the scene, then the player will be offered a choice of action. By the way, the link that is [[inside the text | Several tricks]] does not turn into a button.\n\n\\ [[*Pop-up window|StorySubtitle]]\n\\ [[Several tricks]]",Cell,240,0,false));
LocationArr.push(new Locations("Several tricks","// Remove the sprite in 1 second\nunicorn.hide(1000);\n\n// Stop the music\nmusic();\n\n\\ Apply [[CSS filters|https://www.w3schools.com/cssref/css3_pr_filter.asp]] for background illustration.\nfilter(\"sepia(50%) grayscale(20%)\");\n// To remove filters, use the function without parameters: filter();\n\n\\ We declare the global variable \"key\" and print \"Yes\" if there is a key, or \"No\" if there is no key:\nkey = true; // for a local variable: var key = true;\nif(key) {\n	print(\"Yes\");\n} else {\n	print(\"No\");\n}\n\n\\ Link to the passage, the contents of which will be displayed on the same page: [[+display the text of the beginning of the game|Start]].\n\n\\ Text inserted from another passage:\ndisplay(\"StorySubtitle\");\n\n\\ Random integer from 1 to 10:\nnumber = random(1,10);\nprint(number);\n\n\\ Choice of option:\n// The number of the selected option, starting with 1, is stored in the system variable $$choice. If nothing is selected, $$choice is 0\nchoice(false,\"Option 1\",\"Option 2\",function(n) {\n	message(\"Selected option \"+n);\n});\n\n\\ After selecting this link, the player will be able to return to the previous page:\nprint(back(\"\",false))",168,80,0,false));
}
if (style_view=='vis') {
LocationArr.push(new Locations("Start","// Insert background illustration (press Ctrl+I for quick insertion)\npicture(\"https://online.axmajs.ru/examples/back.jpg\");\n\ntitle(\"Scene title\");\n\n// Scene text output\n\\ Congratulations! This is the first scene of your new interactive novel.\n\\ If the link is one, as in this scene, then the transition to it will occur after pressing the space or on this text.\n\n\\ [[Further|Next scene]]",Cell,Cell,3,false));
} else {
LocationArr.push(new Locations("Start","\\ This is the first passage and it will be the first thing your reader will see under the subtitle. Here your story begins.\n\n\\ By linking to other passages you will enable your reader to [[continue|Next scene]] their adventure.\n\npicture(\"https://online.axmajs.ru/examples/back.jpg\");",Cell,Cell,3,false));
}
}
if (compact) {
LocationArr[1].Text = '';   // StorySubtitle
LocationArr[3].Text = '';   // StoryMenu
LocationArr[4].Text = '\\'; // Start
}
if (pixel_ratio>1) {
for (var key in LocationArr) {
LocationArr[key].Left = LocationArr[key].Left*pixel_ratio;
LocationArr[key].Top = LocationArr[key].Top*pixel_ratio;
}
}
ParseAll();
UpdateFooter();
if (LocSize<=LocSizeSmall || compact) {
ArrangeByName();
} else {
SelectNPaint();
}
fileNum = 0;
CanvasToTop();
UpdateOnlineTitle();
}
function NewGameClipboard()
{
var str = ''
str += "<textarea id='PasteClipboard' placeholder='"+Lang.MenuNewClipboardMess+".' style='width:95%;height:130px;outline:none;resize:none;font-size:11px;padding:4px;border:none;border-radius:3px;'></textarea>";
str += "<div class='menu_item' id='item1'>OK</div>";
mywindow_inner.innerHTML = str;
SetEvent('item1',function(){newGameClipboard();ShowWind(false);});
ShowWind(true);
$('PasteClipboard').focus();
document.body.oncontextmenu = function() {if(getFocusedId()=='PasteClipboard') {return true;} else {return false;}}
}
function newGameClipboard()
{
var data = $('PasteClipboard').value;
if (data.trim()!='')
{
LoadStory(0,false,data,true);
ArrangeByName();
}
}
function LocInfoToFooter(Loc)
{
if (!isGroup(Loc)) {
var title = Loc.Title;
} else {
var title = Lang.PassagesGroup;
}
footer_status.innerHTML = Loc.Left+','+Loc.Top+' / '+title;
}
function UpdateFooter()
{
if (!EditorVisible) {
if (!isMouseDown) {
var errors = 0;
for (var key in LocationArr) {
if (LocationArr[key].ErrorLocation) {
errors++;
}
}
footer_status.innerHTML = Lang.Passages+': '+LocationArr.length;
if (errors) {
footer_status.innerHTML += '. '+Lang.PassagesErrors+': '+errors;
}
}
} else {
footer_status.innerHTML = Lang.Passages+': '+LocationArr.length;
}
}
function ClearCanvas()
{
maincanvas.width = maincanvas.width;
}
function ClearBuffer()
{
buffer.width = buffer.width;
}
function FromBuffer()
{
ctx.drawImage(buffer,0,0);
}
function ResizeEvent()
{
if (!PreviewVisible)
{
toolbarH = toolbar.offsetHeight;
canvasWrap_w = window.innerWidth;
canvasWrap_h = (window.innerHeight-toolbarH-footer.offsetHeight);
canvasWrap.style.width = canvasWrap_w+"px";
canvasWrap.style.height = canvasWrap_h+"px";
maincanvas_w = maincanvas.width;
maincanvas_h = maincanvas.height;
buffer.width  = maincanvas_w;
buffer.height = maincanvas_h;
if (EditorVisible)
{
ResizeEditor();
}
else
{
ResizeCanvas();
}
}
}
function ResizeEditor()
{
var width = 900;
editorTop.style.maxWidth = width+'px';
if ((window.innerWidth-width)<0)
{
width = window.innerWidth;
}
editor.style.width = width+'px';
editor.style.left = (window.innerWidth-width)/2+'px';
backdrop.style.width = width+'px';
backdrop.style.left = (window.innerWidth-width)/2+'px';
editorBlock.style.top = toolbarH+'px';
editorBlock.style.height = canvasWrap_h+'px';
editorTop.style.left = (window.innerWidth-width)/2+'px';
var edH = editorBlock.offsetHeight-editorTop.offsetHeight+'px';
var edTH = editorTop.offsetHeight+'px';
editor.style.top = edTH;
editor.style.height = edH;
backdrop.style.top = edTH;
backdrop.style.height = edH;
}
function ResizeCanvas()
{
maincanvas.style.top = toolbarH+'px';
if (maincanvas_w<MinimalWidth)
{
LocSize = LocSizeSmall;
Arrange();
}
else
{
if (LocSize<=LocSizeSmall)
{
LocSize = LocSizeDefault;
Arrange();
}
}
SelectNPaint();
}
function prefixedEventListener(element, type, callback) {
var pfx = ['webkit', 'moz', 'MS', 'o', ''];
for (var p=0; p<pfx.length; p++) {
if (!pfx[p]) type = type.toLowerCase();
element.addEventListener(pfx[p]+type, callback, false);
}
}
function Animate(obj,animID,callback)
{
var objclass = obj.className.split(' ')[0];
obj.className = objclass+' '+animID;
prefixedEventListener(obj,'AnimationEnd',function() {
if(obj) {
obj.className = objclass;
if (callback) { callback(); }
}
}, false);
}
function GetLocByTitle(Title)
{
Title = Title.split('[::]')[0].trim().toLowerCase();
for (var key in LocationArr)
{
if (LocationArr[key].Title.toLowerCase().trim()==Title)
{
return LocationArr[key];
}
}
return false;
}
function GetLocIndexByTitle(Title)
{
Title = Title.split('[::]')[0].trim().toLowerCase();
for (var i=0;i<LocationArr.length;i++)
{
if (LocationArr[i].Title.toLowerCase().trim()==Title)
{
return i;
}
}
return -1;
}
function Paint(move)
{
GroupArr = {};
var Loc, coords;
for (var i=0;i<LocationArr.length;i++)
{
var Loc = LocationArr[i];
coords = Loc.Left+':'+Loc.Top;
if (GroupArr[coords])
{
GroupArr[coords].push(i);
}
else
{
GroupArr[coords] = [i];
}
}
if (move)
{
var lastLocGroup = GetGroup(LastLocation().Left,LastLocation().Top).toString();
if (prevLastLocGroup != lastLocGroup)
{
if (prevLastLocGroup!='')
{
Message(Lang.Grouped);
}
prevLastLocGroup = lastLocGroup;
ClearBuffer();
DrawLocations(buffer.ctx);
}
ClearCanvas();
DrawLines(move);
}
else
{
ClearCanvas();
if (isShowLines)
{
DrawLines();
}
else
{
DrawLines(true);
}
ClearBuffer();
DrawLocations(buffer.ctx);
}
FromBuffer();
DrawLastLocation();
}
function DrawLocations(g)
{
if (LocationArr.length>0)
{
for (var i=0;i<LocationArr.length-1;i++)
{
DrawLocation(g,i);
}
}
}
function DrawLastLocation()
{
if (LocationArr.length>0)
{
DrawLocation(ctx,LocationArr.length-1);
DrawBorder(ctx,LocationArr.length-1,SelLocColor);
}
}
function GetGroup(x,y)
{
var ret = GroupArr[x+':'+y];
if (ret)
{
return ret;
}
else
{
return false;
}
}
function isGroup(Loc)
{
if (Loc)
{
if (GroupArr[Loc.Left+':'+Loc.Top].length>1)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
function DrawLocation(g,i)
{
var opacity = '0.65';
var half_opacity = '0.7';
var locfontsize = 11;
if (pixel_ratio>1) {
locfontsize = 9;
}
locfontsize = locfontsize * pixel_ratio;
var cl;
var Loc = LocationArr[i];
var LocGroup;
var GroupList = GetGroup(Loc.Left,Loc.Top);
g.font = locfontsize+'px sans-serif';
if (GroupList.length>1) {
if (i==GroupList[GroupList.length-1]) { // отрисовываем последнию в списке
var color = 'rgba(0,0,0,1)';
color = color.replace('1)',opacity+')');
g.fillStyle = color;
g.fillRect(Loc.Left,Loc.Top,LocSize,LocSize);
var title;
var h = 14 * pixel_ratio;
var n = Math.floor((LocSize-h*2)/h);
var b = 0;
for (var j=GroupList.length-1;j>=0;j--) {
LocGroup = LocationArr[GroupList[j]];
title = LocGroup.Title;
g.fillStyle = Colors[LocGroup.ColorNum];
lineText(g,title,Loc.Left+4*pixel_ratio,h+Loc.Top+b*h,LocSize-8*pixel_ratio,16*pixel_ratio,16*pixel_ratio);
if (b>=n)
{
break;
}
b++;
}
var s = GroupList.length;
var w = g.measureText(s).width;
var padding = 4 * pixel_ratio;
g.fillStyle = '#E74C3C';
g.fillRect(Loc.Left+LocSize-(w+padding*2)-2*pixel_ratio,Loc.Top+LocSize-15*pixel_ratio,w+padding*2,14*pixel_ratio);
g.fillStyle = '#FFFFFF';
g.fillText(s,Loc.Left+LocSize-w-padding-2*pixel_ratio,Loc.Top+LocSize-padding-1*pixel_ratio,LocSize);
DrawBorder(g,i,'#666');
}
} else {
var error_color = 'rgba(224,130,131,1)';
var color = Colors[Loc.ColorNum];
if (Loc.ErrorLocation) {
color = error_color;
}
color = color.replace('1)',opacity+')');
g.fillStyle = color;
g.fillRect(Loc.Left,Loc.Top,LocSize,LocSize);
g.fillStyle = '#FFFFFF';
if (LocSize>LocSizeSmall) {
lineText(g,Loc.Title,Loc.Left+4*pixel_ratio,Loc.Top+14*pixel_ratio,LocSize-8*pixel_ratio,16*pixel_ratio,16*pixel_ratio);
} else {
lineText(g,Loc.Title.replace(/\s/g,'\n'),Loc.Left+4*pixel_ratio,Loc.Top+12*pixel_ratio,LocSize-8*pixel_ratio,LocSize-12*pixel_ratio,11*pixel_ratio)
}
g.font = locfontsize+'px Roboto Mono, Menlo, Monaco, Droid Sans Mono, Courier New, Courier, Lucida Console, monospace';
if (LocSize>LocSizeSmall) {
g.fillStyle = '#FFFFFF';
lineText(g,Loc.Text.trim(),Loc.Left+4*pixel_ratio,Loc.Top+31*pixel_ratio,LocSize-8*pixel_ratio,LocSize-34*pixel_ratio,12*pixel_ratio);
}
DrawBorder(g,i,Colors[Loc.ColorNum]);
}
}
function DrawBorder(g,i,cl)
{
var Loc = LocationArr[i];
g.strokeStyle = cl;
g.lineWidth = 2*pixel_ratio;
g.beginPath();
g.rect(Loc.Left+1,Loc.Top+1,LocSize-2,LocSize-2);
g.stroke();
}
function DrawLines(move)
{
var cl, x1, y1, x2, y2;
var coords = [];
var coord = '';
for (var i=0;i<LocationArr.length;i++) {
var Loc = LocationArr[i];
for (var j=0;j<Loc.Links.length;j++) {
if (!move || (i==LocationArr.length-1 && !isGroup(Loc)) ) {
var LocTarget = GetLocByTitle(Loc.Links[j]);
if ( LocTarget && !(Loc.Left==LocTarget.Left && Loc.Top==LocTarget.Top) ) {
x1 = LocTarget.Left+LocSize/2;
y1 = LocTarget.Top+LocSize/2;
x2 = Loc.Left+LocSize/2;
y2 = Loc.Top+LocSize/2;
coord = [x1,y1,x2,y2].join(';');
if (coords.indexOf(coord)==-1) {
coords.push(coord);
if (i==LocationArr.length-1 && SelectedLocation!=-1 && !isGroup(Loc)) {
cl = SelLocColor;
} else {
cl = Colors[Loc.ColorNum];
}
ctx.strokeStyle = cl;
ctx.fillStyle = cl;
DrawOtr(isShowArcs,x1,y1,x2,y2);
}
}
}
}
}
}
function lineText(context,text,marginLeft,marginTop,maxWidth,maxHeight,lineHeight)
{
var lines = text.split('\n');
var line_n = 0;
var maxLines = Math.floor(maxHeight/lineHeight);
var maxCharsInLine = Math.floor(maxWidth/context.measureText('e').width)+1;
for (var l=0; l<lines.length; l++) {
if (line_n>maxLines) {
break;
}
var line = RTrim(lines[l]).replace(/\t/g,'  ');
line = line.replace(/^(\s*?)\\/,'$1❚');
if (line!='') {
if (line.length>maxCharsInLine) {
line = line.substr(0,maxCharsInLine-1)+'…';
}
context.fillText(line, marginLeft, marginTop, maxWidth);
marginTop += lineHeight;
line_n++;
}
}
}
function ArrangeButton()
{
var str = '';
if (!EditorVisible)
{
if (LocationArr.length>0)
{
str += "<div class='menu_item' id='item1'>"+Lang.MenuArrangeByTitle+"</div>";
str += "<div class='menu_item' id='item2'>"+Lang.MenuArrangeByColor+"</div>";
str += "<div class='menu_item' id='item3'>"+Lang.MenuArrangeBySize+"</div>";
}
str += "<div class='menu_item' id='item5'>"+Lang.ThemeEdit+"</div>";
if (LocationArr.length>0)
{
str += "<div class='menu_item' id='item6'>"+Lang.FilesList+"</div>";
if (maincanvas_w>=MinimalWidth)
{
str += "<div style='margin-top:10px;'><span class='button' id='item7' style='float:left;'>"+Lang.MenuArrangeZoomOut+"</span><span class='button' id='item8' style='float:right;'>"+Lang.MenuArrangeZoomIn+"</span></div><div style='clear:both;'></div>";
}
}
}
else
{
str += "<div class='menu_item' id='item12'>"+Lang.SwitchTheme+"</div>";
var sc = Lang.OnColorMode;
if (ColorMode) {
sc = Lang.OffColorMode;
}
str += "<div class='menu_item' id='item13'>"+sc+"</div>";
str += "<div style='margin-top:10px;'><span class='button' id='item14' style='float:left;'>"+Lang.MenuArrangeZoomOut+"</span><span class='button' id='item15' style='float:right;'>"+Lang.MenuArrangeZoomIn+"</span></div><div style='clear:both;'></div>";
}
mywindow_inner.innerHTML = str;
SetEvent('item1',function(){ShowWind(false);Arrange(1);});
SetEvent('item2',function(){ShowWind(false);Arrange(2);});
SetEvent('item3',function(){ShowWind(false);Arrange(3);});
SetEvent('item5',function(){ShowWind(false);ThemeEditor();});
SetEvent('item6',function(){FileDataWind('all',false);});
SetEvent('item7',function(){ChangeZoom(false);});
SetEvent('item8',function(){ChangeZoom(true);});
SetEvent('item9',function(){AreYouSure(ArrangeEditor,Lang.ArrangeByTitle);});
SetEvent('item12',function(){ShowWind(false);DarkModeSwitch();});
SetEvent('item13',function(){ShowWind(false);ColorModeSwitch();});
SetEvent('item14',function(){FontSize(false);});
SetEvent('item15',function(){FontSize(true);});
ShowWind(true);
}
function ArrangeEditor()
{
EditrSave();
Arrange(1,true);
EditrReload();
}
function ArrangeByName()
{
Arrange(1);
}
function Arrange(SortType,nopaint)
{
var LocTitle = [];
var LocNum = [];
var LocNum2 = [];
var LocTextLen = [];
var N = LocationArr.length-1;
if (!SortType || SortType==0)
{
for (var i=0;i<=N;i++)
{
LocNum.push(i);
}
}
if (SortType==1 || SortType==2)
{
for (var i=0;i<=N;i++)
{
LocTitle.push(LocationArr[i].Title);
LocNum.push(i);
}
array_multisort(LocTitle,LocNum,'SORT_NUMERIC');
var LocTitle = [];
}
if (SortType==2)
{
for (var j=0;j<Colors.length;j++)
{
for (var i=0;i<=N;i++)
{
if (LocationArr[LocNum[i]].ColorNum==j)
{
LocNum2.push(LocNum[i]);
}
}
}
LocNum = LocNum2;
}
if (SortType==3)
{
for (var i=0;i<=N;i++)
{
LocTextLen.push(LocationArr[i].Text.length);
LocNum.push(i);
}
array_multisort(LocTextLen,LocNum,'SORT_NUMERIC');
LocTextLen = [];
LocNum.reverse();
}
var LocationArrSorted = [];
for (var i=0;i<LocNum.length;i++)
{
LocationArrSorted.push(LocationArr[LocNum[i]]);
}
LocationArr = LocationArrSorted;
var x = Cell;
var y = Cell;
var spacing  = LocSize + Cell*2;
var in_line  = Math.floor(canvasWrap_w*pixel_ratio/spacing); // штук в строке
var in_col   = Math.floor(maincanvas_h/spacing); // штук в колонке
var in_group = Math.ceil(N/(in_line*in_col));    // штук в группе
var n = 0; // номер в группе
var l = 0; // номер в строке
for (var i=0; i<=N; i++)
{
LocationArr[i].Left = x;
LocationArr[i].Top = y;
n++;
if (n>=in_group)
{
x = x + spacing;
l++;
n = 0;
}
if (l>=in_line)
{
x = Cell;
y = y + spacing;
l = 0;
}
}
if (!nopaint)
{
SelectNPaint();
}
canvasWrap.scrollLeft = 0;
canvasWrap.scrollTop = 0;
}
function GetCurLocTitle() {
return editorTitle.value.toLowerCase().trim();
}
function SaveLocation(update)
{
var loctitle = editorTitle.value.trim();
if (loctitle=='') {
return false;
}
if (NoTitle() || TitleExist(loctitle)) {
Message(Lang.BadPassageTitle);
editorTitle.focus();
return false;
}
var loctext = GetEditorText();
loctext = loctext.replace(/\r/g,'\n');
loctext = loctext.trim();
var locpos = {
scroll:   editor.scrollTop,
selstart: getInputSelection(editor).start,
sellen:   getInputSelection(editor).end-getInputSelection(editor).start,
};
var Loc;
if (editNewLoc) {
editNewLoc = false;
var x, y;
if (OverCanvas()) {
x = MouseX-LocSize/2;
y = MouseY-LocSize/2;
if (x<Cell) { x = Cell; }
if (y<Cell) { y = Cell; }
if (x+LocSize+Cell>maincanvas_w) { x = maincanvas_w-LocSize-Cell; }
if (y+LocSize+Cell>maincanvas_h) { y = maincanvas_h-LocSize-Cell; }
} else if (LocationArr.length>0) {
x = LastLocation().Left+Cell*2;
y = LastLocation().Top+Cell*2;
} else {
x = Cell;
y = Cell;
}
Loc = new Locations(loctitle,loctext,x,y,selectedColor);
LocationArr.push(Loc);
} else {
Loc = LastLocation();
Loc.Title = loctitle;
Loc.Text = loctext;
}
Loc.Pos = locpos; // скролл, позиция курсора и выделение
if (update) {
ParseAll();
SetEditorText('');
editorTitle.value = '';
UpdateFooter();
Paint();
} else {
ParseLocation(LocationArr.length-1);
}
}
function NoTitle() {
var title = GetCurLocTitle();
var text = GetEditorText().trim();
if ((title=='' && text!='' && text!='\\') || title.indexOf('"')!=-1) {
return true;
} else {
return false;
}
}
function TitleExist(s)
{
if (s.indexOf('[::]')!=-1)
{
return true;
}
s = s.toLowerCase().trim();
var n;
if (editNewLoc)
{
n = LocationArr.length;
}
else
{
n = LocationArr.length-1;
}
for (var i=0; i<n; i++)
{
if (LocationArr[i].Title.trim().toLowerCase()==s)
{
return true;
}
}
return false;
}
function CloseEditorButton()
{
OpenEditor(false);
}
function OpenEditor(show,forceOpen,forceClose,animate)
{
ShowWind(false);
if (show==false)
{
if (!forceClose) {
if (NoTitle() || TitleExist(GetCurLocTitle()))
{
Message(Lang.BadPassageTitle);
editorTitle.focus();
return false;
}
}
$('navToolText').innerHTML = Lang.Navigator;
SaveLocation(true);
LocTextBak = '';
HideBackButton();
editorBlock.style.display = 'none';
editor_buttons.style.display = 'none';
ShowLinesButton();
EditorVisible = false;
VisualEventsStart();
SelectNPaint();
editorTitle.blur();
editor.blur();
}
else
{
if (animate) {
navPanelScrollPos = undefined;
navPanel.innerHTML = '';
AnimateEditor();
}
if (EditorVisible)
{
if (NoTitle() || (editNewLoc && TitleExist(GetCurLocTitle())))
{
editorTitle.focus();
return;
}
SaveLocation(true);
AddLocation();
}
else
{
var Loc = LastLocation();
if (!forceOpen && ClickOnLoc && isGroup(Loc))
{
OpenGroup(Loc);
}
else
{
InsertMacro();
if (Loc && Loc.Title.toLowerCase().trim()=='storydata' && ClickOnLoc && LocationArr.length>0) {
FileDataWind('all',false);
return;
}
$('navToolText').innerHTML = Lang.FindInPassages;
VisualEventsStop();
editorBlock.style.display = 'block';
editor_buttons.style.display = 'inline';
show_lines.style.display = 'none';
show_arcs.style.display = 'none';
EditorVisible = true;
ShowWind(false);
if (ClickOnLoc && LocationArr.length>0)
{
editNewLoc = false;
editorTitle.value = Loc.Title;
LocTextBak = NormalizeLineEndings(Loc.Text);
if (LocTextBak.substr(-1)=='>') {
LocTextBak += ' ';
}
SetEditorText(LocTextBak);
if (Loc.Pos) {
editor.scrollTop = Loc.Pos.scroll;
}
if (!isTouchDevice) {
if (Loc.Pos) {
Select(editor,Loc.Pos.selstart,Loc.Pos.sellen);
} else {
Select(editor,0,0);
}
}
SetColorButton(Loc.ColorNum);
}
else
{
AddLocation();
}
LocationsToNavPanel(true);
}
}
ResizeEditor();
}
UpdateFooter();
}
function AnimateEditor(close)
{
if (!close) {
Animate(editorBlock,'effect_scale');
}
}
function NormalizeLineEndings(text)
{
text = text.replace(/\r/g,'\n').trim();
if (text.substr(-1)=='\\') {
text += ' ';
}
return text;
}
function OpenGroup(Loc)
{
var GroupList = GetGroup(Loc.Left,Loc.Top);
var title, color, error;
var str = "<div class='menu_no' id='item1'>"+Lang.SplitAll+"</div>";
var titles = [];
var colors = [];
var errors = [];
for (var key in GroupList)
{
title = LocationArr[GroupList[key]].Title.toLowerCase();
color = Colors[LocationArr[GroupList[key]].ColorNum];
error = LocationArr[GroupList[key]].ErrorLocation;
titles.push(title);
colors.push(color);
errors.push(error);
}
array_multisort(titles,colors,errors);
for (var key in titles)
{
title = titles[key];
color = colors[key];
error = errors[key];
str += NavMenuItem(title,color,error,true);
}
titles = [];
colors = [];
errors = [];
mywindow_inner.innerHTML = str;
SetEventsByAttr(1);
SetEventsByAttr(2,'forevent2');
SetEvent('item1',function(){ShowWind(false);SplitGroup();});
ShowWind(true);
}
function SplitGroup(title)
{
if (!title)
{
var Loc = LastLocation();
var GroupList = GetGroup(Loc.Left,Loc.Top);
var i = 0;
for (var key in GroupList)
{
Loc = LocationArr[GroupList[key]];
Loc.Left += Cell*2*i;
Loc.Top  += Cell*3*i;
i++;
}
}
else
{
var i = GetLocIndexByTitle(title);
var Loc = LocationArr[i];
var x = Loc.Left - Cell*2;
if (x<Cell)
{
x = Loc.Left + Cell*2;
}
Loc.Left = x;
var y = Loc.Top + Cell*3;
if (y>maincanvas_h-LocSize-Cell)
{
y = Loc.Top - Cell*3;
}
Loc.Top = y;
LocationArr.push(Loc);
LocationArr.splice(i,1);
}
SelectNPaint();
}
function AddLocation()
{
editNewLoc = true;
selectedColor = 0;
SetColorButton(selectedColor);
SetEditorText('\\ ');
editorTitle.value = '';
editorTitle.focus();
}
function NewLocation(title,menu)
{
if (menu) {
if (!EditorVisible) {
var s = "<div class='menu_item' id='item1'>"+Lang.PurePassage+"</div>";
s += "<div class='menu_item' id='item2'>"+Lang.CreateStoryStyle+"</div>";
s += "<div class='menu_item' id='item4'>"+Lang.FileImage+"</div>";
s += "<div class='menu_item' id='item3'>"+Lang.FileSound+"</div>";
mywindow_inner.innerHTML = s;
SetEvent('item1',function(){NewLocation();});
SetEvent('item2',function(){ShowWind(false);if(!CreateStoryStyle()){Message(Lang.StoryStyleAlready)};});
SetEvent('item3',function(){ShowWind(false);AddFileData('audio');});
SetEvent('item4',function(){ShowWind(false);AddFileData('image');});
ShowWind(true);
} else {
NewLocation();
LocationsToNavPanel(true);
}
return;
}
ClickOnLoc = false;
OpenEditor(true,true);
if (title) {
editorTitle.value = title;
editor.focus();
}
}
function RemoveLocation()
{
if (LocationArr.length>0)
{
var q;
if (EditorVisible)
{
q = Lang.AYSRemoveThisPassage;
}
else
{
var s = LastLocation().Title;
q = Lang.AYSRemovePassage+' \"'+s+'\"?';
}
AreYouSure(removeLocation,q);
}
}
function removeLocation()
{
var fromEditor = false;
if (EditorVisible) {
fromEditor = true;
if (editNewLoc) {
editorBlock.style.display = 'none';
EditorVisible = false;
VisualEventsStart();
return;
} else {
editorTitle.value = '\n[ASMnoTitle]\r'; // заведомо несуществующее название
}
OpenEditor(false);
}
LocationArr.length--;
ParseAll();
SelectNPaint();
if (fromEditor) {
OpenEditor();
}
}
function VisualEventsStart()
{
if (isTouchDevice) {
maincanvas.ontouchmove = TouchMove;
maincanvas.ontouchstart = MouseDown;
maincanvas.ontouchend = MouseUp;
}
window.onmouseup = MouseUp;
maincanvas.onmousemove = MouseMove;
maincanvas.onmousedown = function (e) {MouseDown(e);}
maincanvas.ondblclick = function() {if (OverCanvas()){OpenEditor(true,false,false,true);}}
document.body.oncontextmenu = function() {MouseUp(); ActionsMenu(); return false;}
}
function VisualEventsStop()
{
if (isTouchDevice) {
maincanvas.ontouchmove = '';
maincanvas.ontouchstart = '';
maincanvas.ontouchend = '';
}
document.onmousedown = '';
document.onmouseup = '';
document.onmousemove = '';
document.ondblclick = '';
document.body.oncontextmenu = function() {if (EditorVisible && (getFocusedId()=='editor' || getFocusedId()=='editorTitle' || getFocusedId()=='findField' || getFocusedId()=='replaceField')) {return true;} else {return false;} }
}
function confirmExit()
{
return Lang.DontForgetSave;
}
function OverCanvas()
{
if (MouseY>=0 && MouseY<=maincanvas.height)
{
return true;
}
else
{
return false;
}
}
function MoveLocation(e)
{
if (OverCanvas()) {
if (isMouseDown && SelectedLocation!=-1) {
maincanvas.style.cursor = 'move';
var x = MouseX-mouseOffsetX;
var y = MouseY-mouseOffsetY;
if (x<Cell) { x = Cell; }
if ((x+LocSize+Cell)>maincanvas_w) { x = maincanvas_w-LocSize-Cell; }
if (y<Cell) { y = Cell; }
if ((y+LocSize+Cell)>(maincanvas_h)) { y = maincanvas_h-LocSize-Cell; }
SetLocPosition(x,y);
Paint(true);
LocInfoToFooter(LastLocation());
if (isTouchDevice && e) {
e.preventDefault();
}
}
}
}
function SetLocPosition(x,y)
{
if (!x && !y)
{
return false;
}
var Loc = LastLocation();
if (!x)
{
x = Loc.Left;
}
if (!y)
{
y = Loc.Top;
}
x = Math.round(x / Cell) * Cell;
y = Math.round(y / Cell) * Cell;
var GroupList = GetGroup(Loc.Left,Loc.Top);
if (GroupList.length>1)
{
for (var i=0;i<GroupList.length;i++)
{
LocationArr[GroupList[i]].Left = x;
LocationArr[GroupList[i]].Top =  y;
}
}
else
{
Loc.Left = x;
Loc.Top =  y;
}
}
function MouseMove(event)
{
event = fixEvent(event);
MouseX = (event.pageX+canvasWrap.scrollLeft)*pixel_ratio;
MouseY = (event.pageY-toolbarH+canvasWrap.scrollTop)*pixel_ratio;
MoveLocation();
}
function TouchMove(e)
{
if (e.targetTouches.length==1)
{
var touch = event.targetTouches[0];
MouseX = (touch.pageX+canvasWrap.scrollLeft)*pixel_ratio;
MouseY = (touch.pageY-toolbarH+canvasWrap.scrollTop)*pixel_ratio;
MoveLocation(event);
}
}
var mylatesttap = 0;
var myprevtapX = 0;
var myprevtapY = 0;
function DoubleTap(mylasttapX,mylasttapY)
{
var now = new Date().getTime();
var timesince = now - mylatesttap;
mylatesttap = now;
if ( timesince<=500 && timesince>0 && Math.abs(mylasttapX-myprevtapX)<22 && Math.abs(mylasttapY-myprevtapY)<22 )
{
isMouseDown = false;
myprevtapX = 0;
myprevtapY = 0;
return true;
}
else
{
myprevtapX = mylasttapX;
myprevtapY = mylasttapY;
return false;
}
}
function RightClick(e)
{
var isRightMB;
e = e || window.event;
if ("which" in e)  // Gecko (Firefox), WebKit (Safari/Chrome) & Opera
{
isRightMB = e.which == 3;
}
else if ("button" in e)  // IE, Opera
{
isRightMB = e.button == 2;
}
if (!isRightMB)
{
return false;
}
else
{
return true;
}
}
function MouseDown(e)
{
if (!RightClick(e))
{
isMouseDown = true;
}
if (isTouchDevice)
{
if (e.targetTouches.length==1 && OverCanvas() && DoubleTap(e.targetTouches[0].pageX,e.targetTouches[0].pageY))
{
OpenEditor(true,false,false,true);
return false;
}
TouchMove(e);
}
if (OverCanvas())
{
var i = 0;
var GroupList = [];
for (var i=LocationArr.length-1; i>=0; i--)
{
Loc = LocationArr[i];
if (MouseX>=Loc.Left && MouseX<=(Loc.Left+LocSize) && MouseY>=Loc.Top && MouseY<=(Loc.Top+LocSize))
{
mouseOffsetX = MouseX - Loc.Left;
mouseOffsetY = MouseY - Loc.Top;
ClickOnLoc = true;
LocationArr.push(Loc);
LocationArr.splice(i,1);
SelectedLocation = LocationArr.length-1;
LocInfoToFooter(Loc);
Paint(true);
break;
}
else
{
ClickOnLoc = false;
SelectedLocation = -1;
}
}
return;
}
ClickOnLoc = false;
}
function MouseUp()
{
maincanvas.style.cursor = 'default';
isMouseDown = false;
if (OverCanvas())
{
SelectNPaint();
}
SelectedLocation = -1;
prevLastLocGroup = '';
UpdateFooter();
}
function AreYouSure(func,text)
{
if (!text) {
text = Lang.AreYouSure;
}
text += "<div style='margin-top:20px;'><span class='button' id='item1' style='float:left;'>"+Lang.NO+"</span><span class='button' id='item2' style='float:right;'>"+Lang.YES+"</span></div>";
mywindow_inner.innerHTML = text;
SetEvent('item1',function(){ShowWind(false);});
SetEvent('item2',function(){ShowWind(false);func();});
ShowWind(true);
}
function AlertMessage(text,callback)
{
text += "<div style='margin-top:20px;'><span class='button' id='item1'>OK</span></div>";
mywindow_inner.innerHTML = text;
if (!callback) {
SetEvent('item1',function(){ShowWind(false);});
} else {
SetEvent('item1',function(){ShowWind(false);callback();});
}
ShowWind(true);
}
function keysPreventDefault(event)
{
if (WindowVisible)
{
var curtag = getFocusedTag();
if (curtag!='input' && curtag!='textarea')
{
event.preventDefault();
}
}
}
function keysPress(event)
{
if (!EditorVisible && !WindowVisible && !PreviewVisible && !PlateVisible)
{
if (!event.ctrlKey && !event.metaKey)
{
var k = GetKeyCode(event);
if ( (k>=48 && k<=57) || (k>=65 && k<63232) || k>63277 || k==60 || k==62 || k==36 )
{
event.preventDefault();
lastSearchQuery = String.fromCharCode(k);
Navigator(true);
}
}
}
}
function keysUp(event)
{
keysPreventDefault(event);
var k = GetKeyCode(event);
if (!PreviewVisible)
{
if (k==27)
{
if (WindowVisible)
{
ShowWind(false);
}
else if (PlateVisible)
{
ShowPlate(false);
}
else if (EditorVisible)
{
CloseEditorButton();
}
}
if (k==115)
{
event.preventDefault();
event.returnValue = false;
}
}
else
{
if (k==27)
{
ClosePreview();
}
}
}
function keys(event)
{
keysPreventDefault(event);
if (PlateVisible && !WindowVisible)
{
event.preventDefault();
event.cancelBubble = true;
event.returnValue = false;
return false;
}
if (!PreviewVisible)
{
var k = GetKeyCode(event);
if (k==27)
{
event.preventDefault();
event.cancelBubble = true;
event.returnValue = false;
return false;
}
if (!EditorVisible && !WindowVisible && k==32)
{
event.preventDefault();
ClickOnLoc = true;
OpenEditor(true,false,false,true);
}
if (k==46 || k==8)
{
if (!EditorVisible && !WindowVisible) {
if (!isGroup(LastLocation())) {
RemoveLocation();
} else {
Message(Lang.UnableRemoveGroup);
}
} else if (EditorVisible && k==8 && (event.ctrlKey || event.metaKey || event.shiftKey)) {
event.preventDefault();
EditrBack();
}  else if (k==8 && getFocusedId()=='editor') {
EnterKeyPress(event,false,true);
}
}
if (k==13 && !(event.shiftKey))
{
if (getFocusedId()=='editorTitle') {
RestoreCaret();
event.preventDefault();
} else if (getFocusedId()=='editor' && !WindowVisible) {
EnterKeyPress(event,true);
} else if (WindowVisible && MenuItemsList.length>0) {
MenuItemsList[SelectedMenuItemNum].dispatchEvent(new CustomEvent('click'));
event.preventDefault();
}
}
if (k==9)
{
event.preventDefault();
event.returnValue = false;
if (WindowVisible)
{
MenuItemNext();
}
else if (!EditorVisible)
{
if (event.shiftKey)
{
if (LocationArr.length>0)
{
var i = 0;
LocationArr.push(LocationArr[i]);
LocationArr.splice(i,1);
SelectNPaint();
}
}
else
{
Navigator();
}
}
else if (EditorVisible && getFocusedId()=='editorTitle')
{
RestoreCaret();
}
else if (EditorVisible && getFocusedId()=='editor')
{
var selData = GetSelection(editor);
var currentLen = selData['end']-selData['start'];
if (currentLen>0)
{
FormatText();
}
else
{
AutoDop(event);
}
}
}
if (k==40)
{
if (WindowVisible)
{
event.preventDefault();
event.returnValue = false;
MenuItemNext();
}
}
if (k==38)
{
if (WindowVisible)
{
event.preventDefault();
event.returnValue = false;
MenuItemPrev();
}
}
if (k==220)
{
if (EditorVisible && getFocusedId()=='editor') {
EnterKeyPress(event);
}
}
if (k==112)
{
event.preventDefault();
event.returnValue = false;
Help();
}
if ((event.ctrlKey || event.metaKey) && k==83)
{
event.preventDefault();
event.returnValue = false;
SaveStoryButton();
}
if ((event.ctrlKey || event.metaKey) && k==79)
{
event.preventDefault();
event.returnValue = false;
SelectStory();
}
if ((event.ctrlKey || event.metaKey) && k==78)
{
event.preventDefault();
event.returnValue = false;
NewGameButton();
}
if ((event.ctrlKey || event.metaKey) && k==77)
{
if (EditorVisible && navPanel2.offsetWidth==0)
{
event.preventDefault();
event.returnValue = false;
InsertMacro();
}
}
if ((event.ctrlKey || event.metaKey) && k==73)
{
if (EditorVisible)
{
event.preventDefault();
event.returnValue = false;
InsertPicture();
}
}
if ((event.ctrlKey || event.metaKey) && k==66)
{
event.preventDefault();
event.returnValue = false;
Publish();
}
if ((event.ctrlKey || event.metaKey) && k==65 && !EditorVisible)
{
event.preventDefault();
event.returnValue = false;
ArrangeButton();
}
if (!event.shiftKey && (((event.ctrlKey || event.metaKey) && k==82) || k==116))
{
event.preventDefault();
event.returnValue = false;
if (!EditorVisible)
{
CompileButton();
}
else
{
CompilePassage();
}
}
if (EditorVisible && (((event.ctrlKey || event.metaKey) && event.shiftKey && k==82) || event.shiftKey && k==116))
{
event.preventDefault();
event.returnValue = false;
CompileButton();
}
if ((event.ctrlKey || event.metaKey) && k==80)
{
event.preventDefault();
event.returnValue = false;
NewLocation();
}
if ((event.ctrlKey || event.metaKey) && k==75)
{
if (EditorVisible && getFocusedId()=='editor')
{
event.preventDefault();
event.returnValue = false;
CommentText();
}
}
if ((event.ctrlKey || event.metaKey) && k==70)
{
if (!EditorVisible)
{
event.preventDefault();
event.returnValue = false;
Navigator(true);
}
else
{
event.preventDefault();
event.returnValue = false;
FindNReplace();
}
}
if (((event.ctrlKey || event.metaKey) && k==71) || k==114)
{
if (EditorVisible)
{
event.preventDefault();
event.returnValue = false;
EditorFindNext();
}
}
if ((event.ctrlKey || event.metaKey) && k==72)
{
if (EditorVisible)
{
event.preventDefault();
event.returnValue = false;
EditorReplaceNext();
}
}
if ((event.ctrlKey || event.metaKey) && k==76)
{
if (EditorVisible)
{
event.preventDefault();
event.returnValue = false;
EditrGotoLink();
}
}
if ((event.ctrlKey || event.metaKey) && k==68)
{
event.preventDefault();
event.returnValue = false;
if (EditorVisible)
{
AddText(3);
}
else
{
DuplicateLocation();
}
}
if ((event.ctrlKey || event.metaKey) && k==90)
{
if (!EditorVisible)
{
event.preventDefault();
event.returnValue = false;
}
}
if ((event.ctrlKey || event.metaKey) && k==221)
{
if (EditorVisible && getFocusedId()=='editor')
{
event.preventDefault();
event.returnValue = false;
AddText(1);
}
}
if ((event.ctrlKey || event.metaKey) && k==219)
{
if (EditorVisible && getFocusedId()=='editor')
{
event.preventDefault();
event.returnValue = false;
AddText(2);
}
}
if ((event.ctrlKey || event.metaKey) && (k==187 || k==107))
{
event.preventDefault();
event.returnValue = false;
if (EditorVisible)
{
FontSize(true);
}
else
{
if (maincanvas_w>=MinimalWidth)
{
ChangeZoom(true);
}
}
}
if ((event.ctrlKey || event.metaKey) && (k==189 || k==109))
{
event.preventDefault();
event.returnValue = false;
if (EditorVisible)
{
FontSize(false);
}
else
{
ChangeZoom(false);
}
}
if (event.shiftKey && k==13)
{
if (EditorVisible)
{
event.preventDefault();
event.returnValue = false;
InsertText('<br>',true);
}
}
}
}
function SelectNPaint(move) {
SelectedLocation = LocationArr.length-1;
Paint(move);
SelectedLocation = -1;
}
function CompileButton() {
Message(Lang.PleaseWait,true);
setTimeout (function() { Compile(true,-1); }, 1);
}
function CompilePassage() {
ClosePreview();
if (NoTitle() || TitleExist(GetCurLocTitle())) {
Message(Lang.BadPassageTitle);
editorTitle.focus();
return false;
}
Compile(true,LocationArr.length-1);
}
function Modules() {
Message(Lang.ListLoading,true);
loadData(CommandServer('com=modules',true),function(Data) {
MessageHide();
if (Data=="none") {
Message(Lang.NoModules);
} else if (Data) {
var list = JSON.parse(Data.trim());
var str = '';
for (var i in list) {
var mod = list[i];
str += "<div style='clear:both;margin:1em 0 0.5em 0;' class='accent'>"+mod["title_"+LangCode]+"&nbsp;"+mod.version+"</div>";
var s = Lang.LoadModule;
var cost = mod["cost_"+LangCode];
if (cost>0) {
s = Lang.BuyModule;
}
str += "<div class='menu_item' forevent='"+mod.id+"'>"+s+'</div>';
if (mod.example) {
str += "<div class='menu_item' forevent2='"+mod.id+"'>"+Lang.ExampleModule+'</div>';
}
if (!cost>0) {
str += "<div class='menu_item' forevent3='"+mod.id+"'>"+Lang.DownloadModule+'</div>';
}
}
mywindow_inner.innerHTML = str;
SetEventsByAttr(18);
SetEventsByAttr(19,'forevent2');
SetEventsByAttr(20,'forevent3');
ShowWind(true);
} else {
Message(Lang.Error2);
}
});
}
function ModuleLoad(mod_id) {
Message(Lang.Loading,true);
loadData(CommandServer('com=module&value='+mod_id,true),function(Data) {
MessageHide();
if (Data) {
LoadStory(false,true,Data,true,true);
} else {
Message(Lang.ErrorLoadFile);
}
});
}
function Help(item) {
if (item==1) {
var helpWin = WindowOpen('account/');
} else if (item==2) {
var helpWin = WindowOpen(LangCode+'/manual/');
} else if (item==3) {
var helpWin = WindowOpen('library/');
} else if (item==4) {
var helpWin = WindowOpen('download/');
} else if (item==5) {
QuickStart();
} else {
var str = '';
if (GetURLHashVar('Develop')) {
str += "<div class='menu_item' id='item0'>"+Lang.MenuRestart+"</div>";
}
str += "<div class='menu_item' id='item1'>"+Lang.MenuQuickStart+"</div>";
str += "<div class='menu_item' id='item2'>"+Lang.MenuUserManual+"</div>";
str += "<div class='menu_item' id='item3'>"+Lang.MenuProfile+"</div>";
str += "<div class='menu_item' id='item4'>"+Lang.MenuToLibrary+"</div>";
if (TargetBrowser) {
str += "<div class='menu_item' id='item5'>"+Lang.MenuDesktopVersion+"</div>";
} else {
str += "<div class='menu_item' id='item6'>"+Lang.ChangeLang+"</div>";
}
mywindow_inner.innerHTML = str;
SetEvent('item0',function(){location.reload();});
SetEvent('item1',function(){ShowWind(false);Help(5);});
SetEvent('item2',function(){ShowWind(false);Help(2);});
SetEvent('item3',function(){ShowWind(false);Help(1);});
SetEvent('item4',function(){ShowWind(false);Help(3);});
SetEvent('item5',function(){ShowWind(false);Help(4);});
if (TargetChromeApp) {
SetEvent('item6',function() {
AreYouSure(chrome_ChangeLanguage,Lang.AppWillBeRestarted);
});
}
ShowWind(true);
}
}
var messageTimeOut;
function Message(text,noHide,noAnimate) {
text = text.toString();
text = text.trim();
if (text!='') {
clearTimeout(messageTimeOut);
message.innerHTML = text;
message.style.display = 'block';
if (!noAnimate) {
Animate(message,'effect_scale_fast');
}
if (!noHide) {
messageTimeOut = setTimeout(MessageHide, 2000);
}
}
}
function MessageHide()
{
message.style.display = 'none';
}
function Account()
{
var profileWin = WindowOpen('/account/');
}
function SaveStoryButton(dialog)
{
if (!TargetDesktop && fileNum==0)
{
AreYouSure(SaveStory,Lang.AYSSaveNewStory);
}
else
{
SaveStory(dialog);
}
}
function SaveStory(dialog,cloudexport)
{
if (!TargetDesktop)
{
ToBackup();
}
if (EditorVisible)
{
SaveLocation(false);
}
var Data = CreateSaveData();
if (TargetDesktop)
{
if (!cloudexport)
{
var com = 'SaveStory';
if (dialog)
{
com = 'SaveStoryDialog';
}
chrome_Save(com,Data);
return;
}
else
{
fileNum = 0;
}
}
if (navigator.onLine)
{
Message(Lang.Saving,true);
saveData(CommandServer('com=save&value='+fileNum),Data,function(response) {
Data = '';
if (response=='register') {
Message(Lang.NeedSignIn);
SignInWindow(function(){
SaveStory(dialog,cloudexport);
});
} else if (response!='') {
fileNum = parseInt(response,10);
SetPrefValue('fileNum',fileNum);
UpdateOnlineTitle();
Message(Lang.Saved);
}
});
}
else
{
Message(Lang.NeedOnline);
}
}
function CreateSaveData(woInfo,woSpecial)
{
var Data = '';
var Separator = '[::]';
if (!woInfo) {
Data = 'ASMJS'+Separator+LocSize/pixel_ratio+Separator+'0'+Separator+'0'+Separator+style_current_theme+Separator+style_view+Separator+TargetFormat+'\n';
}
for (var key in LocationArr) {
var Location = LocationArr[key];
if (woSpecial) {
var arr = ['storystyle','storystyle.bak','storydata'];
if (arr.indexOf(Location.Title.toLowerCase().trim())!=-1) {
continue;
}
}
Data = Data + ":: " + Location.Title;
if (!woInfo) {
Data = Data + Separator + Location.Left/pixel_ratio + "-" + Location.Top/pixel_ratio + "-" + Location.ColorNum;
}
Data = Data + '\n';
var LocText = Location.Text.replace(/\r/g,'\n');
Data = Data + RTrim(LocText) + '\n\n';
}
return Data;
}
function LoadStory(fn,merge,Data,noJSConvert,module)
{
if (EditorVisible) {
OpenEditor(false,false,true);
}
var parseFile = function(fn,merge,Data) {
if (Data!='') {
if (!merge) {
fileNum = fn;
SetPrefValue('fileNum',fileNum);
lastSearchQuery = '';
EditrFindField = '';
EditrReplaceField = '';
LocationArr.length = 0; // удаляем текущие локации
}
var Separator = '[::]';
Data = Data.replace(/\r/g,'\n');
var DataArr = Data.split('\n');
var Title = '';
for (var i=0; i<DataArr.length; i++) {
if (i==0) {
var PrefsArr = DataArr[0].trim().split(Separator);
var signature = PrefsArr.shift();
if (signature!='ASMJS') {
PrefsArr.unshift(signature);
signature = false;
AlertMessage(Lang.OldFormat);
}
if (PrefsArr.length>1 && !isNaN(+PrefsArr[0])) {
if (!merge) {
LocSize = parseInt(PrefsArr[0],10)*pixel_ratio;
if (LocSize<LocSizeMin) {
LocSize = LocSizeMin;
}
if (LocSize>LocSizeMax) {
LocSize = LocSizeMax;
}
if (!LocSize) {
LocSize = LocSizeDefault;
}
style_current_theme = parseInt(PrefsArr[3],10);
if (isNaN(+style_current_theme) || style_current_theme<0 || style_current_theme>=style_themes.length) {
style_current_theme = 0;
}
SetTheme(style_current_theme);
if (PrefsArr[4]=='true') {
style_view = 'sw';
} else if (PrefsArr[4]=='false') {
style_view = 'mw';
} else {
style_view = PrefsArr[4];
}
if (PrefsArr[5]=='audio') {
TargetFormat = 'audio';
} else {
TargetFormat = 'html';
}
if (TargetNovels) {
style_view = 'vis';
TargetFormat = 'html';
style_current_theme = 10;
}
}
continue;
}
}
var line = DataArr[i];
if (line.trim().substr(0,2)=="::") {
var TitleArr = line.trim().split(Separator);
if (TitleArr.length<2) {
TitleArr.push('0-0-0');
}
Title = TitleArr[0].substr(2).trim();
TitleArr = TitleArr[1].trim().split('-');
if (module && Title.substr(0,1)!='$') {
continue; // если модуль, загружать только параграфы с $
}
if (merge && GetLocByTitle(Title)) {
if (module) {
var newTitle = Title + '.bak';
while (GetLocByTitle(newTitle)) {
newTitle += '.bak';
}
GetLocByTitle(Title).Title = newTitle;
} else {
Title += ' 2';
while (GetLocByTitle(Title)) {
Title += ' 2';
}
}
}
var x, y, color;
x = TitleArr[0];
if (!isNaN(+x)) {
x = parseInt(x,10)*pixel_ratio;
} else {
x = Cell;
}
y = TitleArr[1];
if (!isNaN(+y)) {
y = parseInt(y,10)*pixel_ratio;
} else {
y = Cell;
}
color = TitleArr[2];
if (!isNaN(+color)) {
color = parseInt(color,10);
} else {
color = 0;
}
if (module) {
x = Cell*2;
y = Cell*2;
}
LocationArr.push(new Locations(Title,'',x,y,color,false,[]));
} else {
if (module && Title.substr(0,1)!='$') {
continue; // если модуль, загружать только параграфы с $
}
if (LocationArr.length>0) {
line = RTrim(line);
if (!signature && line.trim()!='') {
if (!noJSConvert) {
line = ConvertLineToASMJS(line,Title);
}
}
LastLocation().Text = LastLocation().Text+line+'\n';
}
}
}
if (LocationArr.length<1) {
CreateDefaultPassage(Data);
} else {
Message(Lang.Loaded);
}
Data = '';
ParseAll();
UpdateFooter();
ResizeCanvas();
CanvasToTop();
UpdateOnlineTitle();
return true;
} else {
return false;
}
}
if (!Data) {
if (navigator.onLine) {
SelectedLocation = -1;
Message(Lang.Loading,true);
loadData(CommandServer('com=load&value='+fn),function(Data) {
if (TargetChromeApp && !merge) {
chrome_SetCurrentEntry('');
}
Data = Data.trim();
if (Data) {
parseFile(fn,merge,Data);
if (GetURLHashVar('Run') && !merge) {
CompileButton();
}
} else {
Message(Lang.ErrorLoadFile);
NewGame();
}
});
} else {
Message(Lang.NeedOnline);
}
return;
}
parseFile(fn,merge,Data);
}
function ConvertLineToASMJS(line,title) {
var tab = '';
if (!SimpleLocation(title)) {
var myRe;
for (var i in SysVars) {
var repl = '\\$\\$'+SysVars[i];
myRe = new RegExp(repl,'g');
line = line.replace(myRe,'$$$$$'+SysVars[i]);
}
myRe = new RegExp("\\$([^"+BadVarsSymbs+"]+?["+BadVarsSymbs+"])",'g');
line = line.replace(myRe,'$1');
line = line.replace(/([^:]|^)\/\/(.*?(?!\/\/).*?)\/\//g,'$1<i>$2</i>'); // наклонный
line = line.replace(/{{{((.*?(?!{{{).*?))}}}/g,'<tt>$1</tt>'); // моноширинный
line = ReplaceInText(line,"''","\"\"","<<",">>"); // жирный
line = line.replace(/''(.*?(?!'').*?)''/g,'<b>$1</b>');
line = line.replace(/__((.*?(?!__).*?))__/g,'<u>$1</u>'); // подчёркнутый
line = line.replace(/===((.*?(?!===).*?))===/g,'<center>$1</center>'); // центрированный
line = line.replace(/@@@((.*?(?!@@@).*?))@@@/g,'<right>$1</right>'); // по правому краю
line = line.replace(/%%%((.*?(?!@@@).*?))%%%/g,'<h1>$1</h1>'); // заголовок
line = line.replace(/<<\s*br\s*>>/g,'<br>'); // <br>
line = line.replace(/~~((.*?(?!~~).*?))~~/g,'<sub>$1</sub>'); // sub
line = line.replace(/\^\^((.*?(?!\^\^).*?))\^\^/g,'<sup>$1</sup>'); // sup
line = line.replace(/^\s*?----\s*?$/gm,"<hr>"); // линия
line = line.replace(/^\s*?\*\*\*\s*?$/gm,'<center>***</center>'); // ***
line = line.replace(/--/g,'—'); // тире
line = line.replace(/^\s*?[*]\s+?(.+?)$/gm,'<li>$1</li>'); // список
line = line.replace(/^\s*?#/,'//');
line = line.replace(/\[\[\s*?(файл|file)\s*?:\s*?([^\s]*?)\.(png|gif|jpg|jpeg)\s*?\]\]/gi,"<img src='$2.$3'>");
tab = line.match(/^\s+/);
if (tab) {
tab = tab[0];
} else {
tab = '';
}
if (/^\s*?\/\//.test(line)) {
} else if (/<<.*?>>/.test(line)) {
var splitter = '<@\t#@#_@>';
myRe = new RegExp('(<<.*?>>)','g');
line = line.replace(myRe,splitter+'$1'+splitter);
var lineArr = line.split(splitter);
var formatMacro = function(s,macro,begin,end) {
macroRe = new RegExp('^'+macro,'i');
var ret = s;
if (macroRe.test(s)) {
ret = s.replace(macro,'').trim();
var errRet = '/* '+s+' */';
if (macro=='choice') {
ret = ret.replace(/'/g,'"').replace(/;/g,'","');
ret = ret.replace(/("\s+?|\s+?")/g,'"');
} else if (macro=='random') {
ret = ret.split('=',2);
if (ret.length==2) {
ret = ret[0].trim()+' = random('+ret[1].trim()+')';
} else {
ret = errRet;
}
} else if (macro=='tab') {
ret = 'print(tab('+ret.trim()+'))';
} else if (macro=='repeat') {
ret = ret.replace(/\s+?(\d+?)$/,',$1');
ret = ret;
} else if (macro=='fade') {
ret = ret.replace(/\s/,'').replace('=','');
} else if (macro=='input') {
var retArr = ret.split(/['"]\s+?/);
if (retArr.length>0) {
ret = retArr[0].replace(/['"]/,'');
ret = 'input("'+ret+'");';
} else {
ret = errRet;
}
} else if (macro=='back' || macro=='return') {
var title = '"'+Lang.Back+'"';
if (ret) {
title = ret;
}
ret = 'print(back('+title+',false));';
} else if (macro=='restart') {
var title = '"'+Lang.HTMLRestart+'"';
if (ret) {
title = ret;
}
ret = 'print(restart('+title+',false));';
} else if (macro=='loop') {
ret = 'for(var counter=1; counter<='+ret+'; counter++) {';
} else if (macro=='row') {
var border = true;
if (/noborder$/.test(ret)) {
ret = ret.replace(/noborder$/,'');
border = false;
}
ret = ret.replace(/"/g,"'");
var spl = '\t;\t';
var ret = ret.replace(/('[^']*?')+?/g,function(match,p1) {
p1 = p1.replace(/'/g,'').replace(/$/g,spl);
return p1;
});
ret = ret.replace(new RegExp(spl+'$',''),'');
retArr = ret.split(spl,2);
var tclass = 'trow';
if (!border) {
tclass = 'trow_nb';
}
ret = "print('<table class=\""+tclass+"\"><tr>";
for (var i=0; i<retArr.length; i++) {
tclass = '';
if (i==1 && border) {
tclass = ' class="rcol"';
}
ret += '<td'+tclass+' width="'+(100/retArr.length)+'%">'+retArr[i].trim()+'</td>';
}
ret += "</tr></table>');";
} else if (macro=='class') {
ret = ret.replace(/"/g,"'");
ret = 'print("<span class='+ret+'>");';
} else if (macro=='picture') {
ret = ret.replace(/<img src='(.+?)'>/,"$1");
} else if (macro=='if' || macro=='elseif') {
ret = ret.replace(/\s+?eq\s+?/g,"==");
ret = ret.replace(/\s+?neq\s+?/g,"!=");
ret = ret.replace(/<>/g,"!=");
ret = ret.replace(/\s+?lt\s+?/g,"<");
ret = ret.replace(/\s+?gt\s+?/g,">");
ret = ret.replace(/\s+?lte\s+?/g,"<=");
ret = ret.replace(/\s+?gte\s+?/g,">=");
ret = ret.replace(/\s+?and\s+?/g," && ");
ret = ret.replace(/\s+?or\s+?/g," || ");
ret = ret.replace(/not\s*?/g,"!");
} else if (macro=='delete') {
if (ret != '') {
var i = ret.search(/\s+?\d+?$/);
var time = '';
if (i!=-1) {
time = ret.substr(i).trim();
}
ret = errRet+'\n'+'//sprite_?????.hide('+time+');';
} else {
ret = 'sprites(true);';
}
} else if (macro=='sprite') {
var retArr = ret.split(',');
if (retArr.length>0) {
var name = 'sprite_'+random(10000,99999);
ret = name+' = sprite('+retArr[0].trim()+');\n'; // path
var retParam = function(param,title,onlyReturn) {
if (param!==undefined) {
param = param.trim();
if (param=='' || param=='@') { // по умолчанию
if (title=='left' || title=='right' || title=='top' || title=='bottom') {
param = 0;
} else {
param = 'true';
}
}
if (onlyReturn) {
return param;
} else {
return name+'.'+title+' = '+param+';\n';
}
} else {
return '';
}
};
var origin = retParam(retArr[6],'',true)+0; // угол
if (isNaN(origin) || origin<1){
origin = 1;
} else if (origin>4){
origin = 4;
}
if (origin==1) {
ret += retParam(retArr[1],'left'); // x
ret += name+'.right = 0;\n';
ret += retParam(retArr[2],'top'); // y
ret += name+'.bottom = true;\n';
} else if (origin==2) {
ret += retParam(retArr[1],'right'); // x
ret += name+'.left = 0;\n';
ret += retParam(retArr[2],'top'); // y
ret += name+'.bottom = true;\n';
} else if (origin==3) {
ret += retParam(retArr[1],'left'); // x
ret += name+'.right = 0;\n';
ret += retParam(retArr[2],'bottom'); // y
ret += name+'.top = true;\n';
} else if (origin==4) {
ret += retParam(retArr[1],'right'); // x
ret += name+'.left = 0;\n';
ret += retParam(retArr[2],'bottom'); // y
ret += name+'.top = true;\n';
}
ret += retParam(retArr[3],'width'); // ширина
ret += retParam(retArr[4],'height'); // высота
ret += retParam(retArr[5],'opacity'); // прозрачность
ret += retParam(retArr[8],'action'); // параграф
var time = retParam(retArr[7],'',true); // время
ret += name+'.show('+time+');\n'; // показать спрайт
} else {
ret = errRet;
}
}
if (begin) {
ret = begin + ret;
}
if (end) {
ret = ret + end;
}
}
return ret;
};
myRe = new RegExp('(<<|>>)','g');
for (var i in lineArr) {
var part = lineArr[i];
if (myRe.test(part)) {
part = part.replace(myRe,'').trim();
if (/^pic[^t]/.test(part)) {
part = part.replace(/^pic/,'picture');
}
part = formatMacro(part,'picture','picture(',');');
part = formatMacro(part,'set','',';');
part = formatMacro(part,'if','if(',') {');
part = formatMacro(part,'elseif','} else if(',') {');
part = formatMacro(part,'else','} else {','');
part = formatMacro(part,'endif','','}');
part = formatMacro(part,'noaudio','music()',';');
part = formatMacro(part,'display','display(',');');
part = formatMacro(part,'print','print(',');');
part = formatMacro(part,'filter','filter(',');');
part = formatMacro(part,'effect','effect(',');');
part = formatMacro(part,'texteffect','texteffect(',');');
part = formatMacro(part,'clrscr','clear();','');
part = formatMacro(part,'break','break;','');
part = formatMacro(part,'continue','continue;','');
part = formatMacro(part,'goto','goto(',');');
part = formatMacro(part,'sound','sound(',');');
part = formatMacro(part,'image','image(',');');
part = formatMacro(part,'stop','stop(',');');
part = formatMacro(part,'nop','','');
part = formatMacro(part,'endnop','','');
part = formatMacro(part,'video','video(',');');
part = formatMacro(part,'back','','');
part = formatMacro(part,'restart','','');
part = formatMacro(part,'menu','menu(',');');
part = formatMacro(part,'title','title(',');');
part = formatMacro(part,'choice','choice(',');');
part = formatMacro(part,'random','',';');
part = formatMacro(part,'tab','',';');
part = formatMacro(part,'sprite','','');
part = formatMacro(part,'delete','','');
part = formatMacro(part,'class','','');
part = formatMacro(part,'endclass','','print("</span>");');
part = formatMacro(part,'repeat','repeat(',');');
part = formatMacro(part,'fade','flip(',');');
part = formatMacro(part,'row','','');
part = formatMacro(part,'loop','','');
part = formatMacro(part,'endloop','','}');
part = formatMacro(part,'input','','');
part = formatMacro(part,'return','','');
} else {
if (part.trim()!='') {
part = part.replace(/"/g,'\"');
part = 'print("'+part+'");';
}
}
lineArr[i] = part+'\n';
}
line = tab+lineArr.join('');
} else {
line = '\\ ' + line.trim();
}
line = line.replace(/^\s*?\\\s*?\[\[\s*?(файл|file)\s*?:\s*?([^\s]*?)\.(mp3)\s*?\]\]/gi,"music('$2.$3');");
line = line.replace(/^\s*?\\\s*?(\[\[\s*?(файл|file)\s*?:)/gi,"// $1");
line = line.replace(/\[\[(.+?)({\s*?.+?\s*?\})+?\s*?\]\]/g,function(match,p1,p2) {
p2 = p2.replace(/}\s*?{/g,';');
return '[[' + p1 + p2 + ']]';
});
}
return tab+line.trim();
}
function UpdateOnlineTitle() {
if (TargetBrowser) {
var title = GetLocByTitle('StoryTitle');
if (title) {
title = title.Text.replace(/[\r\n]/g,' ').trim();
}
if (!title) {
title = Lang.Untitled;
}
document.title = title + ' | ' + Lang.AppName;
}
}
function CreateDefaultPassage(text)
{
LocSize = LocSizeDefault;
LocationArr.push(new Locations("Start",text,Cell,Cell,3,false));
}
function SelectStory(menu,cloudimport)
{
if (TargetChromeApp) {
if (!cloudimport) {
chrome_SelectFile(true);
return;
}
}
var str = '';
if (menu) {
if (navigator.onLine) {
str+= "<div class='menu_item' id='item1'>"+Lang.MenuSelectStory+"</div>";
str+= "<div class='menu_item' id='item2'>"+Lang.MenuMergeStory+"</div>";
}
if (isLocalStorageAvailable) {
var backup = localStorage.getItem("backup");
if (backup!=null && backup!='') {
backup = '';
str+= "<div class='menu_item' id='item4'>"+Lang.MenuFromBackUp+"</div>";
}
}
if (navigator.onLine) {
str += "<div class='menu_item' id='item6'>"+Lang.MenuModules+"</div>";
str += "<div class='menu_item' id='item5'>"+Lang.MenuProfile+"</div>";
}
mywindow_inner.innerHTML = str;
SetEvent('item1',function(){LoadMerge=false;SelectStory();});
SetEvent('item2',function(){LoadMerge=true;SelectStory();});
SetEvent('item4',function(){ShowWind(false);FromBackup();});
SetEvent('item5',function(){ShowWind(false);Help(1);});
SetEvent('item6',function(){ShowWind(false);Modules();});
ShowWind(true);
} else {
if (navigator.onLine) {
Message(Lang.ListLoading,true);
loadData(CommandServer('com=filelist'),function(Data) {
MessageHide();
Data = Data.trim();
if (Data=='') {
Message(Lang.NoSavedFiles);
} else if (Data=='register') {
SignInWindow(function(){SelectStory(menu,cloudimport);});
} else {
var DataArr = [];
DataArr = Data.split('\n');
for (var i=0; i<DataArr.length; i++) {
var DataLineArr = [];
DataLineArr = DataArr[i].split('\t');
var fn = parseInt(DataLineArr[0],10);
str+= "<div class='menu_item' forevent='"+fn+"'>"+DataLineArr[1]+'</div>';
}
mywindow_inner.innerHTML = str;
SetEventsByAttr(13);
ShowWind(true);
}
});
} else {
Message(Lang.NeedOnline);
}
}
}
function ShowWind(show,max)
{
if (show)
{
if (!EditorVisible)
{
VisualEventsStop();
}
else
{
RestoreCaret();
}
if (max) {
mywindow.style.maxWidth = '600px';
} else {
mywindow.style.maxWidth = '320px';
}
mywindow.style.display = 'block';
CreateMenuItemsList();
SelectMenuItem(-1,true);
WindowVisible = true;
SelectedLocation = -1;
maincanvas.style.cursor = 'default';
mywindow_inner.scrollTop = 0;
Animate(mywindow,'effect_scale_fast');
}
else
{
if (mywindow.style.display!='none')
{
MenuItemsList  = [];
mywindow_inner.innerHTML = '';
mywindow.style.display = 'none';
WindowVisible = false;
if (!EditorVisible && !PlateVisible)
{
VisualEventsStart();
}
else
{
if (!isTouchDevice)
{
RestoreCaret();
}
}
}
}
}
function Publish()
{
if (navigator.onLine) {
var str = '';
if (TargetFormat=='html') {
str += "<div class='menu_item' id='item2'>"+Lang.MenuPublishInet+"</div>";
str += "<div class='menu_item' id='item1'>"+Lang.MenuPublishFile+"</div>";
}
if (TargetDesktop) {
str += "<div class='menu_item' id='item3'>"+Lang.SaveToCloud+"</div>";
}
str += "<div class='menu_item' id='item4'>"+Lang.SignIn+"</div>";
mywindow_inner.innerHTML = str;
SetEvent('item1',function(){AreYouSure(PublishToFile);});
SetEvent('item2',function(){AreYouSure(PublishToInet,Lang.MenuPublishInetSure);});
SetEvent('item3',function(){AreYouSure(SaveToCloud);});
SetEvent('item4',function(){SignInWindow();});
SetEvent('item5',function(){ApkWindow();});
ShowWind(true);
} else {
Message(Lang.NeedOnline);
}
}
function SaveToCloud()
{
ShowWind(false);
SaveStory(false,true);
}
function PublishToFile()
{
if (AuthLogin=='' || AuthPassword=='') {
SignInWindow(function(){PublishToFile();});
return;
}
Compile(false,-1);
}
function PublishToInet()
{
Message(Lang.PleaseWait,true);
setTimeout (function() { Compile(false,-1,true); }, 1);
}
function EditLocation(LocTitle,force,animate)
{
LocTitle = LocTitle.toLowerCase();
var i = 0;
for (var i=LocationArr.length-1; i>=0; i--)
{
Loc = LocationArr[i];
if (Loc.Title.toLowerCase()==LocTitle)
{
ClickOnLoc = true;
LocationArr.push(Loc);
LocationArr.splice(i,1);
SelectedLocation = -1;
if (force) {
OpenEditor(true,false,false,animate);
} else {
OpenEditor(true,true,false,animate);
}
break;
}
}
}
function Navigator(find)
{
if (LocationArr.length>0)
{
if (EditorVisible)
{
FindNReplace();
return;
}
var query = '';
if (find && lastSearchQuery)
{
query = lastSearchQuery;
}
var str = "<input type='text' id='searchNav' placeholder='"+Lang.FindInPassages+"' value='"+query+"' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' style='margin-bottom:4px;'><div id='resultNav'></div>";
mywindow_inner.innerHTML = str;
SetEvent('searchNav',function(){NavigatorSearch(event,this.value);},'keyup');
SetEvent('searchNav',function(){NavigatorSearch(event,this.value);},'click');
NavigatorSearch();
ShowWind(true);
}
else
{
Message(Lang.NoPassages);
}
document.body.oncontextmenu = function() {if(getFocusedId()=='searchNav') {return true;} else {return false;}}
if (find)
{
var queryfield = $('searchNav');
SelectText(queryfield,queryfield.value.length,0);
}
}
function NavigatorSearch(event,query)
{
if (event)
{
var k = GetKeyCode(event);
if (k==40 || k==38 || k==9 || k==27 || k==13)
{
return;
}
}
if (!query)
{
query = '';
}
query = query.trim().toLowerCase();
lastSearchQuery = query;
var str = '';
var LocationArrResultTitle = []; // совпадение в названии
var LocationArrResultText = []; // совпадение в тексте
var item;
for (var i=0; i<LocationArr.length; i++)
{
item = [LocationArr[i].Title.toLowerCase(),LocationArr[i].ColorNum,LocationArr[i].ErrorLocation];
if (query!='')
{
if (LocationArr[i].Title.toLowerCase().indexOf(query)!=-1)
{
LocationArrResultTitle.push(item);
}
if (LocationArr[i].Text.toLowerCase().indexOf(query)!=-1)
{
LocationArrResultText.push(item);
}
}
else
{
LocationArrResultTitle.push(item);
}
}
LocationArrResultTitle.sort();
LocationArrResultText.sort();
var title, color, error;
var results = [LocationArrResultTitle,LocationArrResultText];
for (var j=0; j<results.length; j++)
{
if (query && j==1 && LocationArrResultText.length>0)
{
str += "<p class='accent'>"+Lang.InText+"</p>";
}
var LocationArrResult = results[j];
for (var i=0; i<LocationArrResult.length; i++)
{
title = LocationArrResult[i][0];
color = Colors[LocationArrResult[i][1]];
error = LocationArrResult[i][2];
str += NavMenuItem(title,color,error);
}
}
if (query!='' && LocationArrResultTitle.length==0 && LocationArrResultText.length==0)
{
str += '<p>'+Lang.NotFound2+'</p>';
}
LocationArrResultTitle.length = 0;
LocationArrResultText.length = 0;
var elem = $('resultNav');
elem.innerHTML = str;
SetEventsByAttr(1);
SetEventsByAttr(2,'forevent2');
CreateMenuItemsList(elem);
SelectMenuItem(-1,true);
}
function DuplicateLocation()
{
if (LocationArr.length>0)
{
var lastLoc = LastLocation();
var newTitle = lastLoc.Title+' 2';
while (TitleExist(newTitle))
{
newTitle = newTitle+' 2';
}
var newLeft = lastLoc.Left + Cell*2;
var newTop = lastLoc.Top + Cell*2;
if ((newLeft+LocSize+Cell)>maincanvas_w)
{
newLeft = lastLoc.Left - Cell*2;
}
if ((newTop+LocSize+Cell)>maincanvas_h)
{
newTop = lastLoc.Top - Cell*2;
}
LocationArr.push(new Locations(newTitle,lastLoc.Text,newLeft,newTop,lastLoc.ColorNum,false));
ParseAll();
SelectNPaint();
}
}
function ActionsMenu()
{
if (LocationArr.length>0)
{
if (!EditorVisible && isGroup(LastLocation()))
{
var Loc = LastLocation();
OpenGroup(Loc);
}
else
{
var str = '';
if (EditorVisible)
{
if (PrevTitle!='') {
str += "<div class='menu_item' id='item0'>"+Lang.SmallButtons[0]+"</div>";
}
str += "<div class='menu_item' id='item1'>"+Lang.MenuUndo+"</div>";
str += "<div class='menu_item' id='item2'>"+Lang.MenuFindNReplace+"</div>";
str += "<div class='menu_item' id='item3'>"+Lang.MenuGotoLink+"</div>";
}
if (!EditorVisible)
{
str += "<div class='menu_item' id='item4'>"+Lang.MenuEdit+"</div>";
}
if (!(editNewLoc && EditorVisible))
{
str += "<div class='menu_item' id='item5'>"+Lang.MenuDelete+"</div>";
}
if (!EditorVisible)
{
str += "<div class='menu_item' id='item6'>"+Lang.MenuDuplicate+"</div>";
str += "<div class='menu_item' id='item7'>"+Lang.MenuLinked+"</div>";
}
str += "<div class='menu_item' id='item8'>"+Lang.MenuTest+"</div>";
mywindow_inner.innerHTML = str;
SetEvent('item0',function(){ShowWind(false);EditrBack();});
SetEvent('item1',function(){ShowWind(false);AreYouSure(CancelChanges,Lang.AYSUndoChanges);});
SetEvent('item2',function(){ShowWind(false);FindNReplace();});
SetEvent('item3',function(){ShowWind(false);EditrGotoLink();});
SetEvent('item4',function(){ClickOnLoc=true;OpenEditor(true,false,false,true);});
SetEvent('item5',function(){RemoveLocation();});
SetEvent('item6',function(){DuplicateLocation();ShowWind(false);});
SetEvent('item7',function(){ShowWind(false);LinkedPassages();});
SetEvent('item8',function(){ShowWind(false);CompilePassage();});
ShowWind(true);
}
}
else
{
Message(Lang.NoPassages);
}
}
function LinkedPassages()
{
var str = '<span class=accent>'+Lang.MenuOutLinks+'</span><p>';
var tmpArr = [];
var link = '';
var color, error;
var loc = LastLocation();
var myloc;
for (var i=0; i<loc.Links.length; i++)
{
link = loc.Links[i].trim().toLowerCase();
tmpArr.push(link);
}
tmpArr = ArrayUnique(tmpArr);
if (tmpArr.length>0)
{
for (var i=0; i<tmpArr.length; i++)
{
link = tmpArr[i];
myloc = GetLocByTitle(link);
color = Colors[myloc.ColorNum];
error = myloc.ErrorLocation;
str += NavMenuItem(link,color,error);
}
}
else
{
str += Lang.No;
}
str += '<p><span class=accent>'+Lang.MenuInLinks+'</span></p>';
var myTitle = loc.Title.toLowerCase();
tmpArr = [];
for (var i=0; i<LocationArr.length-1; i++)
{
loc = LocationArr[i];
for (var j=0; j<loc.Links.length; j++)
{
link = loc.Links[j].trim().toLowerCase();
if (link==myTitle)
{
tmpArr.push(loc.Title.toLowerCase());
}
}
}
tmpArr = ArrayUnique(tmpArr);
if (tmpArr.length>0)
{
for (var i=0; i<tmpArr.length; i++)
{
link = tmpArr[i];
myloc = GetLocByTitle(link);
color = Colors[myloc.ColorNum];
error = myloc.ErrorLocation;
str += NavMenuItem(link,color,error);
}
}
else
{
str += Lang.No;
}
tmpArr = [];
mywindow_inner.innerHTML = str;
SetEventsByAttr(1);
SetEventsByAttr(2,'forevent2');
ShowWind(true);
}
function ClosePreview()
{
closePreview.style.display = 'none';
PreviewVisible = false;
html = '';
if (previewWin) {
previewWin.style.display = 'none';
document.body.removeChild(previewWin);
previewWin = undefined;
}
mainDiv.style.display = 'block';
window.top.focus();
if (!EditorVisible) {
VisualEventsStart();
} else {
if (!isTouchDevice) {
RestoreCaret();
}
}
ResizeEvent();
}
function ReloadApp()
{
document.location.reload(true);
}
function CheckUpdates(vdate)
{
if (navigator.onLine) {
loadData(CommandServer('com=checkupdates&value='+vdate),function(answer) {
if (answer.trim()=='yes') {
AreYouSure(ReloadApp,Lang.UpdateFound+'<br>'+Lang.ReloadApp);
}
});
}
}
function CreateMenuItemsList(elem)
{
if (!isTouchDevice)
{
if (!elem)
{
elem = mywindow_inner;
}
MenuItemsList = getElementsByClass('menu_item button',elem);
SelectedMenuItemNum = 0;
}
}
function SelectMenuItem(sn,top)
{
if (MenuItemsList.length>0)
{
for (var key in MenuItemsList)
{
SetMenuItemStyle(MenuItemsList[key]);
}
if (sn!=-1)
{
var selitem = MenuItemsList[sn];
selitem.scrollIntoView(top);
}
else
{
var selitem = MenuItemsList[0];
}
SetMenuItemStyle(selitem,true);
if (sn==0)
{
mywindow_inner.scrollTop = 0;
}
}
}
function SetMenuItemStyle(item,select)
{
if (select)
{
if (item.hasAttribute('error_item')) {
item.removeAttribute('error_item');
item.setAttribute('error_item_bak','');
}
item.setAttribute('selected_item','');
}
else
{
item.removeAttribute('selected_item');
if (item.hasAttribute('error_item_bak')) {
item.removeAttribute('error_item_bak');
item.setAttribute('error_item','');
}
}
}
function MenuItemNext()
{
if (SelectedMenuItemNum<MenuItemsList.length-1)
{
SelectedMenuItemNum++;
}
else
{
SelectedMenuItemNum = 0;
}
SelectMenuItem(SelectedMenuItemNum,false);
}
function MenuItemPrev()
{
if (SelectedMenuItemNum>0)
{
SelectedMenuItemNum--;
}
else
{
SelectedMenuItemNum = MenuItemsList.length-1;
}
SelectMenuItem(SelectedMenuItemNum,true);
}
function ChangeZoom(increase)
{
if (LocationArr.length>0 && maincanvas_w>=MinimalWidth)
{
if (increase)
{
var NewSize = LocSize + Cell;
if (NewSize>LocSizeMax)
{
NewSize = LocSizeMax;
}
}
else
{
var NewSize = LocSize - Cell;
if (NewSize<LocSizeMin)
{
NewSize = LocSizeMin;
}
}
for (var key in LocationArr)
{
var Location = LocationArr[key];
Location.Left = Location.Left+(NewSize/LocSize-1)*Location.Left;
Location.Left = Math.round(Location.Left/Cell)*Cell;
Location.Top = Location.Top+(NewSize/LocSize-1)*Location.Top;
Location.Top = Math.round(Location.Top/Cell)*Cell;
}
LocSize = NewSize;
SelectNPaint();
}
}
function SetColorButton(n)
{
colorbutton.style.display = 'inline-block';
colorbutton.style.backgroundColor = Colors[n];
}
function SetColor(n)
{
selectedColor = n;
if (!editNewLoc)
{
LastLocation().ColorNum = n;
}
}
function SelectColor()
{
var str = '';
var sel;
var loccolor = 0;
if (!editNewLoc)
{
loccolor = LastLocation().ColorNum;
}
else
{
loccolor = selectedColor;
}
for (var i=0; i<Colors.length; i++)
{
if (i==loccolor)
{
sel = 'outline:3px solid #222222;';
}
else
{
sel = 'outline:3px solid transparent;';
}
str += "<span class='color' forevent='"+i+"' style='"+sel+"background-color:"+Colors[i]+"'>"+"</span>";
}
mywindow_inner.innerHTML = str;
SetEventsByAttr(3);
ShowWind(true);
}
function LastLocation()
{
if (LocationArr.length>0)
{
return LocationArr[LocationArr.length-1];
}
else
{
return false;
}
}
function CenterLocation(title)
{
var i = GetLocIndexByTitle(title);
var Loc = LocationArr[i];
if (isTouchDevice) {
Loc.Left = Math.round((maincanvas_w-LocSize)/2 / Cell) * Cell;
Loc.Top =  Math.round((maincanvas_h-LocSize)/2 / Cell) * Cell;
} else {
canvasWrap.scrollLeft = Loc.Left+LocSize/2-canvasWrap_w/2;
canvasWrap.scrollTop = Loc.Top+LocSize/2-canvasWrap_h/2;
}
LocationArr.push(Loc);
LocationArr.splice(i,1);
SelectNPaint();
}
function ShowLines()
{
if (isShowLines) {
isShowLines = false;
Message(Lang.LinesOff);
SetPrefValue('ShowLines','false');
} else {
isShowLines = true;
Message(Lang.LinesOn);
SetPrefValue('ShowLines','true');
}
SelectNPaint();
}
function ShowArcs()
{
if (isShowArcs) {
isShowArcs = false;
Message(Lang.ArcsOff);
SetPrefValue('ShowArcs','false');
} else {
isShowArcs = true;
Message(Lang.ArcsOn);
SetPrefValue('ShowArcs','true');
}
SelectNPaint();
}
function NavMenuItem(title,color,error,group)
{
if (!group) {
var com = 'CenterLocation';
var sym = '•';
} else {
var com = 'SplitGroup';
var sym = '×';
}
str =  "<div class='menu_no' forevent2='"+com+'\n'+title+"' style='width:8%;float:left;'>"+sym+"</div>";
var attr = ''
if (error) {
attr = ' error_item';
}
str += "<div class='menu_item'"+attr+" forevent='"+title+"' style='width:90%;float:right;color:"+color+";'>"+title+"</div><div style='clear:both;'></div>";
return str;
}
function ShowLinesButton()
{
show_lines.style.display = 'inline-block';
show_arcs.style.display = 'inline-block';
}
function FromBackup()
{
if (TargetChromeApp) {
chrome_FromStorage('backup',function(data) {
if (data) {
chrome_SetCurrentEntry('');
LoadStory(0,false,data);
} else {
Message(Lang.NoBackUp);
}
});
return;
}
if (!TargetDesktop) {
if (isLocalStorageAvailable) {
var data = localStorage.getItem('backup');
LoadStory(0,false,data);
}
}
}
function ToBackup()
{
if (!PreviewVisible) {
if (EditorVisible) {
SaveLocation(false);
}
var data = CreateSaveData();
if (TargetChromeApp) {
chrome_ToStorage('backup',data);
return;
} else {
if (isLocalStorageAvailable) {
localStorage.setItem('backup',data);
}
}
}
}
function GetPrefValue(name,callback)
{
if (TargetBrowser)
{
return getCookie(name);
}
else if (TargetChromeApp)
{
chrome_FromStorage(name,callback);
}
else
{
if (isLocalStorageAvailable)
{
return localStorage.getItem(name);
}
}
}
function SetPrefValue(name,value)
{
if (TargetBrowser)
{
setCookie(name,value);
}
else if (TargetChromeApp)
{
chrome_ToStorage(name,value);
}
else
{
if (isLocalStorageAvailable)
{
localStorage.setItem(name,value);
}
}
}
function WindowOpen(s,name,wo)
{
var addr = '';
if (wo || /^https?:\/\//.test(s))
{
addr = s;
}
else
{
addr = Lang.Server()+'/'+s;
}
if (!name)
{
name = '';
}
window.open(addr,name);
}
function SignInWindow(callback)
{
if (TargetBrowser)
{
AuthLogin = GetPrefValue('login');
AuthPassword = GetPrefValue('password');
}
if (!AuthLogin) {AuthLogin = '';}
if (!AuthPassword) {AuthPassword = '';}
var str = Lang.SignIn+'<p></p>';
str += "<input id='auth_login' type='text' style='margin-bottom:14px;' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' placeholder='"+Lang.Login+"' value=\""+AuthLogin+"\"><br>";
str += "<input id='auth_password' type='password' style='margin-bottom:14px;' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' placeholder='"+Lang.Password+"' value=\""+AuthPassword+"\">";
str += "<div class='button' id='item1'>OK</div>";
str += "<p class='plink' id='item2'>"+Lang.Register+"</p>";
mywindow_inner.innerHTML = str;
SetEvent('auth_login',function(){if (GetKeyCode(event)==9){$('auth_password').focus();}},'keydown');
SetEvent('auth_password',function(){if (GetKeyCode(event)==9){$('auth_login').focus();}},'keydown');
SetEvent('item1',function(){SignIn(callback);});
SetEvent('item2',function(){WindowOpen('wp-login.php?action=register');});
ShowWind(true);
$('auth_login').focus();
document.body.oncontextmenu = function() {if(getFocusedId()=='auth_login' || getFocusedId()=='auth_password') {return true;} else {return false;}}
}
function SignIn(callback)
{
AuthLogin = $('auth_login').value.trim();
AuthPassword = $('auth_password').value.trim();
ShowWind(false);
SetPrefValue('login',AuthLogin);
SetPrefValue('password',AuthPassword);
if (callback)
{
callback();
}
}
function ApkWindow()
{
var domain = AuthLogin.toLowerCase().replace(/[^@a-z0-9\.]/g,'').replace(/@/g,'.').split('.').reverse().join('.');
if (domain) {
domain = domain + '.';
} else {
SignInWindow(ApkWindow);
return;
}
var titleApp = '';
var maxlenName = 25;
var maxlenTitle = 30;
var nameApp = GetLocByTitle('storytitle');
if (nameApp) {
nameApp = nameApp.Text;
titleApp = nameApp.trim().substr(0,maxlenTitle);
nameApp = nameApp.toLowerCase().replace(/\s+?/g,'.').trim().split('');
var translit1 = ['а','б','в','г','д','е','ё','ж','з','и','й','к','л','м','н','о','п','р','с','т','у','ф','х','ц','ч','ш','щ','ъ','ы','ь','э','ю','я'];
var translit2 = ['a','b','v','g','d','e','jo','zh','z','i','jj','k','l','m','n','o','p','r','s','t','u','f','kh','c','ch','sh','shh','','y','','eh','ju','ja'];
for (var i=0; i<nameApp.length; i++) {
var sym = nameApp[i];
var j = translit1.indexOf(sym);
if (j>-1) {
nameApp[i] = translit2[j];
}
}
nameApp = nameApp.join('').replace(/[^a-z0-9\.]/g,'');
if (nameApp.substr(-1,1)=='.') {
nameApp = nameApp.substr(0,nameApp.length-1);
}
nameApp = nameApp.substr(0,maxlenName);
}
var str = '';
str += "<input type='text' readonly style='width:50%;margin-bottom:14px;text-align:right;border-right-style:none;' value='"+domain+"'><input id='package_name' type='text' style='width:50%;margin-bottom:14px;' maxlength='"+maxlenName+"' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' placeholder='package name' value=\""+nameApp+"\"><br>";
str += "<input id='title_app' type='text' maxlength='"+maxlenTitle+"' style='margin-bottom:14px;' autofocus placeholder='app title' value='"+titleApp+"'><br>";
str += "<label><input id='sign_app' type='checkbox' checked style='margin-bottom:14px;'>"+Lang.SaveAXMAKey+"</label><br>";
str += "<div id='item2' style='margin-bottom:14px;'><span class='plink'>"+Lang.SelectAppIcon+"</span></div><input type='file' accept='image/png' value='' id='iconSelecter' style='display:none;'>";
str += "<div><img id='appIcon' style='margin-bottom:14px;' src='"+EmptyImageDataURL+"'></div>";
str += "<div class='button' id='item1'>OK</div>";
mywindow_inner.innerHTML = str;
SetEvent('item1',function(){MakeApk();});
SetEvent('item2',function(){$('iconSelecter').value='';$('iconSelecter').click();});
SetEvent('iconSelecter',function(){readAppIcon();},'change');
ShowWind(true);
}
function MakeApk() {
var packageName = $('package_name').value;
var titleApp = $('title_app').value;
var signApp = $('sign_app').checked;
if (packageName.length<3 || packageName.length>25 || /[^a-z0-9\.]/.test(packageName)) {
$('package_name').select();
} else if (titleApp.length<3 || titleApp.length>30) {
$('title_app').select();
} else if ($('appIcon').src==EmptyImageDataURL) {
Message(Lang.SelectImageSize+' 192x192px');
} else {
ShowWind(false);
}
}
function readAppIcon() {
if (window.FileReader) {
var file = $('iconSelecter').files[0];
var reader = new FileReader();
reader.onload = function() {
var img = new Image();
img.src = reader.result;
img.onload = function()
{
if (img.width==192 && img.height==192) {
$('appIcon').src = reader.result;
} else {
Message(Lang.SelectImageSize+' 192x192px');
}
}
}
reader.readAsDataURL(file);
}
}
function RestoreCaret()
{
if (!isTouchDevice) {
if (GetEditorText().trim()=='\\') {
Select(editor,GetEditorText().length,0);
}
var selData = getInputSelection(editor);
var currentPos = selData['start'];
var currentLen = selData['end']-selData['start'];
Select(editor,currentPos,currentLen);
}
}
function FontSize(more)
{
if (EditorVisible)
{
var step = 1;
if (more)
{
fontSize += step;
}
else
{
fontSize -= step;
}
SetFontEditor();
SetPrefValue('FontSize',fontSize+'');
}
}
function SetFontEditor()
{
var min = -3;
var max = 8;
if (!isNaN(+fontSize)) {
fontSize = parseInt(fontSize);
} else {
fontSize = 0;
}
if (fontSize>max) {
fontSize = max;
}
if (fontSize<min) {
fontSize = min;
}
var size = 14+fontSize+'px'
editor.style.fontSize = size;
editorColor.style.fontSize = size;
}
function ShowPlate(show)
{
ShowWind(false);
if (show)
{
myplate.style.display = 'block';
platecontent.scrollTop = 0;
PlateVisible = true;
if (!EditorVisible)
{
VisualEventsStop();
}
Animate(myplate,'effect_scale');
}
else
{
myplate.style.display = 'none';
platetitle.innerHTML = '';
platecontent.innerHTML = '';
PlateVisible = false;
if (!EditorVisible)
{
VisualEventsStart();
}
ResizeEvent();
}
}
function QuickStart(close)
{
if (!close)
{
platetitle.innerHTML = Lang.MenuQuickStart;
var s = "<div style='max-width:60em;margin:0 auto;'>"+Lang.QuickStart+"<p align='center'><span class='plink' id='item0'>"+Lang.Close+"</span></p></div>";
platecontent.innerHTML = s;
SetEvent('item0',function(){ShowPlate(false);});
SetEvent('item1',function(){WindowOpen(LangCode+'/manual/');});
SetEvent('item2',function(){WindowOpen('forum/');});
SetEvent('item3',function(){WindowOpen('wp-login.php?action=register');});
ShowPlate(true);
}
else
{
ShowPlate(false);
}
}
function CommandServer(com,woLogin)
{
var comtext = 'command.php?'+com;
if (!woLogin) {
comtext = 'command.php?login='+urlencode(AuthLogin)+'&password='+urlencode(AuthPassword)+'&'+com;
}
return 'https://online.axmajs.ru/'+comtext;
}
function CanvasToTop()
{
canvasWrap.scrollLeft = 0;
canvasWrap.scrollTop = 0;
}
function SetEventsByAttr(n,attr,event,div)
{
if (!attr) {
attr = 'forevent';
}
if (!event) {
event = 'click';
}
if (!div) {
div = mywindow_inner;
}
var elems = div.querySelectorAll('['+attr+']');
for (var i=0; i<elems.length; i++) {
var elem = elems[i];
var value = elem.getAttribute(attr);
elem.addEventListener(event,function(value){
return function() {
if (n==1) {
ShowWind(false);
EditLocation(value,false,true);
}
if (n==2) {
ShowWind(false);
value = value.split('\n');
if (value[0]=='CenterLocation') {
CenterLocation(value[1]);
}
if (value[0]=='SplitGroup') {
SplitGroup(value[1]);
}
}
if (n==3) {
ShowWind(false);
SetColorButton(value);
SetColor(value);
}
if (n==4) {
ShowWind(false);
EditrGotoLocation(value);
}
if (n==6) {
ShowWind(false);
EditrGotoLocation(value);
}
if (n==7) {
value = parseInt(value);
SelectTheme(value);
SelectedMenuItemNum = value;
}
if (n==8) {
ShowWind(false);
InsertMacro(value);
}
if (n==9) {
ShowWind(false);
InsertLink(value);
}
if (n==10) {
ShowWind(false);
InsertLink(value);
}
if (n==11) {
ShowWind(false);
FormatText(value);
}
if (n==12) {
ShowWind(false);
InsertText((value),true);
}
if (n==13) {
ShowWind(false);
LoadStory(value,LoadMerge);
}
if (n==15) {
ShowWind(false);
InsertText(value,true);
}
if (n==16) {
value = value.split('|');
if (value[3]=='true') {
value[3] = true;
} else {
value[3] = false;
}
EditFileData(value[0],value[1],value[2],value[3],value[4]); //(id,type,mytype,insert,dataurl)
}
if (n==17) {
ShowWind(false);
chrome_LoadFile(value,false);
}
if (n==18) {
ShowWind(false);
ModuleLoad(value);
}
if (n==19) {
WindowOpen('https://online.axmajs.ru/modules/'+value+'/');
}
if (n==20) {
WindowOpen(CommandServer('com=moduleZIP&value='+value,true));
}
}
}(value));
}
}
function InsertMusic()
{
if (TargetChromeApp) {
chrome_InsertMedia(false,false,true);
} else {
InsertLink('music("https://")');
}
}
function InsertPicture()
{
if (TargetChromeApp) {
chrome_InsertMedia(true,false,false);
} else {
InsertLink('picture("https://")');
}
}
function InsertVideo()
{
if (TargetChromeApp) {
chrome_InsertMedia(false,true,false);
} else {
InsertLink('video("https://")');
}
}
function InsertMacro(text)
{
if (!text) {
if (SimpleLocation(GetCurLocTitle())) {
Message(Lang.NotAvailInPassage);
editor.focus();
return;
}
var macroList = function(nav) {
var str = '';
var delimeter = "<div style='clear:both;'></div><p></p>";
var tileClass = 'tile';
if (nav) {
tileClass = 'tile2';
}
for (var i in MacrosArr) {
var m = MacrosArr[i];
var stop = ['music','picture','video'];
if (stop.indexOf(m.name)==-1) {
var before = '';
if (m.before) {
before = m.before;
}
str += "<div class='menu_item "+tileClass+"' forevent='"+before+m.name+m.syntax+"'><b>"+m.name+"</b>"+m.title+"</div>";
}
}
str += delimeter;
var item = 'item';
if (nav) {
item = 'itemNav';
}
str += "<div class='menu_item "+tileClass+"' id='"+item+"2'>"+"<b>picture</b>"+Lang.MacroPicture+"</div>";
str += "<div class='menu_item "+tileClass+"' id='"+item+"1'>"+"<b>music</b>"+Lang.MacroBackAudio+"</div>";
str += "<div class='menu_item "+tileClass+"' id='"+item+"3'>"+"<b>video</b>"+Lang.MacroVideo+"</div>";
str += delimeter;
for (var i in OperatorsArr) {
var m = OperatorsArr[i];
var before = '';
if (m.before) {
before = m.before;
}
str += "<div class='menu_item "+tileClass+"' forevent='"+before+m.name+m.syntax+"'><b>"+m.name+"</b>"+m.title+"</div>";
}
return str;
};
mywindow_inner.innerHTML = macroList(false);
SetEventsByAttr(8,false,false,mywindow_inner);
SetEvent('item2',function(){ShowWind(false);InsertPicture();});
SetEvent('item1',function(){ShowWind(false);InsertMusic();});
SetEvent('item3',function(){ShowWind(false);InsertVideo();});
ShowWind(true,true);
navPanel2.innerHTML = macroList(true);
SetEventsByAttr(8,false,false,navPanel2);
SetEvent('itemNav2',function(){InsertPicture();});
SetEvent('itemNav1',function(){InsertMusic();});
SetEvent('itemNav3',function(){InsertVideo();});
} else {
if (SimpleLocation(GetCurLocTitle())) {
Message(Lang.NotAvailInPassage);
editor.focus();
} else {
InsertText(text);
}
}
}
function InsertLink(text)
{
if (!text) {
if (SimpleLocation(GetCurLocTitle())) {
Message(Lang.NotAvailInPassage);
editor.focus();
return;
}
var str = '';
var links = [
"[[|&]]::"+Lang.LinkSimple,
"[[+|&]]::"+Lang.LinkAdd,
"[[*|&]]::"+Lang.LinkMulti,
"{variable = true&;}::"+Lang.LinkObj,
"print(back('&',false))::"+Lang.LinkBack,
"print(restart('&',false))::"+Lang.LinkRestart
];
for (var key in links) {
var l = links[key].split('::');
str += "<div class='menu_item' forevent=\""+l[0]+"\">"+l[1]+"</div>";
}
var insmedp = Lang.LinkFileLocal;
if (TargetBrowser) {
insmedp = Lang.LinkFile;
}
LocationArrDup = GetTitlesArray(true);
if (LocationArrDup.length>0) {
str += "<p class='accent'>"+Lang.PassagesUpper+"</p>";
for (var key in LocationArrDup) {
str += "<div class='menu_item' forevent2=\""+LocationArrDup[key]+"\">"+LocationArrDup[key]+"</div>";
}
}
mywindow_inner.innerHTML = str;
SetEventsByAttr(9);
SetEventsByAttr(10,'forevent2');
ShowWind(true);
} else {
var f = text.split('&');
if (f[1]) {
var selData = GetSelection(editor);
var currentPos = selData['start'];
var currentLen = selData['end']-selData['start'];
var strLeft = GetEditorText().substr(0,currentPos);
var strSele = GetEditorText().substr(currentPos,currentLen);
var strRight = GetEditorText().substr(currentPos+currentLen,GetEditorText().length);
SetEditorText(strLeft+f[0]+strSele+f[1]+strRight);
var offset = 0;
Select(editor,currentPos+strSele.length+f[0].length+offset,0);
} else {
InsertText(text);
}
}
}
function HTMLChars()
{
var selData = GetSelection(editor);
var currentPos = selData['start']+1;
var currentLen = selData['end']-selData['start'];
if (currentLen!=0) {
var pos, slen;
var arrChars = Split(Mid(GetEditorText(),currentPos,currentLen),'');
var ent = '';
for (var i=0; i<arrChars.length; i++) {
if (arrChars[i]!='\n' && arrChars[i]!='\r') {
if (arrChars[i]==" ") {
arrChars[i] = "&nbsp;";
} else if (arrChars[i]=="<") {
arrChars[i] = "&lt;";
} else if (arrChars[i]==">") {
arrChars[i] = "&gt;";
} else if (arrChars[i]=="&") {
arrChars[i] = "&amp;";
} else {
arrChars[i] = "&#"+arrChars[i].charCodeAt(0)+";";
}
}
}
ent = arrChars.join('');
pos = currentPos-1;
slen = ent.length;
SetEditorText(Left(GetEditorText(),pos) + ent + Right(GetEditorText(),GetEditorText().length-pos-currentLen));
Select(editor,pos,slen);
} else {
editor.focus();
}
}
function FormatText(text)
{
if (!text)
{
if (SimpleLocation(GetCurLocTitle())) {
Message(Lang.NotAvailInPassage);
editor.focus();
return;
}
var selData = GetSelection(editor);
var currentPos = selData['start'];
var currentLen = selData['end']-selData['start'];
if (currentLen>0)
{
var selText = GetEditorText().substr(currentPos,currentLen);
selText = selText.split(/[\r\n]/)[0];
Select(editor,currentPos,selText.length);
editor.blur();
}
var str = '';
var quotes = '«,»';
if (LangCode=='en')
{
quotes = '“,”';
}
var format = [
"[[,|]]::[["+Lang.FormatLink+"]]",
"<i>,</i>::<i>"+Lang.FormatItalic+"</i>",
"<b>,</b>::<b>"+Lang.FormatBold+"</b>",
"<u>,</u>::<u>"+Lang.FormatUnderline+"</u>",
"<tt>,</tt>::<span class='mono'>"+Lang.FormatMonospace+"</span>",
"<h1>,</h1>::<div style=\"font-size:1.4em;\">"+Lang.FormatHeader+"</div>1",
"<h2>,</h2>::<div style=\"font-size:1.3em;\">"+Lang.FormatHeader+"</div>2",
"<h3>,</h3>::<div style=\"font-size:1.2em;\">"+Lang.FormatHeader+"</div>3",
"<h4>,</h4>::<div style=\"font-size:1.1em;\">"+Lang.FormatHeader+"</div>4",
"<h5>,</h5>::<div style=\"font-size:1.0em;\">"+Lang.FormatHeader+"</div>5",
"<center>,</center>::"+Lang.FormatCenter,
"<right>,</right>::<div style='text-align:right'>"+Lang.FormatRight+"</div>",
tire+"::"+Lang.FormatTire+" —",
quotes+"::"+Lang.FormatQuotes,
"<code>,</code>::<span class='mono'>"+Lang.FormatCode+"</span>",
"<hr>::"+Lang.FormatHorline+"<hr style='margin:10px 0;'>",
"<sub>,</sub>::"+Lang.FormatSub,
"<sup>,</sup>::"+Lang.FormatSup,
"<li>,</li>::"+Lang.FormatLi,
"<br>::"+Lang.FormatBreak,
"<span class=''>,</span>::"+Lang.MacroClass,
"<img src=','>::"+Lang.FormatImg,
];
for (var key in format) {
var f = format[key].split('::');
str += "<div class='menu_item tile_small' forevent=\""+f[0]+"\">"+f[1]+'</div>';
}
str += "<div class='menu_item tile_small' id='item1'>"+Lang.FormatHTML+"</div>";
mywindow_inner.innerHTML = str;
SetEventsByAttr(11);
SetEvent('item1',function(){HTMLChars();ShowWind(false);});
ShowWind(true,true);
}
else
{
var f = text.split(',');
if (f[1])
{
var selData = GetSelection(editor);
var currentPos = selData['start'];
var currentLen = selData['end']-selData['start'];
var strLeft = GetEditorText().substr(0,currentPos);
var strSele = GetEditorText().substr(currentPos,currentLen);
var strRight = GetEditorText().substr(currentPos+currentLen,GetEditorText().length);
SetEditorText(strLeft+f[0]+strSele+f[1]+strRight);
Select(editor,currentPos+f[0].length,strSele.length);
}
else
{
text = text.replace(/\[\[asmNewline\]\]/g,'\n');
InsertText(text);
}
}
}
function CommentText()
{
if (SimpleLocation(GetCurLocTitle())) {
Message(Lang.NotAvailInPassage);
editor.focus();
return;
}
var comment = '//';
var myText = GetEditorText();
myText = ReplaceLineEndings(myText);
var myTextLen = myText.length;
var selData = GetSelection(editor);
var pos = selData['start'];
var sbegin = pos;
var slen_bak = selData['end']-selData['start'];
var slen = slen_bak;
for (var i=pos; i>=0; i--) {
if (i==0 || myText.substr(i-1,1)=='\n') {
sbegin = i;
slen = pos-sbegin+slen;
break;
}
}
if (slen<2) {
slen = 2;
}
var AddComment;
if (Left(LTrim(myText.substr(sbegin,myTextLen)),2)!=comment) {
AddComment = true;
} else {
AddComment = false;
}
var n = 0;
var added = false;
var removed = false;
var s = '';
var linesArr = Split(myText.substr(sbegin,slen),'\n');
for (var i=0; i<linesArr.length; i++) {
s = linesArr[i];
if (AddComment) {
if (s!='' && LTrim(s).substr(0,2)!=comment) {
linesArr[i] = comment + s;
added = true;
n++;
}
} else {
if (s!='' && s.substr(0,2)==comment)
{
linesArr[i] = Right(s,s.length-2);
removed = true;
n++;
if (sbegin==pos) {
pos++;
}
}
}
}
s = linesArr.join('\n');
SetEditorText(Left(myText,sbegin) + s + Right(myText,myText.length-sbegin-slen));
var len = comment.length;
if (added) {
Select(editor,pos+len,slen_bak+n*len-len);
} else if (removed) {
Select(editor,pos-len,slen_bak-n*len+len);
} else {
Select(editor,pos,slen_bak);
}
}
function LocationsToNavPanel(first)
{
var Locs = searchInNavPanel();
var title;
var str = '';
str += "<input id='itemSearch' type='search' value='"+lastSearchQuery+"' placeholder='"+Lang.FindInPassages+"'>";
str += "<div id='navPanelScroll'>";
for (var i in Locs) {
var Loc = Locs[i];
title = Loc.Title.toLowerCase();
var attr = '';
if (Loc.ErrorLocation) {
attr = " error_item";
}
if (title==GetCurLocTitle()) {
attr = " selected_item";
}
var color = Colors[Loc.ColorNum];
str += "<div style='color:"+color+";' class='menu_item'"+attr+" forevent='"+title+"'>"+title+"</div>";
}
str += "</div>";
var block = $('navPanelScroll');
if (block) {
navPanelScrollPos = block.scrollTop;
}
navPanel.innerHTML = str;
if (!first) {
var input = $('itemSearch');
SelectText(input,input.value.length,0)
}
block = $('navPanelScroll');
if (navPanelScrollPos===undefined) {
var selected = navPanel.getElementsByClassName('selected_item');
if (selected.length>0) {
selected[0].scrollIntoView(true);
}
} else {
if (block) {
block.scrollTop = navPanelScrollPos;
}
}
SetEventsByAttr(4,false,false,navPanel);
SetEvent('itemSearch',function() {
lastSearchQuery = LTrim(this.value.toLowerCase());
LocationsToNavPanel();
},'input');
}
function searchInNavPanel() {
var Locs = [];
for (var i in LocationArr) {
var Loc = LocationArr[i];
var title = Loc.Title.toLowerCase();
if (title!='storydata') {
if (title.indexOf(lastSearchQuery)!=-1 || Loc.Text.toLowerCase().indexOf(lastSearchQuery)!=-1) {
Locs.push(Loc);
}
}
}
var compare = function(a,b) {
if (a.Title<b.Title) {
return -1;
}
if (a.Title>b.Title) {
return 1;
}
return 0;
};
Locs.sort(compare);
return Locs;
}
function AutoDopWind(arr,offset) {
if (arr.length>0) {
var str = '';
for (var key in arr) {
var ins = arr[key];
str += "<div class='menu_item' forevent=\""+Mid(ins,offset)+"\">"+ins+"</div>";
}
mywindow_inner.innerHTML = str;
SetEventsByAttr(12);
ShowWind(true);
}
}
function AutoDop(event) {
if (SimpleLocation(GetCurLocTitle())) {
return;
}
var selData = GetSelection(editor);
var pos = selData['start'];
var text = GetEditorText();
if (pos==0 || text.substr(pos-1,1)=='\n' || text.substr(pos-1,1)=='\r' || text.substr(pos,1)=='\t' || text.substr(pos-1,1)=='\t') {
if (!event || !event.shiftKey) {
InsertText('\t',true);
return;
}
}
var ins1, ins2, prev = '';
var found = false;
var n;	// макс. длина поиска влево от курсора
var countLeft, countRight;
if (CompareRegEx(Mid(GetEditorText(),pos-1,2),"\\$\\$")) {
AutoDopWind(SysVars,prev.length+1);
} else if (CompareRegEx(Mid(GetEditorText(),pos-200,200+1),".*?\\$\\$.+?")) {
n = 20;	// макс. длина имени переменной с запасом
var LocVars = [];
for (var i=0; i<SysVars.length; i++) {
LocVars.push(Mid('$$'+SysVars[i],3));
}
prev = Mid(GetEditorText(),pos-n,n+1);
countLeft = CountFields(prev,"$")-1;
prev = LTrim(NthField(prev,"$",countLeft+1));
if (prev!='') {
for (var i=0; i<LocVars.length; i++) {
if (prev.toLowerCase()==Left(LocVars[i],prev.length).toLowerCase() && prev.toLowerCase()!=LocVars[i].toLowerCase())
{
found = true;
InsertText(Mid(LocVars[i],prev.length+1),true);
break;
}
}
}
} else if (Left(LTrim(Mid(GetEditorText(),pos+1,200)),2)=="]]" || Left(ReplaceAll(Mid(GetEditorText(),pos+1,200)," ",""),2)=="{$") {
n = 500;	// макс. длина ссылки с запасом
prev = Mid(GetEditorText(),pos-n,n+1);
prev = ReplaceAll(prev,"[[+","[[");
prev = ReplaceAll(prev,"[[-","[[");
prev = ReplaceAll(prev,"[[*","[[");
prev = ReplaceAll(prev,"[[","|");
countLeft = CountFields(prev,"|")-1;
prev = LTrim(NthField(prev,"|",countLeft+1));
var LocNames = GetTitlesArray(true);
if (prev=='') {
AutoDopWind(LocNames,prev.length+1);
} else {
var foundArr = [];
for (var i=0; i<LocNames.length; i++) {
if (prev.toLowerCase()==Left(LocNames[i],prev.length).toLowerCase()) {
found = true;
foundArr.push(LocNames[i]);
}
}
if (foundArr.length==1) {
InsertText(Mid(foundArr[0],prev.length+1),true);
} else if (foundArr.length>1) {
AutoDopWind(foundArr,prev.length+1);
}
}
} else if (CompareRegEx(Mid(GetEditorText(),pos-200,200+1),".*?"+DisplayPattern.replace("(\\s*?['\"])",""))) {
n = 500; // макс. длина ссылки с запасом
prev = Mid(GetEditorText(),pos-n,n+1);
prev = ReplaceAll(prev,'"',"'");
countLeft = CountFields(prev,"'")-1;
prev = LTrim(NthField(prev,"'",countLeft+1));
var LocNames = GetTitlesArray(true);
if (prev=='') {
AutoDopWind(LocNames,prev.length+1);
} else {
var foundArr = [];
for (var i=0; i<LocNames.length; i++) {
if (prev.toLowerCase()==Left(LocNames[i],prev.length).toLowerCase()) {
found = true;
foundArr.push(LocNames[i]);
}
}
if (foundArr.length==1) {
InsertText(Mid(foundArr[0],prev.length+1),true);
} else if (foundArr.length>1) {
AutoDopWind(foundArr,prev.length+1);
}
}
} else if (Mid(GetEditorText(),pos-1,2)=="[[" && Mid(GetEditorText(),pos+1,1)!="|" && Mid(GetEditorText(),pos+1,2)!="]]") {
ins1 = "|";
if (Mid(GetEditorText(),pos+1,2)!="]]")
{
ins2 = "]]";
}
else
{
ins2 = "";
}
found = true;
FormatText(ins1+','+ins2);
} else if (Mid(GetEditorText(),pos-2,3)=="[[|" && Mid(GetEditorText(),pos+1,1)!="]") {
found = true;
InsertText("]]",true);
Select(editor,pos,0);
} else if (CompareRegEx(Mid(GetEditorText(),pos-20,20+1),".*?asm\\.[a-zA-Z]+?") || Mid(GetEditorText(),pos-3,4)=='asm.') {
var props = [];
for (var prop in asmProps) {
props.push(prop);
}
if (Mid(GetEditorText(),pos-3,4)=='asm.') {
AutoDopWind(props,prev.length+1);
} else {
n = 20;	// макс. длина метода с запасом
prev = Mid(GetEditorText(),pos-n,n+1);
countLeft = CountFields(prev,"asm.",true)-1;
prev = LTrim(NthField(prev,"asm.",countLeft+1,true));
if (prev!='') {
for (var i=0; i<props.length; i++) {
if (prev==Left(props[i],prev.length) && prev!=props[i]) {
found = true;
InsertText(Mid(props[i],prev.length+1),true);
break;
}
}
}
}
} else if (CompareRegEx(Mid(GetEditorText(),pos-20,20+1),".*?Math\\.[a-zA-Z]+?") || Mid(GetEditorText(),pos-4,5)=='Math.') {
var methods = [];
methods.push("abs()");
methods.push("acos()");
methods.push("asin()");
methods.push("atan()");
methods.push("ceil()");
methods.push("cos()");
methods.push("floor()");
methods.push("log()");
methods.push("max()");
methods.push("min()");
methods.push("pow()");
methods.push("random()");
methods.push("round()");
methods.push("sin()");
methods.push("sqrt()");
methods.push("tan()");
if (Mid(GetEditorText(),pos-4,5)=='Math.') {
AutoDopWind(methods,prev.length+1);
} else {
n = 20;	// макс. длина метода с запасом
prev = Mid(GetEditorText(),pos-n,n+1);
countLeft = CountFields(prev,"Math.",true)-1;
prev = LTrim(NthField(prev,"Math.",countLeft+1,true));
if (prev!='') {
for (var i=0; i<methods.length; i++) {
if (prev==Left(methods[i],prev.length) && prev!=methods[i]) {
found = true;
InsertText(Mid(methods[i],prev.length+1),true);
break;
}
}
}
}
} else if (CompareRegEx(Mid(GetEditorText(),pos-20,20+1),".*?\\.[a-zA-Z]+?") || Mid(GetEditorText(),pos,1)=='.') {
var methods = [];
methods.push("bitClear()");
methods.push("bitSet()");
methods.push("bitTest()");
methods.push("bitToggle()");
methods.push("charAt()");
methods.push("charCodeAt()");
methods.push("concat()");
methods.push("indexOf()");
methods.push("join()");
methods.push("length");
methods.push("pop()");
methods.push("push()");
methods.push("replace()");
methods.push("reverse()");
methods.push("shift()");
methods.push("slice()");
methods.push("sort()");
methods.push("splice()");
methods.push("split()");
methods.push("substr()");
methods.push("toLowerCase()");
methods.push("toString()");
methods.push("toUpperCase()");
methods.push("unshift()");
if (Mid(GetEditorText(),pos,1)=='.') {
AutoDopWind(methods,prev.length+1);
} else {
n = 20;	// макс. длина метода с запасом
prev = Mid(GetEditorText(),pos-n,n+1);
countLeft = CountFields(prev,".")-1;
prev = LTrim(NthField(prev,".",countLeft+1));
if (prev!='') {
for (var i=0; i<methods.length; i++) {
if (prev==Left(methods[i],prev.length) && prev!=methods[i]) {
found = true;
InsertText(Mid(methods[i],prev.length+1),true);
break;
}
}
}
}
} else if (CompareRegEx(Mid(GetEditorText(),pos-20,20+1),".*?\\=\\s*?[tfnuN][a-z]*?")) {
n = 20;	// макс. длина с запасом
var methods = [];
methods.push("false");
methods.push("function");
methods.push("null");
methods.push("true");
methods.push("undefined")
prev = Mid(GetEditorText(),pos-n,n+1);
countLeft = CountFields(prev,"=")-1;
prev = LTrim(NthField(prev,"=",countLeft+1));
if (prev!='') {
for (var i=0; i<methods.length; i++) {
if (prev==Left(methods[i],prev.length) && prev!=methods[i]) {
found = true;
InsertText(Mid(methods[i],prev.length+1),true);
break;
}
}
}
} else if (CompareRegEx(Mid(GetEditorText(),pos-20,20+1),".*?sound\\s*?\\(\\s*?['\"]\\s*?")) {
FileDataWind('audio',true);
} else if (CompareRegEx(Mid(GetEditorText(),pos-20,20+1),".*?(image|sprite|\\.path)\\s*?\\(\\s*?['\"]\\s*?")) {
FileDataWind('image',true);
} else if (CompareRegEx(Mid(GetEditorText(),pos-20,20+1),".*?(effect|texteffect)\\s*?\\(\\s*?['\"]\\s*?")) {
AutoDopWind(SpriteEffects,prev.length+1);
} else {
n = 30;	// макс. длина макроса с запасом
var macros = [];
for (var i in MacrosArr) {
var item = MacrosArr[i];
macros.push(
[item.name,item.syntax.substr(0,1)]
);
}
for (var i in OperatorsArr) {
var item = OperatorsArr[i];
macros.push(
[item.name,item.syntax.substr(0,1)]
);
}
prev = Mid(GetEditorText(),pos-n,n+1);
var regex = new RegExp('['+PrepinPattern+']');
prev = prev.split(regex);
prev = prev[prev.length-1];
if (prev!='') {
for (var i=0; i<macros.length; i++) {
if (prev==Left(macros[i][0],prev.length)) {
ins1 = Mid(macros[i][0],prev.length+1)+macros[i][1];
found = true;
break;
}
}
}
if (found) {
InsertText(ins1,true);
}
}
editor.focus();
}
function GetVarsArray()
{
var Vars = [];
var s, macros, Var = '';
var myRe, myMatch, myRe2, myMatch2;
s = GetEditorText();
s = s.replace(/\[\[.*?(?!\]\]).*?\]?\]\]/g,"<<link $&>>"); // ссылки как макрос
myRe = /<<(.*?(?!<<)(?!>>).*?)>>/g;
myRe2 = new RegExp("(\\${1,2}[^"+BadVarsSymbs+"]+?)["+BadVarsSymbs+"]",'g');
while ((myMatch = myRe.exec(s)) != null)
{
macros = ' '+myMatch[1]+' ';
while ((myMatch2 = myRe2.exec(macros)) != null)
{
Var = myMatch2[1].trim();
Var = Var.replace(/^\$/,'');
if (Left(Var,1)!='$')
{
Vars.push(Var);
}
}
}
for (var i=0; i<LocationArr.length; i++)
{
for (var j=0; j<LocationArr[i].Vars.length; j++)
{
Vars.push(LocationArr[i].Vars[j]);
}
}
return ArrayUnique(Vars);
}
function GetTitlesArray(lowercase,nounique)
{
var LocNames = [];
var title;
for (var i=0; i<LocationArr.length; i++)
{
title = LocationArr[i].Title;
if (!ForbiddenLocation(title))
{
if (lowercase)
{
title = title.toLowerCase();
}
LocNames.push(title);
}
}
if (!nounique)
{
LocNames = ArrayUnique(LocNames);
}
else
{
LocNames.sort();
}
return LocNames;
}
function FindNReplace()
{
var str = '';
str += "<div>";
str += "<input id='findField' type='text' style='margin-bottom:10px;' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' placeholder='"+Lang.FindFind+"'>";
str += "<div style='margin-top:4px;'>";
str += "<span class='button' id='button1' style='float:left;'>"+Lang.FindFind+"</span>";
str += "<span class='button' id='button2' style='float:right;'>"+Lang.FindCount+"</span>";
str += "</div>";
str += "<div style='clear:both;'></div>";
str += "</div><div style='clear:both;'></div>";
str += "<div style='font-size:11px;margin-top:8px;text-align:left;'>";
str += "<label><input id='caseField' type='checkbox'>"+Lang.FindCase+"</label>";
str += "<br><label><input id='regexField' type='checkbox'>"+Lang.FindRegEx+"</label>";
str += "</div>";
str += "<div style='margin-top:8px;'>";
str += "<input id='replaceField' type='text' style='margin-bottom:8px;' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' placeholder='"+Lang.FindReplaceTo+"'>";
str += "<div style='margin-top:4px;'>";
str += "<span class='button' id='button3' style='float:left;'>"+Lang.FindReplace+"</span>";
str += "<span class='button' id='button4' style='float:right;'>"+Lang.FindReplaceAll+"</span>";
str += "</div>";
str += "<div style='clear:both;'></div>";
str += "</div>";
mywindow_inner.innerHTML = str;
SetEvent('findField',function(){RememberFindFields();},'blur');
SetEvent('replaceField',function(){RememberFindFields();},'blur');
SetEvent('button1',function(){EditorFindNext();});
SetEvent('button2',function(){EditorFindCount();});
SetEvent('button3',function(){EditorReplaceNext();});
SetEvent('button4',function(){EditorReplaceAll();});
SetEvent('caseField',function(){EditrCaseField=!EditrCaseField},'change');
SetEvent('regexField',function(){EditrRegExField=!EditrRegExField},'change');
ShowWind(true);
var findField = $('findField');
if (EditrFindField=='') {
EditrFindField = lastSearchQuery;
}
findField.value = EditrFindField;
findField.select();
$('replaceField').value = EditrReplaceField;
if (EditrCaseField)
{
$('caseField').checked = true;
}
if (EditrSelectedField)
{
$('selectField').checked = true;
}
if (EditrRegExField)
{
$('regexField').checked = true;
}
}
function RememberFindFields()
{
var findField = $('findField');
if (findField)
{
EditrFindField = findField.value;
}
var replaceField = $('replaceField');
if (replaceField)
{
EditrReplaceField = replaceField.value;
}
}
function EditorFind(from)
{
var ret = new Array(2);
var text = GetEditorText();
var myRe, myMatch;
if (EditrRegExField)
{
try
{
var mod;
if (!EditrCaseField)
{
mod = 'i';
}
else
{
mod = '';
}
myRe = new RegExp(EditrFindField,'g'+mod);
myRe.lastIndex = from;
myMatch = myRe.exec(text);
if (myMatch!=null)
{
ret[1] = myMatch[0].length;
ret[0] = myRe.lastIndex-ret[1]+1;
}
else
{
ret[1] = 0;
ret[0] = 0;
}
}
catch(e)
{
ret[0] = 0;
ret[1] = 0;
return ret;
}
}
else
{
ret[1] = EditrFindField.length;
if (!EditrCaseField)
{
ret[0] = text.toLowerCase().indexOf(EditrFindField.toLowerCase(),from)+1;
}
else
{
ret[0] = text.indexOf(EditrFindField,from)+1;
}
}
return ret;
}
function EditorFindNext(from,replace)
{
RememberFindFields();
var findField = $('findField');
var found = false;
if (EditrFindField!='')
{
if (from===undefined)
{
var selData = GetSelection(editor);
from = selData['start'] + (selData['end']-selData['start']);
found = false;
}
var fnd = EditorFind(from); // массив: начало,длина
var i = fnd[0];
if (i!=0)
{
ShowWind(false);
found = true;
ScrollToPos(editor,i-1);
if (!replace)
{
Select(editor,i-1,fnd[1]);
}
else
{
var MyText = GetEditorText();
MyText = MyText.substr(0,i-1) + EditrReplaceField + MyText.substr(i-1+fnd[1]);
SetEditorText(MyText);
Select(editor,i-1,EditrReplaceField.length);
}
}
else
{
if (from==0 && !found)
{
Message(Lang.NotFound2);
if (findField)
{
Select(findField,0,findField.value.length)
}
else
{
FindNReplace();
}
}
else
{
EditorFindNext(0,replace);
}
}
}
else
{
if (findField)
{
findField.focus();
}
else
{
FindNReplace();
}
}
}
function EditorFindCount(returnCount)
{
RememberFindFields();
var findField = $('findField');
findField.focus();
var MyText;
var n = 0;
if (EditrSelectedField)
{
var selData = GetSelection(editor);
MyText = GetEditorText().substr(selData['start'],selData['end']-selData['start']);
}
else
{
MyText = GetEditorText();
}
if (EditrFindField!='')
{
if (EditrRegExField)
{
try
{
if (!EditrCaseField)
{
n = MyText.split(new RegExp((EditrFindField),'i')).length-1;
}
else
{
n = MyText.split(new RegExp((EditrFindField),'')).length-1;
}
}
catch(e)
{
Message(Lang.NotFound2);
}
}
else
{
if (!EditrCaseField)
{
n = MyText.toLowerCase().split(EditrFindField.toLowerCase()).length-1;
}
else
{
n = MyText.split(EditrFindField).length-1;
}
}
}
else
{
n = MyText.length;
}
if (!returnCount)
{
if (n>0)
{
Message(Lang.Found+": "+n)
}
else
{
Message(Lang.NotFound2);
}
}
else
{
return n;
}
}
function EditorReplaceAll()
{
RememberFindFields();
var findField = $('findField');
if (EditrFindField!='')
{
var n = EditorFindCount(true); // сколько будет замен
if (n>0)
{
var MyText = GetEditorText();
if (EditrRegExField)
{
try
{
if (!EditrCaseField)
{
var mod = 'gi';
}
else
{
var mod = 'g';
}
MyText = MyText.replace(new RegExp((EditrFindField),mod),EditrReplaceField);
}
catch(e)
{
Message(Lang.NotFound2);
}
}
else
{
if (!EditrCaseField)
{
MyText = ReplaceAll(MyText,EditrFindField,EditrReplaceField);
}
else
{
MyText = ReplaceAllB(MyText,EditrFindField,EditrReplaceField);
}
}
SetEditorText(MyText);
ShowWind(false);
Message(Lang.Replaced+': '+n);
ScrollToPos(editor,0);
Select(editor,0,0);
}
else
{
Message(Lang.NotFound2);
}
}
else
{
if (findField)
{
findField.focus();
}
}
}
function EditorReplaceNext()
{
EditorFindNext(undefined,true);
}
function GetCurrPassage(MyText,currentPos)
{
var StartTit, StartPar, EndPar, Title;
var myRe, myMatch;
var selData = GetSelection(editor);
if (!currentPos) {
currentPos = selData['start'];
}
currentPos = currentPos+1;
if (!MyText) {
MyText = GetEditorText();
}
myRe = /^\s*?::/gm;
prev_lastIndex = 0;
while ((myMatch = myRe.exec(MyText)) != null) {
myRe.lastIndex = myRe.lastIndex-myMatch[0].length+1;
if (myRe.lastIndex>currentPos) {
break;
}
prev_lastIndex = myRe.lastIndex-1;
}
StartTit = prev_lastIndex;
EndPar = myRe.lastIndex-1;
if (EndPar<0) {
EndPar = MyText.length;
}
myRe = /$/gm;
myRe.lastIndex = StartTit;
myMatch = myRe.exec(MyText);
StartPar = myRe.lastIndex;
Title = MyText.substr(StartTit,StartPar-StartTit).trim();
if (Title.substr(0,2)=='::') {
Title = Title.substr(2).trim();
} else {
Title = '';
}
var Ret = {};
Ret.startTitle = StartTit; // начало названия
Ret.startText = StartPar; // начало текста
Ret.endText = EndPar;   // конец текста
Ret.title = Title;    // название параграфа
return Ret;
}
function DarkModeSwitch()
{
var setDarkModeAttr = function(on) {
var elems = [editor,editorTop,editorTitle,editorColor,backdrop,navPanel,navPanel2];
for (var i in elems) {
var elem = elems[i];
if (elem) {
elem.style.transition = 'color 300ms ease, background-color 300ms ease';
if (on) {
elem.setAttribute('darkmode','');
} else {
elem.removeAttribute('darkmode');
}
}
}
}
if (DarkMode) {
DarkMode = false;
setDarkModeAttr(false);
SetPrefValue('DarkMode','false');
} else {
DarkMode = true;
setDarkModeAttr(true);
SetPrefValue('DarkMode','true');
}
RefreshText();
}
function ColorModeSwitch()
{
if (ColorMode) {
ColorMode = false;
SetPrefValue('ColorMode','false');
editorColor.removeAttribute('colored');
editorColor.setAttribute('normal','');
} else {
ColorMode = true;
SetPrefValue('ColorMode','true');
editorColor.removeAttribute('normal');
editorColor.setAttribute('colored','');
}
RefreshText();
}
function EditrGotoLocation(title,prevTitle)
{
title = title.trim();
if (GetLocIndexByTitle(title)!=-1)
{
OpenEditor(false);
EditLocation(title);
}
else
{
NewLocation(title);
}
if (prevTitle)
{
if (prevTitle!='')
{
PrevTitle = prevTitle;
buttonBack.style.display = 'inline-block';
}
}
}
function EditrGotoLink()
{
var MyText = GetEditorText();
var myRe, myMatch;
var selData = GetSelection(editor);
var currentPos = selData['start'];
var Link = '';
myRe = LinksPattern;
myRe.lastIndex = 0;
while ((myMatch = myRe.exec(MyText)) != null) {
if (myRe.lastIndex>currentPos) {
Link = myMatch[1];
break;
}
}
if (myMatch==null || currentPos<=(myRe.lastIndex-myMatch[0].length)) {
myRe = new RegExp(DisplayPattern,'g');
myRe.lastIndex = 0;
while ((myMatch = myRe.exec(MyText)) != null) {
if (myRe.lastIndex>currentPos) {
Link = myMatch[4];
break;
}
}
if (myMatch==null || currentPos<=(myRe.lastIndex-myMatch[0].length)) {
Message(Lang.FindLinkPlease);
return;
}
}
Link = Link.toLowerCase().trim();
if (Link.indexOf("://")==-1 && Link!='[[' && Link!=']]' && Link!='|' && Link!='' && Link.substr(0,2)!='$$') {
Link = Link.replace(/\{[^{}]*?\}/g,''); // игнорируем установки переменных в ссылках
Link = Link.trim();
EditrGotoLocation(Link,GetCurLocTitle());
}
}
function EditrBack()
{
if (PrevTitle.trim()!='')
{
EditrGotoLocation(PrevTitle);
}
HideBackButton();
}
function HideBackButton()
{
PrevTitle = '';
buttonBack.style.display = 'none';
}
function CancelChanges()
{
if (!editNewLoc)
{
var Loc = LastLocation();
editorTitle.value = Loc.Title;
SetEditorText(LocTextBak);
ScrollToPos(editor,0);
Select(editor,0,0);
}
else
{
editorTitle.value = '';
editorTitle.focus();
SetEditorText('');
SetColorButton(0);
}
}
function AddText(action)
{
var myText = GetEditorText();
myText = ReplaceLineEndings(myText);
var myTextLen = myText.length;
var selData = GetSelection(editor);
var pos = selData['start'];
var sbegin = 0;
var slen_bak = selData['end']-selData['start'];
var slen = 0;
for (var i=pos; i>=0; i--) {
if (i==0 || myText.substr(i-1,1)=='\n') {
sbegin = i;
break;
}
}
for (var i=pos+slen_bak; i<=myTextLen; i++) {
if (i>=myTextLen || myText.substr(i,1)=='\n') {
slen = i-sbegin;
break;
}
}
if (slen<1) {
slen = 1;
}
var s = '';
if (action==3) {
s = myText.substr(sbegin,slen);
s += '\n' + s;
} else {
var n = 0;
var added = false;
var removed = false;
var linesArr = Split(myText.substr(sbegin,slen),'\n');
for (var i=0; i<linesArr.length; i++) {
s = linesArr[i];
if (action==1) {
if (s!='') {
linesArr[i] = '\t' + s;
added = true;
n++;
}
} else if (action==2) {
if (s!='' && (s.substr(0,1)=='\t' || s.substr(0,1)==' ')) {
linesArr[i] = Right(s,s.length-1);
removed = true;
n++;
}
}
}
s = linesArr.join('\n');
}
SetEditorText(Left(myText,sbegin) + s + Right(myText,myText.length-sbegin-slen));
if (added) {
Select(editor,sbegin,slen+n);
} else if (removed) {
Select(editor,sbegin,slen-n);
} else {
Select(editor,pos,slen_bak);
}
}
function InsertText(text,noselect)
{
var oS = editor.scrollTop;
var selData = GetSelection(editor);
var currentPos = selData['start'];
var currentEnd = selData['end'];
var editorText = GetEditorText();
var strLeft = editorText.substr(0,currentPos);
var strRight = editorText.substr(currentEnd);
SetEditorText(strLeft+text+strRight);
if (noselect) {
Select(editor,currentPos+text.length,0);
} else {
Select(editor,currentPos,text.length);
}
editor.scrollTop = oS;
}
function GetEditorText()
{
return editor.value;
}
var noEditorLine = false;
function SetEditorText(text)
{
editor.value = text;
noEditorLine = true;
RefreshText();
noEditorLine = false;
}
function GetSelectedText()
{
obj = $(getFocusedId());
if (obj.value!==undefined)
{
var selData = GetSelection(obj);
var currentPos = selData['start'];
var currentLen = selData['end']-selData['start'];
if (currentLen>0)
{
var text = obj.value.substr(currentPos,currentLen);
return text;
}
else
{
return false;
}
}
else
{
return false;
}
}
function CutSelectedText()
{
obj = $(getFocusedId());
if (obj.value!==undefined)
{
var selData = GetSelection(obj);
var currentPos = selData['start'];
var currentLen = selData['end']-selData['start'];
if (currentLen>0)
{
var text = obj.value.substr(currentPos,currentLen);
var s = obj.value;
obj.value = s.substr(0,currentPos)+s.substr(currentPos+currentLen);
Select(obj,currentPos,0);
}
}
}
function PasteText(text)
{
if (text!='')
{
obj = $(getFocusedId());
if (obj.value!==undefined)
{
text = text.replace(/\[\[asmNewLine\]\]/g,"\n");
text = text.replace(/\[\[asmApostr\]\]/g,"'");
var selData = GetSelection(obj);
var currentPos = selData['start'];
var currentEnd = selData['end'];
var strLeft = obj.value.substr(0,currentPos);
var strRight = obj.value.substr(currentEnd);
obj.value = strLeft+text+strRight;
Select(obj,currentPos+text.length,0);
}
}
}
function SelectAll() {
obj = $(getFocusedId());
if (obj.value!==undefined)
{
obj.select();
}
}
function Select(obj,SelStart,SelLength) {
SelectText(obj,SelStart,SelLength);
}
function EnterKeyPress(event,enter,backspace) {
if (!SimpleLocation(GetCurLocTitle())) {
var myText = GetEditorText();
var sel = GetSelection(editor);
var pos = sel.start; // текущая позиция курсора
var sbegin = pos; // начало строки
for (var i=pos; i>=0; i--) {
if (i==0 || myText.substr(i-1,1)=='\n') {
sbegin = i;
break;
}
}
var str = myText.substr(sbegin,pos-sbegin);
if (enter) {
if (/^\s*\\?/.test(str)) {
event.preventDefault();
event.returnValue = false;
var s = '\n'+str.replace(/^(\s*\\?\s?).*?$/,'$1');
SetEditorText(myText.substr(0,pos)+s+myText.substr(pos+sel.len));
Select(editor,pos+s.length,0);
}
} else if (backspace) {
if (str.trim()=='\\') {
event.preventDefault();
event.returnValue = false;
var s = str.replace(/^(\s*?)\\.*?$/,'$1');
SetEditorText(myText.substr(0,sbegin)+s+myText.substr(pos));
Select(editor,sbegin+s.length,0);
}
} else {
if (str.trim()=='') {
event.preventDefault();
event.returnValue = false;
SetEditorText(myText.substr(0,pos)+'\\ '+myText.substr(pos));
Select(editor,pos+2,0);
}
}
}
}
function RefreshText() {
var applyHighlights = function(text) {
var attr = '';
if (DarkMode) {
attr = ' darkmode';
}
if (!noEditorLine) {
var showLine = true;
var selection = getInputSelection(editor);
if (selection.end-selection.start>0) {
attr += ' begin';
}
if (showLine) {
var caretPos = selection.start;
for (var i=caretPos; i>=0; i--) {
if (i==0 || text.substr(i-1,1)=='\n') {
break; // начало строки
}
}
for (var j=caretPos; j<=text.length; j++) {
if (j==text.length || text.substr(j,1)=='\n') {
break; // конец строки
}
}
var temp1 = 'SDg2@rer3s7_1';
var temp2 = 'SDg2rer@3s7_2';
var space = '';
if (i==j) {
space = ' ';
}
text = text.substr(0,i)+temp1+'div'+attr+' class=asm_line'+temp2+text.substr(i,j-i)+space+temp1+'/div'+temp2+text.substr(j);
}
}
text = text.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
if (!noEditorLine && showLine) {
var reg1 = new RegExp(temp1,'g');
var reg2 = new RegExp(temp2,'g');
text = text.replace(reg1,'<').replace(reg2,'>');
}
var begText = function() {
text = text.replace(/^(<\/?div[^<>]+?>)?(\s*?)(\\)(.*?)$/gm,'$1$2<span'+attr+' class=asm_begtext>$3</span>$4');
};
var curTitle = GetCurLocTitle();
if (ColorMode) {
if (!SimpleLocation(curTitle)) {
var repl = function(s,reg,type) {
if (!type) {
type = 'function'+attr;
}
var to = '$1<span class=asm_'+type+'>$2</span>$3';
return s.replace(reg,to).replace(reg,to); // надо дважды, иначе будет подсветка через один
};
var regex, reg1;
reg1 = '(^|['+PrepinPattern+'])';
regex = new RegExp(reg1+'(var|new|in|instanceof|delete|throw|class|implements|let|const)(\\s)','gm');
text = repl(text,regex);
regex = new RegExp(reg1+'(return|true|false|null|undefined|window|document|break|continue|RegExp|isNaN|NaN|this|parent|self|screen|navigator|localStorage|void|case|default|parseInt|parseFloat|Number|String|Boolean|Array|Function|Object|Date|Image|Audio|Error|typeof|valueOf|hasOwnProperty|isPrototypeOf|prototype|name|Infinity|isFinite|yield|get|set|Set)(['+PrepinPattern+'])','gm');
text = repl(text,regex);
regex = new RegExp(reg1+'(function|await|async)(\\s|\\s*?\\()','gm');
text = repl(text,regex);
regex = new RegExp(reg1+'(asm|Math|JSON|console)(\\.)','gm');
text = repl(text,regex);
regex = new RegExp(reg1+'(do|try|catch|else)([\\s\\{])','gm');
text = repl(text,regex);
regex = new RegExp(reg1+'(if|for|while|switch|with|alert|prompt|confirm|super|eval|escape|unescape|Error|setTimeout|setInterval|clearTimeout|clearInterval)(\\s*?\\()','gm');
text = repl(text,regex);
var myRe = new RegExp(DisplayPattern,'gm');
var to = '$1$2<span'+attr+' class=asm_link>$4</span>$5';
text = text.replace(myRe,to);
var farr = [];
for (var i in MacrosArrNames) {
farr.push(MacrosArrNames[i]);
}
farr = farr.join('|');
regex = new RegExp(reg1.replace('.','')+'('+farr+')(\\s*?\\()','gm');
text = repl(text,regex,'function'+attr);
text = text.replace(/(')(.*?)(')/g,'$1<span'+attr+' class=asm_text>$2</span>$3');
text = text.replace(/(")(.*?)(")/g,'$1<span'+attr+' class=asm_text>$2</span>$3');
text = text.replace(/^((<\/?div.+?>)?\s*?\\\s*?)(.*?)$/gm,
function(match,p1,p2,p3) {
return p1+"<span"+attr+" class=asm_text>"+p3.replace(/<span.*?>|<\/span>/g,'')+"</span>";
}
);
begText();
text = text.replace(/\[\[([\+\-\*]?)([^"]*?)(\|*)([^|\r\n]*?)\]\]/g,
function(match,p1,p2,p3,p4) {
p4 = p4.replace(/<span.*?>|<\/span>/g,'').replace(/\{.*?\}/g,"<span"+attr+" class=asm_main>$&</span>");
return "<span"+attr+" class=asm_link>[[</span><span"+attr+" class=asm_function>"+p1+"</span>"+p2+"<span"+attr+" class=asm_link>"+p3+"</span><span"+attr+" class=asm_link>"+p4+"</span><span"+attr+" class=asm_link>]]</span>";
}
);
var badlinks = [];
var Link;
var myMatch;
var found;
var myRe = /<span[^<>]*? class=asm_link>(.+?)<\/span>/g;
var Titles = GetTitlesArray(true,false);
while ((myMatch = myRe.exec(text)) != null) {
Link = myMatch[1].toLowerCase().replace(/<span.*?>|<\/span>/g,'');
Link = Link.replace(/\{[^{}]*?\}/g,''); // игнорируем установки переменных в ссылках
Link = Link.trim();
if (Link.indexOf("://")==-1 && Link!='[[' && Link!=']]' && Link!='|' && Link.substr(0,2)!='$$' && Link!='') {
found = false;
if (Link==GetCurLocTitle()) {
found = true;
}
if (!found) {
for (var key in Titles) {
if (Titles[key]==Link) {
found = true;
break;
}
}
if (!found) {
badlinks.push(Link);
}
}
}
}
badlinks = ArrayUnique(badlinks);
for (var key in badlinks) {
text = text.replace(new RegExp("(<span"+attr+" class=asm_link>\\s*?)("+EscapeRegExp(badlinks[key])+")(\\s*?(<span.*?>)?\\s*?</span>)",'gi'),
function(match,p1,p2,p3) {
return p1+"<span"+attr+" class=asm_error>"+p2+"</span>"+p3;
}
);
}
text = text.replace(/\/\*[\s\S]*?\*\/|&lt;!--[\s\S]*?--&gt;/gm,
function(match) {
var s = '<span'+attr+' class=asm_comment>'+match.replace(/<span.*?>|<\/span>/g,'')+'</span>';
s = s.replace('</div>','</span></div><span'+attr+' class=asm_comment>');
s = s.replace('\n<div','</span>\n<div');
s = s.replace(/(<div.+?>)/,'$1<span'+attr+' class=asm_comment>');
return s;
}
);
text = text.replace(/([^\\:]|^)((<\/?div.+?>)?\/\/.*$)/gm,
function(match,p1,p2) {
return p1+'<span'+attr+' class=asm_comment>'+p2.replace(/<span.*?>|<\/span>/g,'')+'</span>';
}
);
} else {
text = "<div"+attr+" class='asm_text'>"+text+"</div>";
}
} else {
if (!SimpleLocation(curTitle)) {
begText();
}
}
if (isIE) {
text = text.replace(/ /g,' <wbr>');
}
return text;
};
var handleInput = function() {
editorColor.innerHTML = applyHighlights(GetEditorText());
};
handleScroll = function() {
var scroll = editor.scrollTop;
backdrop.scrollTop = scroll;
scroll = editor.scrollLeft;
backdrop.scrollLeft = scroll;
};
editor.oninput = function() {
handleInput();
};
editor.onclick = editor.oninput;
editor.onkeyup = editor.oninput;
editor.onscroll = function() {
handleScroll();
};
handleInput();
}
var style_mainBgColor;		// основной фон - цвет
var style_toolbarFontColor;	// цвет шрифта тулбара
var style_toolbarBackColor;	// цвет фона тулбара
var style_menuFontColor;	// цвет шрифта меню
var style_menuBackColor;	// цвет фона меню
var style_windBgColor;		// цвет фона окон
var style_fontColor;		// цвет шрифта
var style_linkColor;		// цвет ссылок
var style_headerColor;		// цвет заголовков (#RRGGBB)
var style_fontType;			// тип шрифта (через запятую)
var style_shadows;			// тени (стиль)
var style_shadows_block;	// тени блоков (true/false)
var style_buttonRadius;		// закругление кнопок (в пикс.)
var style_borderWidth;		// рамка - ширина (в пикс.)
var style_borderImage;		// рамка - картинка (dataurl)
var style_cursor;			// курсор - обычный (dataurl)
var style_cursorHover;		// курсор - активный (dataurl)
var style_buttonConsole;	// кнопка консоли (dataurl)
var style_buttonAudio;		// кнопка аудио (dataurl)
var style_buttonPrefs;		// кнопка настроек (dataurl)
var style_buttonView;		// кнопка просмотра (dataurl)
var style_mainBgTexture;	// основной фон - бесшовная текстура (dataurl)
var style_emptyImage = '#';
var	style_pictureDefault = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQI12NgAAIAAAUAAeImBZsAAAAASUVORK5CYII=";
var themes_fonts = [
"'Trebuchet MS', 'Droid Sans', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', sans-serif",
"Georgia, 'Droid Serif', 'Times New Roman', Times, serif",
"Menlo, Monaco, 'Droid Sans Mono', 'Courier New', Courier, 'Lucida Console', monospace",
"Palatino, 'Palatino LT STD', 'Palatino Linotype', 'Book Antiqua', Georgia, 'Droid Serif', serif",
"Tahoma, Geneva, 'Droid Sans', sans-serif"
];
style_buttonConsole = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMCAwaDI0djI0SDB6IiBmaWxsPSJub25lIi8+PHBhdGggZD0iTTIwIDhoLTIuODFjLS40NS0uNzgtMS4wNy0xLjQ1LTEuODItMS45NkwxNyA0LjQxIDE1LjU5IDNsLTIuMTcgMi4xN0MxMi45NiA1LjA2IDEyLjQ5IDUgMTIgNWMtLjQ5IDAtLjk2LjA2LTEuNDEuMTdMOC40MSAzIDcgNC40MWwxLjYyIDEuNjNDNy44OCA2LjU1IDcuMjYgNy4yMiA2LjgxIDhINHYyaDIuMDljLS4wNS4zMy0uMDkuNjYtLjA5IDF2MUg0djJoMnYxYzAgLjM0LjA0LjY3LjA5IDFINHYyaDIuODFjMS4wNCAxLjc5IDIuOTcgMyA1LjE5IDNzNC4xNS0xLjIxIDUuMTktM0gyMHYtMmgtMi4wOWMuMDUtLjMzLjA5LS42Ni4wOS0xdi0xaDJ2LTJoLTJ2LTFjMC0uMzQtLjA0LS42Ny0uMDktMUgyMFY4em0tNiA4aC00di0yaDR2MnptMC00aC00di0yaDR2MnoiLz48L3N2Zz4=";
style_buttonAudio   = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMyA5djZoNGw1IDVWNEw3IDlIM3ptMTMuNSAzYzAtMS43Ny0xLjAyLTMuMjktMi41LTQuMDN2OC4wNWMxLjQ4LS43MyAyLjUtMi4yNSAyLjUtNC4wMnpNMTQgMy4yM3YyLjA2YzIuODkuODYgNSAzLjU0IDUgNi43MXMtMi4xMSA1Ljg1LTUgNi43MXYyLjA2YzQuMDEtLjkxIDctNC40OSA3LTguNzdzLTIuOTktNy44Ni03LTguNzd6Ii8+PHBhdGggZD0iTTAgMGgyNHYyNEgweiIgZmlsbD0ibm9uZSIvPjwvc3ZnPg==";
style_buttonPrefs   = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMCIgaGVpZ2h0PSIyMCIgdmlld0JveD0iMCAwIDIwIDIwIj48cGF0aCBmaWxsPSJub25lIiBkPSJNMCAwaDIwdjIwSDBWMHoiLz48cGF0aCBkPSJNMTUuOTUgMTAuNzhjLjAzLS4yNS4wNS0uNTEuMDUtLjc4cy0uMDItLjUzLS4wNi0uNzhsMS42OS0xLjMyYy4xNS0uMTIuMTktLjM0LjEtLjUxbC0xLjYtMi43N2MtLjEtLjE4LS4zMS0uMjQtLjQ5LS4xOGwtMS45OS44Yy0uNDItLjMyLS44Ni0uNTgtMS4zNS0uNzhMMTIgMi4zNGMtLjAzLS4yLS4yLS4zNC0uNC0uMzRIOC40Yy0uMiAwLS4zNi4xNC0uMzkuMzRsLS4zIDIuMTJjLS40OS4yLS45NC40Ny0xLjM1Ljc4bC0xLjk5LS44Yy0uMTgtLjA3LS4zOSAwLS40OS4xOGwtMS42IDIuNzdjLS4xLjE4LS4wNi4zOS4xLjUxbDEuNjkgMS4zMmMtLjA0LjI1LS4wNy41Mi0uMDcuNzhzLjAyLjUzLjA2Ljc4TDIuMzcgMTIuMWMtLjE1LjEyLS4xOS4zNC0uMS41MWwxLjYgMi43N2MuMS4xOC4zMS4yNC40OS4xOGwxLjk5LS44Yy40Mi4zMi44Ni41OCAxLjM1Ljc4bC4zIDIuMTJjLjA0LjIuMi4zNC40LjM0aDMuMmMuMiAwIC4zNy0uMTQuMzktLjM0bC4zLTIuMTJjLjQ5LS4yLjk0LS40NyAxLjM1LS43OGwxLjk5LjhjLjE4LjA3LjM5IDAgLjQ5LS4xOGwxLjYtMi43N2MuMS0uMTguMDYtLjM5LS4xLS41MWwtMS42Ny0xLjMyek0xMCAxM2MtMS42NSAwLTMtMS4zNS0zLTNzMS4zNS0zIDMtMyAzIDEuMzUgMyAzLTEuMzUgMy0zIDN6Ii8+PC9zdmc+";
style_buttonView    = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMCAwaDI0djI0SDB6IiBmaWxsPSJub25lIi8+PHBhdGggZD0iTTEyIDQuNUM3IDQuNSAyLjczIDcuNjEgMSAxMmMxLjczIDQuMzkgNiA3LjUgMTEgNy41czkuMjctMy4xMSAxMS03LjVjLTEuNzMtNC4zOS02LTcuNS0xMS03LjV6TTEyIDE3Yy0yLjc2IDAtNS0yLjI0LTUtNXMyLjI0LTUgNS01IDUgMi4yNCA1IDUtMi4yNCA1LTUgNXptMC04Yy0xLjY2IDAtMyAxLjM0LTMgM3MxLjM0IDMgMyAzIDMtMS4zNCAzLTMtMS4zNC0zLTMtM3oiLz48L3N2Zz4=";
if (LangCode=='ru') {style_themes.push('Обсидиан');} else {style_themes.push('Obsidian');}
if (LangCode=='ru') {style_themes.push('Классика');} else {style_themes.push('Classic');}
if (LangCode=='ru') {style_themes.push('Хакер');} else {style_themes.push('Hacker');}
if (LangCode=='ru') {style_themes.push('Фентези');} else {style_themes.push('Fantasy');}
if (LangCode=='ru') {style_themes.push('Подземелье');} else {style_themes.push('Dungeon');}
if (LangCode=='ru') {style_themes.push('Море');} else {style_themes.push('Sea');}
if (LangCode=='ru') {style_themes.push('Заметки');} else {style_themes.push('Notes');}
if (LangCode=='ru') {style_themes.push('Апельсин');} else {style_themes.push('Orange');}
if (LangCode=='ru') {style_themes.push('Даэдра');} else {style_themes.push('Daedra');}
if (LangCode=='ru') {style_themes.push('Лес');} else {style_themes.push('Forest');}
if (LangCode=='ru') {style_themes.push('Новелла');} else {style_themes.push('Novel');}
if (LangCode=='ru') {style_themes.push('Асфальт');} else {style_themes.push('Asphalt');}
function SetTheme(themeNum) {
if (isNaN(+themeNum) || themeNum<0 || themeNum>=style_themes.length) {
themeNum = 0;
}
style_current_theme = themeNum;
style_mainBgColor = "#222222";
style_windBgColor = "rgba(20,20,20,0.5)";
style_toolbarFontColor = "#FFFFFF";
style_toolbarBackColor = style_windBgColor;
style_menuFontColor = "#FFFFFF";
style_menuBackColor = "rgba(64,64,64,0.5)";
style_fontColor = "#FFFFFF";
style_linkColor = "#E9D460";
style_headerColor = "#d2d7d3";
style_fontType = themes_fonts[4];
style_shadows = "none";
style_shadows_block = false;
style_buttonRadius = "5";
style_borderWidth = "0";
style_borderImage = style_emptyImage;
style_cursor = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAABYlBMVEUAAAA/Pz82Njb///8vLy////8tLS03NzeJiYklJSX39/ciIiJBQUEzMzMzMzOZmZn///8mJiY3Nzc0NDTg4OA2NjZMTEwsLCxubm5GRkZWVlYzMzM0NDQzMzM0NDQzMzMyMjIxMTEzMzMyMjIyMjIpKSk0NDTn5+f9/f09PT3Jycns7Oza2tpycnKrq6tDQ0OysrJcXFwzMzMzMzMyMjIxMTEzMzMxMTEzMzMxMTFAQECioqLZ2dkdHR03Nzfv7+/r6+vS0tJCQkIzMzOYmJi8vLy4uLhRUVEwMDDp6emioqJpaWmLi4uGhoZlZWXGxsaQkJB6enpZWVk0NDSFhYU2NjaXl5c2NjYzMzMyMjI1NTUyMjIyMjIyMjIyMjI1NTUzMzMrKys5OTn////7+/s6OjokJCQ3Nzc0NDSampomJiYxMTEtLS39/f04ODg5OTkvLy8qKir4+PgsLCwjIyMeHh7+hwJIAAAAY3RSTlMAA/H7Bfr47eL79/r201T+9/b19fT08/Px8fDvz7u1X0o7KhYR/vn29PTz8vDw7+/u7evdkXNoYkMmCPj39/b19fT09PPy8vHx8PDw7+/v7ezs6ebk5OPgyMbBrJ2AeiIZDAnUBOCsAAABsElEQVQ4y33SZ1vqMBQH8JTYXluGcEH2Bvce13X33su91yEk0lrA8f2N9YmPJOJpkhc5v+f/ojnoODeYr6Ae1LVyzVZz7egJ8dFOJVim3F28uXo57aeDpa7ieb0PJiOMLXHRFeDPBqMhIRRwBhfwN2G7i0h7DPRzUKvB+6jTfCGECvg37nPIAdJU4vMAX0Mf2mQeiRAF8D2WapN9IVTAD+urSfaEUAE/h2dMkuNCAn0e8AT+4yc7PULICQDnEJ4wSbCKtA7wj4N7gf+/pnOVjoRGL66JNi/9k+FuK4A3eRfrujX0anzVYcsPwLNGr/cnAayJdHyk3zAZzZzIoAZv3wFOXrdsSimbLSIJXIAV+A0QM9xsIVQqryCtE2AYm2oELMA/2xvendaZsA6xQJvUJwFGI+QQrYi2AFeb3785NHqZ1kFPO1vKWM06M4FLUlggkVGALyYpyI+VdQ2bLqKqbyCJIRxvZeWEUoZGQ+gUzbuJGMAPPynKEdWlyu2klWn9F0A4ZecloHmbrzwbGdanp+wgkku7O4rUSMb9NhGzrVawOdAicwtqQ+QsB9luSLm/ARNReAP/nQ5NAAAAAElFTkSuQmCC";
style_cursorHover = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAABZVBMVEUAAABDQ0M0NDQ2NjI1NDI3NjIzMzP/1gAlKDb3xgI0NDM2NjKKdB3/1AD/0AAiJjdsXiQzMzMzMzIyMjL/zQAmKTZCPi/gtAfouwUsLjRMRixZUClEPy6wkRM0MzM0NDIzNDMyMjMzMzMyMjItLjQ0NDMtLjX/0QD9ygA3NjLJpA5HQi1TSyu6mBHsvgRyYiPasAmOdhwzMzNZTyo2NTKHcR4zMzMyMzMyMjMxMTIzMzMxMjQzMzMzMzMzMzMyMjIxMTH/3AAvMDQrLTSihxcdIzlBPS/ZsAk+PDDrvQXvwQRBPjDSqguYfxk8OjAxMjOihhdlWSaGcR4zMzOqjBbGoA56aSE0MzOXfhoyMjIyMjQyMjQyMjIwMDU1NTUrKyv/////1gAkKDc6OTaagBkmKTc2NjYwMTU3NjQ4ODYtLzX/0wArLTU6OTT/2AD/0AAyMzYpLDY2NTP/4wD/zQAeJDn/2QAjmktHAAAAYHRSTlMAAwb18O3+/fv39fLj/Pv68dO9Fvn29vT08/Py7+/PtV9KKhH5+ff39PPz8vLy8vDw7uvp4uLdx5FzaGJVU0M8Jvr5+Pj39/f19fX09PPy8fDv7+3t7ezm46ydgHo6Igwu7hV9AAABs0lEQVQ4y33SZ1PbQBAG4JPiqIF7740WeocQWnpC772sfFhdxqb9ftBgcYNuzI6kD7eP3pubWxSN9BajiEUdK4JV/fjqAyGpQ2nFV+ksPtV+5YNK7yURFLi5P4gr3DIRFJD5kZ+ctkgEBeDpMK1q3xDTEYC8IRn6VyIoAI3xLsM+RwxNvrwCkFPrFp5HiOkEQB7NWfiMFl0uAFMcFvApERQAcyAr4AgRFIDbwG4Qz7FtQUAD3kT/mGCHq++Erz5BADz4j34rs1FHEDDDAynz++YPfQ69S+jm3b8DMTH1d3zK4FYRy7QLfa53y87uAOJYNvNP6hM4Zf+aBLSBvPYf+NCjqiqKxk2WEeMBppjYa0CyTyuUFlcq7XMSwJujuXpCBH+oNe0suX0XzNwn/1h2LS/DYBxfINZtu6B2kto2NMkaDkAga0xTYzVpTCUsXFrA8UETRgRc8l5WQe9pvkxb1dcK+SGWUQvehBWfJi0hFs3r6eQt7ATtsjeiuhx1Jq1yV5uQoX+oWfQAxnmdp6hsDcTyuWaY9AhxPmWtJ5QJqtidbbrCeku1ZxfohpuzGr6LLFHrzy8SdsLD0lZqAAAAAElFTkSuQmCC";
style_mainBgTexture = style_emptyImage;
switch (themeNum) {
case 1:
style_mainBgColor = "#DDDDDD";
style_windBgColor = "#FFFFFF";
style_toolbarFontColor = "#555555";
style_toolbarBackColor = style_windBgColor;
style_menuFontColor = style_toolbarFontColor;
style_menuBackColor = style_windBgColor;
style_fontColor = "#555555";
style_linkColor = "#5A8BBC";
style_headerColor = "#666666";
style_fontType = themes_fonts[1];
style_shadows = "2px 2px 5px #888888";
style_shadows_block = true;
style_buttonRadius = "6";
style_borderWidth = "0";
style_borderImage = style_emptyImage;
style_cursor = style_emptyImage;
style_cursorHover = style_emptyImage;
style_mainBgTexture = style_emptyImage;
break;
case 2:
style_mainBgColor = "#222222";
style_windBgColor = "#222222";
style_toolbarFontColor = "#FFFFFF";
style_toolbarBackColor = style_windBgColor;
style_menuFontColor = style_toolbarFontColor;
style_menuBackColor = style_windBgColor;
style_fontColor = "#00CC00";
style_linkColor = "#e74c3c";
style_headerColor = "#00CC00";
style_fontType = themes_fonts[2];
style_shadows = "none";
style_shadows_block = false;
style_buttonRadius = "0";
style_borderWidth = "10";
style_borderImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkAQMAAADbzgrbAAAABlBMVEUAAAAaxgQuGyu4AAAAAXRSTlMAQObYZgAAACdJREFUCNdjqGBgYHzA8IeBgfkDw38ggJIQEaisAQMDw4FBRBLhZgA6eTdRaHQ1IAAAAABJRU5ErkJggg==";
style_cursor = style_emptyImage;
style_cursorHover = style_emptyImage;
style_mainBgTexture = style_emptyImage;
break;
case 3:
style_mainBgColor = "#693F24";
style_windBgColor = "#DCC096";
style_toolbarFontColor = "#643B0F";
style_toolbarBackColor = style_windBgColor;
style_menuFontColor = style_toolbarFontColor;
style_menuBackColor = style_windBgColor;
style_fontColor = "#000000";
style_linkColor = "#643B0F";
style_headerColor = "#3D270E";
style_fontType = themes_fonts[3];
style_shadows = "0 0 8px #693F24";
style_shadows_block = true;
style_buttonRadius = "2";
style_borderWidth = "12";
style_borderImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAhCAMAAABgOjJdAAAAgVBMVEUAAABdNR1hNx4AAAAAAABKJBFVMRw6IRIwGw/iwI3au4qQelpxYEeqiGJbMx3uzJeRb026mW9EHgyYg2Gmgl2hflmZdlN8bFFZNB5OJxQ8FwfqyJS5mG+0kGeujGWMaUmCYEFINSRQNSJBLB0VBwK+nXJZPyo5FQYdCwS/nXJZPiqHD1KcAAAABHRSTlMA/f4B87d6vAAAASxJREFUOMutk8uWwiAMQIUJVbBKS+nbvmvt+P8fOOEgi64yC+85bOCekEByAooT7Ft2RbJ5hXMA1tlvvnc0NpZrKduET8DuHgYTT1opdc7eaGR5kyg1Nl0JVeSpoOyaUamkyTM0rjoxxWByHUMtPDXEOjdDYRJ9dYZUhRFWyRh+00ea4npCLJUVplDyYwxCFM7ob57eGYUQw8doR2Mx4PEWd7U1Y+uMDPPBpF72kKl9YfpYg8t05p3GwixfgDMPh4Vbt9nxGY11KmOkXAAuAYDFb04r/OfVz6yqn31d8QucAnDhVd0/64qdnXGPRHoTETsYLBK3VET3YDyC8eMIxsMbxxh4iivE+KJB50HXQr8HAf0v9N/S/UH3GN2ndK/T80LPHDm3GzX7244GxR/iGy9djlnlLAAAAABJRU5ErkJggg==";
style_cursor = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAA7VBMVEUAAADIzMP/5claWjoCAgJGPjgBAQADAwANDQwAAAAXFxUDAwEDBAMaGhkODg0BAQAKCghVQ2sAAADZ2dk7OzsxMC84PD0JCQc+Pj4KCwhJSVQEBAICAgI6NzBmZmbS0tLR0dHOzs7ExMXLy8u8vLzGxsawsLC5ubmlpaV1dXXIyMjCwsJlZWWamppqamoPDw7Kysqzs7OXl5dSUlIrKioBAQG2traysrKSkpKMjIx+fn1wcHBiYmJLS0tHRka/v7+srKyqqqqioqKEhIR4eHdcXFxDQkI5ODghISGWlpYwLy0ZGRiop7JTUl9WVlYSe3RjAAAAH3RSTlMAAgEBKwRWDrjVq4DV1Kupci0dBvHx5ePV1Y+NjU8P6gBz0wAAAZdJREFUOMvdkteS2yAUhg+oOfZma3oDNUB1Lcly716X3U3y/o8TNPJ44CIvsN8NM/Bxfs4ZAK7r2oYW1C4GYAQXbiuxXpoGNOB2ywKV08SjYWWrFXQGpU+J/+GdBM5gXRh7lJDnRVGMXx9Pr/eyDtKUbrqNKXGnVRHzdCS+3KGHB4yUMKczW4fSKJeszydk+OkXwloXBlzlmyZll8eUUjKsQcewZMqmqRF6xKXU/2PrAjIsp7Nn0iAeaeA38pba8L1pOl/nzCdnko4DliKY7xdVF7r5yiW0NdIUq7O0F4JNrz4fhnJeLZMUdGFbBHy+5xfh9+HUcdSIaJ2Eq8R3z0I/3AZzppS4qbIiCX33Ing8mD2BQp1nQ2lIpbE8LwiCXBN6x6hkqzCO434/lsecs6U+rNtj9CyCIEk8eZ0LthnLR2r8OP6dlmI0GjEmxkJkh28YdHrXg/0siqJZmk+y7KmWk9RA4JiPDYP5rsymAxN00MX/vox20cefoGEghDDC56yXl56NkS40Z5YBLXdm+4v+C4ZWeGP8A9wzObf5MbrGAAAAAElFTkSuQmCC";
style_cursorHover = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAABBVBMVEUAAADVxpT09P+/38MCAgIBAQABAQEQEA8EBAD/9u0oGigaGxgEAwEJCQcODg0BAQADAwILCwoAAAAAAABJSUk6OThDSEsLCwhKSkogICAgHx5XV2RHRDpFZXWIO453d3f////8/Pz6+vrv7+/39/fJycl5eXnt7e3X19fV1dX+/v719fXz8/Ph4eGQkI/x8fHq6urk5OTi4uLb29vQ0NC4uLiAgH9kZGM0MzIBAQLm5ube3t65ubmqqqqZmZiNjY1bW1tWVVUTExPExMSwsLCgn5+JiYmDg4NtbGxSUVC8vLy1tbVzc3JGREM6OTcmJiYeHh0ODg7My9iysrJlZHNIR0crLCsShDi9AAAAIHRSTlMAAQIDK1bVuA4FBKuA1aqpjXIdEPHx5ePV1NSPTzArDw8+1JQAAAGiSURBVDjL3dPXcqMwFIDhI8Ax2E6yyfYuiiimd+PudU/P7ibv/yhRBsagSZ4g3wVc6B8d0ADASVG0oMSXNwQIwcFZTpKFgMqVuqs9TgxZzcs9OHjFINVkbH84oqCC2GBlyBhfzuP439397d053Ydjkq6+dGSsTHPTcTOTfPkpSRLipDoQ2xtLpUW6sGx3gkeffksIUOM5ERxlCS3weuvIch/HBbBQh05JfLqHqmJF7mv/W2zAoY7YvrL8PsYqfuaeAqDmC58LgnisWxquBO330GkEwtd53oVuNlRwvyx0nY6ttebEmh5/3o+0ah1PdGCDZRy5+i46BH/3t22xMeKblwRqEGhKFdj+cnhlQe00H8eGbyuKXAWGG249aCiy8SjwNU1RNFqpahhFGRP0rr3UHPqO49i2ow7DkWst2MM6e5hdkigMDCp0iZms6FEw3l3vpikxKYusCLnYf0fA6p0MdpuZ52307eRi7BU8BwwOROH+DzXQ1+l4OhCAxfGHWYvZevbxBzAQz/OIR9Wsm5teCzEDyn+ABqVfwsvPls2r6xvzBP+ePdLD+03oAAAAAElFTkSuQmCC";
style_mainBgTexture = "data:image/jpeg;base64, ";
break;
case 4:
style_mainBgColor = "#222222";
style_windBgColor = "#232323";
style_toolbarFontColor = "#ffcc00";
style_toolbarBackColor = "#404040";
style_menuFontColor = style_toolbarFontColor;
style_menuBackColor = style_toolbarBackColor;
style_fontColor = "#c0c0c0";
style_linkColor = "#ffcc00";
style_headerColor = "#ffcc00";
style_fontType = themes_fonts[0];
style_shadows = "0 0 5px #000000";
style_shadows_block = true;
style_buttonRadius = "6";
style_borderWidth = "16";
style_borderImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAdVBMVEUAAAAxMTEkJCQmJiYoKCgiIiIaGhogICAsLCwqKipZWVkuLi4dHR1UVFRxcXFISEg9PT05OTk0NDRlZWVNTU1RUVEWFhZ+fn4QEBB5eXlsbGxERER1dXVpaWlBQUGJiYldXV1gYGCEhIQwMDCPj49iYmKWlpbt3VElAAAAAXRSTlMAQObYZgAAA/dJREFUSMeFVdcSozAMdK+42xBqKEn+/xNP3L0fHhjGsnZkid1Z5Ibf57eU4Tca7/3ql/M9FD+8P5/3WPbix2EY3vD64qZxnGZUPr878PmMw7ks47IM51TOYXwDYAL0OZznsPhlN8fqTbZo+P2m8Xy/fZm8H4ZlHBcz/d5+WMqxjucC0WnyBYpNZd80QbB17nCmttZMMW43Be6zRxcxTjHPrhzHuLQtOOM2RSRyCV9UKziM2xzm4NrXz1ipjK2yWM3Tt7pltzjlNGNKOGptyxbv4WLqsnGLc0yqF1oppZXNNjc4tUTahPOMGSMo7IAIu5WSEKIZV5Z2r54L0XWSQ4j3fde/BEs5x4sCwB8u5g0TSBBCvF5Siu5fTic7CHavl+iFJBZjrKXkAGg1ZiqEhENIgxfOGekkgQIQEoSJniicoaMbsLnig4Y4+u+qpsWKKcOo7usaoXv5f4CpKWPNcEbjGqFVrfkDYLZWUbgjMlkxzRR7qLC6OWJNOoFsNkeNF3uoEOa5bVBCIzOeU5gVfQDkZtYKWRp93uucMpMPVyrfcmRKJENLgf6zZez/AN8qZvzvWKsLKYaL/h+QApDKMhxQNWVvNdD+AWD2LVlOLDLOmYCZeD2M9dvyTQ2FmgtZU949APxaQVCMahRavSgl/QNgKWFzlUgQUAwZZy0eyHc4HA0WgqIWQqiZd/iBrWEzhfWSQfumJdpL9UC+Y12NkpShth5BSaHZw5TK0ZIGHaNlnBKV/Il8Lmyb5SA/UEbFDMT9wKU5b5F1nQZqRKxUS09srXO0VFKrUDnM3MZIyANbvVOMaCpRdbvbDRMPgGMyMVqtCZqraVnL7oGt0dUtKQI3d24/IsjhoQJuAQPlCEcmmIavi3YPEnVGMZgmu7mUcLg68TBW57S18KAd/kjYtXjoYTdVKc1iBJKUddq6J/Kte8VXhqsgB1bUlODqSQ9gHAkrjsazFIMpfQCcpX0Pxbse+QWgl7LhOy3jUKbPuS7v9xf8FpxxBBf1g8dpGCY/GXZzNOEMA2CbHxcw5KX8Ph6y/Tj597mCX4PvVjUvNbh4gUIlwml9r9g6E9zqJ79+3vvcwLLX7+gNWPnwGcw+ljTfLOWgh8MvjVEbsM452+i+e0zmnGLa7v9jXJ3x1Q4Hetusopyi6WiWgH1imywjFGOcU62WXVgRgpMFjnIcZhM1o9YSfTuFppcmlCnGbrJwShnvJNyXME2EgP2F6W2xOGmQfk1KU6oZUB1SpBR9f+fAV8BMxEuAndHbSvlVVd9TBPmgTwqeJToBWWDQnPK/+WB8HZxQ2b0AIInqXiAb4CzvIAKrhwXphHb3hmtQCcMXlOkhn5L7Q/gf+vFTE+yZDhsAAAAASUVORK5CYII=";
style_cursor = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAACGVBMVEUAAAAAAAD///////8AAAAAAAAAAAAAAAAAAAAAAAAAAACPj48AAADU1NQAAAAAAAAAAACysrIGBgbX19e0tLT+/v4AAAAAAAAAAAAAAAD29vZeXVhRUVFkY2BsbGydnZ0AAADs7OwAAAAAAAAAAAD+/v4AAABKSkoAAAAAAABERERMTExgX1uGhYBpaGZ2dnZxcXG0tLSoqKjKyspJSUnZ2dm5ubm8vLwAAADMzMwAAADk5OQAAAAAAAD///8AAACEhIQAAACqqqoAAABbVDcmJiZORR9nY1NqaGBZWFVxbmJeXl68vLy6urqrq6uhoaGSkpJubm68vLyqqqp+fn7d3d1VVVXf39+3t7epqalKSkpJSUl5eXmIiIgVFRVwcHDJyclaWlr///8sLCyPj4+qqqokJCSCgoK2trYAAABhYWEAAADAwMBlZWX///+xsbGfn58rKyuLi4sAAAD4+Pj////19fWysrL////e3t4AAABfX19ubm7///8WFhYAAAAYGBjOzs6FagAAAADrvADCmwAzKQD+ywD3xgDXrABLPAC0kACiggAxJwALCABJOgHjtQC6lQBrVgDUqQCwjQCDaQB9ZAByWwBcSQBGOAANDQ37yQDnuQC2kgCZegCQcwCJbQCBZwB3XwBAMwA5LgAsIwAhGgAaFQAdHR1SQgHtvgDbrwDQpgDGngDFngCXeQBjTwBhTgARDgAUpD+PAAAAgnRSTlMAAalVEAgCHwQGFVoKzAwnGJAqyZSHVEQzIhr5+fbt3pqRjXZpXVxORjb7+fjy8vHr5+HHrZyYkn12cG5kS0JBNy4nHf7+/vz7+fjx49rX19fOycnFw8K7u7u7uLGwrauqqKWkn5yMi4mFhISBgYB8d3FwamlmYlZQTU1DQTw5OTUV52hIuAAAAgRJREFUOMt10+Vy20AQAOColUVRLFWpMa0Zk4aZqczMzMzMjew2cW3FEHKYmZ8w55xlz+SindEf6Rvt7t1uhtH50mnEQGQoRIOmSOM0UgShRHbuEIs0H1tUNE1gSkA0WWtbcLUsUCBJJmt1E49DgQJpMh4qKH/+ncRVCYGC6b7xaLzg9uNMKFAw1Tsc7O7cm70LChSEerr8/9vSAgF/uyMdHQoCgjZ/2AdEYB8UFIaCwXYoslABge8fFDmyQEFCDI0CsRsKFAy0+2JdY/EjiIAAfJ8PxyIr0dAeWWwtMhxbGgqORiekLQKew0J4MRIc6Yn2BUKSmBbpk1z2B8fWOvcfOpyTOyuKeVmVma1QpO5iZPVgfnGJ2Xzq5IniwgN52a8EHs5H8jZ7544eP33m4rWysju3blwpLTFXfpOTALA+EZjMP3f+6k2L7Zm95t2bF48eVLz+bWBYOgnEmZnCy9fvWSxPauq0Xz06XaPb/VMgmUQOCMTcC/cf2mxVDq3O2yxwHAceksfZFOgvrXhqr7LX1f8SSJ5JBM8zYIgpOYWp/K3L4XDV6w2MWkWDULEg5D34fLf/UrVb69J69JuFg5cYRhAURSVX6YfmmPWTXudp1BvS0wRMahuNH87WNglebzPoa/vNaXj/hSE5DrQFi0LjD4szrTyoj1DYb4Jm1TjoevsfbAAzLJR3GN8ufAAAAABJRU5ErkJggg==";
style_cursorHover = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAACH1BMVEUAAAAAAAD///////8AAAAAAAAAAAAAAAAAAACPj48AAAAAAAAAAAAAAAAAAADT09OysrIAAAAAAAAAAABfX1m1tbUFBQUGBgYAAAAAAADW1tb+/v4AAAD8/PwAAAD29vZNTU1kZGBpaWidnZ3a2toAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABERERSUlKGhoBtbW1xcXG0tLSpqalJSUnQ0NAAAAC9vb3w8PAAAABjY2Pk5OQAAABPT0////+EhIQAAAAAAABbWzcmJiZOTh9nZ1NqamBZWVVxcWJ2dnZeXl53d3e8vLypqam6urqhoaGSkpJubm68vLyqqqrHx8fNzc1+fn5VVVXf39+3t7epqal5eXmIiIhGRkYVFRVwcHBNTU1aWlr///8sLCyPj4+qqqrc3Nzk5OQAAAC6urokJCSCgoK2trbAwMD///+xsbHJycmfn5/Pz88rKyuLi4sAAAD4+Pj///+ysrL///8+Pj7e3t5fX19ubm7///8dHR2ampq9vb3Ozs4AAADr6wDCwgCFhQBKSgC1tQA0NAD+/gD39wDX1wAMDABHRwGCggDT0wC6ugCjowAwMACwsACGhgB9fQAyMgANDQ37+wDn5wDj4wDh4QDGxgCZmQCQkACEhAB0dABxcQBtbQBpaQBiYgBdXQBAQAA5OQAsLAAhIQAaGgAdHR1SUgHt7QDb2wCfnwCXlwCLiwB4eABbWwDCVoQVAAAAg3RSTlMAAalVBAMQHghaCQYMFhLMkChDIfmVNzQYFMqHaV5UGvn28d7GjXx1XExGKiT7+fLt6+fhuqWdlY+Fg25kTkI3Lhz+/v78+/n48/Hu49za19fOycnIxsXCu7u7sbCvrauqqKWkn5yXlpWRjIuJgYB8d3d1cXBwaWZWUE5NQ0E8LCsjFWetwacAAAIUSURBVDjLddP3V9NQFAdwokkKaRJsUpKUTroXguw93Hvvvffee6UlVZp0IaCAiEzFrX+giUmbc/rs97d33uec+8a9ZU77VbsTklNWIj3WFVa7E0aQUmTpEl4WLzAjjEClAF/f1vkcxY2aAIEous/d7OVQVYBAXJBG3M1XnhjQckWA4POfqWnJ3Xy5QhUg+PTx/Y+UVONdpgoQ5IaH4okPQk21JgAwksokk6DQwauB+FgsmRgQzKqAIRC8G5TFG8FcqQkAxF4XCRAAAgBvB2PpoZS0rrJKFUVA3v82ls78nMktz4viQ46nJxLZXzPz4j9BYorQ3+H7eDqTnRyenhNyIu8qCP0lJ+LZ1Ky0cs1ac+0XnndVX6joV6rof5GdnF1d19Do8WzbsrVhwyqX99ozTukP7Tfnfk99Xb95+459TUeOnzh2+ODuRk/rY6WIBsR5YaFu196moy2+dv8d262OS2eqbrC0Bc8DfnFx04FDp1rOtwe6HKEwRVEPu5mIDOQaKuBrvacv+nx+m4Ni+iImJVGak0vkweie1o6AP9AVYiIGzkKSFoIgLHITF0rUn70dtNmCIZYmcMwoB8NwvDAHD06O7r/e7Qg6wiyNYrAyPhCEIDAMa6P01Lqx7T5LhSk2SurdBClRF857Ozt7TQzTRxPY/yen5+4jwmCKGgjt3mBeYijRz5F4OVJivhEjhqParcD8Ba5oluH+mSqBAAAAAElFTkSuQmCC";
style_mainBgTexture = "data:image/jpeg;base64, ";
break;
case 5:
style_mainBgColor = "#c0e0f0";
style_windBgColor = "#DDDDDD";
style_toolbarFontColor = "#ffffff";
style_toolbarBackColor = "#399fd2";
style_menuFontColor = style_toolbarFontColor;
style_menuBackColor = style_toolbarBackColor;
style_fontColor = "#222222";
style_linkColor = "#004f8e";
style_headerColor = "#FC9600";
style_fontType = themes_fonts[1];
style_shadows = "0 0 5px #004f8e";
style_shadows_block = true;
style_buttonRadius = "4";
style_borderWidth = "24";
style_borderImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABIBAMAAACnw650AAAAElBMVEUAAAB0dHQFT478lgADT47///8IePh+AAAAAXRSTlMAQObYZgAAAWRJREFUSMftloGNwyAMRbkN7sddoJEYwGKCk5IFULL/KgeoNnFELQbIl2gaeCUfR7UdMKGAxInK+PZRBgJRxRwOzIGY4YqoQLSsTe/0+SK3r63pjzkAMssWogI1VeNcZmKbtRBX6CiDEEih++MU4gbluOYRtG/HrlCMcbzTcRwNap7OPDa+nx9PWM+q/CYY8WtvCxs4kO6UcI00kuxkPcG8EfVkTwej6+l6MPk3XPRD12BCILIQC9SMa2AslOTd0TQEkYV0ukL94BbqEeMADc39dPJjwvVxwUinxXi5jiSLkxDqFWMIFQLrdSTZYeJxj/HH+GNcoIm/OVgSwz1h9IoXqCdmC8ksYyaJeelQS80k5KToCuUy4CV7gQhO2VjWWFdWW4BM/UH1lHMukFfKChTPZtwpiktsCyu88qo7wSnU4skt+f10TvOgcWKnDVEITkMjt4DTGsn8fJMFt1tLYJ5r/DChf0eK+flk8ZQvAAAAAElFTkSuQmCC";
style_cursor = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAABR1BMVEUAAAAODg4AAAAAAAACAgIAAAABAQHExMQiIiK9vb0CAgIBAQEBAQEBAQEDAwMCAgIDAwMCAgICAgIAAAAAAADFxcXFxcWmpqa/v7+ysrInJycCAgIEBAQGBgYCAgICAgIEBAQCAgIFBQUBAQEFBQUBAQEAAAAAAAAPDw+4uLhsbGxbW1tFRUW/v7+UlJTCwsKfn5/R0dE3Nze6uroqKioCAgKqqqojIyNbW1sdHR0YGBgCAgIMDAwiIiIBAQEFBQUAAAAICAiEhIRycnJOTk5jY2NTU1Ozs7OLi4vLy8uQkJA2NjYjIyOJiYkZGRmSkpJDQ0MrKysCAgIxMTEeHh4BAQESEhISEhIZGRk2NjYDAwMXFxcBAQEREREYGBgEBAQAAAAAAAAEBARtbW0BAQGwsLCysrKvr6+0tLR+fn6qqqqdnZ0cHBweHy8lAAAAZHRSTlMAAgMB/QRR+Ar9tYiDPSX6p19UOSv7+fn39/DX08uhmI18d29bWBwZFv7+/v38+/r6+fn39fLx7+zs5trXu7hwMRH+/v38/Pv7+vr6+fPy8e3q6ubl4t7Y0MjFta+mopFnSUgHvlKsVwAAAYxJREFUOMt90ld7gjAUBuATAoiAuLd11NW93dbRvffeIwGp/f/Xjbc1mDse3nzkfAEgmAcBJizp9dc/UQQv4gl5ktDtw5Vmb4LY/BksHrUNZ/FIB1bEnpoB5JxgWq65FwUwH2TtsGVS13wGIb4I3UTd1DRjC7rTMYqJKhOD9eMPkHjvEfhrUbdFZ+MbDnUIEGisLFrUHW16nITcWFqm1L10H3ISnrsDF7WWtxzqYCLUtiPUCs91FCY4SAJjajtCWR3pb4QxN6Ok7rpYYTsa218sAR4Xfd9ebGDG1vKQbZU5KQiUzML6rLl/rSYNwNzGILcWD1dPkjP8SgEjyG+c10jqi2m+YJVViEiIz3ASaLqiiqJIWvzSEXRJV0kRJq6CvAwMPg3g0yuKXpIsAeIAPYAkmCajr6RBEDi/hgaSANpIeANsx1iCofYRQjjnZbPc6iHOjbznAEkSyClydmo/lP9nYFx+8gNb7Bz11dX6+LAYep2M7JHTvuLlcJhgs3KurKBntYICgec3tcCe/wB2Jjhrv+suoQAAAABJRU5ErkJggg==";
style_cursorHover = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAABOFBMVEUAAAAAAAAAAAARERECAgL///////8CAgIAAAABAQH///8DAwMCAgICAgIAAAACAgIDAwMBAQECAgIBAQEAAAAiIiLw8PBLS0s5OTkBAQEEBAQBAQEFBQUCAgICAgIAAAAAAAAPDw8PDw8eHh57e3teXl7IyMji4uKysrL7+/vr6+sDAwM1NTUxMTEoKCghISEYGBgREREFBQUJCQkDAwMwMDAaGhoGBgYCAgIAAAACAgIAAAAAAAAEBASMjIyPj49nZ2eDg4NwcHC7u7vU1NTBwcHc3Nzb29vZ2dkvLy/5+fkiIiLn5+e+vr56enpZWVk7OzsCAgJzc3NDQ0MoKCgBAQEhISFKSkoeHh4DAwMBAQEEBAQFBQUAAAAAAAAAAAD8/PwBAQH///+pqanj4+PPz8+Xl5coKCggSyIsAAAAYHRSTlMAAgMB/fz5hgRQ94tZVBv6tX1ePjoI/Pr02da3p6GYcCYXEgz+/fv5+ff38vDv7Obb19LLxbukd25kSC0qIwX9/fz8+/r6+fn5+fby8fHu7erq6ebl4tDIta+nkXA2My+NUfz3AAABgElEQVQ4y33S13qCQBAF4FmWKoi912i6vURjTe+998SFaN7/DTLmMi5yBR//nh0OCxDMgABzLrX105krglfrRW2e8NnyfuVzjtj4lqSDWtZZPIWtkWw3F4A4J4xG8tZLHigf6LY8wozF9JDwRf9+RULhWlKcxjCiU2GtRTqg8t4T8JcOcQwrHHWoQwB3+RiFdFQJOAmtvDwVy9W+kwhU92QUqw2sgy96NRuFPEnkUXCQCtnGBIVrMTWklHIzTO+OC+vYVnC9YQKdFbnXXRRrkQzoMZOTQiCUXjq1pPCdN54Fym0MfJF16/wkluNXCpTAZvSixOpd1HyBpRaYyFhy4CRIu5AQRZHF+KXjFuw9FGcoboK8DApJBaDrEUUPi5tAOEBxkxBk2HSXFAgC52jooAqgT4XHjStmEgbeHCGE+jz4LQ9Kj/NH3nxAVBW0OjtbtR8X/mdQajb9f3dtdinLt0EQZjb5SqS1gJZKGtfjcfEDyOyceUPRFSME7ueW14/PvxWPNQwuF8qJAAAAAElFTkSuQmCC";
style_mainBgTexture = "data:image/jpeg;base64, ";
break;
case 6:
style_mainBgColor = "#F0EEC8";
style_windBgColor = "rgba(255,255,255,0.5)";
style_toolbarFontColor = "#e74c3c";
style_toolbarBackColor = "transparent";
style_menuFontColor = style_toolbarFontColor;
style_menuBackColor = style_windBgColor;
style_fontColor = "#222222";
style_linkColor = "#597bd5";
style_headerColor = "#e74c3c";
style_fontType = themes_fonts[4];
style_shadows = "none";
style_shadows_block = false;
style_buttonRadius = "16";
style_borderWidth = "16";
style_borderImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAABuSTznTDyBjUBgAAAAAXRSTlMAQObYZgAAADJJREFUKM9jCEUCqJwABjhgReOsWgVhrlqFl7NCC8JZoYXCId4AhKWjHHTOoI4fnKkKAGNaRP3D5CNTAAAAAElFTkSuQmCC";
style_cursor = style_emptyImage;
style_cursorHover = style_emptyImage;
style_mainBgTexture = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGkAAACfCAMAAADNlwcMAAAANlBMVEXw7sjw7crx7s7x7svx7cfv7sL17czt7c7q8Mbt78bq8M7t78nEw8u9xcnm8cjDw8bm8sK3x8GNR1hkAAABO0lEQVR42u3Yza6DIBiE4QFR4Xh+7/9mT5qyaDSEaj8mWuZpu+nmDQujDr5Y8MuCmQUTCwILsSQidhILPAsCC/FMIwsWFvyw4JsFLkNrKqnUUWlTVEkllXYLLIgs2iMuske4ldAK0kpwjTYKuApYUUmlDkqpQHvE6faIWPnZwEeF9oj6HlGHV6mkkkobKqmkUpnP5if5zO2FdNCBJxYWfLIgsmBhwcgCf9DrG0uzK1kllTooTSzbzTIzv08hsrzlij0edObniD8WuMxnza7gNy4FnekSZ2KUhswZUUmlnku+YM7M9gqkRrRHXHWPCAXjeJY9YvdegcHdP49uf/jM7koeSvx8+xJK/k4llZqVJhaUpMxsr8CyEltB6a6uPaLXPWKoMHuTU4lQCjrTyc9k9iankkodlHyF2V7xDwOO5fb67rYUAAAAAElFTkSuQmCC";
break;
case 7:
style_mainBgColor = "#f1c40f";
style_windBgColor = "rgba(230,126,34,0.9)";
style_toolbarFontColor = "#FFFFFF";
style_toolbarBackColor = "#d35400";
style_menuFontColor = style_toolbarFontColor;
style_menuBackColor = style_toolbarBackColor;
style_fontColor = "#FFFFFF";
style_linkColor = "#FFFF66";
style_headerColor = "#FFFFFF";
style_fontType = themes_fonts[0];
style_shadows = "-2px -2px 0 #FFFFFF inset,2px 2px 0 #FFFFFF inset";
style_shadows_block = false;
style_buttonRadius = "5";
style_borderWidth = "0";
style_borderImage = style_emptyImage;
style_cursor = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAABUFBMVEUAAADe3t4JCQkRERHe3t7BwcELCwsCAgIDAwOAgIDd3d3Pz880NDQUFBQAAAAAAAABAQGsrKx3d3clJSU+Pj4dHR0yMjIZGRkoKCgdHR0PDw8WFhYMDAwWFhYICAgICAgKCgoLCwsPDw8AAAAAAAAXFxc0NDQSEhIAAAAeHh5XV1fR0dEAAAC1tbVEREQREREsLCxDQ0MnJydAQEBISEgpKSkeHh4fHx8aGhoAAAAAAAAiIiIxMTEODg4aGhoAAAAiIiJ4eHhmZmbe3t7d3d3b29vc3NzZ2dnHx8cQEBDT09OLi4tnZ2dcXFxNTU1ISEjV1dWwsLClpaWfn5+IiIiAgIBiYmI/Pz/Ly8u/v7+8vLy5ubmzs7Orq6uoqKiioqKWlpaEhIRwcHAhISEdHR0YGBjExMSTk5OSkpJ0dHRra2tUVFRRUVFDQ0M8PDwpKSlCcaapAAAAQ3RSTlMA/AMB/gbNKRUP/v750o9lWv7+/vjp6OLY1MfFv7yzpJt+dG5WU1BFQD8WCwf++fn29fXy5uDPtJGGhYF3XE02JSAFw/pwUQAAAYxJREFUKM9VkdV26zAQRefYDmOZmeEyM4xkCEOTlLn3lvv/b53YWU261/KDZ0szRxLR91fLZJCPaVKXb8nC0JoYKYo2TMPo2LM9HIc3DCmaFApRl5EXQHmeKLZOPydSy7Hs0kbQMVMC9kf+LKXGZl/Xj4bGb1ufg5HmTB1cCCcP+7x+4PocibdrgYkMV+LbF1dA/0BOJwYaOJluC/nmGuDGeULnzk6Z855bSa6QnyU65qLyUGA+9nZUbsvF5WRIMotcLILr3h7zfYkVs61bP4Jmf6cPwOU7pXZqrGzWqKVi7Vgy/40T3/Vq3EGp1kq7vp6NfPkPVd1m2/aFtpoLImJTpffhC1fxExpbs0Q0fwNdbeZZPykbhxNya+N9cMBOzw5luR9+E82Vd2E73INiNbhKZmjx44kDrXoNihkSol/fVWHpZ9PTEksO+WvyNAcJG6AcHISJfLW5MHxkQXfWY//lJ/KRTZGZ4j9YSk4HtzC1Gjxy0C87mo9bGjo/mtmkLobcf7pcbJYG09H23yPTflcTLrtRWgAAAABJRU5ErkJggg==";
style_cursorHover = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAABa1BMVEUAAAAAAAARERH///////8WFhYGBgaAgID19fU8PDwVFRUMDAwWFhYAAAAAAAAHBwcAAAAAAADg4ODx8fHv7+/Hx8cqKipFRUVNTU1JSUkhISEuLi4cHBwLCwsZGRkKCgoJCQkMDAwREREAAAAAAAAaGhobGxv09PQAAABVVVXQ0NDPz8+Li4syMjItLS08PDxTU1M5OTkeHh4vLy8aGhojIyMiIiIZGRkjIyMeHh4AAAAAAAAXFxcmJiYAAAA4ODg+Pj46OjojIyMiIiIAAAAGBgYpKSmHh4dcXFwODg6xsbH////+/v78/Pz5+fn7+/vy8vLm5ubLy8tYWFji4uK5ubmdnZ2YmJiTk5N2dnZubm5oaGhSUlJISEglJSUSEhLr6+vY2NjV1dXFxcXAwMC9vb22trasrKypqamgoKCCgoJ5eXleXl4fHx/t7e3d3d3a2trBwcGhoaGHh4eFhYVzc3NVVVVNTU0vLy8fQuFdAAAAS3RSTlMAAwH9/P1aEP750M3Cj2VBKBYIBf7+/v339OnY1MG8s6SbdG5WU0oLBwT+/v329erm5uPg4NPPyLSRhoWDgXp3Uk9CPDYtJSAZEg358J37AAABjUlEQVQoz02QZXMrMQxFtSuFuSkzw2NmfmXZG2YqM/PPr7LbNjkz/uB7RtcaA/x2/QUDbEwTWvz0lfr/iZFQtGEaxoOtb9BuYMaQ0IR4B7R49wzpZhxg1QPTQf8fj3tqxmkMZwiff1iaGhwce7mT6/98VPvqPGmO7iAfBnxbXY1LxMNj6nz13zHR11615rpCfNGd1J3dRSqMNIWcX0XkYv1EJ+sHzHlXyuubBnuXlY9Z9N6VmHcbpyqZT9HeUFx2FjlZQc41Nph7MqyYdaLmtsvm5kY2iau3Sp1tsdKscdvvkVyGFnotte7a5geUqkWa+bI7+m0PVXqNtbaF5vKECM9w5k3gOKX4iQTlx6Rq/Ih0+vqCE09K03lQfm2oiyxkq21Ccer9IsCP6jppi7ldqJ4ImB2TnwoWJVS7wXIYhNj3vjSybgmNhZCsZQDMBw+SpB+VsmjTD2Cr2Ym3OUbHaMR07xewkaHoaCVLrKSRsqXhSNwRdp97YF9y0vsD4VloIR8dC1Ur5UxfKNa83QMq4GHoZJZOFAAAAABJRU5ErkJggg==";
style_mainBgTexture = "data:image/jpeg;base64, ";
break;
case 8:
style_mainBgColor = "#200";
style_windBgColor = "#000";
style_toolbarFontColor = "#f00";
style_toolbarBackColor = "#000";
style_menuFontColor = style_toolbarFontColor;
style_menuBackColor = style_toolbarBackColor;
style_fontColor = "#999";
style_linkColor = "#f00";
style_headerColor = "#900";
style_fontType = themes_fonts[1];
style_shadows = "0 0 5px #000000";
style_shadows_block = true;
style_buttonRadius = "4";
style_borderWidth = "10";
style_borderImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAMAAAAM7l6QAAACLlBMVEUAAAAoAAAqAAAuAAAdAABeAABZAAA9AAAlAAAfAAATAABCAAA3AABlAABgAABUAABNAAA0AAAXAABrAABiAAAxAACbJyd6AAB2AABQAABIAAA/AAAbAAAZAAALAACWAABtAABXAABEAAA6AAAiAACbPDyHPDydAABuAABLAAAPAADKhoa+goKePDxzAABwAAC2j4+xgoKmbGx8QEB5PDyIKCh4IyOgEBCNAACKAAB/AACohYWcbGyXa2uSQEBmPz+BPj6XPT10PT2PPDyEPDxtIiJzHBxcHByiAACBAAB1AABnAADRlZXPj4/Hj4/Cj4/UhobChoa5hoashoakgoLBamqcSkqGSkp5SkqsQECFQECxPT2iPT2NPT24PDynNjafNjaRKCiTIiKHIiKvICBWHh57EhKLERGCEBCSAACHAACFAAB8AAAGAAC9lpbglZWqkpK8j4+mj4/DgoK3goKzbGysbGymZ2ejYWGuWVm4SkqVSkqMSkptSkqKQECmPj6rPDxhPDyvNjaZNjaTNjaRNjaCNjaiKCiOIiJzIiKQHByAHBxqHBxjHBymEBCaEBCTEBCKDw+rAACTAAB+AADZj4+/hoajhoaWhobMgoK3bGyQbGy5YWGtYWHBWVmjWVmoSkqjSkphSkrOQEDBPT1ZPT1LPT2jNjaaNjaWNjZ3NjZjKCilIiJhIiJCHByPExNeERFVERFBERF3EBByEBBoEBC4Dg6PDg5uDg7MAACyIoB8AAAAAXRSTlMAQObYZgAAAx9JREFUKM9NzlN7HGEAhuFvbM+sBmsz6904jVPbsZPatm3bNv5de9Tte71n98kDNm5ctGhxPL5o58/NmxZk5l2fP3/B5g2bltTX31iyuPEX2LV7VS7X0tz8xV+X2Ho7kdiWqKu//+Bp0+rVLblPBEiOhLvL1+w4FLibvZNdtqNhe2M238FpV50K4TXAOlulu3uy3Ncn7dm7YuXK/csf7V++djTNqYoS1TWwpkNiKc2H+NHRzq4zI2fOdnadbRsqezAhonIQeDZi53qmcCZAcr264PXgfph8/l4gMCziFFkQLDoqv6+EyxHRifsJVzQKQWyy6NI4DHN4SZA8LfgEXVX6fAiLwmhMlil5/bCnUnWkPU4YfKyaOOYUeSdCy7QcsGhTtsYlSU2lMNVFApdJ0wEIJiEIIk0UskgNRqFZmqJkFDUosDZ01HbJYVcJBPxb8PAJ25go+kk/COX7C996FcVP1fjFnCO20qQSlRDQ3HK0MD7jwCCyxodDrwoXpjHJJ4F8e//JC5hLj0o1DgVfD15mpnmJBKH247aLKZwitBrn8ycGS2E7iyCgNThQ+Nrr1Qm2xsk5A4MXFZyQAqA1OWCbcPsC8H8cTL45WeJIxIuA9cFjxe9TDAMbNV77t/wSz3mjLGhv7387odFUjK7xmvXHbaV0BKNksCZ0zFYqp5lZtMZzDr0sTLjtAq2BDXMX19+ML1y47PKWLZnMvHnzMwsyc+cujC+5FY/v/AF2PTzQlDu4atVnYmmi7u+3Lt1Wd293U251c9OBcRc4eErFxeq1qxzbmM027mhoaNi+bN1wFWEdbg8Pg+ApRWE8dt1FPdm3csXjPctX7NvbOlRxXwmH3T0QaOvgVdElYoL1YfR8V+e5rvPnOtcN2+2pnim+FwGH3oXTnJfhhVnZ6MFURtB90ZYOfDIluN08C9pOd1cjIotYFoTCJEP28bjYWsQdKXd42kGAtiF7RVRnBAY16JhBMDBMEKEiH8HxGQcvgTGPJ+1kOGfEb8ZoKIAgEISOwbqu+ZxenwxcAdlAKdoyaMqIUTAMwTCqmZYVM03UjP0BUFymBv3mU28AAAAASUVORK5CYII=";
style_cursor = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAACDVBMVEUAAAAAAAD///////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACPj48AAAAAAADT09O0tLQAAAAAAAAGBgaxsbEAAACPj48GBgZsbGxfX19ra2v+/v4AAAD8/PwAAAAAAAAAAAAAAABZWVldXV1kZGSfn5/W1tba2toAAAD19fUAAABKSkoAAAAAAADy8vJCQkJSUlJMTEx2dnZxcXGoqKjU1NRJSUkAAADg4OC9vb24uLjw8PAAAAAAAAD///9mZmaEhISqqqoAAABPT0+EhISGhoazs7O8vLy0tLScnJy6urqrq6uSkpJubm68vLyqqqrHx8fNzc1+fn5VVVXf39+3t7epqalKSkpJSUl5eXmIiIgVFRVwcHDJyclaWlr///8sLCzW1taPj4+qqqoAAAAkJCSCgoK2trYAAABhYWEAAADAwMBlZWX///+xsbHJycmfn5/Pz88rKyuLi4vg4OCUlJSysrL////e3t7///8WFhb////Ozs4AAAAODg4AAAAtLS1UVFS0tLSrq6sLCwvOzs5zc3NmZmY9PT2Hh4eBgYF+fn53d3ddXV1ISEg5OTkDAwPk5OTR0dGgoKBQUFAzMzMrKysnJycgICAWFhYJCQno6Ojh4eHLy8u/v7+oqKikpKSQkJBNTU1KSkolJSUdHR3u7u7V1dXGxsbBwcGZmZmOjo4/Pz8uLi4Sr+EjAAAAf3RSTlMAAalVEQQIAx8GFQoMWScYzJNFNiqPa1sx/fbuh3ZeVCIeE/359drKxo1qXE5MQRn8+fnx6+HKrZ2XlZWPfWRCQjcnHPn27urj4+La19fOycnIxsXCu7u7u7ixsK2rqqilpKCfnJWMi4mFhISBgYB8d3d1cXBsWFZQTTw5HhUPHcZa7gAAAh5JREFUOMt10+dy2kAQAGCTSAgkghKkKHQIGEI1jh33bqf33nvvvTdEQAiI6SWAHXc7Pc+YiyWZGR/sjP5ovtndu9ttCpgfmgMyEE0NYsi4zWgOoBjWiKxdwwIxKleimKwRYA39L0YRlVIUMMhmDT1PR0hEEDDIBqtVw9X7w5sRORB1wMRSqLTouHh7nSBgwC3G5+f/OlwbBQGD4Jd0jE+VHFskAYMiP5eIZfRAKGABQOjT+GzkFx8XBSqrAyLT07PJuL5TFBD4HJ76PhVJxpvXbxAEDKJfc3lBbFoWEMjnvk1GZ/iMXRJwhslcPvw7Vd4qiVVN/oxGf4QL4LBcTdRAMVmIzBTmxnWpdIhjt0uidlELukSCT6XtMV1zeoll2zr7Xo5JAgCu3GqPFRd27OpwOp379+1pL7e5HtGkNB/gNSulPxnd7gMHj5/p6rp04dypIx17e4elIgBkq5XKzsPHTp/vdt8zMcyzB7eu9z3RWnFCAuwE137y7JXuG3dMgxa/RtPS4vO9oxW4WAMAttV17abbPcBYNJSWVqvV4FOQCIFKgDvae9c0YBr0U7SCxG02G06SOBjilRKGnudehvH6KSuukitByAkQ0h68vhw88dhn8YL0y42DnzIZhqEoKq7SW6O+/5UWtKa11qYJmJVtfO855BmhKer/uepvzpDnDa4AbeMqoSk4PhAIPkbaVHKswX5jSkKFfCSU9RP8A8O+k0UOi7+wAAAAAElFTkSuQmCC";
style_cursorHover = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAB/lBMVEUAAAAAAAD///////8AAAAAAAAAAAAAAAAAAACPj48AAAAEBATU1NQAAAAAAAAAAAAAAACysrK0tLQAAAAFBQUGBgYAAAAAAABbV1f+/v4AAAAAAAD8/PwAAAAAAABRUVFgXFxkYmLa2toAAAAAAAAAAAAAAABKSkoAAAAAAAAAAADy8vJERERsYWFMTEyFgIB2dnZpaWltbW1xcXG0tLSpqamfn5/KyspJSUnQ0NC5ubng4OC8vLzw8PBjY2PMzMzk5OT8/Pz///8AAACEhIQAAABbNzdKHx9nU1NeXl68vLycnJyfn5+pqam6urqSkpJubm68vLyqqqp+fn5VVVXf39+3t7epqalKSkpJSUl5eXmIiIgVFRVwcHBaWlr///8sLCyPj48AAACqqqoAAAAAAAAkJCSCgoK2trbAwMD///+xsbGfn58rKyuLi4uysrL////e3t5fX19ubm7///+ampq9vb3////Ozs4tAAAOAAAAAABUAAC0AAA9AADOAABzAABPAAALAABJAQGqAACAAAB+AAB3AABdAAA5AAAfAAADAADjAADRAADJAAClAACgAACPAACIAABlAAAzAAApAAAlAAAWAAAJAAAhISHnAADhAAC/AACsAABsAAAODg4MDAzuAADVAADBAACrAACZAACCAABpAABZAABCAADvNVPVAAAAeXRSTlMAAalVBAgCHxBaBijLChYSDJCUVTc0GBT5h2lhXkQi+fj1xo2CeXNOTEYtGfv6+fLx7+3r5+HYx62lmJeSj4N2bmdCQTcc/v788ePi3dza187JycXCu7u7u7ixsK2rqKWkn52cnJWMi4mBgHx3cXBWUE1DQTwrIx4VaWIyqgAAAhNJREFUOMt10/dz2jAUB3DcGuNAbNMyHGbLXtnN3rN777333i1xARto2JuEJE3Tvf7Lmsiu7yr4/ibd5/R00nuygPm+OYDwkTXJjGGXwRxAMawZ2bqF4cVruRLFkGaA6R2feoWrlYKAQSbTMzo5p8eBgEFmoVbrGb73QoHL6wIGK+lgddk2fLcFCBhEl8McF7TZtwEBg4WlWIVNVm2tgoBBkGNL5V+pnaKAwbvFQvwHGxYEijQAH9fXCwlJQOB9KP81H0+E20QBg8iHbO57XWwHAgK57Je1SIFNSQI6YS2bC5WSSztE8d8lv0Ui+VCxXElFNwUFhAi4RDEeL5YWN5KxYJSRhPSSG+WfbDK2e29HW/sqw3S2jrXMgyrCX/z5XeH2dPX1HxwYOHS4r3u10/5ApQf9AX6zGk517D9y9OS5oaHLly6cGew/MPYcFAH9UEunu46fOHvxpsPpchsfTdy5MfJQZ6UJETAr0e7T569ev+V0mzRen8Uy6/Fo/Qq6XgMApt1+7bbD4TRqLFq/CkShpwhUBJ8HRyZcLrfJq+X3aYqiSZKk+Sb+V6J39LHJaDR5dVZSLVfykRN8xDl4euXTqUmPRqPx6TZfmN9EEAxDUVQYpZeGfeNPdBbfrM5KSd2E1AMWb6aPTc2ptFq/lSQaT87M9DNSwV+bVINLwXlL4OS8nlLLMVnjYEpCjeOEsvEBfwHzoIzGd/h+PgAAAABJRU5ErkJggg==";
style_mainBgTexture = "data:image/jpeg;base64, ";
break;
case 9:
style_mainBgColor = "#73AC37";
style_windBgColor = "rgba(47,91,12,0.8)";
style_toolbarFontColor = "#ffffff";
style_toolbarBackColor = "#945034";
style_menuFontColor = style_toolbarFontColor;
style_menuBackColor = style_toolbarBackColor;
style_fontColor = "#ffffff";
style_linkColor = "#D5AB81";
style_headerColor = "#ffffff";
style_fontType = themes_fonts[3];
style_shadows = "0 0 5px #000000";
style_shadows_block = true;
style_buttonRadius = "16";
style_borderWidth = "12";
style_borderImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAMAAADyHTlpAAAC91BMVEUAAADUq4cwIRYuHRIxIxflzrgvIBVCKRjbvKPTrY/gx7AwIRZjRCzhybbdx7izh2mKVzUrGxDdwbCfYDnKn3lnSzLYs5Sxf1JcQiowIhbmy7V1UjZONyTNmnIvIBXdvaOAWDjauqDlz70rGxFSNB/buKPdwrFnPyYpGRCsbkdOLxyYaU+0bUNeRCw7KhxCLx7QoHnMlWexfFCUaEPk0L/GiVnTqIjHk2riybRELx+6gVOWZT/Rr5WjcEjQrI+9jmo3JhgtHhSpZj2MVDOXXTnauKIpGhCIUjK+iWebZT7iwK3CkXLXspvexLS9lXozJhrVq4HMmGZ3LxJBGQogDAXcuJXCno/Ro3XJl2SyhVmmfFKjelFvLRIkDgYdCwXPo5LUqX7TqHy6jF1JHQxEGgs9Fwnp077evZy/nY/Ek2Kedk+naU+Vb0pwVDhQOycoDwbr18Pkya7du5rZtI7ZsozWrYTQoXLPn2/Nm2jCkWCpZ06cdE2Zc0xXPyo6Jhg9JhdbJA5XIg0bCwTly7Hfw63iw6bfv5/btpLIoJDYr4jSpXjGlWO3iVuzbFChd0+iZ0+jZU2SbUiLaUV+Xj90VzqbVTaOUzZiSTFeRi9ZQyxCMSGSORd8NRZeJxHnz7nmzrTjx6vfwKjgwaPcupbMopHFno/QonrNnGy+jl+ob1W+cFGCYkFmTTOORiZDKho1JxpnMBiFNBWBNBVSHgzWt6LUq5PPpILTp3q1hlutgVa1blOtbVK3bVCZYk2dZEyWYUuPbEd5WjykVjeUUDSTQyRINSNQNiI+Lx86Kx2qQBqfPhlMKhdKJRPIqZ3LnoLCkHe8jnK0g2+6hmvJlmjHjGfAkGCxek+SX0qiY0mGZEKpXkCuWzh7UTOGSzOmWDKASTJuTDGFUC9iQyueTSlYOiSCOx8yJRl0MxiMOBdZLBdQKhZpKxLGn4q5mIWuemexdluxclSzf1K1cUmhZUKlaUGBYUCWYT5hSTB8RyluPSNKLBpfLRcwEgePMwaGAAAAT3RSTlMA/fVS/PvhIf789/Lp21VVSSgmJv78+/n5+Pf29fLq5+Tj2WBSRTszMyso/v77+vf29vX08ezr6+rp5+Hf2dbS0dFlXFJNSEM+OC4lHRQSW4LC0AAABBhJREFUOMuF1HV02kAcB/ArW9u5u7u7u7slQCnaYi0UChQtMKxdXVYvTl1X79zd3d3d3ffHbmP7k/BNcu/y7vPyktzvDpw+nZiYWBoYGBgWFlZaGhj2pwPb0hImM5G5mclkliQGMkuYJecfg/Nv1qaHV75uFpu/+Vxl+p703Wc3xcY229T8QvrOHTsrXxXyCjef3bljR/ihjWDtwWeOG7G8mCK+nORjbqzZJM0vksv5fFKnh45rvjxZvFxOKrvjaCCEQtpwQSpDqSI9J1lZPLIwRqHNrMqiU1iKLu/yClTUTBGHrGKPcjBCwa7cSl48x4bgWtr24VUkRYoY6d6y+5hqoVpZnES1IjicIYsSib8D6fobsUWpdj9/AEa0ui6kZ9ubNgEwTTpn0YU5dS3bA+DfSkcR0J5Ceiku2eIHB6EdbTiKPIHyTwZZJceQplDCzKwQCL+FgA1bSKmH/d3DQ+fh/KD8Z/1w84e5ux3xGv09Iljvk0TrBbykN1n0gAt2lbFSe3qjzVnXjxDhu0bi05Ziy8FxkdU/iGDXB4FGMGE4llzRg08/+hN+1s33KWpK146eZQffGLKllgDpgYd4Mp7ezzPtKyPRDzf+pcdvsjj7u3mmPkpy5qETjVyw/sCJLeg+ex/PdDJFS/tyvAFWVu6ZOIoEzqbHLNJt51A/OSB9K1N+fjIQYGRhmlZAq9kIMs7Ep0igxMqCFLzwFhfs8VHSxwIvGa/W3+OCvVtQndcaGJesfxACdpexaN28UR9U9CgEZJRv9V4uXdCqIyFgz7ZIPL0dtlwcp7acJIJrHwUaStflWHJID77wWD0XZNy+AlcZFeO5g/NkkZZaBhdcvVtzMRmfhlEu/QsSaBIngQiu3nbmotvEBozPTyLrHjtfEsHeu2b+1qpjGOUyQ3t5u6iGAam5MJ5qb7rEM20nonFS05xEsPtcAbsaNwxgZOhETgrtPtyzmhdT7e0BZjpqNWm3QkG4Ikk4HXjJVLLOQgThKHt7K290CrpPAmvgIlmQ6f9vWlq3mNX2/3CbAS3mLHN3VxWxc2rhU6/gyytmu1exVBojR9v+k1KpjFTm3h9ax1VIXhBBei5VW66euwbKSXl8FZvVCVooefnFKJvdeyUAqwfks8R1L0NBxkGzjqpWkfq25hUk67MzL7MTmrXw9c2L12Rl6yloQv9pvBg0G6knwD9gbrifLarYqkhg0Wx1z4/k0DWoIiGpPOuwsd5QtY2sJKk41cjzZwQuCM91Nn63WcX7xRLEyCAwHhmsnXPE1qNILYPw1PBVvD/HhtTVHz8B6SGCKyrKdcqIIMZTrujoqKgXJqPRZDKdioY3rpMmBDGddDEYhOhfICoiOHgdPNfBNmBdADyDA4LgERAcHATboKCgiIiIv9dv4xyyP+TJkucAAAAASUVORK5CYII=";
style_cursor = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAA7VBMVEUAAADIzMP/5claWjoCAgJGPjgBAQADAwANDQwAAAAXFxUDAwEDBAMaGhkODg0BAQAKCghVQ2sAAADZ2dk7OzsxMC84PD0JCQc+Pj4KCwhJSVQEBAICAgI6NzBmZmbS0tLR0dHOzs7ExMXLy8u8vLzGxsawsLC5ubmlpaV1dXXIyMjCwsJlZWWamppqamoPDw7Kysqzs7OXl5dSUlIrKioBAQG2traysrKSkpKMjIx+fn1wcHBiYmJLS0tHRka/v7+srKyqqqqioqKEhIR4eHdcXFxDQkI5ODghISGWlpYwLy0ZGRiop7JTUl9WVlYSe3RjAAAAH3RSTlMAAgEBKwRWDrjVq4DV1Kupci0dBvHx5ePV1Y+NjU8P6gBz0wAAAZdJREFUOMvdkteS2yAUhg+oOfZma3oDNUB1Lcly716X3U3y/o8TNPJ44CIvsN8NM/Bxfs4ZAK7r2oYW1C4GYAQXbiuxXpoGNOB2ywKV08SjYWWrFXQGpU+J/+GdBM5gXRh7lJDnRVGMXx9Pr/eyDtKUbrqNKXGnVRHzdCS+3KGHB4yUMKczW4fSKJeszydk+OkXwloXBlzlmyZll8eUUjKsQcewZMqmqRF6xKXU/2PrAjIsp7Nn0iAeaeA38pba8L1pOl/nzCdnko4DliKY7xdVF7r5yiW0NdIUq7O0F4JNrz4fhnJeLZMUdGFbBHy+5xfh9+HUcdSIaJ2Eq8R3z0I/3AZzppS4qbIiCX33Ing8mD2BQp1nQ2lIpbE8LwiCXBN6x6hkqzCO434/lsecs6U+rNtj9CyCIEk8eZ0LthnLR2r8OP6dlmI0GjEmxkJkh28YdHrXg/0siqJZmk+y7KmWk9RA4JiPDYP5rsymAxN00MX/vox20cefoGEghDDC56yXl56NkS40Z5YBLXdm+4v+C4ZWeGP8A9wzObf5MbrGAAAAAElFTkSuQmCC";
style_cursorHover = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAABBVBMVEUAAADVxpT09P+/38MCAgIBAQABAQEQEA8EBAD/9u0oGigaGxgEAwEJCQcODg0BAQADAwILCwoAAAAAAABJSUk6OThDSEsLCwhKSkogICAgHx5XV2RHRDpFZXWIO453d3f////8/Pz6+vrv7+/39/fJycl5eXnt7e3X19fV1dX+/v719fXz8/Ph4eGQkI/x8fHq6urk5OTi4uLb29vQ0NC4uLiAgH9kZGM0MzIBAQLm5ube3t65ubmqqqqZmZiNjY1bW1tWVVUTExPExMSwsLCgn5+JiYmDg4NtbGxSUVC8vLy1tbVzc3JGREM6OTcmJiYeHh0ODg7My9iysrJlZHNIR0crLCsShDi9AAAAIHRSTlMAAQIDK1bVuA4FBKuA1aqpjXIdEPHx5ePV1NSPTzArDw8+1JQAAAGiSURBVDjL3dPXcqMwFIDhI8Ax2E6yyfYuiiimd+PudU/P7ibv/yhRBsagSZ4g3wVc6B8d0ADASVG0oMSXNwQIwcFZTpKFgMqVuqs9TgxZzcs9OHjFINVkbH84oqCC2GBlyBhfzuP439397d053Ydjkq6+dGSsTHPTcTOTfPkpSRLipDoQ2xtLpUW6sGx3gkeffksIUOM5ERxlCS3weuvIch/HBbBQh05JfLqHqmJF7mv/W2zAoY7YvrL8PsYqfuaeAqDmC58LgnisWxquBO330GkEwtd53oVuNlRwvyx0nY6ttebEmh5/3o+0ah1PdGCDZRy5+i46BH/3t22xMeKblwRqEGhKFdj+cnhlQe00H8eGbyuKXAWGG249aCiy8SjwNU1RNFqpahhFGRP0rr3UHPqO49i2ow7DkWst2MM6e5hdkigMDCp0iZms6FEw3l3vpikxKYusCLnYf0fA6p0MdpuZ52307eRi7BU8BwwOROH+DzXQ1+l4OhCAxfGHWYvZevbxBzAQz/OIR9Wsm5teCzEDyn+ABqVfwsvPls2r6xvzBP+ePdLD+03oAAAAAElFTkSuQmCC";
style_mainBgTexture = "data:image/jpeg;base64, ";
break;
case 10:
style_mainBgColor = "#222222";
style_windBgColor = "rgba(0,0,0,0.5)";
style_toolbarFontColor = "#FFFFFF";
style_toolbarBackColor = "transparent";
style_menuFontColor = "#E9D460"
style_menuBackColor = style_windBgColor;
style_fontColor = "#FFFFFF";
style_linkColor = "#E9D460";
style_headerColor = "#59ABE3";
style_fontType = themes_fonts[4];
style_shadows = "0 0 3px #000";
style_shadows_block = false;
style_buttonRadius = "24";
style_borderWidth = "10";
style_borderImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkAQMAAADbzgrbAAAABlBMVEUAAAD9/f16ZUgdAAAAAnRSTlMAgJsrThgAAAAbSURBVAjXY0AG9v///z8AJQ2A/KFAIrsZCQAAqo8qMRrCikYAAAAASUVORK5CYII=";
style_cursor = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAABYlBMVEUAAAA/Pz82Njb///8vLy////8tLS03NzeJiYklJSX39/ciIiJBQUEzMzMzMzOZmZn///8mJiY3Nzc0NDTg4OA2NjZMTEwsLCxubm5GRkZWVlYzMzM0NDQzMzM0NDQzMzMyMjIxMTEzMzMyMjIyMjIpKSk0NDTn5+f9/f09PT3Jycns7Oza2tpycnKrq6tDQ0OysrJcXFwzMzMzMzMyMjIxMTEzMzMxMTEzMzMxMTFAQECioqLZ2dkdHR03Nzfv7+/r6+vS0tJCQkIzMzOYmJi8vLy4uLhRUVEwMDDp6emioqJpaWmLi4uGhoZlZWXGxsaQkJB6enpZWVk0NDSFhYU2NjaXl5c2NjYzMzMyMjI1NTUyMjIyMjIyMjIyMjI1NTUzMzMrKys5OTn////7+/s6OjokJCQ3Nzc0NDSampomJiYxMTEtLS39/f04ODg5OTkvLy8qKir4+PgsLCwjIyMeHh7+hwJIAAAAY3RSTlMAA/H7Bfr47eL79/r201T+9/b19fT08/Px8fDvz7u1X0o7KhYR/vn29PTz8vDw7+/u7evdkXNoYkMmCPj39/b19fT09PPy8vHx8PDw7+/v7ezs6ebk5OPgyMbBrJ2AeiIZDAnUBOCsAAABsElEQVQ4y33SZ1vqMBQH8JTYXluGcEH2Bvce13X33su91yEk0lrA8f2N9YmPJOJpkhc5v+f/ojnoODeYr6Ae1LVyzVZz7egJ8dFOJVim3F28uXo57aeDpa7ieb0PJiOMLXHRFeDPBqMhIRRwBhfwN2G7i0h7DPRzUKvB+6jTfCGECvg37nPIAdJU4vMAX0Mf2mQeiRAF8D2WapN9IVTAD+urSfaEUAE/h2dMkuNCAn0e8AT+4yc7PULICQDnEJ4wSbCKtA7wj4N7gf+/pnOVjoRGL66JNi/9k+FuK4A3eRfrujX0anzVYcsPwLNGr/cnAayJdHyk3zAZzZzIoAZv3wFOXrdsSimbLSIJXIAV+A0QM9xsIVQqryCtE2AYm2oELMA/2xvendaZsA6xQJvUJwFGI+QQrYi2AFeb3785NHqZ1kFPO1vKWM06M4FLUlggkVGALyYpyI+VdQ2bLqKqbyCJIRxvZeWEUoZGQ+gUzbuJGMAPPynKEdWlyu2klWn9F0A4ZecloHmbrzwbGdanp+wgkku7O4rUSMb9NhGzrVawOdAicwtqQ+QsB9luSLm/ARNReAP/nQ5NAAAAAElFTkSuQmCC";
style_cursorHover = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAABZVBMVEUAAABDQ0M0NDQ2NjI1NDI3NjIzMzP/1gAlKDb3xgI0NDM2NjKKdB3/1AD/0AAiJjdsXiQzMzMzMzIyMjL/zQAmKTZCPi/gtAfouwUsLjRMRixZUClEPy6wkRM0MzM0NDIzNDMyMjMzMzMyMjItLjQ0NDMtLjX/0QD9ygA3NjLJpA5HQi1TSyu6mBHsvgRyYiPasAmOdhwzMzNZTyo2NTKHcR4zMzMyMzMyMjMxMTIzMzMxMjQzMzMzMzMzMzMyMjIxMTH/3AAvMDQrLTSihxcdIzlBPS/ZsAk+PDDrvQXvwQRBPjDSqguYfxk8OjAxMjOihhdlWSaGcR4zMzOqjBbGoA56aSE0MzOXfhoyMjIyMjQyMjQyMjIwMDU1NTUrKyv/////1gAkKDc6OTaagBkmKTc2NjYwMTU3NjQ4ODYtLzX/0wArLTU6OTT/2AD/0AAyMzYpLDY2NTP/4wD/zQAeJDn/2QAjmktHAAAAYHRSTlMAAwb18O3+/fv39fLj/Pv68dO9Fvn29vT08/Py7+/PtV9KKhH5+ff39PPz8vLy8vDw7uvp4uLdx5FzaGJVU0M8Jvr5+Pj39/f19fX09PPy8fDv7+3t7ezm46ydgHo6Igwu7hV9AAABs0lEQVQ4y33SZ1PbQBAG4JPiqIF7740WeocQWnpC772sfFhdxqb9ftBgcYNuzI6kD7eP3pubWxSN9BajiEUdK4JV/fjqAyGpQ2nFV+ksPtV+5YNK7yURFLi5P4gr3DIRFJD5kZ+ctkgEBeDpMK1q3xDTEYC8IRn6VyIoAI3xLsM+RwxNvrwCkFPrFp5HiOkEQB7NWfiMFl0uAFMcFvApERQAcyAr4AgRFIDbwG4Qz7FtQUAD3kT/mGCHq++Erz5BADz4j34rs1FHEDDDAynz++YPfQ69S+jm3b8DMTH1d3zK4FYRy7QLfa53y87uAOJYNvNP6hM4Zf+aBLSBvPYf+NCjqiqKxk2WEeMBppjYa0CyTyuUFlcq7XMSwJujuXpCBH+oNe0suX0XzNwn/1h2LS/DYBxfINZtu6B2kto2NMkaDkAga0xTYzVpTCUsXFrA8UETRgRc8l5WQe9pvkxb1dcK+SGWUQvehBWfJi0hFs3r6eQt7ATtsjeiuhx1Jq1yV5uQoX+oWfQAxnmdp6hsDcTyuWaY9AhxPmWtJ5QJqtidbbrCeku1ZxfohpuzGr6LLFHrzy8SdsLD0lZqAAAAAElFTkSuQmCC";
style_mainBgTexture = "";
break;
case 11:
style_mainBgColor = "#222222";
style_windBgColor = "rgba(58,58,58,0.5)";
style_toolbarFontColor = "#FFFFFF";
style_toolbarBackColor = "#3a3a3a";
style_menuFontColor = style_toolbarFontColor;
style_menuBackColor = style_windBgColor;
style_fontColor = "#FFFFFF";
style_linkColor = "#8EC5F9";
style_headerColor = "#FFFFFF";
style_fontType = themes_fonts[0];
style_shadows = "0 0 5px #000000";
style_shadows_block = true;
style_buttonRadius = "16";
style_borderWidth = "0";
style_borderImage = style_emptyImage;
style_cursor = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAB9VBMVEUAAAAAAAAAAAAAAAD///////8AAAAAAAAAAAAAAAAAAADFxcZkZGQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAAAAAAACTk5P9/f0AAABXW3qWlpb5+fkAAAAHBwcAAABSU3RNTXBcXnzMzMyYmJi6uroAAAAAAAD9/f0AAAD8/PwAAAD8/PxDQ2hgY4FjZIJpaYdtbYpxcY2pqbCkpKTn5+m6urpMTEzMzMwAAAAAAACdnZ0AAABDQ0NfX18AAADr6+s8SW0lN2AmJlFlaoaAgpd2do9eXn56epOGiJ61tbibm6y1tbu/v7+goKCwsLCYmJjR0dK+vstycnLNzc3S0tpXV1eHh4dMTEy0tLScnJz///+lpaUWFhZTU1OJiYl8fHzf399jY2MAAACrq6syMjLv7++amprt7e3S0tKoqKgAAAD///+9vb1paWlpaWlycnItLS3a2tri4uJ8fHx7e3tLS0urq6v///9bW1vV1dX///8AAAB0dHRvb28dHR27u7umpqYQQmsddJYAADMJJVIHGkkgfZ4fepsXWX8GGEgbao0YYIQBBTgUUHcQP2gOOWMccJIaaIwXXIELLloJI1EIDj8YX4QWVnwTS3MRRm4MM14IIE4ONmEGFkUDDD0bbI8ZYoYZYYYLKVYOJlMdHUqNUKhSAAAAg3RSTlMAAQgEqVUDEAYfDNqBSjIpFTEdGEdCIxOviBL7sV9aNy77+/rUo5N1aWdTQSAV+/n17+zr4NW4uKqojH12YlQ7OR7+/v729PPx6+ro4+DU1NHOzcjHwsC+t7GwraWkop2cmpmYlZGQj46Mh4eFgIB8enJyb2ppaF9bUExIQzw5NywpKMDsqM0AAAIVSURBVDjLbdP3e5pAGAdwgRYBKxARqLGOWnc0q9k73XvvvffeeymmiQlqEjXLNJ1/Z+/CtXly8P7Ifbjv897da0v77vvSNE3RNEHYrKrBs9njG2ZIkqFoS7F2jQbEF1W1cwwSJqC13nz6QWElOxImoOstVx684QWXnQTCDPSRSr6l+/pLuQ4JHFTLpcVKc2fkkRsJHHwrzRUyleZwZB0SOMgXZyfGMrmm8HogWChwkJkeHwdikwMJilgNRjIzk9l/wmkSEExkR3GBg6+G8ELBGwID/8UGXCAAxdRssbJxRWARo9nJqem5hTwS9UigLrJw+cdYYX6hpmPCOIfv4O/CfHGxnMvrWshx9qEcdBkp6CR/zhSK5d9bvE3exj+aFgqffzwkSMvvA90F2Hvrjr1t7QfbDx3Yv3Nb6MgtOWiEoNss/druOHzs5Omui1cvR84cb9sXHahTRA4BvZar7ek81XXh2r1Yv9858LwvGu0LCCkRZkCgLS3t7r50o6enN56UA0FBEAYHPykpCUQgoDV23H0S6431O4cEVhJVVRUlSQSPGEVo1RN3Xvjjcb+TB7kkA4okOQ7OAQKtt1+9T/qTbj4FewcfCQJMEgXWIXh9rtrx7CMvu2VeqV95TcRyGZO1y/PWJQQCQUWE66YaThxNfBZZQWBR36Z6l2gg7aJLUjmStllWmmZIzo66siyCohjQHWW5wV9UN5XTbM6XJwAAAABJRU5ErkJggg==";
style_cursorHover = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAACBFBMVEUAAAAAAAAAAAD///////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABkZGQAAAAAAAAAAAAAAAAEBARPT3HGxsaTk5MGBgYAAAAAAABYWnvExMWWlpYAAAAAAABcX35jZYNra4hxcY3Ozs+6uroAAAD///8AAAAAAAD9/f0AAAAAAAD8/Pxubm4AAAAAAAAAAAAAAADs7Oy1tbqpqbDIyMmhoaHn5+m6urpMTEzMzMyVlZXu7u75+fkAAABpaWmdnZ309PT+/v4AAABUVFSxsbE+VHspRXEmJlFFRWliZ4VcY4JCQmhmb4yAhJl2do9eXn56epOHiqCbm6y/v7+wsLCmpqaYmJi+vstycnLNzc3S0tpXV1eHh4dMTEy0tLScnJz///+lpaUWFhadnZ1TU1OJiYl8fHzf399jY2Orq6syMjKamprS0tKoqKgAAAD///+9vb1ycnItLS3a2tri4uJ8fHx7e3tLS0urq6s5OTn////V1dX///8AAABXV1cdHR3///////8aap0AADMKKl0mm84POWwvvO8kkcQzy/4xxvkttukrrN8aaJsPPXEKJ1oCCDwuu+4llckWWYwFF0sqqd0jjcAggrUeeq0ZZJcXXpESSX0MMWUJDT4yyfwnntEdc6YbbaEVVYgTToIJI1YvvvEsr+Irq94qptkhg7Ygf7IdHUp8jacvAAAAgnRSTlMAAQSpVQMRCB8GFTAKgUkNMhhC+9qvNion+9uxYUf69e7r0ZOPhnVpZ1NMQTo4IyIcGuTg2Ne4uKqopY6KfXt2YlxYTyj+/v78+vr59vTz8evq49TR0c7Ix8LAvrexsK2lpKKfnZyamZiRkI6Hh4WAgHJyb2ppaF9bVVBIQzw4LB4RNdDCygAAAh9JREFUOMtt02dX4kAUBmCS3QAJcSFhlwQXFgSkCQr23rf33nvvvXcjQUEgUsQCa9vun3SGjOd4Qt6PyXNm5s7cq4kOPR2KEgROEBimUUtDfV39YJSkdSROqIqtW4S63sFRitIaSSSqgODseRlq1DNaJKqAJDnvPhsxcXqtDohqII2LGWfX/besAQklyC/M50RHx81+OxJK8DM3+z8lOlzdNUgoQWZuJjYxJjpad9RsqxIQjKeyU3+A2LUdCRxTgLFYMj6lEAownYAirSYQmJSFFQoTEptBfLIiloHYuSGU4EdiujCTEq21CoG2AP9/JQvZ2ZWMWSFQFYl4srA4UVxeKUkKId/D7+Tf7L+ludyCmJEEc+vVftYQkQW6ycVYMbUq7j6w37pvTRDMruvPwzxT6Q/0FsWl1T2Hm1va2k6fOtl8ZK/Z9ZBF14Fecz59qPbMuYuXO2/du9N95XzLCfeIoYmiESiX0qXjHZc6b3ieeG3DwfevB9zuAQunp+AeEAj5/LGu2w88nj5fgA0bOJ7/EvoKO5DGERAOtj9+4e3z2oJhTs9QMAwDmxhtIZQvPHpj8/lsQUsTZdSRIDoaBM4Bavued58DwwG7pXJw8BHDwCThuDxKH66V21+FTKydNTVu6iasEnmyjvZ+jHAWC6xLbS6++c/6Ryk9z4OycNXZ++RvoLVUhAHnIzSq+U6QtFFrpGFV6sFwnATV4aoLrAPYB5aZtyfIXwAAAABJRU5ErkJggg==";
style_mainBgTexture = "data:image/jpeg;base64, ";
}
}
function ToStyle(str) {
StyleText += str+'\n';
}
function ToStylW(str) {
StyleText += str;
}
function SetStyleText() {
StyleText = '';
if (style_view=='vis' || style_view=='bt') {
style_mainBgTexture = style_emptyImage;
}
ToStyle("*, #body {");
ToStyle("	-webkit-text-size-adjust:none; -webkit-tap-highlight-color:rgba(0,0,0,0); -webkit-focus-ring-color:rgba(0,0,0,0); outline:none; -webkit-touch-callout:none; -moz-user-select:none; -o-user-select:none; -khtml-user-select:none; -webkit-user-select:none; -ms-user-select:none; user-select:none; -webkit-user-drag:none; user-drag:none; -webkit-overflow-scrolling:touch; !important; -moz-tab-size:4; -o-tab-size:4; tab-size:4; -moz-box-sizing:border-box; -webkit-box-sizing:border-box; box-sizing:border-box;");
ToStyle("}");
ToStyle("center {display:block; text-align:center;}");
ToStyle("right {display:block; text-align:right;}");
ToStyle("p {margin-top:0; margin-bottom:0.6em;}");
ToStyle("select {width:100%; -webkit-appearance:none; padding:8px 6px; border-radius:0; margin:0 auto; clear:both; line-height:1;}");
ToStyle("html, #body {margin:0; height:100%; overflow:hidden;}");
ToStyle("#body, input, select {font-size:95%;}");
ToStyle("#body, .input_text, .input_butt, select {font-family:"+style_fontType+";}");
ToStyle(".input_text, .input_butt, select, #printCont, #printAdd, #printImage, .wind, .button, .buttonno, .dialogButton, #shadowlayer {background-color:"+style_windBgColor+"; color:"+style_fontColor+";}");
ToStyle("#body {height: 100%; width: 100%;overflow: auto;");
ToStyle("	background-image:url("+style_mainBgTexture+");");
ToStyle("	background-repeat:repeat;");
ToStyle("	background-color:"+style_mainBgColor+";");
ToStyle("	word-wrap:break-word;");
ToStyle("}");
ToStyle("#menu, #buttonsList * {background-color:"+style_menuBackColor+"; color:"+style_menuFontColor+";}");
ToStyle("#toolbar, #printTitle {height:36px; position:absolute; top:0; left:0; right:0; padding:6px 0; overflow:hidden; z-index:1; font-size:0.9em;}");
ToStyle("#page {display:none; height:100%; max-height:100%; width:100%; max-width:600px; text-align:left; margin:0 auto; overflow:hidden;}");
ToStyle("#printTitle {background-color:"+style_toolbarBackColor+"; color:"+style_toolbarFontColor+"; z-index:-1; display:block; line-height:36px; padding:0 80px; overflow:hidden;}");
ToStyle("#printTitle * {display:inline;}");
var shadows = 'none';
if (style_shadows_block) {
shadows = style_shadows;
}
ToStyle("#printCont, #printImage, #menu, #buttonsList * {box-shadow:"+shadows+";}");
ToStyle("#printCont {position:absolute; top:36px; bottom:36px; left:0; right:0; overflow:auto; }");
ToStyle("#printImage {display:none; overflow:hidden; position:absolute; top:36px; bottom:36px; left:0; right:0;}");
ToStyle("#clickImage {width:100%; height:100%; object-fit:cover; max-width:none;}");
ToStyle("#print, #printAdd {padding:1em 1.5em; line-height:1.4em;}");
ToStyle("#print {margin:0 auto; max-width:600px;}");
ToStyle("#menu {height:36px; max-height:36px; margin:0; padding:1em; font-size:13px; overflow:auto; position:absolute; left:0; right:0; bottom:0; text-align:center; z-index:98; line-height:1.1em;}");
ToStyle("#menuTable {height:100%;}");
ToStyle("#menu span {background-color:transparent; border:none; border-radius:0; padding:0; display:inline-block; margin:0 10px; max-width:100px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}");
ToStyle("#menu img {display:inline; max-height:20px; vertical-align:middle;}");
ToStyle("#printAddCont {display:none; position:absolute; left:1em; right:1em; top:56px; bottom:56px; z-index:100; overflow:hidden;}");
ToStyle("#printAdd {width:100%; max-width:668px; position:absolute; margin:0 auto; left:0; right:0; top:30%; transform:translateY(-30%); max-height:100%; overflow:auto; box-shadow:"+style_shadows+";}");
ToStyle("#printAddText {text-align:left;position:relative;}");
ToStyle(".wind {display:none; position:absolute; width:240px; margin-left:-120px; height:auto; max-height:220px; left:50%; top:50%; transform:translateY(-50%); z-index:101; padding:1em; text-align:center; overflow:auto; font-size:15px; box-shadow:"+style_shadows+"; line-height:1.6em;}");
ToStyle(".plink, .plinkno, a, .button, .buttonno, .dialogButton {color:"+style_linkColor+"; text-decoration:none; -webkit-tap-highlight-color:rgba(128,128,128,0.2);}");
ToStyle(".wind .plink, .wind .plinkno {color:inherit;}");
ToStyle(".button, .buttonno, .dialogButton {display:table; font-size:0.95em; border-width:2px; border-style:solid; border-color:"+style_fontColor+"; padding:3px 8px; margin:0 4px 2px 0; max-width:90%; -webkit-hyphens: auto; hyphens: auto; border-radius:"+style_buttonRadius+"px; -webkit-tap-highlight-color:rgba(128,128,128,0.2);}");
ToStyle(".dialogButton {display:inline-block; padding:2px 0px; margin:0; min-width:30px; width:44%;}");
ToStyle(".plinkno, .buttonno {opacity:0.6; pointer-events:none;}");
ToStyle("#storyauthor {font-size:1.3em; letter-spacing:0.12em; line-height:1;}");
ToStyle("#storytitle {font-size:1.8em; margin:1em 0; line-height:1;}");
ToStyle("#storyauthor p, #storytitle p {margin:0;}");
ToStyle("#storysubtitle {font-size:0.8em; text-align:center; max-height:8em; overflow:auto; }");
ToStyle("code, tt, #console {font-family:Menlo, Monaco, 'Droid Sans Mono', 'Courier New', Courier, 'Lucida Console', monospace;}");
ToStyle("code {display:block; white-space:pre-wrap; margin:1em 0; padding:0.5em; border:2px dotted;}");
ToStyle(".input_text {-webkit-appearance:none; margin:0; padding:4px; width:90%; border-width:0;}");
ToStyle(".input_text, #console, #console *, code, tt, code *, tt * {-moz-user-select:text; -o-user-select:text; -khtml-user-select:text; -webkit-user-select:text; -ms-user-select:text; user-select:text;}");
ToStyle(".input_butt {-webkit-appearance:none; margin:0; text-align:right; width:10%; padding:4px; border:none;}");
ToStyle(".myinput, .trow, select {border-width:2px; border-style:solid; border-color:"+style_fontColor+";}");
ToStyle(".myinput {padding:2px; width:100%; margin:0 auto; clear:both;}");
ToStyle("h1,h2,h3,h4,h5,h6 {color:"+style_headerColor+";}");
ToStyle("h1,h2,h3,h4,h5,h6 {text-align:center; padding:0.5em 0; display:block; font-weight:normal; margin:0.5em auto;}");
ToStyle("h1 {font-size:1.4em;}");
ToStyle("h2 {font-size:1.3em;}");
ToStyle("h3 {font-size:1.2em;}");
ToStyle("h4 {font-size:1.1em;}");
ToStyle("h5 {font-size:1.0em;}");
ToStyle("h6 {font-size:0.9em;}");
ToStyle("img {max-width:100%; border:none; margin:0; padding:0;}");
ToStyle(".file {max-width:100%; display:block; margin:0.2em auto;}");
ToStyle(".accentLogASM {color: #96281B;}");
ToStyle(".avatar {visibility:hidden; max-width:90%;}");
ToStyle(".video {position:relative; padding-bottom:56.25%; padding-top:30px; height:0; overflow:hidden;}");
ToStyle(".video iframe, .video object, .video embed {position:absolute; top:0; left:0; width:100%; height:100%;}");
ToStyle("ol, ul, dl, li {margin-left:0px;}");
ToStyle(".choice {display:inline-block; margin-left:0.75em; position:relative;}");
ToStyle(".choice .plink {margin:0.5em 0;}");
ToStyle(".choice .plink:before {content:'✓'; position:relative; left:-0.5em; visibility:hidden; color:"+style_fontColor+"; -webkit-transition:opacity 0.5s ease; transition:opacity 0.5s ease; opacity:0;}");
ToStyle(".choice .selected:before {visibility:visible; opacity:1;}");
ToStyle("#console {position:absolute; top:0; right:0; left:0; z-index:99; margin-top:36px; padding:0 5px; color:#000000; height:0; overflow:hidden; font-size:12px; background-color:rgba(255,255,255,0.8); -webkit-transition:height 0.5s ease; transition:height 0.5s ease;}");
ToStylW("body {scrollbar-face-color:"+style_fontColor+"; scrollbar-track-color:"+style_windBgColor+";} "); // ie
ToStylW("::-webkit-scrollbar {-webkit-appearance:none; width:6px; height:6px;} ");
ToStylW("::-webkit-scrollbar-corner {background:transparent;} ");
ToStylW("::-webkit-scrollbar-track {background:transparent;} ");
ToStylW("::-webkit-scrollbar-thumb {background-color:"+style_fontColor+"; border-radius:6px; opacity:0.7;} ");
ToStyle("::-webkit-scrollbar-thumb:hover {opacity:0.6;}");
ToStyle(".imgbutton {display:inline-block; border-radius:50%; width:24px; height:24px; background-position:center; background-repeat:no-repeat; background-color:rgba(255,255,255,0.75); background-size:20px;}");
ToStyle(".imgbutton:hover {opacity:0.8;}");
ToStyle("#showImageButton {position:fixed; background:#FF0000; bottom:0; left:0; width:20px; height:36px; overflow:hidden; z-index:100; background-color:rgba(255,255,255,0.3); background-repeat:no-repeat; background-size:80%; background-position:center center; background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABUFBMVEUAAAAHBwcAAAALCwsAAAAAAAAXFxcGBgYaGhoMDAz///8HBwcICAgJCQkZGRkKCgoaGho/Pz/T09MRERGoqKiOjo4JCQkKCgoLCwsRERERERETExMfHx8YGBgeHh4eHh4gICA5OTlTU1N2dnYICAgHBwcNDQ0JCQkMDAwTExMvLy9gYGCkpKQLCwsNDQ0QEBAWFhYbGxsnJycuLi4pKSlgYGAGBgYJCQkICAgHBwcMDAwREREPDw8LCwsHBwcNDQ0VFRUUFBQbGxsVFRUfHx8gICAcHBwrKysxMTFYWFhJSUkTExMFBQUXFxcKCgoLCwsLCwsTExMYGBgdHR0iIiIrKysqKipGRkYFBQUODg4SEhIMDAwFBQUXFxcQEBAeHh5DQ0OwsLAnJycMDAwSEhIWFhYODg4pKSlMTEweHh5gYGAAAAACAgIEBAQQEBAMDAzFBWcXAAAAa3RSTlMABf0D+/kB9nfdAvPl32PJgBoFkgkI79zTuqOcbV9dWEUuFg3o4dLNwKAlGAvXx46DWkovKxP57N/Twrazs6admHlzZmJLRkI7Gxj89/S8t7WzjmdUPSYj+/O9ubWQaiccDgrkx8aojlRDQGI2Q8gAAAUcSURBVFjDpVf3W9swEFUck51ABgkFQtiQEMosUCh7QwuUMrr3lkT//9/6ZHRWjJ2U76s+cJK7986nO0l3Yv4RCannh3L+zeOR45s/x6nHb/LleSULRdi/R1jRL/OTknuGLOX3W5swbx+MTQpQbNuyLMXFh23jU5Q2B2Gi9esZm3iXBMe2vA5oUfT8EUDN+bAei3Leptk+G22cJ7eaOxEJs7ku0AVvOgRMjM6xcGAkIOyVRG9lQm4FTgOiHsFtD9gJHx4eo4B0Ax7Af+B5vUDkDckWHicegODz/xtva4w5gHKk/eTt2+WxEQlJY178FiLO+w3d4mKxe6aWu9XmajPdw0JJjYXnIHny1wOhUYv2viFnYmo4wKHKQ+mBbLBwI79XuEqEbHJXCUOg6vyGVOpnuxBW14LoBc0N4IDkwg2y7ICIFr1Z43hhh6Q0AS4HQKQAjEJB/Oh+k7UG+EGxAdgFqp5ADHMi8eK12XJh+I6ZhM1OO4wTFJ8xUB3DE1EuiD+chVTDNdFMCKqhkvYBlOQgyEqYJ6sWT14TX31k997H3pf7s4wZ6USRW+TCOX7DRvYpOSDkgUbC7Vxm+alwpNGTTKdJ2KUUDS5EIJnWDuCjg/iM9X1xFiT2ArQy3RtyI9Zh8JsKn0trnyyKK/iF5wLHgrgVlzJXHy5+1m91eEy6hFICkn5aHZacBdXhP4qDTnF9wpzx6RPIjgu7LkP0Q9DDbW3vIfELlCwljYMTxmC/D8m/dm5p4z2MJUr0S1QoryvEV9I+Rwru5x8UxxlhmznMS4rpcAEopd8R4JP05TULa94TZ+UANDRMeZPzrMxt7U5VqwspyjSlShtYX8jpV3S7pAybou9iBhqlfYEJmCHmXQ++8x0NmXEN5NkZLU15pZD4X9YOaMg0+6xTU+TjGnIluU7xCRtz4HikOuEflEe0MygIAyyEweC3Fc0CAFhniliP2TOyNab40P+iLFMei/sMo1DlFvIOACzoRIL6jP0hV0/11srgu9eCPJ2aWl/kFhTbAKi3nNI0b5ggA2vQ0eHgtUCrBn+b2sATeovFZEsDVBTbUBgaDaySAcGOycCZnsI26fzDTGHcTCFO8WzXQdyjIPqHCeKYCWL73TRmFyAPGhAHpNGEQ9agJPeCBsTLGlJzF9J4w1Ku6CiWhS+KdAK90JA+QUt5g9KOZ7feTLmRYBcwy0LAZpqTgrZzXaszwS60iR3azotck+Qcyy35DxRU6qAJrEB1OwP3EEvjUKz6j7T6JOA+frwOlf9IazwiZ1nId6hqHfgTjhaPC2ETYw+ChO9YB6b+QKAnoQoCOl+p09nI4i5hKUeFIqCwpAUgNnaBQqd2qKfxFKJppurNYDKwtCX6xqm0jWcKkGj+vrRoYS5gYSrRuSmuxYnG4vqxv7wV2/YW18OkKa55ndZHSVPe40P/KO9pU96jR5TXLTdrKtgtGwzimwZD704jLh6A2aTFuWxscUbB/P8mK7jN65q9R5uHndnonbfRlA8rBR0EHYLOC1+jGfK2uq/vtLrD1UpNNzadtcp6qnWrix+Jr0HN9ura2mp7SopWzTZNIvG6Vbtvedr9leALQ1XcLUqWjWFcpwJTDb6y3PvK00t8/6VrYPQely7kP9Li2pdsfe2LxgBrefEcfBdtfvFc2Dgy7jd14qhDnSXCCZ/64oRS+T8y/RGAyD0u34m9nrT0Tl6m13dzoIfve39PzGXyZ6NLr25uXi2NrU6V5xMsmP4XV/4R83ayoXMAAAAASUVORK5CYII=);}");
ToStyle("#AudioButton {display:none; opacity:0.5; background-image:url("+style_buttonAudio+");}");
ToStyle("#ConsoleButton {background-image:url("+style_buttonConsole+");}");
ToStyle("#ViewButton {background-image:url("+style_buttonView+");}");
ToStyle("#PrefsButton {background-image:url("+style_buttonPrefs+");}");
ToStyle("#body {cursor:url("+style_cursor+"),default;}");
ToStyle("a, .plink, .button, .dialogButton, select, .input_butt, .imgbutton, #showImageButton, .sprite[active], #backVideoSkip, #shadowlayer, .updateButton {cursor:url("+style_cursorHover+"),pointer;}");
ToStyle("	#printCont, #printAdd, #printImage, #menu, .wind {border-width:"+style_borderWidth+"px; border-style:solid; border-color:inherit; border-image:url("+style_borderImage+") "+style_borderWidth+" round;}");
ToStyle("#shadowlayer {position:absolute; left:0; top:0; right:0; bottom:0; text-align:center; padding:2em; font-size:1.2em; background-color:transparent; z-index:99;}");
ToStyle("#shadowlayer[visible] {background-color:rgba(0,0,0,0.5);}");
ToStyle("#shadowlayer div {margin-left:auto; margin-right:auto; max-width:50em;}");
ToStyle("#spritesDiv {position:relative; top:-100%; height:100%; overflow:hidden; text-align:left;}");
ToStyle(".sprite {display:block; position:absolute; max-width:none; max-height:none; margin:auto; opacity:0;}");
ToStyle(".sprite[active] {webkit-transition:all 300ms linear; transition:all 300ms linear;}");
ToStyle(".sprite[active]:hover {-webkit-transform:scale(1.05); transform:scale(1.05);}");
ToStyle(".sprite[drag] {cursor:move !important;}");
ToStyle("#backVideo {position:absolute; top:50%; left:50%; min-width:100%; min-height:100%; width:auto; height:auto; transform:translate(-50%,-50%);}");
ToStyle("#backVideoSkip {position:absolute; left:50%; width:1em; height:1em; line-height:1em; padding:0.2em; margin-left:-0.6em; top:50%; margin-top:-0.6em; font-size:2em; color:#fff; background-color:rgba(128,128,128,0.5); border-radius:50%; z-index:1; text-shadow:none; -webkit-transition:all 300ms ease; transition:all 300ms ease;}");
ToStyle("#backVideoSkip:hover {-webkit-transform:scale(1.1); transform:scale(1.1);}");
ToStyle("*[nohover]:hover {-webkit-transform:none !important; transform:none !important; -webkit-transition:none !important; transition:none !important;}");
ToStyle(".clickEffect {position:fixed; background-color:#555; border-radius:50%; -webkit-animation:clickEffect 0.4s ease-out; animation:clickEffect 0.3s ease-out; z-index:99999; pointer-events:none;}");
ToStyle("@-webkit-keyframes clickEffect {");
ToStyle("	0% {opacity:0.8; width:8px; height:8px; margin:-4px;}");
ToStyle("	100% {opacity:0; width:48px; height:48px; margin:-24px; background-color:#ccc;}");
ToStyle("}");
ToStyle("@keyframes clickEffect {");
ToStyle("	0% {opacity:0.8; width:8px; height:8px; margin:-4px;}");
ToStyle("	100% {opacity:0; width:48px; height:48px; margin:-24px; background-color:#ccc;}");
ToStyle("}");
ToStyle(".clickEffect[active] {-webkit-animation-name:clickEffectActive; animation-name:clickEffectActive;}");
ToStyle("@-webkit-keyframes clickEffectActive {");
ToStyle("	0% {opacity:0.8; width:8px; height:8px; margin:-4px;}");
ToStyle("	100% {opacity:0; width:240px; height:240px; margin:-120px; background-color:#ccc;}");
ToStyle("}");
ToStyle("@keyframes clickEffectActive {");
ToStyle("	0% {opacity:0.8; width:8px; height:8px; margin:-4px;}");
ToStyle("	100% {opacity:0; width:240px; height:240px; margin:-120px; background-color:#ccc;}");
ToStyle("}");
if (style_view!='vis' && style_view!='bt') {
ToStyle("@media only screen and (max-width:599px), only screen and (max-height:599px) {");
ToStyle("	#menu {padding:0 2em;}");
ToStyle("	#printCont, #printImage, #menu {border-width:0; border-image:none;}");
ToStyle("	#shadowlayer {padding:1em;}");
ToStyle("}");
}
if (style_view=='sw') {
ToStyle("@media only screen and (min-width:600px) and (min-height:600px) {");
ToStyle("	#body, input {font-size:100%;}");
ToStyle("	#printHelper {position:absolute; top:0; bottom:0; left:0; right:0; padding:56px 1em;}");
ToStyle("	#printCont {position:static; margin:0 auto; max-width:728px; height:100%;}");
ToStyle("	#print {max-width:100%;}");
ToStyle("	#printImage {top:112px; bottom:112px; left:76px; right:76px;}");
ToStyle("	#menu {border-width:0; border-image:none;}");
ToStyle("}");
} else if (style_view=='rpg') {
ToStyle("@media only screen and (min-width:600px) and (min-height:600px) {");
ToStyle("	#body, input {font-size:100%;}");
ToStyle("	#page {max-width:1024px; margin:0 auto; position:relative;}");
ToStyle("	#printCont {position:absolute; top:73%; left:1em; right:1em; bottom:1em;}");
ToStyle("	#print {max-width:none;}");
ToStyle("	#printImage {display:block; overflow:hidden; position:absolute; top:56px; left:1em; right:30%; bottom:30%;}");
ToStyle("	#menu {position:absolute; top:56px; left:73%; right:1em; bottom:30%; height:auto; max-height:none; font-size:0.9em; line-height:1.6em; opacity:1; z-index:0;}");
ToStyle("	#menuTable {height:auto;}");
ToStyle("	#menu span {display:block; float:none; margin:0 auto; white-space:normal; word-break:break-all; max-width:none;}");
ToStyle("	#menu img {float:none; display:block; margin:0 auto; max-height:36px;}");
ToStyle("	#spacer, #showImageButton {display:none;}");
ToStyle("}");
} else if (style_view=='bt') {
ToStyle("#body {font-size:110%;}");
ToStyle("#console {text-shadow:none; letter-spacing:normal;}");
ToStyle("#page {max-width:none; margin:0 auto; position:absolute; left:0; right:0; top:0; bottom:0;}");
ToStyle("#avatarBlock {max-width:25%; float:left;}");
ToStyle("#printCont {position:absolute; margin:0 auto; left:0; right:0; bottom:auto; top:50%; transform:translateY(-50%); padding:0.5em 1em; width:100%; max-width:40em; height:auto; min-height:0; max-height:50%; overflow:auto; z-index:1;}");
ToStyle("#print {max-width:none; padding:0;}");
ToStyle("#printAdd {padding:1em; max-width:35em; max-height:65%;}");
ToStyle("#printImage {display:block; position:absolute; top:0; left:0; right:0; bottom:0; border:none;	background-color:rgba(0,0,0,0); cursor:url("+style_cursor+"),default;}");
ToStyle("#menu {font-size:1em; line-height:1.2; position:absolute; padding:0 1em; height:auto; max-height:70%; top:50%; bottom:auto; transform:translateY(-50%); left:auto; right:1em; width:auto; overflow-y:auto; overflow-x:hidden; max-width:10em;}");
ToStyle("#menuTable {height:auto;}");
ToStyle("#menu span {display:block; margin:0.8em 0; white-space:normal; width:auto; max-width:none; word-break:break-all;}");
ToStyle("#menu img {display:block; margin:0 auto; max-width:100%; max-height:4em;}");
ToStyle("#printCont, #printAdd, #printTitle, #menu, #buttonsList *, .wind, #console {-webkit-backdrop-filter:blur(3px); backdrop-filter:blur(3px);}");
ToStyle(".dialogButton, button, .button, .buttonno {border-style:none;}");
ToStyle("#buttonsList * {-webkit-transition:all 500ms ease; transition:all 500ms ease;}");
ToStyle("#buttonsList {line-height:1; min-height:0; max-height:20%; height:auto; opacity:1; padding:1em; width:95%; max-width:90em; min-width:0; position:absolute; margin:auto; left:0; right:0; bottom:0; overflow-y:auto; overflow-x:hidden; text-align:center;}");
ToStyle("#buttonsList * {display:inline-block; padding:0.5em 1em; text-align:center; margin:0.2em 0.5em; max-width:none; min-width:10em;}");
ToStyle("#buttonsList>*:hover {-webkit-transform:scale(1.08); transform:scale(1.08);}");
ToStyle(".myinput *, select {background-color:rgba(0,0,0,0);}");
ToStyle("#spacer, #showImageButton {display:none;}");
ToStyle("@media only screen and (max-width:1149px) {");
ToStyle("	#menu {width:100%; max-width:40em; max-height:15%; margin:0 auto; left:50%; right:auto; top:56px; transform:translateY(0); transform:translateX(-50%); padding:0.5em;}");
ToStyle("	#menu img {max-height:2.5em;}");
ToStyle("	#menu span, #menu div, #menu p, #menu img {display:inline; padding:0 0.25em;}");
ToStyle("	#printCont {max-height:50%;}");
ToStyle("	#buttonsList * {min-width:0;}");
ToStyle("}");
ToStyle("@media only screen and (max-width:599px) {");
ToStyle("	#body {font-size:100%;}");
ToStyle("}");
ToStyle("@media only screen and (max-height:599px) {");
ToStyle("	#body {font-size:90%;}");
ToStyle("	#menu {width:100%; max-width:40em; max-height:15%; margin:0 auto; left:50%; right:auto; top:36px; transform:translateY(0); transform:translateX(-50%); padding:0 0.5em;}");
ToStyle("	#menu img {max-height:2em;}");
ToStyle("	#menu span, #menu p, #menu img {display:inline; padding:0 0.25em;}");
ToStyle("	#buttonsList {padding:0;}");
ToStyle("}");
} else if (style_view=='vis') {
ToStyle("#body {font-size:130%;}");
ToStyle("#body,input {letter-spacing:1px;}");
ToStyle("#console {text-shadow:none; letter-spacing:normal;}");
ToStyle("#page {max-width:none; margin:0 auto; position:relative;}");
ToStyle("#printCont {transform:translateZ(0); position:absolute; top:auto; left:0; right:0; bottom:0; width:100%; min-width:0; max-width:55em; height:auto; max-height:33%; padding:0 1em 0.3em 1em; margin:0 auto; border:none; z-index:1;}");
ToStyle("#avatarBlock {max-width:25%; float:left;}");
ToStyle("#print {max-width:none; padding:0;}");
ToStyle("#printAddCont {padding:80px 50px 44px 50px;}");
ToStyle("#printAdd {padding:0.5em 1em; max-width:35em; max-height:65%;}");
ToStyle("#printImage {display:block; position:absolute; top:0; left:0; right:0; bottom:0; border:none;	background-color:rgba(0,0,0,0); cursor:url("+style_cursor+"),default;}");
ToStyle("#menu {position:absolute; top:56px; left:auto; right:10px; bottom:auto; max-width:240px; height:auto; max-height:50%; font-size:0.9em; line-height:1.6em; opacity:1; padding:0; border:none; box-shadow:none; z-index:0;}");
ToStyle("#menu, #menu *, .myinput *, select {background-color:rgba(0,0,0,0);}");
ToStyle("#menuTable {height:auto;}");
ToStyle("#menu span {display:block; text-align:right; float:none; clear:both; margin:0 auto; white-space:normal; word-break:break-all; width:auto; max-width:none; padding:0 0.3em;}");
ToStyle("#menu span:hover {padding-left:0.3em; -webkit-transform:translate(-0.2em); transform:translate(-0.2em);}");
ToStyle("#menu img {display:block; float:right; clear:both; max-height:64px;}");
ToStyle(".button, .buttonno {width:auto; margin:0 auto 1em auto; text-align:center; background-color:transparent; border:none;}");
ToStyle("#printCont, #printAdd, .wind, #console {-webkit-backdrop-filter:blur(3px); backdrop-filter:blur(3px);}");
ToStyle(".typer_1 {opacity:0;}");
ToStyle(".typer_2 {opacity:1; -webkit-transition:opacity 100ms ease; transition:opacity 100ms ease;}");
ToStyle("#buttonsList {position:absolute; width:auto; padding:1em 0; margin:0 auto; max-height:50%; top:auto; left:0; right:0; bottom:40%; overflow-y:auto; overflow-x:hidden; }");
ToStyle("#buttonsList * {background-color:transparent;}");
ToStyle("#buttonsList *, #menu span, #menu span:hover {-webkit-transition:all 500ms ease; transition:all 500ms ease; border-style:none; box-shadow:none;}");
ToStyle("#buttonsList *:hover {-webkit-transform:scale(1.08); transform:scale(1.08); margin-top:1em;	text-shadow:inherit;}");
ToStyle("#spacer, #showImageButton {display:none;}");
ToStyle(".video {margin:0 auto; padding:0; max-width:300px; height:200px;}");
ToStyle("@media only screen and (max-width:599px), only screen and (max-height:599px) {");
ToStyle("	#body {font-size:90%;}");
ToStyle("	#printAddCont {padding:36px 20px 44px 20px;}");
ToStyle("	#menu img {max-height:32px;}");
ToStyle("	#avatarBlock {max-width:40%; max-height:100%;}");
ToStyle("}");
} else {
ToStyle("@media only screen and (min-width:600px) and (min-height:600px) {");
ToStyle("	#body, input {font-size:100%;}");
ToStyle("	#page {max-width:1024px; padding:56px 1em 1em 1em; margin:0 auto;}");
ToStyle("	#printCont {float:left; width:68%; height:100%; min-height:100%; max-height:100%; margin:0; position:static;}");
ToStyle("	#print {max-width:none;}");
ToStyle("	#printAddCont {padding:80px 50px 44px 50px;}");
ToStyle("	#printImage, #menu {float:right; width:30%; position:relative; top:0; margin:0;}");
ToStyle("	#printImage {display:block; height:36%;}");
ToStyle("	#menu {height:62%; max-height:62%; font-size:1.15em; line-height:1.6em; opacity:1;}");
ToStyle("	#menuTable {height:auto;}");
ToStyle("	#menu span {display:block; float:none; margin:0 auto; white-space:normal; word-break:break-all; max-width:none;}");
ToStyle("	#menu img {float:none; display:block; margin:0 auto; max-height:36px;}");
ToStyle("	#spacer {float:right; width:30%; height:2%; pointer-events:none;}");
ToStyle("	#showImageButton {display:none;}");
ToStyle("}");
ToStyle("@media only screen and (min-width:600px) and (min-height:600px) and (orientation:portrait) {");
ToStyle("	#printCont {float:none; width:100%; min-height:65%; height:65%; max-height:65%; margin-bottom:3%;}");
ToStyle("	#printImage, #menu {width:49%; margin:0; min-height:32%; height:32%; max-height:32%;}");
ToStyle("	#printImage {float:left;}");
ToStyle("	#menu {float:right;}");
ToStyle("	#menuTable {height:100%;}");
ToStyle("	#spacer {display:none;}");
ToStyle("}");
}
if (style_view=='bt' || style_view=='vis') {
ToStyle("#printCont, #buttonsList, #menu, #toolbar {-webkit-transition:opacity 0.5s ease; transition:opacity 0.5s ease;}");
}
ToStyle(".effect_fade {");
ToStyle("	-webkit-animation-name: effect_fade;");
ToStyle("	animation-name: effect_fade;");
ToStyle("	-webkit-animation-fill-mode: both;");
ToStyle("	animation-fill-mode: both;");
ToStyle("	-webkit-animation-duration: 1000ms;");
ToStyle("	animation-duration: 1000ms;");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_fade {");
ToStyle("	0% {opacity: 0;}	");
ToStyle("	100% {opacity: 1;}");
ToStyle("}");
ToStyle("@keyframes effect_fade {");
ToStyle("	0% {opacity: 0;}	");
ToStyle("	100% {opacity: 1;}");
ToStyle("}");
ToStyle(".effect_fade_fast {");
ToStyle("	-webkit-animation-name: effect_fade;");
ToStyle("	animation-name: effect_fade;");
ToStyle("	-webkit-animation-fill-mode: both;");
ToStyle("	animation-fill-mode: both;");
ToStyle("	-webkit-animation-duration: 400ms;");
ToStyle("	animation-duration: 400ms;");
ToStyle("}");
ToStyle(".effect_bounce {");
ToStyle("-webkit-animation-name:effect_bounce;");
ToStyle("animation-name:effect_bounce;");
ToStyle("-webkit-animation-fill-mode:both;");
ToStyle("animation-fill-mode:both;");
ToStyle("-webkit-animation-duration:.7s;");
ToStyle("animation-duration:.7s;");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_bounce {");
ToStyle("0% {");
ToStyle("opacity:0;");
ToStyle("-webkit-transform:scale(.3);");
ToStyle("}");
ToStyle("50% {");
ToStyle("opacity:1;");
ToStyle("-webkit-transform:scale(1.05);");
ToStyle("}");
ToStyle("70% {");
ToStyle("-webkit-transform:scale(.9);");
ToStyle("}");
ToStyle("100% {");
ToStyle("-webkit-transform:scale(1);");
ToStyle("}");
ToStyle("}");
ToStyle("@keyframes effect_bounce {");
ToStyle("0% {");
ToStyle("opacity:0;");
ToStyle("transform:scale(.3);");
ToStyle("}");
ToStyle("50% {");
ToStyle("opacity:1;");
ToStyle("transform:scale(1.05);");
ToStyle("}");
ToStyle("70% {");
ToStyle("transform:scale(.9);");
ToStyle("}");
ToStyle("100% {");
ToStyle("transform:scale(1);");
ToStyle("}");
ToStyle("}");
ToStyle(".effect_scale {");
ToStyle("-webkit-animation:effect_scale .2s ease-out both;");
ToStyle("animation:effect_scale .2s ease-out both;");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_scale {");
ToStyle("from { opacity:0; -webkit-transform:scale(.4); }");
ToStyle("}");
ToStyle("@keyframes effect_scale {");
ToStyle("from { opacity:0; transform:scale(.4); }");
ToStyle("}");
ToStyle(".effect_fade_sprite {");
ToStyle("-webkit-animation:effect_fade_sprite 1s both linear;");
ToStyle("animation:effect_fade_sprite 1s both linear;");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_fade_sprite {");
ToStyle("from { opacity:0; }");
ToStyle("}");
ToStyle("@keyframes effect_fade_sprite {");
ToStyle("from { opacity:0; }");
ToStyle("}");
ToStyle(".effect_flip {");
ToStyle("-webkit-transform-origin:50% 50%;");
ToStyle("-webkit-animation:effect_flipx .7s both ease-out;");
ToStyle("transform-origin:50% 50%;");
ToStyle("animation:effect_flipx .7s both ease-out;");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_flipx {");
ToStyle("from { -webkit-transform:translateZ(-1000px) rotateY(90deg); opacity:0.2; }");
ToStyle("}");
ToStyle("@keyframes effect_flipx {");
ToStyle("from { transform:translateZ(-1000px) rotateY(90deg); opacity:0.2; }");
ToStyle("}");
ToStyle(".effect_flipY {");
ToStyle("-webkit-transform-origin:50% 50%;");
ToStyle("-webkit-animation:effect_flipy .7s both ease-out;");
ToStyle("transform-origin:50% 50%;");
ToStyle("animation:effect_flipy .7s both ease-out;");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_flipy {");
ToStyle("from { -webkit-transform:translateZ(-1000px) rotateX(90deg); opacity:0.2; }");
ToStyle("}");
ToStyle("@keyframes effect_flipy {");
ToStyle("from { transform:translateZ(-1000px) rotateX(90deg); opacity:0.2; }");
ToStyle("}");
ToStyle(".effect_fly {");
ToStyle("-webkit-animation:effect_fly 1s ease both;");
ToStyle("animation:effect_fly 1s ease both;");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_fly {");
ToStyle("from { opacity:0; -webkit-transform:scale(3); }");
ToStyle("}");
ToStyle("@keyframes effect_fly {");
ToStyle("from { opacity:0; transform:scale(3); }");
ToStyle("}");
ToStyle(".effect_flash {");
ToStyle("-webkit-animation:effect_flash 10s 10s linear infinite;");
ToStyle("animation:effect_flash 10s 10s linear infinite;");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_flash {");
ToStyle("0% { -webkit-transform:scale(1); }");
ToStyle("3% { -webkit-transform:scale(1.02); }");
ToStyle("6% { -webkit-transform:scale(1); }");
ToStyle("9% { -webkit-transform:scale(1.02); }");
ToStyle("12%{ -webkit-transform:scale(1); }");
ToStyle("}");
ToStyle("@keyframes effect_flash {");
ToStyle("0% { transform:scale(1); }");
ToStyle("3% { transform:scale(1.02); }");
ToStyle("6% { transform:scale(1); }");
ToStyle("9% { transform:scale(1.02); }");
ToStyle("12%{ transform:scale(1); }");
ToStyle("}");
ToStyle(".effect_pulse {");
ToStyle("-webkit-animation:effect_pulse 435ms ease-in-out infinite;");
ToStyle("animation:effect_pulse 435ms ease-in-out infinite;");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_pulse {");
ToStyle("0% { -webkit-transform:scale(0.98); }");
ToStyle("50% { -webkit-transform:scale(1); }");
ToStyle("100%{ -webkit-transform:scale(0.98); }");
ToStyle("}");
ToStyle("@keyframes effect_pulse {");
ToStyle("0% { transform:scale(0.98); }");
ToStyle("50% { transform:scale(1); }");
ToStyle("100%{ transform:scale(0.98); }");
ToStyle("}");
ToStyle(".effect_slide_left {");
ToStyle("-webkit-animation-name:effect_slide_left; animation-name:effect_slide_left;");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_slide_left {");
ToStyle("from {-webkit-transform:translate3d(100%,0,0); opacity:0;}");
ToStyle("to {-webkit-transform:translate3d(0,0,0);}");
ToStyle("}");
ToStyle("@keyframes effect_slide_left {");
ToStyle("from {transform:translate3d(100%,0,0); opacity:0;}");
ToStyle("to {transform:translate3d(0,0,0);}");
ToStyle("}");
ToStyle("#printCont.effect_slide_left {");
ToStyle("-webkit-animation-name:effect_slide_left2; animation-name:effect_slide_left2;");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_slide_left2 {");
ToStyle("from {-webkit-transform:translate3d(100%,-50%,0); opacity:0;}");
ToStyle("to {-webkit-transform:translate3d(0,-50%,0);}");
ToStyle("}");
ToStyle("@keyframes effect_slide_left2 {");
ToStyle("from {transform:translate3d(100%,-50%,0); opacity:0;}");
ToStyle("to {transform:translate3d(0,-50%,0);}");
ToStyle("}");
ToStyle(".effect_slide_right {");
ToStyle("-webkit-animation-name:effect_slide_right; animation-name:effect_slide_right;");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_slide_right {");
ToStyle("from {-webkit-transform:translate3d(-100%,0,0); opacity:0;}");
ToStyle("to {-webkit-transform:translate3d(0,0,0);}");
ToStyle("}");
ToStyle("@keyframes effect_slide_right {");
ToStyle("from {transform:translate3d(-100%,0,0); opacity:0;}");
ToStyle("to {transform:translate3d(0,0,0);}");
ToStyle("}");
ToStyle("#printCont.effect_slide_right {");
ToStyle("-webkit-animation-name:effect_slide_right2; animation-name:effect_slide_right2;");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_slide_right2 {");
ToStyle("from {-webkit-transform:translate3d(-100%,-50%,0); opacity:0;}");
ToStyle("to {-webkit-transform:translate3d(0,-50%,0);}");
ToStyle("}");
ToStyle("@keyframes effect_slide_right2 {");
ToStyle("from {transform:translate3d(-100%,-50%,0); opacity:0;}");
ToStyle("to {transform:translate3d(0,-50%,0);}");
ToStyle("}");
ToStyle(".effect_slide_up {");
ToStyle("-webkit-animation-name:effect_slide_up; animation-name:effect_slide_up;");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_slide_up {");
ToStyle("from {-webkit-transform:translate3d(0,100%,0); opacity:0;}");
ToStyle("to {-webkit-transform:translate3d(0,0,0);}");
ToStyle("}");
ToStyle("@keyframes effect_slide_up {");
ToStyle("from {transform:translate3d(0,100%,0); opacity:0;}");
ToStyle("to {transform:translate3d(0,0,0);}");
ToStyle("}");
ToStyle("#printCont.effect_slide_up {");
ToStyle("-webkit-animation-name:effect_slide_up2; animation-name:effect_slide_up2;");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_slide_up2 {");
ToStyle("from {-webkit-transform:translate3d(0,100%,0); opacity:0;}");
ToStyle("to {-webkit-transform:translate3d(0,-50%,0);}");
ToStyle("}");
ToStyle("@keyframes effect_slide_up2 {");
ToStyle("from {transform:translate3d(0,100%,0); opacity:0;}");
ToStyle("to {transform:translate3d(0,-50%,0);}");
ToStyle("}");
ToStyle(".effect_slide_down {");
ToStyle("-webkit-animation-name:effect_slide_down; animation-name:effect_slide_down;");
ToStyle("animation-duration:1.7s;	-webkit-animation-duration:1.7s;");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_slide_down {");
ToStyle("from {-webkit-transform:translate3d(0,-100%,0); opacity:0;}");
ToStyle("to {-webkit-transform:translate3d(0,0,0);}");
ToStyle("}");
ToStyle("@keyframes effect_slide_down {");
ToStyle("from {transform:translate3d(0,-100%,0); opacity:0;}");
ToStyle("to {transform:translate3d(0,0,0);}");
ToStyle("}");
ToStyle("#printCont.effect_slide_down {");
ToStyle("-webkit-animation-name:effect_slide_down2; animation-name:effect_slide_down2;");
ToStyle("animation-duration:1.7s;	-webkit-animation-duration:1.7s;");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_slide_down2 {");
ToStyle("from {-webkit-transform:translate3d(0,-100%,0); opacity:0;}");
ToStyle("to {-webkit-transform:translate3d(0,-50%,0);}");
ToStyle("}");
ToStyle("@keyframes effect_slide_down2 {");
ToStyle("from {transform:translate3d(0,-100%,0); opacity:0;}");
ToStyle("to {transform:translate3d(0,-50%,0);}");
ToStyle("}");
ToStyle(".effect_hatch {");
ToStyle("animation-name:effect_hatch;");
ToStyle("-webkit-animation-name:effect_hatch;");
ToStyle("animation-duration:2s;	");
ToStyle("-webkit-animation-duration:2s;");
ToStyle("animation-timing-function:ease-in-out;	");
ToStyle("-webkit-animation-timing-function:ease-in-out;");
ToStyle("transform-origin:50% 100%;");
ToStyle("-webkit-transform-origin:50% 100%; ");
ToStyle("}");
ToStyle("@keyframes effect_hatch {");
ToStyle("0% {");
ToStyle("transform:rotate(0deg) scaleY(0.6);");
ToStyle("}");
ToStyle("20% {");
ToStyle("transform:rotate(-2deg) scaleY(1.05);");
ToStyle("}");
ToStyle("35% {");
ToStyle("transform:rotate(2deg) scaleY(1);");
ToStyle("}");
ToStyle("50% {");
ToStyle("transform:rotate(-2deg);");
ToStyle("}");
ToStyle("65% {");
ToStyle("transform:rotate(1deg);");
ToStyle("}");
ToStyle("80% {");
ToStyle("transform:rotate(-1deg);");
ToStyle("}");
ToStyle("100% {");
ToStyle("transform:rotate(0deg);");
ToStyle("}");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_hatch {");
ToStyle("0% {");
ToStyle("-webkit-transform:rotate(0deg) scaleY(0.6);");
ToStyle("}");
ToStyle("20% {");
ToStyle("-webkit-transform:rotate(-2deg) scaleY(1.05);");
ToStyle("}");
ToStyle("35% {");
ToStyle("-webkit-transform:rotate(2deg) scaleY(1);");
ToStyle("}");
ToStyle("50% {");
ToStyle("-webkit-transform:rotate(-2deg);");
ToStyle("}");
ToStyle("65% {");
ToStyle("-webkit-transform:rotate(1deg);");
ToStyle("}");
ToStyle("80% {");
ToStyle("-webkit-transform:rotate(-1deg);");
ToStyle("}");
ToStyle("100% {");
ToStyle("-webkit-transform:rotate(0deg);");
ToStyle("}");
ToStyle("}");
ToStyle(".effect_fade_out {");
ToStyle("-webkit-animation-name:effect_fade_out;");
ToStyle("animation-name:effect_fade_out;");
ToStyle("-webkit-animation-fill-mode:both;");
ToStyle("animation-fill-mode:both;");
ToStyle("-webkit-animation-duration:1000ms;");
ToStyle("animation-duration:1000ms;");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_fade_out {");
ToStyle("0% {opacity:1;}	");
ToStyle("100% {opacity:0;}");
ToStyle("}");
ToStyle("@keyframes effect_fade_out {");
ToStyle("0% {opacity:1;}	");
ToStyle("100% {opacity:0;}");
ToStyle("}");
ToStyle(".effect_button {");
ToStyle("-webkit-animation:effect_button .5s ease-out both;");
ToStyle("animation:effect_button .5s ease-out both;");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_button {");
ToStyle("from { -webkit-transform:scale(.6); }");
ToStyle("}");
ToStyle("@keyframes effect_button {");
ToStyle("from { transform:scale(.6); }");
ToStyle("}");
ToStyle(".effect_avatar {");
ToStyle("-webkit-animation:effect_avatar 700ms ease;");
ToStyle("animation:effect_avatar 700ms ease;");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_avatar {");
ToStyle("from {-webkit-transform:scale(.3);}");
ToStyle("to {-webkit-transform:scale(1);}");
ToStyle("}");
ToStyle("@keyframes effect_avatar {");
ToStyle("from {transform:scale(.3);}");
ToStyle("to {transform:scale(1);}");
ToStyle("}");
ToStyle(".effect_sprite_hide {");
ToStyle("-webkit-animation-name:effect_sprite_hide;");
ToStyle("animation-name:effect_sprite_hide;");
ToStyle("-webkit-animation-fill-mode:both;");
ToStyle("animation-fill-mode:both;");
ToStyle("}");
ToStyle("@-webkit-keyframes effect_sprite_hide {");
ToStyle("100% {opacity:0;}");
ToStyle("}");
ToStyle("@keyframes effect_sprite_hide {");
ToStyle("100% {opacity:0;}");
ToStyle("}");
return StyleText;
}
var style_badImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAhUlEQVQ4y7VUQQrAIAzzOf57H/Af+gt/UPC+FXoQVxe3RSEopSQprQ1hxymlxJzzcd1VYe/4Od8CrYfGZoQw35TaABmVO2fi5FdEeFP2nLmEIFHdJIOsCKNSEGTaROAUO3sYB/nlzCFOC4TpzaBzCOkl05pCH5sdg839evTlsGN9cRcs85zfmkXOXkhCxwAAAABJRU5ErkJggg==";
function asm_macros(TestMode,only$) {
if (only$) {
ToTheme("function $(s,elem) {");
ToTheme("	if (!s) {return;}");
ToTheme("	if (!elem) {");
ToTheme("		elem = document;");
ToTheme("	}");
ToTheme("	s = s.replace(/^\s*?#/,'').trim();");
ToTheme("	if (/^\\./.test(s)) {"); // класс
ToTheme("		s = s.replace(/^\\./,'');");
ToTheme("		return elem.getElementsByClassName(s);");
ToTheme("	} else if (/^<.+?>$/.test(s)) {"); // тег
ToTheme("		s = s.replace(/^<(.+?)>$/,'$1');");
ToTheme("		return elem.getElementsByTagName(s);");
ToTheme("	} else if (/^\\{.+?\\}$/.test(s)) {"); // css
ToTheme("		s = s.replace(/^\\{(.+?)\\}$/,'$1');");
ToTheme("		return elem.querySelectorAll(s);");
ToTheme("	} else {"); // id
ToTheme("		s = s.replace(/^#/,'');");
ToTheme("		return document.getElementById(s);");
ToTheme("	}");
ToTheme("}");
return;
}
ToHTML("window.print = function(s,p,fromstart,div) {");
ToHTML("if (arguments.length>0) {");
ToHTML("if (p) {");
ToHTML("s = '"+Newline+"'+s+'"+Newline+"';");
ToHTML("}");
ToHTML("asmGlobal_ToText(s,fromstart,div);");
ToHTML("}");
ToHTML("return asmGlobal.printDiv.innerHTML+asmGlobal.Output.string;");
ToHTML("};");
ToHTML("window.log = function(s,show) {");
if (TestMode) {
ToHTML("if (arguments.length==0) {");
ToHTML("asmGlobal.console = '';");
ToHTML("} else {");
ToHTML("asmGlobal.console += s+'\\n';");
ToHTML("}");
ToHTML("if (show) {");
ToHTML("asmGlobal.consoleShow = false;");
ToHTML("asmGlobal_showConsole();");
ToHTML("}");
ToHTML("return asmGlobal.console;");
}
ToHTML("};");
ToHTML("window.link = function(title,passage,type,code) {");
ToHTML("return asmGlobal_linkGenerate(title,passage,type,code,false);");
ToHTML("};");
ToHTML("window.button = function(title,passage,type,code) {");
ToHTML("return asmGlobal_linkGenerate(title,passage,type,code,true);");
ToHTML("};");
ToHTML("window.back = function(title,button) {");
ToHTML("var myclass = 'plink';");
ToHTML("if (button) {");
ToHTML("myclass = 'button';");
ToHTML("}");
ToHTML("if (!title) {");
ToHTML("title = '"+Lang.Back+"';");
ToHTML("}");
ToHTML("return \"<span class='\"+myclass+\"' onclick='asmGlobal_Back();event.stopPropagation();'>\"+title+\"</span>\";");
ToHTML("};");
ToHTML("window.restart = function(title,button) {");
ToHTML("var myclass = 'plink';");
ToHTML("if (button) {");
ToHTML("myclass = 'button';");
ToHTML("}");
ToHTML("if (!title) {");
ToHTML("title = '"+Lang.HTMLRestart+"';");
ToHTML("}");
ToHTML("return \"<span class='\"+myclass+\"' onclick='asmGlobal_NewGame();event.stopPropagation();'>\"+title+\"</span>\";");
ToHTML("};");
ToHTML("window.clear = function() {");
ToHTML("asmGlobal_ToText('',true);");
ToHTML("};");
ToHTML("window.display = function(passage) {");
ToHTML("asmGlobal_DisplayLocation(passage);");
ToHTML("};");
ToHTML("window.random = function(n1,n2) {");
ToHTML("if (arguments.length==1) {");
ToHTML("return Math.floor(Math.random()*(parseInt(n1)+1));");
ToHTML("} else {");
ToHTML("return Math.floor(Math.random()*(n2-n1+1))+n1;");
ToHTML("}");
ToHTML("};");
ToHTML("window.title = function(s) {");
ToHTML("asmGlobal_ToText(s,true,asmGlobal.printTitle,true);");
ToHTML("};");
ToHTML("window.flip = function(n) {");
ToHTML("if (n<0) { n = 0; };");
ToHTML("if (n>1000) { n = 1000; };");
ToHTML("asmGlobal.TimeToFade = n;");
ToHTML("};");
ToHTML("window.menu = function(s) {");
ToHTML("if (arguments.length>0) {");
ToHTML("asmGlobal_ToText(s,true,asmGlobal.menuDiv,true);");
ToHTML("asmGlobal_ImagesOnError(asmGlobal.menuDiv);");
ToHTML("}");
ToHTML("return asmGlobal.menuDiv.innerHTML;");
ToHTML("};");
ToHTML("window.goto = function(passage) {");
ToHTML("asmGlobal_PrintLocation(passage);");
ToHTML("asmGlobal_fade(asmGlobal.printDiv);");
ToHTML("throw new Error('goto exception');");
ToHTML("};");
ToHTML("window.sound = function(sound) {");
ToHTML("if (asmGlobal.audio_enable) {");
ToHTML("var sound = asmGlobal_GetFileData(sound);");
ToHTML("if (sound) {");
ToHTML("sound.play();");
ToHTML("}");
ToHTML("}");
ToHTML("};");
ToHTML("window.picture = function(path) {");
ToHTML("asmGlobal.printImage.src = '';");
ToHTML("asmGlobal.printImage.src = asmGlobal.pictureDefault;");
ToHTML("asmGlobal.printImage.onload = function() {");
ToHTML("if (path) {");
ToHTML("asmGlobal.printImage.src = asmGlobal_GetMediaPath(path);");
ToHTML("}");
ToHTML("asmGlobal_showImageForce(true);");
ToHTML("this.onload = null;");
ToHTML("}");
ToHTML("};");
ToHTML("window.image = function(sprite) {");
ToHTML("var prt = function() {");
ToHTML("asmGlobal_ToText(\"<img class='file' border='0' onload='asmGlobal_goodImageShow(this)' src=\"+asmGlobal_GetFileData(sprite).src+\">\");");
ToHTML("};");
if (style_view=='vis' || style_view=='bt') {
ToHTML("if (asmGlobal.printDiv.id=='print') {");
ToHTML("asmGlobal_SetAvatar(sprite)");
ToHTML("} else {");
ToHTML("prt();");
ToHTML("};");
} else {
ToHTML("prt();");
}
ToHTML("};");
ToHTML("window.update = function() {");
ToHTML("asmGlobal.Output.print();");
ToHTML("};");
ToHTML("window.music = function(path,loop) {");
ToHTML("if (path) {");
ToHTML("asmGlobal_setAudioPath(path,loop);");
ToHTML("asmGlobal_playMusic();");
ToHTML("} else {");
ToHTML("asmGlobal_setAudioPath();");
ToHTML("asmGlobal_stopMusic();");
ToHTML("}");
ToHTML("};");
ToHTML("window.texteffect = function(effect) {");
ToHTML("asmGlobal_setEffect(effect,true);");
ToHTML("};");
ToHTML("window.effect = function(effect) {");
ToHTML("asmGlobal_setEffect(effect);");
ToHTML("};");
ToHTML("window.tab = function(n) {");
ToHTML("var s = '';");
ToHTML("for (var i=1;i<=n;i++) {");
ToHTML("s = s + '&nbsp;';");
ToHTML("}");
ToHTML("return s;");
ToHTML("};");
ToHTML("window.filter = function(s) {");
ToHTML("if (!s) {");
ToHTML("s = 'none';");
ToHTML("}");
ToHTML("asmGlobal.printImage.style.WebkitFilter = s;");
ToHTML("asmGlobal.printImage.style.filter = s;");
ToHTML("var backVideo = $('backVideo');");
ToHTML("if (backVideo) {");
ToHTML("backVideo.style.WebkitFilter = s;");
ToHTML("backVideo.style.filter = s;");
ToHTML("}");
ToHTML("};");
ToHTML("window.repeat = function(passage,sec) {");
ToHTML("if (!sec) {");
ToHTML("sec = 1;");
ToHTML("}");
ToHTML("if (parseFloat(sec)<0.1) {");
ToHTML("sec = 0.1;");
ToHTML("}");
ToHTML("asmGlobal_startEvent(passage,sec);");
ToHTML("};");
ToHTML("window.stop = function(passage) {");
ToHTML("asmGlobal_stopEvent(passage);");
ToHTML("};");
ToHTML("window.choice = function() {");
ToHTML("$$choice = 0;");
ToHTML("arguments = [].slice.call(arguments);");
ToHTML("var func = null;");
ToHTML("var multi = false;");
ToHTML("if (arguments[0]===true) {");
ToHTML("multi = true;");
ToHTML("$$choice = [];");
ToHTML("arguments.splice(0,1);");
ToHTML("} else if (arguments[0]===false) {");
ToHTML("arguments.splice(0,1);");
ToHTML("}");
ToHTML("var n = arguments.length;");
ToHTML("if (asmGlobal_isFunction(arguments[n-1])) {");
ToHTML("func = arguments[n-1];");
ToHTML("arguments.length--; n--;");
ToHTML("}");
ToHTML("if (n>0) {");
ToHTML("var s = \"<div class='choice'>\";");
ToHTML("var nn = 1;");
ToHTML("for (var i=0; i<n; i++) {");
ToHTML("var print = function(arg) {");
ToHTML("s += \"<div class='plink' onclick='asmGlobal_choice(\"+multi+\",this,\"+nn+\",\"+func+\");event.stopPropagation();'>\"+arg+\"</div>\";");
ToHTML("nn++;");
ToHTML("};");
ToHTML("var arg = arguments[i];");
ToHTML("if (asmGlobal_isArray(arg)) {");
ToHTML("for (var j in arg) {");
ToHTML("print(arg[j]);");
ToHTML("}");
ToHTML("} else {");
ToHTML("print(arg);");
ToHTML("}");
ToHTML("}");
ToHTML("s += '</div>';");
ToHTML("asmGlobal_ToText(s);");
ToHTML("}");
ToHTML("};");
ToHTML("window.select = function() {");
ToHTML("$$select = 0;");
ToHTML("arguments = [].slice.call(arguments);");
ToHTML("var selected = false;");
ToHTML("var func = null;");
ToHTML("if (asmGlobal_isNumber(arguments[0]) && arguments[0]>0) {");
ToHTML("selected = arguments[0];");
ToHTML("$$select = selected;");
ToHTML("arguments.splice(0,1);");
ToHTML("} else if (!arguments[0]) {");
ToHTML("arguments.splice(0,1);");
ToHTML("}");
ToHTML("var n = arguments.length;");
ToHTML("if (asmGlobal_isFunction(arguments[n-1])) {");
ToHTML("func = arguments[n-1];");
ToHTML("arguments.length--; n--;");
ToHTML("}");
ToHTML("if (n>0) {");
ToHTML("var s = \"<select onchange='asmGlobal_select(this.value,this.options[this.selectedIndex].text,\"+func+\");'><option value='0' disabled selected>→</option>\";");
ToHTML("var nn = 1;");
ToHTML("for (var i=0; i<n; i++) {");
ToHTML("var print = function(arg) {");
ToHTML("var sel = '';");
ToHTML("if (selected==nn) {");
ToHTML("sel = ' selected';");
ToHTML("}");
ToHTML("s += \"<option\"+sel+\" value='\"+nn+\"'>\"+arg+\"</option>\";");
ToHTML("nn++;");
ToHTML("};");
ToHTML("var arg = arguments[i];");
ToHTML("if (asmGlobal_isArray(arg)) {");
ToHTML("for (var j in arg) {");
ToHTML("print(arg[j]);");
ToHTML("}");
ToHTML("} else {");
ToHTML("print(arg);");
ToHTML("}");
ToHTML("}");
ToHTML("s += '</select>';");
ToHTML("asmGlobal_ToText(s);");
ToHTML("}");
ToHTML("};");
ToHTML("window.script = function(path,func) {");
ToHTML("if (path) {");
ToHTML("var myscript = document.createElement('script');");
ToHTML("if (func && asmGlobal_isFunction(func)) {");
ToHTML("myscript.onload = func();");
ToHTML("}");
ToHTML("myscript.type = 'text/javascript';");
ToHTML("myscript.src = asmGlobal_GetMediaPath(path);");
ToHTML("document.getElementsByTagName('head')[0].appendChild(myscript);");
ToHTML("}");
ToHTML("};");
ToHTML("window.style = function(path,media) {");
ToHTML("if (path) {");
ToHTML("if (!media) {"); // тип медиа
ToHTML("media = 'all';");
ToHTML("}");
ToHTML("if (/(?=.*{)(?=.*})(?=.*:)/.test(path)) {"); // внутренние стили
ToHTML("var head = document.head || document.getElementsByTagName('head')[0];");
ToHTML("var style = document.createElement('style');");
ToHTML("style.type = 'text/css';");
ToHTML("style.media = media;");
ToHTML("style.appendChild(document.createTextNode(path));");
ToHTML("head.appendChild(style);");
ToHTML("} else {"); // внешняя таблица стилей
ToHTML("var head  = document.getElementsByTagName('head')[0];");
ToHTML("var link  = document.createElement('link');");
ToHTML("link.rel  = 'stylesheet';");
ToHTML("link.type = 'text/css';");
ToHTML("link.href = asmGlobal_GetMediaPath(path);");
ToHTML("link.media = media;");
ToHTML("head.appendChild(link);");
ToHTML("}");
ToHTML("}");
ToHTML("};");
ToHTML("window.message = function(s) {");
ToHTML("asmGlobal_AlertMessage(s);");
ToHTML("};");
ToHTML("window.video = function(path,onEnd) {");
ToHTML("if (path) {");
ToHTML("var backVideo = $('backVideo');");
ToHTML("if (!backVideo) {");
ToHTML("backVideo = document.createElement('video');");
ToHTML("backVideo.id = 'backVideo';");
ToHTML("backVideo.setAttribute('autoplay','');");
ToHTML("backVideo.setAttribute('playsinline','');");
ToHTML("backVideo.setAttribute('muted','');");
ToHTML("backVideo.type = 'video/mp4';");
ToHTML("asmGlobal.videoDiv.appendChild(backVideo);");
ToHTML("}");
ToHTML("if (onEnd) {");
ToHTML("backVideo.onended = function() {");
ToHTML("asmGlobal.videoDiv.innerHTML = '';");
ToHTML("asmGlobal_PrintLocation(onEnd);");
ToHTML("};");
ToHTML("var backVideoSkip = $('backVideoSkip');");
ToHTML("if (!backVideoSkip) {");
ToHTML("backVideoSkip = document.createElement('div');");
ToHTML("backVideoSkip.id = 'backVideoSkip';");
ToHTML("backVideoSkip.innerHTML = '⇥';");
ToHTML("backVideoSkip.onclick = function(event) {");
ToHTML("event.stopPropagation();");
ToHTML("asmGlobal.videoDiv.innerHTML = '';");
ToHTML("asmGlobal_PrintLocation(onEnd);");
ToHTML("};");
ToHTML("asmGlobal.videoDiv.appendChild(backVideoSkip);");
ToHTML("}");
ToHTML("asmGlobal_Animate(backVideoSkip,'effect_scale');");
ToHTML("} else {");
ToHTML("backVideo.setAttribute('loop','');");
ToHTML("}");
ToHTML("backVideo.src = asmGlobal_GetMediaPath(path);");
ToHTML("backVideo.onerror = function() {");
ToHTML("asmGlobal_AlertMessage('"+Lang.ErrorLoadFile+"<br>'+this.src);");
ToHTML("};");
ToHTML("} else {");
ToHTML("asmGlobal.videoDiv.innerHTML = '';"); // удаляем видео
ToHTML("}");
ToHTML("};");
ToHTML("window.input = function(passage) {");
ToHTML("if (passage) {");
ToHTML("var value = $$input;");
ToHTML("if (!value) {");
ToHTML("value = '';");
ToHTML("} else {");
ToHTML("value = value.toString();");
ToHTML("}");
ToHTML("var focus = '';");
ToHTML("if (!asmGlobal.isTouchDevice) {");
ToHTML("focus = 'autofocus';");
ToHTML("}");
ToHTML("if (asmGlobal_isFunction(passage)) {");
ToHTML("var code = \"eval(\"+passage+\"($$input));\";");
ToHTML("} else {");
ToHTML("var code = \"asmGlobal_PrintLocation(&quot;\"+passage+\"&quot;);\";");
ToHTML("}");
ToHTML("asmGlobal_ToText(\"\
<div class='myinput'><form action='' onsubmit='\
if (this.childNodes[0].value.trim()!=&quot;&quot;) {\
$$input = this.childNodes[0].value.trim();\
if (!isNaN($$input)) {\
$$input = parseFloat($$input);\
}\
\"+code+\"\
}\
this.childNodes[0].select();\
return false;\
'><input class='input_text' type='text' onclick='event.stopPropagation();' autocapitalize='off' size='10' value='\"+value+\"'\"+focus+\"><input class='input_butt' type='submit' onclick='event.stopPropagation();' value='✓'></form></div>\
\");");
ToHTML("}");
ToHTML("};");
ToHTML("window.popup = function(passage) {");
ToHTML("if (passage) {");
ToHTML("asmGlobal_PopupLocation(passage);");
ToHTML("}");
ToHTML("return asmGlobal.popupPassage;"); // имя параграфа в окне или false
ToHTML("};");
ToHTML("window.sprite = function(path) {");
ToHTML("var img = document.createElement('img');");
ToHTML("img.className = 'sprite';");
ToHTML("var setCoord = function(n,prop) {"); // функция установки координат в %%
ToHTML("if (n!==undefined && n!==null) {");
ToHTML("if (n===true) {");
ToHTML("img.style[prop] = 'auto';");
ToHTML("} else {");
ToHTML("n = Number(n);");
ToHTML("if (isNaN(n)) {n = 0;}");
ToHTML("img.style[prop] = n+'%';");
ToHTML("}");
ToHTML("}");
ToHTML("var ret = img.style[prop];");
ToHTML("if (ret=='auto') {");
ToHTML("ret = true;");
ToHTML("} else {");
ToHTML("ret = Number(ret.replace('%',''));");
ToHTML("}");
ToHTML("return ret;");
ToHTML("};");
ToHTML("var checkTime = function(time) {"); // функция проверки времени
ToHTML("if (isNaN(time) || time<0) {time = 0;}");
ToHTML("else if (time>10000) {time = 10000;}");
ToHTML("return time;");
ToHTML("};");
ToHTML("img.copy = function(path) {"); // копирование спрайта
ToHTML("return copy(this,path);");
ToHTML("};");
ToHTML("img.mypath = undefined;");
ToHTML("Object.defineProperty(img,'path',{"); // путь к спрайту
ToHTML("set: function(path) {");
ToHTML("if (path!==undefined && path!==null) {");
ToHTML("path = path.toString();");
ToHTML("this.mypath = path;");
ToHTML("var src;");
ToHTML("var dataURL = asmGlobal_GetFileData(path).src;");
ToHTML("if (dataURL) {"); // dataURL из StoryData
ToHTML("src = dataURL;");
ToHTML("} else if (/https?:\\/\\//i.test(path)) {"); // url
ToHTML("src = path;");
ToHTML("} else if (path) {"); // относительный путь к файлу
ToHTML("src = asmGlobal_GetMediaPath(path);");
ToHTML("}");
ToHTML("this.src = src;");
ToHTML("}");
ToHTML("},");
ToHTML("get: function() {");
ToHTML("return this.mypath;");
ToHTML("}");
ToHTML("});");
ToHTML("if (path!==undefined && path!==null && path!='') {");
ToHTML("img.path = path;");
ToHTML("}");
ToHTML("Object.defineProperty(img,'right',{"); // right в %%
ToHTML("set: function(n) {");
ToHTML("return setCoord(n,'right');");
ToHTML("},");
ToHTML("get: function() {");
ToHTML("return setCoord(undefined,'right');");
ToHTML("}");
ToHTML("});");
ToHTML("img.right = 0;");
ToHTML("Object.defineProperty(img,'left',{"); // left в %%
ToHTML("set: function(n) {");
ToHTML("return setCoord(n,'left');");
ToHTML("},");
ToHTML("get: function() {");
ToHTML("return setCoord(undefined,'left');");
ToHTML("}");
ToHTML("});");
ToHTML("img.left = 0;");
ToHTML("Object.defineProperty(img,'bottom',{"); // bottom в %%
ToHTML("set: function(n) {");
ToHTML("return setCoord(n,'bottom');");
ToHTML("},");
ToHTML("get: function() {");
ToHTML("return setCoord(undefined,'bottom');");
ToHTML("}");
ToHTML("});");
ToHTML("img.bottom = 0;");
ToHTML("Object.defineProperty(img,'top',{"); // top в %%
ToHTML("set: function(n) {");
ToHTML("return setCoord(n,'top');");
ToHTML("},");
ToHTML("get: function() {");
ToHTML("return setCoord(undefined,'top');");
ToHTML("}");
ToHTML("});");
ToHTML("img.top = 0;");
ToHTML("Object.defineProperty(img,'width',{"); // ширина в %% от окна
ToHTML("set: function(n) {");
ToHTML("setCoord(n,'width');");
ToHTML("},");
ToHTML("get: function() {");
ToHTML("return setCoord(undefined,'width');");
ToHTML("}");
ToHTML("});");
ToHTML("img.width = 30;");
ToHTML("Object.defineProperty(img,'height',{"); // высота в %% от окна
ToHTML("set: function(n) {");
ToHTML("setCoord(n,'height');");
ToHTML("},");
ToHTML("get: function() {");
ToHTML("return setCoord(undefined,'height');");
ToHTML("}");
ToHTML("});");
ToHTML("img.height = true;");
ToHTML("Object.defineProperty(img,'opacity',{"); // прозрачность спрайта 0-100
ToHTML("set: function(n) {");
ToHTML("if (n!==undefined) {");
ToHTML("n = Number(n);");
ToHTML("if (isNaN(n) || n<0) {n = 0;}");
ToHTML("else if (n>100) {n = 100;}");
ToHTML("this.style.opacity = n/100;");
ToHTML("}");
ToHTML("},");
ToHTML("get: function() {");
ToHTML("var ret = Number(img.style.opacity);");
ToHTML("return ret*100;");
ToHTML("}");
ToHTML("});");
ToHTML("img.opacity = 100;");
ToHTML("img.myaction = undefined;");
ToHTML("Object.defineProperty(img,'action',{"); // нажатие на спрайт
ToHTML("set: function(act) {");
ToHTML("this.drag = undefined;"); // блокируем перетаскивание
ToHTML("if (asmGlobal_isFunction(act)) {");
ToHTML("this.setAttribute('active','');"); // функция
ToHTML("this.onclick = function(e) {");
ToHTML("e.stopPropagation();");
ToHTML("if (img.order) {");
ToHTML("img.parentNode.appendChild(img);");
ToHTML("}");
ToHTML("var x = Math.round((e.clientX-img.offsetLeft)/img.offsetWidth*100);");
ToHTML("var y = Math.round((e.clientY-img.offsetTop)/img.offsetHeight*100);");
ToHTML("var coords = {x:x, y:y};");
ToHTML("act(img,coords);");
ToHTML("};");
ToHTML("} else if (act) {");
ToHTML("this.setAttribute('active','');");
ToHTML("this.onclick = function(e) {");
ToHTML("e.stopPropagation();");
ToHTML("if (act.search(/:\\/\\//)!=-1) {");
ToHTML("window.open(act);"); // внешняя ссылка
ToHTML("} else {");
ToHTML("asmGlobal_PopupLocation(act);"); // параграф в окне
ToHTML("}");
ToHTML("};");
ToHTML("} else {");
ToHTML("this.removeAttribute('active');"); // удаляем
ToHTML("this.onclick = null;");
ToHTML("}");
ToHTML("this.myaction = act;");
ToHTML("},");
ToHTML("get: function() {");
ToHTML("return this.myaction;");
ToHTML("}");
ToHTML("});");
ToHTML("img.mydrag = undefined;"); // перетаскивание спрайта
ToHTML("Object.defineProperty(img,'drag',{");
ToHTML("set: function(drg) {");
ToHTML("if (asmGlobal_isFunction(drg)) {");
ToHTML("this.action = undefined;"); // блокируем нажатие
ToHTML("this.setAttribute('drag','');");
ToHTML("this.dragState = {};");
ToHTML("var block = asmGlobal.spritesDiv;");
ToHTML("var setOffset = function(x,y) {");
ToHTML("if (img.order) {");
ToHTML("img.parentNode.appendChild(img);");
ToHTML("}");
ToHTML("img.dragState.offsetX = Math.round((x-img.offsetLeft)/block.offsetWidth*100);");
ToHTML("img.dragState.offsetY = Math.round((y-img.offsetTop)/block.offsetHeight*100);");
ToHTML("};");
ToHTML("var setPos = function(x,y) {");
ToHTML("x = Math.round(x/block.offsetWidth*100);");
ToHTML("y = Math.round(y/block.offsetHeight*100);");
ToHTML("img.left = x - img.dragState.offsetX;");
ToHTML("img.top  = y - img.dragState.offsetY;");
ToHTML("img.style.right  = 'auto';");
ToHTML("img.style.bottom = 'auto';");
ToHTML("drg(img);");
ToHTML("};");
ToHTML("this.onmousedown = function(e) {");
ToHTML("setOffset(e.clientX,e.clientY);");
ToHTML("};");
ToHTML("this.ontouchstart = function(e) {");
ToHTML("var touch = e.targetTouches[0];");
ToHTML("setOffset(touch.pageX,touch.pageY);");
ToHTML("};");
ToHTML("this.onmousemove = function(e) {");
ToHTML("if (asmGlobal.mouseDown) {");
ToHTML("setPos(e.clientX,e.clientY);");
ToHTML("}");
ToHTML("};");
ToHTML("this.ontouchmove = function(e) {");
ToHTML("if (asmGlobal.mouseDown && e.targetTouches.length==1) {");
ToHTML("var touch = e.targetTouches[0];");
ToHTML("setPos(touch.pageX,touch.pageY);");
ToHTML("}");
ToHTML("};");
ToHTML("} else {");
ToHTML("this.removeAttribute('drag');"); // удаляем перетаскивание
ToHTML("this.dragState = undefined;");
ToHTML("this.onmousedown = null;");
ToHTML("this.onmouseup = null;");
ToHTML("this.onmousemove = null;");
ToHTML("this.ontouchstart = null;");
ToHTML("this.ontouchend = null;");
ToHTML("this.ontouchmove = null;");
ToHTML("}");
ToHTML("this.mydrag = drg;");
ToHTML("},");
ToHTML("get: function() {");
ToHTML("return this.mydrag;");
ToHTML("}");
ToHTML("});");
ToHTML("img.myfilter = undefined;");
ToHTML("Object.defineProperty(img,'filter',{"); // установка CSS3 фильтров
ToHTML("set: function(s) {");
ToHTML("if (!s) {");
ToHTML("s = 'none';");
ToHTML("}");
ToHTML("this.style.WebkitFilter = s;");
ToHTML("this.style.filter = s;");
ToHTML("this.myfilter = s;");
ToHTML("},");
ToHTML("get: function() {");
ToHTML("return this.myfilter;");
ToHTML("}");
ToHTML("});");
ToHTML("img.myFlipX = false;");
ToHTML("Object.defineProperty(img,'flipX',{"); // отражение по горизонтали
ToHTML("set: function(n) {");
ToHTML("if (n) {");
ToHTML("var s = 'scaleX(-1)';");
ToHTML("if (img.myFlipY===true) {");
ToHTML("s += ' scaleY(-1)';");
ToHTML("}");
ToHTML("if (img.myRotate!==0) {");
ToHTML("s += ' rotate('+img.myRotate+'deg)';");
ToHTML("}");
ToHTML("img.style.WebkitTransform = s;");
ToHTML("img.style.transform = s;");
ToHTML("img.myFlipX = true;");
ToHTML("} else {");
ToHTML("var s = 'scaleX(1)';");
ToHTML("img.style.WebkitTransform = s;");
ToHTML("img.style.transform = s;");
ToHTML("img.myFlipX = false;");
ToHTML("}");
ToHTML("},");
ToHTML("get: function() {");
ToHTML("return img.myFlipX;");
ToHTML("}");
ToHTML("});");
ToHTML("img.myFlipY = false;");
ToHTML("Object.defineProperty(img,'flipY',{"); // отражение по вертикали
ToHTML("set: function(n) {");
ToHTML("if (n) {");
ToHTML("var s = 'scaleY(-1)';");
ToHTML("if (img.myFlipX===true) {");
ToHTML("s += ' scaleX(-1)';");
ToHTML("}");
ToHTML("if (img.myRotate!==0) {");
ToHTML("s += ' rotate('+img.myRotate+'deg)';");
ToHTML("}");
ToHTML("img.style.WebkitTransform = s;");
ToHTML("img.style.transform = s;");
ToHTML("img.myFlipY = true;");
ToHTML("} else {");
ToHTML("var s = 'scaleY(1)';");
ToHTML("img.style.WebkitTransform = s;");
ToHTML("img.style.transform = s;");
ToHTML("img.myFlipY = false;");
ToHTML("}");
ToHTML("},");
ToHTML("get: function() {");
ToHTML("return img.myFlipY;");
ToHTML("}");
ToHTML("});");
ToHTML("img.myRotate = 0;");
ToHTML("Object.defineProperty(img,'rotate',{"); // вращение спрайта
ToHTML("set: function(n) {");
ToHTML("var s = 'rotate('+n+'deg)';");
ToHTML("if (img.myFlipX===true) {");
ToHTML("s += ' scaleX(-1)';");
ToHTML("}");
ToHTML("if (img.myFlipY===true) {");
ToHTML("s += ' scaleY(-1)';");
ToHTML("}");
ToHTML("img.style.WebkitTransform = s;");
ToHTML("img.style.transform = s;");
ToHTML("img.myRotate = n;");
ToHTML("},");
ToHTML("get: function() {");
ToHTML("return img.myRotate;");
ToHTML("}");
ToHTML("});");
ToHTML("img.show = function(time,callback) {"); // показать спрайт
ToHTML("time = checkTime(time);");
ToHTML("this.style.display = 'none';");
ToHTML("this.style.WebkitAnimationDuration = time+'ms';");
ToHTML("this.style.animationDuration = time+'ms';");
ToHTML("this.style.opacity = this.opacity+'%';");
ToHTML("asmGlobal.spritesDiv.appendChild(this);");
ToHTML("var show = function() {");
ToHTML("img.style.display = 'block';");
ToHTML("if (asmGlobal.isAnimation && asmGlobal.animation_enable) {");
ToHTML("asmGlobal_Animate(img,asmGlobal_getEffectName(asmGlobal.SpriteEffect));");
ToHTML("}");
ToHTML("asmGlobal_showImageForce(false);");
ToHTML("};");
ToHTML("if (this.naturalWidth===0) {");
ToHTML("this.onload = function() {");
ToHTML("show();");
ToHTML("if (callback && asmGlobal_isFunction(callback)) {");
ToHTML("callback();");
ToHTML("}");
ToHTML("};");
ToHTML("} else {");
ToHTML("show();");
ToHTML("if (callback && asmGlobal_isFunction(callback)) {");
ToHTML("callback();");
ToHTML("}");
ToHTML("}");
ToHTML("};");
ToHTML("img.hide = function(time) {"); // скрыть спрайт
ToHTML("var remove = function() {");
ToHTML("if (img) {");
ToHTML("img.parentNode.removeChild(img);");
ToHTML("}");
ToHTML("};");
ToHTML("if (!time || !asmGlobal.isAnimation || !asmGlobal.animation_enable) {");
ToHTML("remove();");
ToHTML("} else {");
ToHTML("time = checkTime(time);");
ToHTML("this.style['-webkit-animation-duration'] = time+'ms';");
ToHTML("this.style['animation-duration'] = time+'ms';");
ToHTML("asmGlobal_Animate(this,'effect_sprite_hide',function(){remove();});"); // с эффектом
ToHTML("}");
ToHTML("};");
ToHTML("Object.defineProperty(img,'visible',{"); // показан ли спрайт
ToHTML("set: function(show) {");
ToHTML("if (show===true) {");
ToHTML("this.show();");
ToHTML("} else if (show===false) {");
ToHTML("this.hide()");
ToHTML("}");
ToHTML("},");
ToHTML("get: function() {");
ToHTML("if (this.parentNode && this.parentNode==asmGlobal.spritesDiv) {");
ToHTML("return true;");
ToHTML("} else {");
ToHTML("return false;");
ToHTML("}");
ToHTML("}");
ToHTML("});");
ToHTML("img.onerror = function() {"); // ошибка загрузки спрайта
ToHTML("asmGlobal_badImageShow(this);");
ToHTML("};");
ToHTML("return img;");
ToHTML("};");
ToHTML("window.copy = function(value,path) {");
ToHTML("if (value instanceof Array) {"); // массив
ToHTML("return asmGlobal_CloneArray(value);");
ToHTML("} else if (value && typeof value==='object' && value.constructor===Object) {"); // объект
ToHTML("return asmGlobal_CloneObject(value);");
ToHTML("} else if (value instanceof HTMLImageElement && value.className=='sprite') {"); // спрайт
ToHTML("if (path!==undefined && path!==null) {");
ToHTML("path = path.toString();");
ToHTML("var clone = sprite(path);");
ToHTML("} else {");
ToHTML("var clone = sprite(value.path);");
ToHTML("}");
ToHTML("clone.width = value.width;");
ToHTML("clone.height = value.height;");
ToHTML("clone.top = value.top;");
ToHTML("clone.bottom = value.bottom;");
ToHTML("clone.left = value.left;");
ToHTML("clone.right = value.right;");
ToHTML("clone.opacity = value.opacity;");
ToHTML("clone.filter = value.filter;");
ToHTML("clone.action = value.action;");
ToHTML("clone.drag = value.drag;");
ToHTML("for (var i=0; i<value.attributes.length; i++) {");
ToHTML("var attrName  = value.attributes[i].nodeName;");
ToHTML("var attrValue = value.attributes[i].nodeValue;");
ToHTML("clone.setAttribute(attrName,attrValue);");
ToHTML("}");
ToHTML("clone.style.transition = value.style.transition;");
ToHTML("clone.style.WebkitTransition = value.style.WebkitTransition;");
ToHTML("return clone;");
ToHTML("} else {"); // другой тип
ToHTML("return value;");
ToHTML("}");
ToHTML("};");
ToHTML("window.sprites = function(deleteAll) {");
ToHTML("var list = asmGlobal.spritesDiv.querySelectorAll('.sprite');");
ToHTML("if (deleteAll) {");
ToHTML("asmGlobal.spritesDiv.innerHTML = '';");
ToHTML("}");
ToHTML("return list;");
ToHTML("};");
ToHTML("window.visited = function() {");
ToHTML("var indexes = [];");
ToHTML("if (arguments.length<1) {");
ToHTML("indexes.push(asmGlobal_GetIndexLocation($$title));");
ToHTML("} else {");
ToHTML("for (var i in arguments) {");
ToHTML("indexes.push(asmGlobal_GetIndexLocation(arguments[i]));");
ToHTML("}");
ToHTML("}");
ToHTML("var result = [];");
ToHTML("for (var i in indexes) {");
ToHTML("var index = indexes[i];");
ToHTML("result.push([index,0]);");
ToHTML("for (var j in asmGlobal.visitedList) {");
ToHTML("var item = asmGlobal.visitedList[j];");
ToHTML("if (item[0]==index) {");
ToHTML("result[result.length-1] = item;");
ToHTML("break;");
ToHTML("}");
ToHTML("}");
ToHTML("}");
ToHTML("if (result.length==0) {");
ToHTML("return 0;");
ToHTML("} else {");
ToHTML("var min = result[0];");
ToHTML("for (var i in result) {");
ToHTML("if (result[i][1]<min[1]) {");
ToHTML("min = result[i];");
ToHTML("}");
ToHTML("}");
ToHTML("return min[1];");
ToHTML("}");
ToHTML("};");
ToHTML("window.either = function() {");
ToHTML("var arr = [];");
ToHTML("for (var i in arguments) {");
ToHTML("var arg = arguments[i];");
ToHTML("if (asmGlobal_isArray(arg)) {");
ToHTML("for (var j in arg) {");
ToHTML("arr.push(arg[j]);");
ToHTML("}");
ToHTML("} else {");
ToHTML("arr.push(arg);");
ToHTML("}");
ToHTML("}");
ToHTML("return arr[Math.floor(Math.random()*arr.length)];");
ToHTML("};");
var dop_func = function() {
ToHTML("function asmGlobal_plinks(elem,type,title,passage,code,button) {");
ToHTML("if (title) {");
ToHTML("var linkclass = 'plink';");
ToHTML("if (button) {");
ToHTML("linkclass = 'button';");
ToHTML("}");
ToHTML("if (!passage) {");
ToHTML("passage = title;");
ToHTML("}");
ToHTML("if (code) { code(); };");
ToHTML("passage = passage.trim();");
ToHTML("if (passage.substr(0,2)=='$$') {"); // подстановка системной переменной
ToHTML("passage = eval(passage);");
ToHTML("}");
ToHTML("type = type.trim();");
ToHTML("if (type=='*') {");
ToHTML("asmGlobal_PopupLocation(passage);");
ToHTML("} else if (type=='+') {");
ToHTML("var randID = new Date().getTime()+Math.random().toString();");
ToHTML("asmGlobal_ToText(\"<div id='addBlock_\"+randID+\"'>"+Newline+"\");");
ToHTML("asmGlobal_DisplayLocation(passage,false);");
ToHTML("asmGlobal_ToText('</div>');");
ToHTML("asmGlobal.Output.disabledIDs.push(elem.id);");
ToHTML("asmGlobal.Output.print();");
if (style_view=='vis' || style_view=='bt') {
ToHTML("asmGlobal_moveButtonsPage();");
}
ToHTML("var addBlock = $('addBlock_'+randID);");
ToHTML("asmGlobal_scrollDiv(false,true,true,addBlock);");
ToHTML("asmGlobal_Animate(addBlock,'effect_scale');");
ToHTML("} else {");
ToHTML("asmGlobal_PrintLocation(passage);");
ToHTML("}");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_linkGenerate(title,passage,type,code,button) {");
ToHTML("if (title) {");
ToHTML("var replaceQuotes = function(s) {");
ToHTML("return s.toString().replace(/\"/g,\"'\");");
ToHTML("};");
ToHTML("var myclass = 'plink';");
ToHTML("if (button) {");
ToHTML("myclass = 'button';");
ToHTML("}");
ToHTML("if (asmGlobal_isFunction(passage) && !type && !code) {");
ToHTML("passage = replaceQuotes(passage);");
ToHTML("return \"<span class=\"+myclass+\" onclick=\\[[asmQuot]]eval(\"+passage+\"());event.stopPropagation();\\[[asmQuot]]>\"+title+\"</span>\";"); // кнопка/ссылка с функцией без перехода на параграф
ToHTML("}");
ToHTML("if (!passage) {");
ToHTML("passage = title;");
ToHTML("}");
ToHTML("if (code && asmGlobal_isFunction(code)) {");
ToHTML("code = replaceQuotes(code);");
ToHTML("}");
ToHTML("var id = '';");
ToHTML("if (type=='+') {");
ToHTML("id = new Date().getTime()+Math.random().toString();");
ToHTML("id = \" id='\"+id+\"'\";");
ToHTML("}");
ToHTML("return \"<span\"+id+\" class=\"+myclass+\" onclick=\\[[asmQuot]]asmGlobal_plinks(this,'\"+type+\"','\"+title+\"','\"+passage+\"',\"+code+\",\"+button+\");event.stopPropagation();\\[[asmQuot]]>\"+title+\"</span>\";");
ToHTML("} else {");
ToHTML("return '';");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_choice(multi,elem,n,func) {");
ToHTML("var text = '';");
ToHTML("if (!multi) {");
ToHTML("if (elem.className=='plink selected') {");
ToHTML("elem.className = 'plink';");
ToHTML("$$choice = 0;");
ToHTML("} else {");
ToHTML("var elems = elem.parentNode.getElementsByClassName('plink selected');");
ToHTML("for (var i=0; i<elems.length; i++) {");
ToHTML("elems[i].className ='plink';");
ToHTML("}");
ToHTML("elem.className ='plink selected';");
ToHTML("text = elem.textContent;");
ToHTML("$$choice = n;");
ToHTML("}");
ToHTML("} else {"); // множественный выбор
ToHTML("if (elem.className=='plink selected') {");
ToHTML("var i = $$choice.indexOf(n);");
ToHTML("if (i!=-1) {");
ToHTML("$$choice.splice(i,1);");
ToHTML("}");
ToHTML("elem.className = 'plink';");
ToHTML("} else {");
ToHTML("$$choice.push(n);");
ToHTML("elem.className ='plink selected';");
ToHTML("text = elem.textContent;");
ToHTML("}");
ToHTML("}");
ToHTML("if (func && asmGlobal_isFunction(func)) {");
ToHTML("func($$choice,text);");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_select(n,s,func) {");
ToHTML("$$select = n;");
ToHTML("if (func && asmGlobal_isFunction(func)) {");
ToHTML("func(n,s);");
ToHTML("}");
ToHTML("}");
}
dop_func();
}
var Newline;
var loop_n = 0;
function ToHTMW(str) {
html += str;
}
function ToHTML(str) {
html += str+'\n';
}
function Compile(TestMode,OnlyPassageNum,PublishToInet) {
var isPrint = false;
Newline = '<p></p>';
TargetFormatBak = TargetFormat;
if (TestMode) {
TargetFormat = 'html';
}
ShowWind(false);
if (EditorVisible) {
if (OnlyPassageNum!=-1 && editNewLoc) {
OnlyPassageNum = LocationArr.length;
}
SaveLocation(false);
}
if (LocationArr.length<1 || OnlyPassageNum>LocationArr.length-1) {
Message(Lang.NoPassage);
TargetFormat = TargetFormatBak;
return;
}
var StoryStyleIndex = GetLocIndexByTitle('StoryStyle');
var TimeToFade = 700;
var LocNum = [];
if (OnlyPassageNum==-1) {
for (var i=0; i<LocationArr.length; i++) {
if (!ForbiddenLocation(LocationArr[i].Title)) {
LocNum.push(i);
}
}
} else {
LocNum.push(OnlyPassageNum);
var s = LocationArr[OnlyPassageNum].Text;
var myMatch;
var myRe = new RegExp(DisplayPattern,'g');
var i;
while ((myMatch = myRe.exec(s)) != null) {
var i = GetLocIndexByTitle(myMatch[4]);
if (i>=0) {
LocNum.push(i);
}
}
LocNum.sort();
for (var i=LocNum.length-1; i>=1; i--) {
if (LocNum[i]==LocNum[i-1]) {
LocNum.splice(i,1);
}
}
}
html = '';
ToHTML (ThemeTop(false,TestMode,OnlyPassageNum));
ToHTML("asmGlobal.LangCode = '"+LangCode+"';");
ToHTML("asmGlobal.isWebKit  = 'WebkitAppearance' in document.documentElement.style;");
ToHTML("asmGlobal.isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox')>-1;");
ToHTML("asmGlobal.isAndroid = navigator.userAgent.toLowerCase().indexOf('android')>-1;");
ToHTML("asmGlobal.isOnline  = /^http(s)?:\\/\\/.+?$/.test(document.URL);");
ToHTML("asmGlobal.isAndroidWebview = asmGlobal.isAndroid && asmGlobal.isOnline;");
ToHTML("function asmGlobal_isMobile() {");
ToHTML("var elem = asmGlobal.showImageButton;");
ToHTML("if (!elem || getComputedStyle(elem,null).display=='none') {");
ToHTML("return false;");
ToHTML("}");
ToHTML("return true;");
ToHTML("}");
ToHTML("function asmGlobal_clickEffect(e) {");
ToHTML("var element = e.target;");
ToHTML("var checkParents = function(parents,child) {");
ToHTML("var node = child.parentNode;");
ToHTML("while (node!=null) {");
ToHTML("if (parents.indexOf(node)!=-1) {");
ToHTML("return true;");
ToHTML("}");
ToHTML("node = node.parentNode;");
ToHTML("}");
ToHTML("return false;");
ToHTML("};");
ToHTML("if (e.button!==0 || !(checkParents([asmGlobal.pageDiv,asmGlobal.printAdd,asmGlobal.menuDiv,$('buttonsList')],element))) {");
ToHTML("return;");
ToHTML("}");
ToHTML("var d = document.createElement('div');");
ToHTML("d.className='clickEffect';");
ToHTML("if (element.onclick) {");
ToHTML("d.setAttribute('active','');");
ToHTML("}");
ToHTML("d.style.top  = e.clientY+'px';");
ToHTML("d.style.left = e.clientX+'px';");
ToHTML("document.body.appendChild(d);");
ToHTML("asmGlobal_prefixedEventListener(d,'AnimationEnd',function() {");
ToHTML("d.parentElement.removeChild(d);");
ToHTML("});");
ToHTML("}");
ToHTML("function asmGlobal_setClickEffect() {");
ToHTML("document.removeEventListener('mousedown',asmGlobal_clickEffect);");
ToHTML("if (asm.click) {");
ToHTML("document.addEventListener('mousedown',asmGlobal_clickEffect);");
ToHTML("}");
ToHTML("}");
ToHTML("asmGlobal.stopNames = [];");
ToHTML("for (var name in window) {");
ToHTML("asmGlobal.stopNames.push(name);");
ToHTML("}");
ToHTML("asmGlobal.stopNames = asmGlobal.stopNames.concat(['"+MacrosArrNames.join("','")+"']);");
ToHTML("function asmGlobal_Resize() {");
ToHTML("if (asmGlobal_isMobile()) {");
ToHTML("asmGlobal.printImageBlock.style.display = 'none';");
ToHTML("} else {");
ToHTML("asmGlobal.printImageBlock.style.display = 'block';");
ToHTML("}");
ToHTML("}");
ToHTML("window.addEventListener('resize', asmGlobal_Resize, false);");
ToHTML("window.addEventListener('orientationchange', asmGlobal_Resize, false);");
ToHTML("document.addEventListener('dragstart', function(e){e.preventDefault();});");
ToHTML("window.onkeyup = function(e) {asmGlobal_keysUp(e);};");
ToHTML("window.onkeydown = function(e) {asmGlobal_keysDown(e);};");
ToHTML("asmGlobal.printImage.onerror = function() {asmGlobal_badImageShow(this);};");
ToHTML("if ('ontouchmove' in window) {");
ToHTML("asmGlobal.spritesDiv.addEventListener('touchmove',function(e) {");
ToHTML("e = e || window.event;");
ToHTML("e.returnValue = false;");
ToHTML("e.cancelBubble = true;");
ToHTML("if (e.preventDefault) {");
ToHTML("e.preventDefault();");
ToHTML("e.stopPropagation();");
ToHTML("}");
ToHTML("return false;");
ToHTML("},false);");
ToHTML("}");
ToHTML("if ('onmousemove' in window) {");
ToHTML("asmGlobal.mouseDown = false;");
ToHTML("document.onmousedown = function(e) {");
ToHTML("asmGlobal.mouseDown = true;");
ToHTML("};");
ToHTML("document.onmouseup = function(e) {");
ToHTML("asmGlobal.mouseDown = false;");
ToHTML("};");
ToHTML("}");
ToHTML("if ('ontouchmove' in window) {");
ToHTML("document.ontouchstart = function(e) {");
ToHTML("asmGlobal.mouseDown = true;");
ToHTML("};");
ToHTML("document.ontouchend = function(e) {");
ToHTML("asmGlobal.mouseDown = false;");
ToHTML("};");
ToHTML("}");
ToHTML("function asmGlobal_isFunction(obj) {");
ToHTML("var getType = {};");
ToHTML("return obj && getType.toString.call(obj)==='[object Function]';");
ToHTML("}");
ToHTML("function asmGlobal_isArray(obj) {");
ToHTML("if (typeof Array.isArray==='undefined') {");
ToHTML("Array.isArray = function(obj) {");
ToHTML("return Object.prototype.toString.call(obj)==='[object Array]';");
ToHTML("};");
ToHTML("}");
ToHTML("return Array.isArray(obj);");
ToHTML("}");
ToHTML("function asmGlobal_isObject(obj) {");
ToHTML("if (typeof obj=='object') {");
ToHTML("return true;");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_isNumber(obj) {");
ToHTML("return !isNaN(parseInt(obj,10));");
ToHTML("}");
ToHTML("function asmGlobal_isString(obj) {");
ToHTML("return typeof obj==='string';");
ToHTML("}");
ToHTML("asmGlobal.visitedList = [];");
asm_macros(TestMode,false);
ToHTML("asmGlobal.effectNames = ['effect_fade_sprite','effect_scale','effect_flip','effect_fly','effect_hatch','effect_slide_left','effect_slide_right','effect_slide_up','effect_slide_down'];");
ToHTML("function asmGlobal_rgb2hex(rgb) {");
ToHTML("rgb = rgb.match(/^rgba?[\\s+]?\\([\\s+]?(\\d+)[\\s+]?,[\\s+]?(\\d+)[\\s+]?,[\\s+]?(\\d+)[\\s+]?/i);");
ToHTML("return (rgb && rgb.length === 4) ? '#'+('0'+parseInt(rgb[1],10).toString(16)).slice(-2)+('0'+parseInt(rgb[2],10).toString(16)).slice(-2)+('0'+ parseInt(rgb[3],10).toString(16)).slice(-2) : '';");
ToHTML("}");
if (style_view!='vis' && style_view!='bt') {
ToHTML("function asmGlobal_setWindsBG() {");
ToHTML("var windElems = [asmGlobal.prefsDiv,asmGlobal.dialogWind,asmGlobal.printAdd];");
ToHTML("for (var key in windElems) {");
ToHTML("var elem = windElems[key];");
ToHTML("var bg = getComputedStyle(elem,null).backgroundColor;");
ToHTML("if (bg.substr(0,3)=='rgb') {");
ToHTML("elem.style.backgroundColor = asmGlobal_rgb2hex(bg);");
ToHTML("}");
ToHTML("}");
ToHTML("}");
ToHTML("asmGlobal_setWindsBG();");
} else if (style_view=='vis') {
ToHTML("function asmGlobal_rgb2yuv(rgb) {");
ToHTML("var y = asmGlobal_clamp(rgb.r *  0.29900 + rgb.g *  0.587   + rgb.b * 0.114);");
ToHTML("var u = asmGlobal_clamp(rgb.r * -0.16874 + rgb.g * -0.33126 + rgb.b * 0.50000 + 128);");
ToHTML("var v = asmGlobal_clamp(rgb.r *  0.50000 + rgb.g * -0.41869 + rgb.b * -0.08131 + 128);");
ToHTML("return {y:y, u:u, v:v};");
ToHTML("}");
ToHTML("function asmGlobal_yuv2rgb(yuv) {");
ToHTML("var y = yuv.y;");
ToHTML("var u = yuv.u;");
ToHTML("var v = yuv.v;");
ToHTML("var r = asmGlobal_clamp(y + (v - 128) *  1.40200);");
ToHTML("var g = asmGlobal_clamp(y + (u - 128) * -0.34414 + (v - 128) * -0.71414);");
ToHTML("var b = asmGlobal_clamp(y + (u - 128) *  1.77200);");
ToHTML("return {r:r,g:g,b:b};");
ToHTML("}");
ToHTML("function asmGlobal_clamp(n){");
ToHTML("if (n<0) {return 0;}");
ToHTML("if (n>255) {return 255;}");
ToHTML("return Math.floor(n);");
ToHTML("}");
ToHTML("function asmGlobal_dec2hex(n) {");
ToHTML("var hex = n.toString(16);");
ToHTML("if (hex.length < 2) {");
ToHTML("return '0' + hex;");
ToHTML("}");
ToHTML("return hex;");
ToHTML("}");
ToHTML("function asmGlobal_rgb2hexColor(rgb) {");
ToHTML("return '#' + asmGlobal_dec2hex(rgb.r) + asmGlobal_dec2hex(rgb.g) + asmGlobal_dec2hex(rgb.b);");
ToHTML("}");
ToHTML("function asmGlobal_hexColor2rgb(color) {");
ToHTML("color = color.substring(1);");
ToHTML("return {");
ToHTML("r: parseInt(color.substring(0, 2), 16),");
ToHTML("g: parseInt(color.substring(2, 4), 16),");
ToHTML("b: parseInt(color.substring(4, 6), 16)");
ToHTML("};");
ToHTML("}");
ToHTML("function asmGlobal_invertColor(rgb) {");
ToHTML("var yuv = asmGlobal_rgb2yuv(rgb);");
ToHTML("var factor = 180;");
ToHTML("var threshold = 100;");
ToHTML("yuv.y = asmGlobal_clamp(yuv.y + (yuv.y > threshold ? -factor : factor));");
ToHTML("return asmGlobal_yuv2rgb(yuv);");
ToHTML("}");
ToHTML("function asmGlobal_setInvertColor() {");
ToHTML("var c = window.getComputedStyle(asmGlobal.printContDiv,null).getPropertyValue('color');");
ToHTML("if (c.substr(0,3).trim()=='rgb') {");
ToHTML("c = asmGlobal_rgb2hex(c);");
ToHTML("}");
ToHTML("c = asmGlobal_rgb2hexColor(asmGlobal_invertColor(asmGlobal_hexColor2rgb(c)));");
ToHTML("var ts = c+' 1px 0px,'+c+' 1px 1px,'+c+' 0px 1px,'+c+' -1px 1px,'+c+' -1px 0px,'+c+' -1px -1px,'+c+' 0px -1px,'+c+' 1px -1px';");
ToHTML("document.getElementsByTagName('style')[0].innerHTML += 'body,input{text-shadow:'+ts+';}';");
ToHTML("}");
ToHTML("asmGlobal_setInvertColor();");
}
if (style_view=='vis') {
ToHTML("asmGlobal.typer = {");
ToHTML("tags: ['img','button','input','u','textarea','hr','li','td','tr','th','table','thead','tfoot','tbody','video','audio'],");
ToHTML("classes: ['button','buttonno','buttonback','myinput'],");
ToHTML("class1: 'typer_1',");
ToHTML("class2: 'typer_2',");
ToHTML("spans: [],");
ToHTML("nextInt: undefined,");
ToHTML("typing: false,");
ToHTML("start: function() {");
ToHTML("this.spans = [];");
ToHTML("clearInterval(this.nextInt); this.nextInt = undefined;");
ToHTML("this.typing = true;");
ToHTML("asmGlobal.printDiv.style.visibility = 'hidden';");
ToHTML("var text = asmGlobal.printDiv.innerHTML;");
ToHTML("var textNodes = this.textNodesUnder(asmGlobal.printDiv);");
ToHTML("var tag;");
ToHTML("for (var i=0; i<textNodes.length; i++) {");
ToHTML("var node = textNodes[i];");
ToHTML("var words = node.textContent;");
ToHTML("if (node.nodeType==3) {");
ToHTML("var parentNode = node.parentNode;");
ToHTML("var parentNodeTag = this.getTag(parentNode);");
ToHTML("tag = '';");
ToHTML("if (parentNodeTag=='a') {");
ToHTML("tag += '<span class='+this.class1+'>'+words+'</span>';");
ToHTML("} else {");
ToHTML("words = words.split('');");
ToHTML("for (var j=0; j<words.length; j++) {");
ToHTML("var word = words[j];");
ToHTML("if (word!='') {");
ToHTML("tag += '<span class='+this.class1+'>'+word+'</span>';");
ToHTML("}");
ToHTML("}");
ToHTML("}");
ToHTML("var newNode = document.createElement('span');");
ToHTML("newNode.innerHTML = tag;");
ToHTML("parentNode.replaceChild(newNode,node);");
ToHTML("} else if (this.tags.indexOf(this.getTag(node))!=-1 || this.classes.indexOf(node.className)!=-1) {");
ToHTML("var classes = node.className;");
ToHTML("if (classes=='') {");
ToHTML("node.className = this.class1;");
ToHTML("} else {");
ToHTML("node.className += ' '+this.class1;");
ToHTML("}");
ToHTML("}");
ToHTML("}");
ToHTML("asmGlobal.printDiv.style.visibility = 'visible';");
ToHTML("this.spans = [].slice.call(asmGlobal.printDiv.getElementsByClassName(this.class1));");
ToHTML("if (this.spans.length>0) {");
ToHTML("this.next(0,this);");
ToHTML("} else {");
ToHTML("this.stop();");
ToHTML("}");
ToHTML("},");
ToHTML("next: function(i,cont) {");
ToHTML("this.nextInt = setTimeout(function() {");
ToHTML("var classes = cont.spans[i].className;");
ToHTML("cont.spans[i].className = classes.replace(cont.class1,cont.class2);");
ToHTML("i++;");
ToHTML("if (i<cont.spans.length) {");
ToHTML("asmGlobal.typer.next(i,cont);");
ToHTML("} else {");
ToHTML("cont.typing = false;");
ToHTML("cont.nextInt = undefined;");
ToHTML("clearInterval(cont.nextInt);");
ToHTML("setTimeout(function() {cont.stop();}, 60);");
ToHTML("}");
ToHTML("}, 30);");
ToHTML("},");
ToHTML("stop: function() {");
ToHTML("var buttonsList = $('buttonsList');");
ToHTML("if (buttonsList) {");
ToHTML("var buttonsCount = buttonsList.querySelectorAll('*').length;");
ToHTML("if (buttonsCount>1) {");
ToHTML("if (buttonsList.style.display=='none') {");
ToHTML("buttonsList.style.display = 'block';");
ToHTML("if (asmGlobal.isAnimation && asmGlobal.animation_enable) {");
ToHTML("asmGlobal_Animate(buttonsList,'effect_fly');");
ToHTML("}");
ToHTML("}");
ToHTML("} else if (buttonsCount==1) {");
ToHTML("if (asmGlobal_printIsEmpty()) {"); // одна кнопка и нет текста
ToHTML("buttonsList.style.display = 'block';");
ToHTML("if (asmGlobal.isAnimation && asmGlobal.animation_enable) {");
ToHTML("asmGlobal_Animate(buttonsList,'effect_fly');");
ToHTML("}");
ToHTML("} else {");
ToHTML("asmGlobal_Animate(asmGlobal.printDiv,'effect_flash');");
ToHTML("}");
ToHTML("}");
ToHTML("}");
ToHTML("if (this.typing) {");
ToHTML("clearInterval(this.nextInt);");
ToHTML("this.typing = false;");
ToHTML("for (var i=0; i<this.spans.length; i++) {");
ToHTML("var classes = this.spans[i].className;");
ToHTML("this.spans[i].className = classes.replace(this.class1,this.class2);");
ToHTML("}");
ToHTML("}");
ToHTML("if (!asmGlobal.isTouchDevice) {");
ToHTML("var input = document.getElementsByClassName('input_text')[0];");
ToHTML("if (input) {input.select();}");
ToHTML("}");
ToHTML("},");
ToHTML("textNodesUnder: function(node) {");
ToHTML("var all = [];");
ToHTML("for (var node=node.firstChild;node;node=node.nextSibling){");
ToHTML("if (node.nodeType==3 || this.tags.indexOf(this.getTag(node))!=-1 || this.classes.indexOf(node.className)!=-1) {");
ToHTML("all.push(node);");
ToHTML("}");
ToHTML("else {");
ToHTML("all = all.concat(this.textNodesUnder(node));");
ToHTML("}");
ToHTML("}");
ToHTML("return all;");
ToHTML("},");
ToHTML("getTag: function(node) {");
ToHTML("return node.tagName.toLowerCase();");
ToHTML("}");
ToHTML("};");
}
ToHTML("function asmGlobal_isInputActive() {");
ToHTML("var tag = document.activeElement.tagName.toLowerCase();");
ToHTML("if (tag=='input' || tag=='textarea') {return true;} else {return false;};");
ToHTML("}");
ToHTML("function asmGlobal_keysDown(event) {");
ToHTML("if (asmGlobal_isInputActive()) {return;};");
ToHTML("var key = asmGlobal_keyCode(event);");
ToHTML("if (key==32) {event.preventDefault();}");
ToHTML("}");
ToHTML("function asmGlobal_keysUp(event) {");
ToHTML("if (asmGlobal_isInputActive()) {return;};");
ToHTML("if (asmGlobal.showCover) {asmGlobal_StartGame(); return;};");
ToHTML("var key = asmGlobal_keyCode(event);");
ToHTML("if (key==27) {");
ToHTML("if (getComputedStyle(asmGlobal.prefsDiv,null).display=='none') {");
ToHTML("asmGlobal_showPrefs();");
ToHTML("} else {");
ToHTML("asmGlobal_closeWinds();");
ToHTML("}");
ToHTML("return;");
ToHTML("}");
if (style_view!='vis' && style_view!='bt') {
if (style_view=='sw') {
ToHTML("if (key==32) {asmGlobal_showImageToggle(); return;}");
} else {
ToHTML("if (key==32 && asmGlobal_isMobile()) {asmGlobal_showImageToggle(); return;}");
}
} else if (style_view=='bt') {
ToHTML("if (key==32) {");
ToHTML("asmGlobal_firstButtonClick();");
ToHTML("return;");
ToHTML("}");
} else {
ToHTML("if (key==32) {");
ToHTML("if (asmGlobal.typer.typing) {");
ToHTML("asmGlobal.typer.stop();");
ToHTML("} else {");
ToHTML("asmGlobal_firstButtonClick();");
ToHTML("}");
ToHTML("return;");
ToHTML("}");
}
ToHTML("var keyN = -1;");
ToHTML("if (key>=49 && key<=57)  {keyN=key-49;}");
ToHTML("if (key>=97 && key<=105) {keyN=key-97;}");
ToHTML("if (keyN>=0) {");
ToHTML("var elems = asmGlobal.menuDiv.querySelectorAll('*');");
ToHTML("var clickElems = [];");
ToHTML("for (var i=0; i<elems.length; i++) {");
ToHTML("if (elems[i].onclick) {");
ToHTML("clickElems.push(elems[i]);");
ToHTML("}");
ToHTML("}");
ToHTML("if (clickElems[keyN]) {clickElems[keyN].click();};");
ToHTML("}");
ToHTML("}");
if (style_view=='vis' || style_view=='bt') {
ToHTML("function asmGlobal_printIsEmpty() {");
ToHTML("if (asmGlobal.printDiv.textContent.trim()=='' && asmGlobal.avatarBlock.innerHTML=='' && !(/<img/.test(asmGlobal.printDiv.innerHTML))) {");
ToHTML("return true;"); // пустой блок (видимого текста нет)
ToHTML("} else {");
ToHTML("return false;");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_togglePrint(show,close) {");
ToHTML("if (asmGlobal_printIsEmpty()) {");
ToHTML("asmGlobal.printContDiv.style.display = 'none';");
ToHTML("} else {");
ToHTML("asmGlobal.printContDiv.style.display = 'block';");
ToHTML("}");
ToHTML("var opacity = window.getComputedStyle(asmGlobal.printContDiv,null).getPropertyValue('opacity');");
ToHTML("var objs = [asmGlobal.printContDiv,asmGlobal.consoleDiv,asmGlobal.toolbarDiv,$('menu'),$('buttonsList'),$('backVideoSkip')];");
ToHTML("for (var i in objs) {");
ToHTML("var obj = objs[i];");
ToHTML("if (obj) {");
ToHTML("if (close) {");
ToHTML("obj.style.pointerEvents = 'none';");
ToHTML("obj.style.opacity = 0;");
ToHTML("continue;");
ToHTML("}");
ToHTML("if (show || opacity==0) {");
ToHTML("obj.style.pointerEvents = 'auto';");
ToHTML("obj.style.opacity = 1;");
ToHTML("} else {");
ToHTML("obj.style.pointerEvents = 'none';");
ToHTML("obj.style.opacity = 0;");
ToHTML("}");
ToHTML("}");
ToHTML("}");
ToHTML("}");
}
ToHTML("function asmGlobal_firstButtonClick() {");
ToHTML("var buttonsList = $('buttonsList');");
ToHTML("if (buttonsList) {");
ToHTML("var opacity = window.getComputedStyle(buttonsList,null).getPropertyValue('opacity');");
ToHTML("if (opacity>0) {");
ToHTML("var click = function(element,parent) {"); // функция клика
ToHTML("if (element.onclick) {");
ToHTML("var action = element.onclick.toString();");
ToHTML("action = action.substring(action.indexOf('{')+1,action.lastIndexOf('}')).trim();");
ToHTML("var re = /^this\.parentNode\.innerHTML.+?;/;");
ToHTML("if (re.test(action)) {"); // добавляющая кнопка/ссылка
ToHTML("action = action.replace(re,'');");
ToHTML("parent.innerHTML = parent.innerHTML.replace(/\.onclick\s*?=/,'.noclick=');");
ToHTML("}");
ToHTML("eval(action);");
ToHTML("}");
ToHTML("};");
ToHTML("var n = buttonsList.getElementsByTagName('*').length;");
ToHTML("if (n==1) {"); // на кнопку
ToHTML("click(buttonsList.firstChild,buttonsList);");
ToHTML("} else if (n==0) {");
ToHTML("var links = asmGlobal.printDiv.getElementsByClassName('plink');");
ToHTML("if (links.length==1) {"); // на ссылку
ToHTML("click(links[0],asmGlobal.printDiv);");
ToHTML("}");
ToHTML("}");
ToHTML("}");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_showImageToggle()");
ToHTML("{");
ToHTML("if (asmGlobal_isMobile()) {");
ToHTML("if (getComputedStyle(asmGlobal.printImageBlock,null).display=='none') {asmGlobal.printImageBlock.style.display='block';asmGlobal_Animate(asmGlobal.printImageBlock,'effect_scale');} else {asmGlobal.printImageBlock.style.display='none';}");
ToHTML("}");
ToHTML("else {");
ToHTML("if (getComputedStyle(asmGlobal.printAddCont,null).display=='none') {asmGlobal_showImage();} else {asmGlobal_showPrintAdd(false);}");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_showImageForce(fade)");
ToHTML("{");
ToHTML("if (asmGlobal_isMobile()) {");
ToHTML("asmGlobal.printImageBlock.style.display = 'block';");
ToHTML("}");
ToHTML("if (fade) {");
ToHTML("asmGlobal_Animate(asmGlobal.printImage,'effect_fade');");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_goodImageShow(img)");
ToHTML("{");
ToHTML("if(asmGlobal.isTouchDevice) {");
ToHTML("var obj = img.parentNode;");
ToHTML("obj.style.display = 'none';");
ToHTML("asmGlobal_scrollDiv(obj);");
ToHTML("obj.style.display = 'block';");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_badImageShow(img)");
ToHTML("{");
ToHTML("img.src = asmGlobal.badImage;");
ToHTML("}");
ToHTML("function asmGlobal_ImagesOnError(div)");
ToHTML("{");
ToHTML("var images = div.getElementsByTagName('img');");
ToHTML("for(var i=0; i<images.length; i++) {");
ToHTML("images[i].onerror = function() {");
ToHTML("this.src = asmGlobal_GetMediaPath(this.src);");
ToHTML("this.onerror = function() { this.src = asmGlobal.badImage; };");
ToHTML("};");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_GetMediaPath(path)");
ToHTML("{");
if (TestMode && TargetChromeApp) {
ToHTML("if (!/^http(s)?:\\/\\//.test(path.trim())) {");
ToHTML("return 'file://'+\""+chrome_GetFilesDirectory()+"\"+path.replace(/^chrome-extension:\\/\\/.+?\\//,'');");
ToHTML("} else {");
ToHTML("return path;");
ToHTML("}");
} else {
ToHTML("return path;");
}
ToHTML("}");
ToHTML("function asmGlobal_showImage()");
ToHTML("{");
ToHTML("if (!asmGlobal_isMobile()) {");
ToHTML("asmGlobal.printAddText.innerHTML = \"<img src='\"+asmGlobal.printImage.src+\"' style='height:600px;margin:0;padding:0;' border='0'>\";");
ToHTML("asmGlobal.printAddText.innerHTML += asmGlobal.spritesDiv.innerHTML;");
ToHTML("asmGlobal_showPrintAdd(true,false,true);");
ToHTML("}");
ToHTML("else {");
ToHTML("asmGlobal.printImageBlock.style.display = 'none';");
ToHTML("}");
ToHTML("}");
ToHTML("asmGlobal.printAddTextAlign = asmGlobal.printAddText.style.textAlign;");
ToHTML("function asmGlobal_showPrintAdd(show,center) {");
ToHTML("if (show) {");
ToHTML("asmGlobal_closeWinds();");
ToHTML("asmGlobal_showShadow(true);");
ToHTML("if (center) {asmGlobal.printAddText.style.textAlign = 'center';} else {asmGlobal.printAddText.style.textAlign = asmGlobal.printAddTextAlign;}");
ToHTML("var inner = asmGlobal.printAddText.innerHTML;");
ToHTML("if (inner=='') {return;}");
ToHTML("asmGlobal.printAddText.innerHTML = inner;");
ToHTML("asmGlobal_ImagesOnError(asmGlobal.printAddText);");
ToHTML("asmGlobal.printAddCont.style.display = 'block'; asmGlobal_scrollDiv(asmGlobal.printAdd); if (asmGlobal.isAnimation && asmGlobal.animation_enable) { var effect='effect_scale'; asmGlobal_Animate(asmGlobal.printAdd,effect); } else { asmGlobal_fade(asmGlobal.printAddText); }");
ToHTML("} else {");
ToHTML("asmGlobal.popupPassage = false;");
ToHTML("asmGlobal_showShadow(false);");
ToHTML("asmGlobal.printAddCont.style.display = 'none';");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_MenuInit() {");
ToHTML("var StoryMenu = asmGlobal_GetLocation('StoryMenu');");
ToHTML("if (StoryMenu!=false) {");
ToHTML("asmGlobal.menuDiv.innerHTML = '';");
ToHTML("var maindiv = asmGlobal.printDiv;");
ToHTML("asmGlobal.printDiv = asmGlobal.menuDiv;");
ToHTML("StoryMenu.Text();");
ToHTML("asmGlobal.Output.print();");
ToHTML("asmGlobal.printDiv = maindiv;");
ToHTML("asmGlobal_ToText('',false,asmGlobal.menuDiv,true);");
ToHTML("}");
ToHTML("}");
ToHTML("asmGlobal.fontSize = 1;");
ToHTML("function asmGlobal_ChangeFontSize(){");
ToHTML("if (asmGlobal.fontSize<1.2){");
ToHTML("asmGlobal.fontSize = asmGlobal.fontSize + 0.1;");
ToHTML("}");
ToHTML("else {");
ToHTML("asmGlobal.fontSize = 0.8");
ToHTML("}");
ToHTML("asmGlobal_fade(asmGlobal.printDiv);");
ToHTML("asmGlobal.printDiv.style.fontSize = asmGlobal.fontSize+'em';");
ToHTML("asmGlobal.printAdd.style.fontSize = asmGlobal.fontSize+'em';");
ToHTML("}");
ToHTML("function asmGlobal_scrollDiv(obj,bottom,typerstop,toDiv) {");
if (style_view=='vis') {
ToHTML("if (typerstop) {");
ToHTML("asmGlobal.typer.start(); asmGlobal.typer.stop();");
ToHTML("}");
}
ToHTML("if (!obj) {");
ToHTML("obj = asmGlobal.printContDiv;");
ToHTML("}");
ToHTML("var offset = obj.scrollHeight;");
ToHTML("if (toDiv) {");
ToHTML("var fsize = parseFloat(window.getComputedStyle(toDiv,null).getPropertyValue('font-size'));");
ToHTML("offset = toDiv.offsetTop-fsize;");
ToHTML("}");
ToHTML("if (bottom) {");
ToHTML("obj.scrollTop = offset;");
ToHTML("}");
ToHTML("else {");
ToHTML("obj.scrollTop = 0;");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_toVisitedList(index) {");
ToHTML("var n = 1;");
ToHTML("for (var i in asmGlobal.visitedList) {");
ToHTML("var item = asmGlobal.visitedList[i];");
ToHTML("if (item[0]==index) {");
ToHTML("n = item[1]+1;");
ToHTML("asmGlobal.visitedList.splice(i,1);");
ToHTML("break;");
ToHTML("}");
ToHTML("}");
ToHTML("asmGlobal.visitedList.push([index,n]);");
ToHTML("}");
ToHTML("function asmGlobal_closeWinds() {");
ToHTML("asmGlobal_showPrintAdd(false);");
ToHTML("asmGlobal_showPrefs(true);");
ToHTML("asmGlobal_showWindow(false,true);");
ToHTML("}");
ToHTML("function asmGlobal_showShadow(show) {");
ToHTML("if (show) {");
ToHTML("if (!$('shadowlayer')) {");
ToHTML("var shadow = document.createElement('div');");
ToHTML("if (asmGlobal.showCover) {");
ToHTML("shadow.removeAttribute('visible');");
ToHTML("} else {");
ToHTML("shadow.setAttribute('visible','');");
ToHTML("}");
ToHTML("shadow.className = 'effect_fade_fast';");
ToHTML("shadow.onclick = function() {asmGlobal_showPrefs(true);};");
ToHTML("shadow.id='shadowlayer'; document.body.appendChild(shadow);");
ToHTML("}");
ToHTML("} else {");
ToHTML("var shadow = $('shadowlayer');");
ToHTML("if (shadow) {");
ToHTML("document.body.removeChild(shadow);");
ToHTML("}");
ToHTML("asmGlobal.showCover = false;");
ToHTML("asmGlobal.printAddCont.style.display = 'none';");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_keyCode(event) {");
ToHTML("return event.keyCode ? event.keyCode : event.charCode ? event.charCode : event.which;");
ToHTML("}");
ToHTML("asmGlobal.isTouchDevice = false;");
ToHTML("if ('ontouchmove' in window) {");
ToHTML("asmGlobal.isTouchDevice = true;");
ToHTML("}");
ToHTML("(function () {");
ToHTML("if (asmGlobal.isTouchDevice) {");
ToHTML("try {");
ToHTML("var ignore = /:hover/;");
ToHTML("for (var i=0; i<document.styleSheets.length; i++) {");
ToHTML("var sheet = document.styleSheets[i];");
ToHTML("if (!sheet.cssRules) {");
ToHTML("continue;");
ToHTML("}");
ToHTML("for (var j=sheet.cssRules.length-1; j>=0; j--) {");
ToHTML("var rule = sheet.cssRules[j];");
ToHTML("if (rule.type===CSSRule.STYLE_RULE && ignore.test(rule.selectorText)) {");
ToHTML("sheet.deleteRule(j);");
ToHTML("}");
ToHTML("}");
ToHTML("}");
ToHTML("} catch(e) {");
ToHTML("}");
ToHTML("}");
ToHTML("}());");
ToHTML("asmGlobal.musicAudio = $('musicAudio');");
ToHTML("asmGlobal.musicAudio.addEventListener('play',function() {");
ToHTML("asmGlobal_audioPlayEvent();");
ToHTML("},false);");
ToHTML("asmGlobal.musicAudio.addEventListener('pause',function() {");
ToHTML("asmGlobal_audioPauseEvent();");
ToHTML("},false);");
ToHTML("asmGlobal.musicAudio.addEventListener('durationchange',function() {");
ToHTML("asmGlobal_audioPlayEvent();");
ToHTML("},false);");
ToHTML("asmGlobal.musicAudio.addEventListener('error',function() {");
ToHTML("if (this.src.substr(-4)=='.mp3') {");
ToHTML("asmGlobal_AlertMessage('"+Lang.ErrorLoadFile+"<br>'+this.src);");
ToHTML("}");
ToHTML("},false);");
ToHTML("var asm = {};");
ToHTML("asmGlobal.audio_enable = true;");
ToHTML("asmGlobal.animation_enable = true;");
ToHTML("asmGlobal.showCover = false;");
ToHTML("asmGlobal.TimeToFade = "+TimeToFade+";");
ToHTML("asmGlobal.SpriteEffect = 0;");
ToHTML("asmGlobal.TextEffect = 0;");
ToHTML("asmGlobal.isAnimation= false;");
ToHTML("if (document.body.style.WebkitAnimation!==undefined || document.body.style.MozAnimation!==undefined || document.body.style.OAnimation!==undefined || document.body.style.msAnimation!==undefined || document.body.style.KhtmlAnimation!==undefined || document.body.style.animation!==undefined) {");
ToHTML("asmGlobal.isAnimation = true;");
ToHTML("}");
ToHTML("function asmGlobal_tbAnimate(obj,event) {");
ToHTML("asmGlobal_Animate(obj,'effect_button');");
ToHTML("event.stopPropagation();");
ToHTML("}");
ToHTML("function asmGlobal_prefixedEventListener(element, type, callback) {");
ToHTML("var pfx = ['webkit', 'moz', 'MS', 'o', ''];");
ToHTML("for (var p=0; p<pfx.length; p++) {");
ToHTML("if (!pfx[p]) type = type.toLowerCase();");
ToHTML("element.addEventListener(pfx[p]+type, callback, false);");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_Animate(obj,animID,callback)");
ToHTML("{");
ToHTML("if (asmGlobal.isAnimation) {");
ToHTML("var objclass = obj.className.split(' ')[0];");
ToHTML("obj.className = objclass+' '+animID;");
ToHTML("asmGlobal_prefixedEventListener(obj,'AnimationEnd',function() {");
ToHTML("if(obj) {");
ToHTML("obj.className = objclass;");
ToHTML("if (callback) { callback(); }");
ToHTML("}");
ToHTML("}, false);");
ToHTML("}");
ToHTML("}");
ToHTML("asmGlobal.confirm_func;");
ToHTML("function asmGlobal_AreYouSure(func,text) {");
ToHTML("asmGlobal_showPrefs(true);");
ToHTML("asmGlobal.confirm_func = func;");
ToHTML("if (!text) {");
ToHTML("text = '"+Lang.AreYouSure+"';");
ToHTML("}");
ToHTMW("	text += [[asmQuot]]<div style='margin-top:16px;'><span class='dialogButton' onclick=\\[[asmQuot]]asmGlobal_showWindow(false,true);");
ToHTML("\\[[asmQuot]] style='float:left;'>"+Lang.NO+"</span><span class='dialogButton' style='float:right;' onclick='window[asmGlobal.confirm_func]();event.stopPropagation();'>"+Lang.YES+"</span></div>[[asmQuot]];");
ToHTML("asmGlobal_showWindow(text);");
ToHTML("}");
ToHTML("function asmGlobal_AlertMessage(text)");
ToHTML("{");
ToHTMW("	text += [[asmQuot]]<div style='margin-top:16px;'><span class='dialogButton' onclick=\\[[asmQuot]]asmGlobal_showWindow(false,true);");
ToHTML("\\[[asmQuot]]>OK</span></div>[[asmQuot]];");
ToHTML("asmGlobal_showWindow(text);");
ToHTML("}");
ToHTML("asmGlobal.isLocalFile;");
ToHTML("if (location.href.substr(0,7)=='file://')");
ToHTML("{asmGlobal.isLocalFile=true;}");
ToHTML("else");
ToHTML("{asmGlobal.isLocalFile=false;}");
ToHTML("function asmGlobal_isLocalStorageAvailable() {");
ToHTML("if (!window.localStorage) {");
ToHTML("return false;");
ToHTML("}");
ToHTML("else {");
ToHTML("return true;");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_LocNotFound(Title) {");
if (OnlyPassageNum==-1) {
if (TestMode) {
ToHTML("asmGlobal_AlertMessage('"+Lang.Location+"<br>[[asmQuot]]'+Title+'[[asmQuot]]<br>"+Lang.NotFound+"');");
} else {
ToHTML("asmGlobal_AlertMessage('"+Lang.Location+" "+Lang.NotFound+"');");
}
}
ToHTML("}");
ToHTMW("asmGlobal.storydata = [];");
var data = GetLocByTitle('StoryData');
if (data) {
data = data.Text.split('\n');
for (var key in data) {
var line = data[key];
if (line.indexOf('::')==-1) {
continue;
}
line = line.split('::');
line[0] = line[0].toLowerCase().trim(); // название файла
line[1] = line[1].trim(); // dataurl
var datatype = line[1].substr(0,11);
if (datatype=='data:image/') {
datatype = "Image";
} else if (datatype=='data:audio/') {
datatype = "Audio";
} else {
continue;
}
ToHTMW ("asmGlobal.obj=new "+datatype+"();asmGlobal.obj.src='"+line[1]+"';asmGlobal.storydata.push(['"+line[0]+"',asmGlobal.obj]);");
}
data = '';
}
ToHTML("function asmGlobal_GetFileData(id) {");
ToHTML("if (/^http(s)?:\\/\\/.+?$/.test(id)) {"); // по URL
ToHTML("var ret = {};");
ToHTML("ret.src = id;");
ToHTML("return ret;");
ToHTML("}");
ToHTML("id = id.toString().trim().toLowerCase();");
ToHTML("for (var key in asmGlobal.storydata) {");
ToHTML("if (asmGlobal.storydata[key][0]==id) {");
ToHTML("return asmGlobal.storydata[key][1];");
ToHTML("}");
ToHTML("}");
ToHTML("return '';");
ToHTML("}");
ToHTML("function asmGlobal_prefsFill()");
ToHTML("{");
ToHTML("asmGlobal.prefsDiv.innerHTML='';");
ToHTML("asmGlobal.prefsDiv.innerHTML+='<div><span class=plink onclick=\\[[asmQuot]]asmGlobal_AreYouSure(&quot;asmGlobal_NewGame&quot;,&quot;"+Lang.StartAgain+"&quot;);event.stopPropagation();\\[[asmQuot]]>"+Lang.HTMLRestart+"</span></div>';");
ToHTML("if (asm.save) {");
ToHTMW("	asmGlobal.prefsDiv.innerHTML+='<div><span class=plink onclick=\\[[asmQuot]]asmGlobal_SaveLoadWind(true);\\[[asmQuot]]>"+Lang.HTMLSave+"</span></div><div><span class=plink onclick=\\[[asmQuot]]asmGlobal_SaveLoadWind(false);\\[[asmQuot]]>"+Lang.HTMLLoad+"</span></div>';");
ToHTML("}");
ToHTML("if (asmGlobal.audio_enable)");
ToHTML("{");
ToHTML("asmGlobal.prefsDiv.innerHTML+='<div><span class=plink onclick=\\[[asmQuot]]asmGlobal.audio_enable=false;asmGlobal_stopMusic();asmGlobal_prefsFill();\\[[asmQuot]]>"+Lang.HTMLSoundOff+"</span></div>';");
ToHTML("}");
ToHTML("else");
ToHTML("{");
ToHTML("asmGlobal.prefsDiv.innerHTML+='<div><span class=plink onclick=\\[[asmQuot]]asmGlobal.audio_enable=true;asmGlobal_playMusic();asmGlobal_prefsFill();\\[[asmQuot]]>"+Lang.HTMLSoundOn+"</span></div>';");
ToHTML("}");
ToHTML("if (asmGlobal.isAnimation)");
ToHTML("{");
ToHTML("if (asmGlobal.animation_enable)");
ToHTML("{");
ToHTMW("asmGlobal.prefsDiv.innerHTML+='<div><span class=plink onclick=\\[[asmQuot]]asmGlobal.animation_enable=false;");
if (style_view=='vis') {
ToHTMW("asmGlobal.typer.stop();");
}
ToHTML("asmGlobal_prefsFill();\\[[asmQuot]]>"+Lang.HTMLAnimOff+"</span></div>';");
ToHTML("}");
ToHTML("else");
ToHTML("{");
ToHTML("asmGlobal.prefsDiv.innerHTML+='<div><span class=plink onclick=\\[[asmQuot]]asmGlobal.animation_enable=true;asmGlobal_prefsFill();\\[[asmQuot]]>"+Lang.HTMLAnimOn+"</span></div>';");
ToHTML("}");
ToHTML("}");
ToHTML("asmGlobal.prefsDiv.innerHTML+='<div><span class=plink onclick=\\[[asmQuot]]asmGlobal_ChangeFontSize();\\[[asmQuot]]>"+Lang.HTMLTextSize+"</span></div>';");
ToHTML("}");
ToHTML("function asmGlobal_showWindow(text,close,modal) {");
ToHTML("if (arguments.length>0) {");
ToHTML("if (close) {");
ToHTML("asmGlobal.dialogWind.style.display = 'none';");
ToHTML("asmGlobal_showShadow();");
ToHTML("} else {");
ToHTML("asmGlobal_showShadow(true);");
ToHTML("if (text) {");
ToHTML("asmGlobal.dialogWind.innerHTML = text;");
ToHTML("}");
ToHTML("asmGlobal.dialogWind.style.display = 'block';");
ToHTML("asmGlobal_Animate(asmGlobal.dialogWind,'effect_fade_fast');");
ToHTML("}");
ToHTML("}");
ToHTML("if (asmGlobal.dialogWind.style.display=='none') {");
ToHTML("return false;");
ToHTML("} else {");
ToHTML("return true;");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_showPrefs(close) {");
ToHTML("if (asmGlobal.showCover) {return;}");
ToHTML("if(close || asmGlobal.prefsDiv.style.display!='none' || asmGlobal_showWindow()) {");
ToHTML("asmGlobal_showShadow(false);");
ToHTML("asmGlobal_showWindow(false,true);");
ToHTML("asmGlobal.prefsDiv.style.display = 'none';");
ToHTML("}");
ToHTML("else {");
ToHTML("asmGlobal_showShadow(true);");
ToHTML("asmGlobal_prefsFill();");
ToHTML("asmGlobal.prefsDiv.style.display = 'block';");
ToHTML("asmGlobal_Animate(asmGlobal.prefsDiv,'effect_fade_fast');");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_togglePrefs() {");
ToHTML("if (getComputedStyle(asmGlobal.prefsDiv,null).display=='none') {");
ToHTML("asmGlobal_showPrefs();");
ToHTML("} else {");
ToHTML("asmGlobal_closeWinds();");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_setCookie(name, value)");
ToHTML("{");
ToHTML("var expires = new Date();");
ToHTML("expires.setTime(expires.getTime()+31536000000);");
ToHTML("document.cookie = name + '=' + escape(value) + '; expires=' + expires.toGMTString() + '; path=/';");
ToHTML("}");
ToHTML("function asmGlobal_getCookie(name)");
ToHTML("{");
ToHTML("var cookie = ' ' + document.cookie;");
ToHTML("var search = ' ' + name + '=';");
ToHTML("var setStr = null;");
ToHTML("var offset = 0;");
ToHTML("var end = 0;");
ToHTML("if (cookie.length>0)");
ToHTML("{");
ToHTML("offset = cookie.indexOf(search);");
ToHTML("if (offset != -1)");
ToHTML("{");
ToHTML("offset += search.length;");
ToHTML("end = cookie.indexOf(';', offset);");
ToHTML("if (end == -1)");
ToHTML("{");
ToHTML("end = cookie.length;");
ToHTML("}");
ToHTML("setStr = decodeURIComponent(cookie.substring(offset, end));");
ToHTML("}");
ToHTML("}");
ToHTML("if (setStr==null)");
ToHTML("{");
ToHTML("setStr = '';");
ToHTML("}");
ToHTML("return(setStr);");
ToHTML("}");
ToHTML("function asmGlobal_fade(element)");
ToHTML("{");
ToHTML("if (asmGlobal.TimeToFade==0 || !element) {return;}");
ToHTML("var eid = element.id;");
ToHTML("element.style.opacity = '0';");
ToHTML("if (element.FadeState == null)");
ToHTML("{");
ToHTML("if (element.style.opacity == null");
ToHTML("|| element.style.opacity == ''");
ToHTML("|| element.style.opacity == '1')");
ToHTML("{");
ToHTML("element.FadeState = 2;");
ToHTML("}");
ToHTML("else");
ToHTML("{");
ToHTML("element.FadeState = -2;");
ToHTML("}");
ToHTML("}");
ToHTML("if (element.FadeState == 1 || element.FadeState == -1)");
ToHTML("{");
ToHTML("element.FadeState = element.FadeState == 1 ? -1 : 1;");
ToHTML("element.FadeTimeLeft = asmGlobal.TimeToFade - element.FadeTimeLeft;");
ToHTML("}");
ToHTML("else");
ToHTML("{");
ToHTML("element.FadeState = element.FadeState == 2 ? -1 : 1;");
ToHTML("element.FadeTimeLeft = asmGlobal.TimeToFade;");
ToHTML("setTimeout([[asmQuot]]asmGlobal_animateFade([[asmQuot]] + new Date().getTime() + [[asmQuot]],'[[asmQuot]] + eid + [[asmQuot]]')[[asmQuot]], 33);");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_animateFade(lastTick, eid){");
ToHTML("var curTick = new Date().getTime();");
ToHTML("var elapsedTicks = curTick - lastTick;");
ToHTML("var element = $(eid);");
ToHTML("if (!element) { return; }");
ToHTML("if(element.FadeTimeLeft <= elapsedTicks){");
ToHTML("element.style.opacity = '1';");
ToHTML("element.style.filter = 'alpha(opacity = 100)';");
ToHTML("element.FadeState = element.FadeState == 1 ? 2 : -2;");
ToHTML("return;");
ToHTML("}");
ToHTML("element.FadeTimeLeft -= elapsedTicks;");
ToHTML("var newOpVal = element.FadeTimeLeft/asmGlobal.TimeToFade;");
ToHTML("newOpVal = 1 - newOpVal;");
ToHTML("element.style.opacity = newOpVal;");
ToHTML("element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';");
ToHTML("setTimeout([[asmQuot]]asmGlobal_animateFade([[asmQuot]] + curTick + [[asmQuot]],'[[asmQuot]] + eid + [[asmQuot]]')[[asmQuot]], 33);");
ToHTML("}");
ToHTML("function asmGlobal_Locations(Index,Title,Text)");
ToHTML("{");
ToHTML("this.Index = Index;");
ToHTML("this.Title = Title;");
ToHTML("this.Text = Text;");
ToHTML("}");
ToHTML("function asmGlobal_EscapeRegExp(str) {return str.replace(/[\\-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g,'\\\\$&');}");
ToHTML("function asmGlobal_NthField(str,delim,n,caseSens)");
ToHTML("{");
ToHTML("var cs = 'i';");
ToHTML("if (caseSens)");
ToHTML("{");
ToHTML("cs = '';");
ToHTML("}");
ToHTML("n--;");
ToHTML("var arr = str.split(new RegExp(asmGlobal_EscapeRegExp(delim),cs));");
ToHTML("if (n>(arr.length-1))");
ToHTML("{");
ToHTML("return '';");
ToHTML("}");
ToHTML("else");
ToHTML("{");
ToHTML("return arr[n];");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_SortNumberArray(x,y) {return x-y;}");
ToHTML("function asmGlobal_bitTest(bit){num=this;return ((num>>bit)%2!=0);}");
ToHTML("function asmGlobal_bitSet(bit){num=this;return num|1<<bit;}");
ToHTML("function asmGlobal_bitClear(bit){num=this;return num &~(1<<bit);}");
ToHTML("function asmGlobal_bitToggle(bit){num=this;return num.bitTest(bit)?num.bitClear(bit):num.bitSet(bit);}");
ToHTML("Number.prototype.bitTest = asmGlobal_bitTest;");
ToHTML("Number.prototype.bitSet = asmGlobal_bitSet;");
ToHTML("Number.prototype.bitClear = asmGlobal_bitClear;");
ToHTML("Number.prototype.bitToggle = asmGlobal_bitToggle;");
ToHTML("String.prototype.bitTest = asmGlobal_bitTest;");
ToHTML("String.prototype.bitSet = asmGlobal_bitSet;");
ToHTML("String.prototype.bitClear = asmGlobal_bitClear;");
ToHTML("String.prototype.bitToggle = asmGlobal_bitToggle;");
ToHTML("function asmGlobal_CloneArray(myarr) {return [].concat(myarr);}");
ToHTML("function asmGlobal_CloneObject(myobj) {return JSON.parse(JSON.stringify(myobj));}");
ToHTML("asmGlobal.Location = [];");
ToHTML("asmGlobal.PrevLocation;");
ToHTML("asmGlobal.CurLocation;");
ToHTML("function asmGlobal_$$time() {");       // время в секундах с 01.01.1970
ToHTML("var d = new Date();");
ToHTML("return Math.round(d.getTime()/1000);");
ToHTML("}");
ToHTML("Object.defineProperty(window,'$$time',{ get: asmGlobal_$$time });");
ToHTML("function asmGlobal_$$title() {");   // имя текущей локации
ToHTML("return asmGlobal.CurLocation.Title;");
ToHTML("}");
ToHTML("Object.defineProperty(window,'$$title',{ get: asmGlobal_$$title });");
ToHTML("function asmGlobal_$$from() {");  // имя предыдущей локации
ToHTML("return asmGlobal.PrevLocation.Title;");
ToHTML("}");
ToHTML("Object.defineProperty(window,'$$from',{ get: asmGlobal_$$from });");
ToHTML("function asmGlobal_getAsmSys_story(title) {"); // данные истории
ToHTML("var pass = asmGlobal_GetLocation(title);");
ToHTML("if (pass) {");
ToHTML("return pass.Text.trim();");
ToHTML("} else {");
ToHTML("return '';");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_$$storytitle() {"); // название игры
ToHTML("return asmGlobal_getAsmSys_story('storytitle');");
ToHTML("}");
ToHTML("Object.defineProperty(window,'$$storytitle',{ get: asmGlobal_$$storytitle });");
ToHTML("function asmGlobal_$$storysubtitle() {"); // описание игры
ToHTML("return asmGlobal_getAsmSys_story('storysubtitle');");
ToHTML("}");
ToHTML("Object.defineProperty(window,'$$storysubtitle',{ get: asmGlobal_$$storysubtitle });");
ToHTML("function asmGlobal_$$storyauthor() {"); // автор игры
ToHTML("return asmGlobal_getAsmSys_story('storyauthor');");
ToHTML("}");
ToHTML("Object.defineProperty(window,'$$storyauthor',{ get: asmGlobal_$$storyauthor });");
ToHTML("var $$choice = 0;"); // номер последнего варианта (1...n)
ToHTML("var $$select = 0;"); // номер последнего выбора (1...n)
ToHTML("var $$input = '';"); // последнее введённое значение в input()
ToHTML("var $$online = asmGlobal.isOnline;"); // игра онлайн true/false
ToHTML("var $$test = "+TestMode+";"); // режим тестирования true/false
ToHTML("asmGlobal.console = '';");
if (TestMode) {
ToHTML("function asmGlobal_toConsole() {");
ToHTML("var consoleText = '';");
ToHTML("consoleText += \"<div style='padding:1em 0;'>\";");
ToHTML("consoleText += \"<div class='updateButton' onclick='asmGlobal_showConsole(true);' style='height:1em;float:right;font-size:1.5em;line-height:1;'>⟳</div>\";");
ToHTML("var title = '';");
ToHTML("if (asmGlobal.CurLocation) { title = asmGlobal.CurLocation.Title.toLowerCase(); }");
ToHTML("consoleText += \"<div style='font-weight:bold;font-size:1.2em;'>\"+title+'</div>';");
ToHTML("consoleText += '<p></p>';");
ToHTML("for (var i=0; i<=(asmGlobal.Location.length-1); i++) {");
ToHTML("if (window['asmGlobal.eventNum'+i]!==undefined) {");
ToHTML("consoleText +='<i>'+asmGlobal.Location[i].Title.toLowerCase()+'</i>; ';");
ToHTML("}");
ToHTML("}");
ToHTML("consoleText += '<p></p>';");
ToHTML("var SysVars = ['"+SysVars.join("','")+"'];");
ToHTML("for (var i in SysVars) {");
ToHTML("consoleText += \"<span class='accentLogASM'><b>$$\"+SysVars[i]+'</b></span> = ';");
ToHTML("consoleText += JSON.stringify(window['$$'+SysVars[i]]);");
ToHTML("consoleText += '<br>';");
ToHTML("");
ToHTML("}");
ToHTML("consoleText += '<p></p>';");
ToHTML("for (var prop in asm) {");
ToHTML("consoleText += \"<span class='accentLogASM'><b>asm.\"+prop+'</b></span> = ';");
ToHTML("consoleText += JSON.stringify(asm[prop]);");
ToHTML("consoleText += '<br>';");
ToHTML("");
ToHTML("}");
ToHTML("consoleText += '<p></p>';");
ToHTML("var vars = [];");
ToHTML("for (var name in window) {");
ToHTML("if ( asmGlobal.stopNames.indexOf(name)==-1 && !(/^asmGlobal\./.test(name)) ) {");
ToHTML("var value = window[name];");
ToHTML("if (asmGlobal_isFunction(window[name])) {");
ToHTML("value = {};");
ToHTML("name = name+'()';");
ToHTML("}");
ToHTML("if (asmGlobal_isObject(value)) {"); // сериализуемый объект
ToHTML("var seen=[];");
ToHTML("value = JSON.stringify(value,function(key,val) {");
ToHTML("if (val!= null && typeof val=='object') {");
ToHTML("if (seen.indexOf(val)>=0) {");
ToHTML("return;");
ToHTML("}");
ToHTML("seen.push(val);");
ToHTML("}");
ToHTML("return val;");
ToHTML("});");
ToHTML("} else {");
ToHTML("value = JSON.stringify(value);");
ToHTML("}");
ToHTML("value += '';");
ToHTML("var max = 150;");
ToHTML("if (value.length>max) {");
ToHTML("value = value.substr(0,max-1)+'…';");
ToHTML("}");
ToHTML("value = value.replace(/</g,'&lt;').replace(/>/g,'&gt;');");
ToHTML("vars.push(\"<span class='accentLogASM'><b>\"+name+'</b></span> = '+value);");
ToHTML("}");
ToHTML("}");
ToHTML("vars.sort();");
ToHTML("consoleText += vars.join('<br>');");
ToHTML("asmGlobal.consoleDiv.innerHTML = consoleText + '</div>';");
ToHTML("}");
ToHTML("asmGlobal.consoleShow = false;");
ToHTML("function asmGlobal_showConsole(reload) {");
ToHTML("var output = function() {");
ToHTML("asmGlobal_toConsole();");
ToHTML("asmGlobal.consoleDiv.innerHTML += asmGlobal.console.replace(/\\n/g,'<br>');");
ToHTML("};");
ToHTML("if(reload) {");
ToHTML("output();");
ToHTML("asmGlobal_Animate(asmGlobal.consoleDiv,'effect_fade_fast');");
ToHTML("} else if(!asmGlobal.consoleShow) {"); // показать
ToHTML("output();");
ToHTML("asmGlobal.consoleShow = true;");
ToHTML("asmGlobal.consoleDiv.style.overflow = 'auto';");
ToHTML("asmGlobal.consoleDiv.style.height = '35%';");
ToHTML("} else {"); // скрыть
ToHTML("asmGlobal.consoleShow = false;");
ToHTML("asmGlobal.consoleDiv.style.overflow = 'hidden';");
ToHTML("asmGlobal.consoleDiv.style.height = '0';");
ToHTML("}");
ToHTML("}");
}
ToHTML("function asmGlobal_GetLocation(Title) {");
ToHTML("Title = Title.toString().toLowerCase().trim();");
ToHTML("for (var key in asmGlobal.Location) {");
ToHTML("var Loc = asmGlobal.Location[key];");
ToHTML("if (Loc.Title.toLowerCase().trim()==Title) {");
ToHTML("return Loc;");
ToHTML("}");
ToHTML("}");
ToHTML("return false;");
ToHTML("}");
ToHTML("function asmGlobal_GetIndexLocation(Title) {");
ToHTML("if (!Title) {return -1;}");
ToHTML("Title = Title.toString().toLowerCase().trim();");
ToHTML("var LocIndex = 0;");
ToHTML("for (var key in asmGlobal.Location) {");
ToHTML("var Loc = asmGlobal.Location[key];");
ToHTML("if (Loc.Title.toLowerCase().trim()==Title) {");
ToHTML("return LocIndex;");
ToHTML("}");
ToHTML("LocIndex++;");
ToHTML("}");
ToHTML("return -1;");
ToHTML("}");
if (style_view=='vis' || style_view=='bt') {
ToHTML("function asmGlobal_moveButtons(from,to) {");
ToHTML("var buttons = [].slice.call(from.querySelectorAll('button,.button,.buttonno,.buttonback'));");
ToHTML("var len = buttons.length;");
ToHTML("for (var i=0; i<len; i++) {");
ToHTML("to.appendChild(buttons[i]);");
ToHTML("}");
ToHTML("return len;");
ToHTML("}");
ToHTML("function asmGlobal_moveButtonsPage() {");
ToHTML("var buttonsList = $('buttonsList');");
ToHTML("if (buttonsList) {asmGlobal.pageDiv.removeChild(buttonsList);}");
ToHTML("buttonsList = document.createElement('div');");
ToHTML("buttonsList.id = 'buttonsList';");
ToHTML("asmGlobal.pageDiv.appendChild(buttonsList);");
ToHTML("if (asmGlobal_moveButtons(asmGlobal.printDiv,buttonsList)==0) {");
ToHTML("asmGlobal.pageDiv.removeChild(buttonsList);");
ToHTML("}");
ToHTML("}");
}
ToHTML("function asmGlobal_FlipPage() {");
ToHTML("var asmGlobal_AnimatePage = function(elem) {");
ToHTML("var time = asmGlobal.TimeToFade;");
if (style_view=='vis') {
ToHTML("var style = 'overflow';");
} else {
ToHTML("var style = 'overflowX';");
}
ToHTML("var overflow = elem.parentNode.style[style];");
ToHTML("elem.parentNode.style[style] = 'hidden';");
ToHTML("elem.style.WebkitAnimationDuration = time+'ms';");
ToHTML("elem.style.animationDuration = time+'ms';");
ToHTML("asmGlobal_Animate(elem,asmGlobal_getEffectName(asmGlobal.TextEffect),function() {");
ToHTML("elem.parentNode.style[style] = overflow;");
ToHTML("});");
ToHTML("};");
if (style_view=='vis' || style_view=='bt') {
ToHTML("asmGlobal.printDiv.className = asmGlobal.printDiv.className.replace(/effect_flash/g,'').trim();");
ToHTML("var buttonsList = $('buttonsList');");
ToHTML("asmGlobal_moveButtonsPage();");
}
if (style_view=='vis') {
ToHTML("var buttonsList = $('buttonsList');");
ToHTML("if (buttonsList) {buttonsList.style.display = 'none';}");
ToHTML("asmGlobal.printContDiv.onclick = function() {");
ToHTML("if (asmGlobal.typer.typing) {");
ToHTML("asmGlobal.typer.stop();");
ToHTML("} else {");
ToHTML("asmGlobal_firstButtonClick();");
ToHTML("}");
ToHTML("};");
ToHTML("if (asmGlobal.isAnimation && asmGlobal.animation_enable && asmGlobal.TimeToFade>0) {");
ToHTML("asmGlobal_AnimatePage(asmGlobal.printContDiv);");
ToHTML("asmGlobal.typer.start();");
ToHTML("} else {");
ToHTML("asmGlobal.typer.stop();");
ToHTML("}");
} else if (style_view=='bt') {
ToHTML("if (asmGlobal.isAnimation && asmGlobal.animation_enable) {");
ToHTML("asmGlobal_AnimatePage(asmGlobal.printContDiv);");
ToHTML("if (buttonsList) {");
ToHTML("asmGlobal_Animate(buttonsList,'effect_scale');");
ToHTML("}");
ToHTML("}");
} else {
ToHTML("if (asmGlobal.isAnimation && asmGlobal.animation_enable && asmGlobal.TimeToFade>0) {");
ToHTML("asmGlobal_AnimatePage(asmGlobal.printDiv);");
ToHTML("} else {");
ToHTML("asmGlobal_fade(asmGlobal.printDiv);");
ToHTML("}");
}
ToHTML("}"); // asmGlobal_FlipPage
ToHTML("asmGlobal.Output = {");
ToHTML("string: '',");
ToHTML("div: '',");
ToHTML("disabledIDs: [],");
ToHTML("print: function() {");
ToHTML("this.div.innerHTML = this.string;");
ToHTML("for (var i in this.disabledIDs) {");
ToHTML("var nolink = $(this.disabledIDs[i]);");
ToHTML("if (nolink && nolink.className.substr(-2)!='no') {");
ToHTML("nolink.className += 'no';"); // нажатые ссылки [+]
ToHTML("}");
ToHTML("}");
if (style_view=='vis' || style_view=='bt') {
ToHTML("var divs = ['print','printAddText','menuInner','printTitle'];");
ToHTML("var hides = ['printCont','printAddCont','menu','printTitle'];"); // какие скрывать
ToHTML("var hideDiv = hides[divs.indexOf(this.div.id)];");
ToHTML("if (!hideDiv) {");
ToHTML("hideDiv = this.div;");
ToHTML("} else {");
ToHTML("hideDiv = $(hideDiv);");
ToHTML("}");
ToHTML("var foo = document.createElement('div');");
ToHTML("foo.innerHTML = this.div.innerHTML;");
ToHTML("if (this.div.id=='print') {");
ToHTML("asmGlobal_moveButtons(foo,document.createElement('div'));");
ToHTML("}");
ToHTML("if (foo.textContent.trim()=='' && foo.querySelectorAll('img,video').length==0) {");
ToHTML("hideDiv.style.display = 'none';"); // нет текста, скрываем блок
ToHTML("return;");
ToHTML("} else {");
ToHTML("hideDiv.style.display = 'block';");
ToHTML("}");
}
ToHTML("if (asm.grammar) {");
ToHTML("var mono = false;");
ToHTML("var parentNodeMono = function(node) {");
ToHTML("node = node.parentElement;");
ToHTML("if (!node) {");
ToHTML("mono = false;");
ToHTML("return;");
ToHTML("}");
ToHTML("var tag = node.tagName.toLowerCase();");
ToHTML("if (tag=='code' || tag=='tt') {");
ToHTML("mono = true;");
ToHTML("return;");
ToHTML("} else {");
ToHTML("parentNodeMono(node);");
ToHTML("}");
ToHTML("};");
ToHTML("var replaceTextNodes = function(node) {");
ToHTML("for (var node=node.firstChild; node; node=node.nextSibling) {");
ToHTML("if (node.nodeType==3) {");
ToHTML("var s = node.nodeValue;");
ToHTML("if (s.trim()) {");
ToHTML("mono = false;");
ToHTML("parentNodeMono(node);");
ToHTML("if (!mono && !/https?:\\/\\//i.test(s.trim())) {");
ToHTML("s = s.replace(/(^\\s*?)-\\s*?/g,'$1— ');"); // тире в начале строки
ToHTML("s = s.replace(/(\\s+?)-(\\s+?)/g,'$1—$2');"); // тире в тексте
ToHTML("s = s.replace(/\\s*([.,;:?!])\\s*([^!?\"»)])/g,'$1 $2');"); // пробелы вокруг знаков пунктуации
ToHTML("for (var i=0; i<2; i++) {");
ToHTML("s = s.replace(/(\\d[.,]) (\\d)/g,'$1$2');"); // за исключением цифра.цифра
ToHTML("}");
ToHTML("node.nodeValue = s;");
ToHTML("}");
ToHTML("}");
ToHTML("} else {");
ToHTML("replaceTextNodes(node);");
ToHTML("}");
ToHTML("}");
ToHTML("};");
ToHTML("replaceTextNodes(this.div);");
ToHTML("}");
ToHTML("asmGlobal_ImagesOnError(this.div);");
ToHTML("},");
ToHTML("};");
ToHTML("function asmGlobal_ToText(s,fromstart,div,now) {");
ToHTML("var bakDiv = asmGlobal.Output.div;");
ToHTML("if (!div) {");
ToHTML("asmGlobal.Output.div = asmGlobal.printDiv;");
ToHTML("} else {");
ToHTML("asmGlobal.Output.div = div;");
ToHTML("}");
ToHTML("var bak = asmGlobal.Output.string;");
ToHTML("if (fromstart) {");
ToHTML("asmGlobal.Output.string = s;");
ToHTML("} else {");
ToHTML("asmGlobal.Output.string += s;");
ToHTML("}");
ToHTML("if (now) {");
ToHTML("asmGlobal.Output.print();");
ToHTML("asmGlobal.Output.string = bak;");
ToHTML("asmGlobal.Output.div = bakDiv;");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_PrintLocation(Title,replay) {");
ToHTML("if (!Title) {return false;}");
ToHTML("Title = Title.toString();");
ToHTML("if (Title.indexOf('://')!=-1) {");
ToHTML("window.open(Title);");
ToHTML("} else {");
ToHTML("var Loc = asmGlobal_GetLocation(Title);");
ToHTML("if (Loc!=false) {");
ToHTML("asmGlobal_closeWinds();");
ToHTML("if (!replay) {");
ToHTML("asmGlobal.PrevLocation = asmGlobal.CurLocation;");
ToHTML("asmGlobal.CurLocation = Loc;");
ToHTML("}");
ToHTML("asmGlobal_showPrintAdd(false);");
ToHTML("asmGlobal_toVisitedList(asmGlobal_GetIndexLocation(Title));");
ToHTML("if (asmGlobal_isFunction(Loc.Text)) {");
ToHTML("asmGlobal_ToText('',true);");
ToHTML("Loc.Text();");
ToHTML("asmGlobal_setClickEffect();");
ToHTML("} else {");
ToHTML("asmGlobal_ToText(Loc.Text,true);");
ToHTML("}");
ToHTML("asmGlobal.Output.print();");
ToHTML("asmGlobal.Output.disabledIDs = [];");
ToHTML("asmGlobal_scrollDiv();");
ToHTML("if (Title.toLowerCase()!='storymenu') {");
ToHTML("var pp = document.createElement('p');");
ToHTML("asmGlobal.printDiv.insertBefore(pp.cloneNode(),asmGlobal.printDiv.firstChild);"); // отступ сверху
ToHTML("asmGlobal.printDiv.appendChild(pp);"); // отступ снизу
ToHTML("}");
ToHTML("asmGlobal_FlipPage();");
if (TestMode) {
ToHTML("asmGlobal_toConsole();");
ToHTML("if (asmGlobal.consoleShow) {");
ToHTML("asmGlobal_showConsole(true);");
ToHTML("}");
}
ToHTML("} else {");
ToHTML("asmGlobal_LocNotFound(Title);");
ToHTML("}");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_DisplayLocation(Title,forceOutput) {");
ToHTML("if (!Title) {return false;}");
ToHTML("Title = Title.toString();");
ToHTML("if (asmGlobal.CurLocation && asmGlobal.CurLocation.Title.toLowerCase()==Title.toLowerCase() && asmGlobal.printDiv!=asmGlobal.printAddText) {return;}"); // чтобы не было зацикливания
ToHTML("if (Title.indexOf('://')!=-1) {");
ToHTML("} else {");
ToHTML("var Loc = asmGlobal_GetLocation(Title);");
ToHTML("if (Loc!==false) {");
ToHTML("asmGlobal_toVisitedList(asmGlobal_GetIndexLocation(Title));");
ToHTML("if (asmGlobal_isFunction(Loc.Text)) {");
ToHTML("Loc.Text();");
ToHTML("} else {");
ToHTML("asmGlobal_ToText(Loc.Text);");
ToHTML("}");
ToHTML("if (forceOutput) {");
ToHTML("asmGlobal.Output.print();");
ToHTML("}");
if (TestMode) {
ToHTML("asmGlobal_toConsole();");
ToHTML("if (asmGlobal.consoleShow) {");
ToHTML("asmGlobal_showConsole(true);");
ToHTML("}");
}
ToHTML("}");
ToHTML("else {");
ToHTML("asmGlobal_LocNotFound(Title);");
ToHTML("}");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_PopupLocation(Title) {");
ToHTML("if (asmGlobal_GetLocation(Title)) {");
ToHTML("asmGlobal.popupPassage = Title;");
ToHTML("asmGlobal.printDiv = asmGlobal.printAddText;");
ToHTML("asmGlobal_ToText('',true);");
ToHTML("asmGlobal_DisplayLocation(Title,true);");
ToHTML("asmGlobal_ToText('',false);");
ToHTML("asmGlobal.printDiv = $('print');");
ToHTML("asmGlobal_showPrintAdd(true);");
ToHTML("asmGlobal_scrollDiv(asmGlobal.printAdd);");
ToHTML("} else {");
ToHTML("asmGlobal.popupPassage = false;");
ToHTML("asmGlobal_LocNotFound(Title);");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_Back() {");
ToHTML("if (asmGlobal.PrevLocation) {");
ToHTML("asmGlobal_PrintLocation(asmGlobal.PrevLocation.Title);");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_setAudioPath(path,loop) {");
ToHTML("if (!path) {");
ToHTML("asmGlobal.musicAudio.loop = false;");
ToHTML("asmGlobal.musicAudio.src = 'data:audio/mpeg;base64,SUQzAwAAAAAAFlRFTkMAAAAMAAAAQW1hZGV1cyBQcm//+5AEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABJbmZvAAAADwAAAAIAAATkAICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID//////////////////////////////////////////////////////////////////wAAADxMQU1FMy45OHIBqgAAAAAt/gAAFIAkBsBGAACAAAAEZPXRNx0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/+5AEAA/wAABpAAAACAAADSAAAAEAAAGkAAAAIAAANIAAAARMQU1FMy45OC4yVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVMQU1FMy45OC4yVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVX/+5IEvo/wAABpAAAACAAADSAAAAEAAAGkAAAAIAAANIAAAARVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVEFHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8=';");
ToHTML("} else {");
ToHTML("if (loop===false) {");
ToHTML("asmGlobal.musicAudio.loop = false;");
ToHTML("} else {");
ToHTML("asmGlobal.musicAudio.loop = true;");
ToHTML("}");
ToHTML("asmGlobal.musicAudio.src = asmGlobal_GetMediaPath(path);");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_audioPlayEvent() {");
ToHTML("if (asmGlobal.audio_enable && (asmGlobal.musicAudio.src.substr(-4)=='.mp3' || asmGlobal.musicAudio.src.substr(0,15)=='data:audio/mp3;')) {");
ToHTML("asmGlobal.AudioButton.style.display = 'inline-block';");
ToHTML("asmGlobal.AudioButton.style.opacity = 1;");
ToHTML("} else {");
ToHTML("asmGlobal.AudioButton.style.display = 'none';");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_audioPauseEvent() {");
ToHTML("asmGlobal.AudioButton.style.opacity = 0.5;");
ToHTML("}");
ToHTML("function asmGlobal_PlayPauseButton() {");
ToHTML("if (asmGlobal.musicAudio.paused) {");
ToHTML("asmGlobal.musicAudio.play();");
ToHTML("} else {");
ToHTML("asmGlobal.musicAudio.pause();");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_playMusic() {");
ToHTML("if (asmGlobal.audio_enable) {");
ToHTML("asmGlobal.musicAudio.play();");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_stopMusic() {");
ToHTML("asmGlobal.AudioButton.style.display = 'none';");
ToHTML("asmGlobal.musicAudio.pause();");
ToHTML("}");
ToHTML("function asmGlobal_getEffectName(effect) {");
ToHTML("if (effect==-1) {"); // random
ToHTML("return asmGlobal.effectNames[Math.floor(Math.random()*asmGlobal.effectNames.length)];");
ToHTML("} else {");
ToHTML("return asmGlobal.effectNames[effect];");
ToHTML("}");
ToHTML("};");
ToHTML("function asmGlobal_setEffect(effect,forText) {");
ToHTML("effect = effect.toLowerCase().trim();");
ToHTML("var n = -1;");
ToHTML("if (effect!='random') {");
ToHTML("n = "+JSON.stringify(SpriteEffects)+".indexOf(effect);");
ToHTML("if (n==-1) {");
ToHTML("n = 0;");
ToHTML("}");
ToHTML("}");
ToHTML("if (!forText) {");
ToHTML("asmGlobal.SpriteEffect = n;");
ToHTML("} else {");
ToHTML("asmGlobal.TextEffect = n;");
ToHTML("}");
ToHTML("}");
ToHTML("asmGlobal.Events = [];");
ToHTML("function asmGlobal_startEvent(locTitle,timerSec)");
ToHTML("{");
ToHTML("var locIndex = asmGlobal_GetIndexLocation(locTitle);");
ToHTML("if (locIndex!=-1)");
ToHTML("{");
ToHTML("asmGlobal_stopEvent(locTitle);");
ToHTML("if (window['asmGlobal.eventNum'+locIndex]===undefined)");
ToHTML("{");
ToHTML("asmGlobal.Events.push(asmGlobal_GetIndexLocation(locTitle)+':'+timerSec);"); // добавляем в массив таймеров
ToHTML("window['asmGlobal.eventNum'+locIndex] = setInterval (function() { asmGlobal_DisplayLocation(locTitle,true); },timerSec*1000);");
ToHTML("}");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_stopEvent(locTitle)");
ToHTML("{");
ToHTML("var locIndex = asmGlobal_GetIndexLocation(locTitle);");
ToHTML("if (locIndex!=-1)");
ToHTML("{");
ToHTML("clearInterval(window['asmGlobal.eventNum'+locIndex]);");
ToHTML("window['asmGlobal.eventNum'+locIndex] = undefined;");
ToHTML("for (var i=0; i<=(asmGlobal.Events.length-1); i++)");
ToHTML("{");
ToHTML("var curEvent = asmGlobal.Events[i]; var curEventArr = curEvent.split(':'); curEvent = curEventArr[0];");
ToHTML("if (curEvent==asmGlobal_GetIndexLocation(locTitle)) { asmGlobal.Events.splice(i,1); break; }"); // удаляем из массива
ToHTML("}");
ToHTML("");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_stopAllEvents() {");
ToHTML("asmGlobal.Events.length = 0;"); // очищаем массив
ToHTML("for (var i=0; i<=(asmGlobal.Location.length-1); i++) {");
ToHTML("if (window['asmGlobal.eventNum'+i]!==undefined) {");
ToHTML("clearInterval(window['asmGlobal.eventNum'+i]);");
ToHTML("window['asmGlobal.eventNum'+i] = undefined;");
ToHTML("}");
ToHTML("}");
ToHTML("for (var i=1; i<99999; i++) {");
ToHTML("window.clearInterval(i);"); // хак для остановки всех остальных таймеров
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_SetAvatar(src) {");
ToHTML("asmGlobal.avatarBlock.innerHTML = '';");
ToHTML("if (src) {");
ToHTML("asmGlobal.avatarBlock.innerHTML = \"<img class='avatar' onload=\\[[asmQuot]]asmGlobal_goodImageShow(this);this.style.visibility='visible';if(asmGlobal.isAnimation && asmGlobal.animation_enable){asmGlobal_Animate(this,'effect_avatar');}\\[[asmQuot]] src=\"+asmGlobal_GetFileData(src).src+\">\";");
ToHTML("}");
ToHTML("}");
function getRandID(type) {
if (type=='+') {
return " id='"+new Date().getTime()+Math.random().toString()+"'";
} else {
return '';
}
}
for (var i=0; i<LocNum.length; i++) {
var Location = LocationArr[LocNum[i]];
var LocTitle = Location.Title;
var LocText = Location.Text.trim();
if (!SimpleLocation(LocTitle)) {
LocText = RemoveComments(LocText);
var reg = '\\[\\[([\\+\\-\\*]?)([^\\|]*?)\\s*?(\\|\\s*?([^|\\r\\n]*?))?({([^{}]+)})?\\s*?\\]\\]';
var regex = new RegExp('^(.*?)'+reg+'(.*?)$','gm');
LocText = LocText.replace(regex,
function(match,p1,p2,p3,p4,p5,p6,p7,p8) {
p3 = p3.replace(/["']/g,'');
if (p1.trim()=='\\' && p8.trim()=='') { // кнопка
if (!p7) {
p7 = '';
}
if (!p5) {
p5 = '';
}
return p1+"<span"+getRandID(p2)+" class=button onclick=\\[[asmQuot]]asmGlobal_plinks(this,&quot;"+p2+"&quot;,&quot;"+p3+"&quot;,&quot;"+p5+"&quot;,function(){"+p7+"},true);event.stopPropagation();\\[[asmQuot]]>"+p3+"</span>"+p8;
} else { // ссылка
regex = new RegExp(reg,'gm');
return match.replace(regex,
function(match,p1,p2,p3,p4,p5,p6) {
if (!p1) {p1 = '';}
if (!p2) {p2 = '';}
if (!p4) {p4 = '';}
if (!p6) {p6 = '';}
return "<span"+getRandID(p1)+" class=plink onclick=\\[[asmQuot]]asmGlobal_plinks(this,&quot;"+p1+"&quot;,&quot;"+p2+"&quot;,&quot;"+p4+"&quot;,function(){"+p6+"},false);event.stopPropagation();\\[[asmQuot]]>"+p2+"</span>";
}
);
}
}
);
}
var ParsedLocText = '';
if (SimpleLocation(LocTitle)) {
ParsedLocText = LocText.replace(/"/g,'&quot;');
ParsedLocText = "[[asmQuot]]"+ParsedLocText+"[[asmQuot]]";
} else {
ParsedLocText = LocText;
ParsedLocText = ParsedLocText.replace(/^\s*?\\(.*?)$/gm,function(match,m1){return "print(\""+m1.replace(/"/g,"&quot;").trim()+"\",true)"});
ParsedLocText = ParsedLocText.replace(/([\r\n])+/g,'\n').trim();
ParsedLocText = ParsedLocText.replace(/^([\s\S]+?[^\{\(\[;,])\s*?$/gm,'$1;');
ParsedLocText = ParsedLocText.replace(/([\t\r\n])+/g,'').trim();
if (ParsedLocText) {
ParsedLocText = "function(){try{"+ParsedLocText+"}catch(e){asmGlobal_errorJSCode(e)}}";
} else {
ParsedLocText = "function(){}";
}
}
ToHTML("asmGlobal.Location.push(new asmGlobal_Locations("+i+",\""+LocTitle+"\","+ParsedLocText+"));");
}
ToHTML("function asmGlobal_errorJSCode(e) {");
ToHTML("if (e.message!='goto exception') {");
ToHTML("console.log(e.name+': '+e.message);");
if (OnlyPassageNum==-1) {
ToHTML("log(\"<span class='accentLogASM'>\"+'"+Lang.Error+"'+': '+e.message+'</span>',true);");
}
ToHTML("}");
ToHTML("}");
var date = new Date();
ToHTML("asmGlobal.buildInfo = {label:'"+date.getTime()+Math.random()+"', date:'"+date.getDate()+'.'+(date.getMonth()+1)+'.'+date.getFullYear()+"'};");
ToHTML("asmGlobal.b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';");
ToHTML("function asmGlobal_base64encode(str) {");
ToHTML("str = unescape(encodeURIComponent(str));");
ToHTML("var b64encoded = '';");
ToHTML("var chr1, chr2, chr3;");
ToHTML("var enc1, enc2, enc3, enc4;");
ToHTML("for (var i=0; i<str.length;) {");
ToHTML("chr1 = str.charCodeAt(i++);");
ToHTML("chr2 = str.charCodeAt(i++);");
ToHTML("chr3 = str.charCodeAt(i++);");
ToHTML("enc1 = chr1 >> 2;");
ToHTML("enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);");
ToHTML("enc3 = isNaN(chr2) ? 64:(((chr2 & 15) << 2) | (chr3 >> 6));");
ToHTML("enc4 = isNaN(chr3) ? 64:(chr3 & 63);");
ToHTML("b64encoded += asmGlobal.b64chars.charAt(enc1) + asmGlobal.b64chars.charAt(enc2) + asmGlobal.b64chars.charAt(enc3) + asmGlobal.b64chars.charAt(enc4);");
ToHTML("}");
ToHTML("return b64encoded;");
ToHTML("}");
ToHTML("function asmGlobal_base64decode(str) {");
ToHTML("var b64decoded = '';");
ToHTML("var chr1, chr2, chr3;");
ToHTML("var enc1, enc2, enc3, enc4;");
ToHTML("str = str.replace(/[^a-z0-9+/=]/gi, '');");
ToHTML("for (var i=0; i<str.length;) {");
ToHTML("enc1 = asmGlobal.b64chars.indexOf(str.charAt(i++));");
ToHTML("enc2 = asmGlobal.b64chars.indexOf(str.charAt(i++));");
ToHTML("enc3 = asmGlobal.b64chars.indexOf(str.charAt(i++));");
ToHTML("enc4 = asmGlobal.b64chars.indexOf(str.charAt(i++));");
ToHTML("chr1 = (enc1 << 2) | (enc2 >> 4);");
ToHTML("chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);");
ToHTML("chr3 = ((enc3 & 3) << 6) | enc4;");
ToHTML("b64decoded = b64decoded + String.fromCharCode(chr1);");
ToHTML("if (enc3 < 64) {");
ToHTML("b64decoded += String.fromCharCode(chr2);");
ToHTML("}");
ToHTML("if (enc4 < 64) {");
ToHTML("b64decoded += String.fromCharCode(chr3);");
ToHTML("}");
ToHTML("}");
ToHTML("return decodeURIComponent(escape(b64decoded));");
ToHTML("}");
ToHTML("function asmGlobal_urlencode(str)");
ToHTML("{");
ToHTML("str = (str+'').toString();");
ToHTML("return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\\(/g, '%28').replace(/\\)/g, '%29').replace(/\\*/g, '%2A').replace(/%20/g, '+');");
ToHTML("}");
ToHTML("asmGlobal.filename = window.location.pathname.substring(window.location.pathname.lastIndexOf('/')+1).trim();");
ToHTML("if (!asmGlobal.filename) {asmGlobal.filename='test';}");
ToHTML("function asmGlobal_inLibNow()");
ToHTML("{");
ToHTML("if (!navigator.onLine) {return false;}");
ToHTML("var myhost = window.location.hostname;");
ToHTML("if (myhost=='hyperbook.ru' || myhost=='ifiction.net' || myhost=='novels.ru') {");
ToHTML("if (asmGlobal.filename!='test') {");
ToHTML("return true;");
ToHTML("}");
ToHTML("else {");
ToHTML("return false;");
ToHTML("}");
ToHTML("}");
ToHTML("else {");
ToHTML("return false;");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_getXmlHttp(){");
ToHTML("var xmlhttp;");
ToHTML("try {");
ToHTML("xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');");
ToHTML("} catch (e) {");
ToHTML("try {");
ToHTML("xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');");
ToHTML("} catch (E) {");
ToHTML("xmlhttp = false;");
ToHTML("}");
ToHTML("}");
ToHTML("if (!xmlhttp && typeof XMLHttpRequest!='undefined') {");
ToHTML("xmlhttp = new XMLHttpRequest();");
ToHTML("}");
ToHTML("return xmlhttp;");
ToHTML("}");
ToHTML("function asmGlobal_getServerData(url)");
ToHTML("{");
ToHTML("var xmlhttp = asmGlobal_getXmlHttp();");
ToHTML("xmlhttp.open('GET', url, false);");
ToHTML("xmlhttp.send(null);");
ToHTML("return xmlhttp.responseText;");
ToHTML("}");
ToHTML("function asmGlobal_putServerData(url,data)");
ToHTML("{");
ToHTML("var xmlhttp = asmGlobal_getXmlHttp();");
ToHTML("xmlhttp.open('POST', url, false);");
ToHTML("xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-asmGlobal_urlencoded; charset=UTF-8');");
ToHTML("xmlhttp.send(data);");
ToHTML("if(xmlhttp.status == 200)");
ToHTML("{");
ToHTML("return xmlhttp.responseText;");
ToHTML("}");
ToHTML("else");
ToHTML("{");
ToHTML("return '';");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_SavedList(save,savesList)");
ToHTML("{");
ToHTML("var save_slots = 6;");
ToHTML("savesList = [];");
ToHTML("var item;");
ToHTML("if (asmGlobal_inLibNow()) {"); // из библиотеки
ToHTML("var url = 'https://'+window.location.hostname+'/command.php?login='+asmGlobal_urlencode(asmGlobal_getCookie('login'))+'&password='+asmGlobal_urlencode(asmGlobal_getCookie('password'))+'&com=savedstorylist&value='+asmGlobal.filename;");
ToHTML("savesList = asmGlobal_getServerData(url).split(',');");
ToHTML("}");
ToHTML("else {"); // локальный
ToHTML("for (var i=1; i<=save_slots; i++) {");
ToHTML("if (asmGlobal_isLocalStorageAvailable()) {");
ToHTML("item = localStorage.getItem(i+'_'+asmGlobal.filename);");
ToHTML("}");
ToHTML("else {");
ToHTML("item = asmGlobal_getCookie(i+'_'+asmGlobal.filename);");
ToHTML("}");
ToHTML("if (item) {savesList.push('1');} else {savesList.push('');}");
ToHTML("}");
ToHTML("}");
ToHTML("var com = '';");
ToHTML("if (save) {com='asmGlobal_SaveStory';} else {com='asmGlobal_LoadStory';}");
ToHTML("var str = '';");
ToHTML("for (var i=1; i<=save_slots; i++) {");
ToHTML("if (savesList[i-1]) {");
ToHTML("if (save) {var savep='"+Lang.Overwrite+"';} else {var savep='"+Lang.HTMLLoad+"';}");
ToHTML("str += '<div><span class=plink onclick=\"asmGlobal_showPrefs(true);'+com+'('+i+');\">'+savep+'</span></div>';");
ToHTML("} else {");
ToHTML("if (save) {");
ToHTML("str += '<div><span class=plink onclick=\"asmGlobal_showPrefs(true);'+com+'('+i+');\">"+Lang.HTMLSave+"</span></div>';");
ToHTML("} else {");
ToHTML("str += '<div>"+Lang.Empty+"</div>';");
ToHTML("}");
ToHTML("}");
ToHTML("}");
ToHTML("return str;");
ToHTML("}");
ToHTML("function asmGlobal_SaveSuccess()");
ToHTML("{");
ToHTML("asmGlobal_AlertMessage('"+Lang.StorySaved+"');");
ToHTML("}");
ToHTML("function asmGlobal_SaveError()");
ToHTML("{");
ToHTML("asmGlobal_AlertMessage('"+Lang.StoryNotSaved+"');");
ToHTML("}");
ToHTML("function asmGlobal_SaveStory(slot_num)");
ToHTML("{");
ToHTML("if (slot_num===undefined) { slot_num = 1; };");
ToHTML("var status = '';");
ToHTML("if (asmGlobal_inLibNow()) {");
ToHTML("status = asmGlobal_SaveStoryLib(asmGlobal_SaveStoryData(),slot_num);"); // в библиотеку
ToHTML("}");
ToHTML("else {");
ToHTML("status = asmGlobal_SaveStoryLocal(asmGlobal_SaveStoryData(),slot_num);"); // локально
ToHTML("}");
ToHTML("if (status!='') {");
ToHTML("asmGlobal_SaveSuccess();");
ToHTML("}");
ToHTML("else {");
ToHTML("asmGlobal_SaveError();");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_SaveStoryLib(data,slot_num)");
ToHTML("{");
ToHTML("var url = 'https://'+window.location.hostname+'/command.php?login='+asmGlobal_urlencode(asmGlobal_getCookie('login'))+'&password='+asmGlobal_urlencode(asmGlobal_getCookie('password'))+'&com=savestory&value='+asmGlobal.filename+'&slot='+slot_num;");
ToHTML("return asmGlobal_putServerData(url,asmGlobal_SaveStoryData());");
ToHTML("}");
ToHTML("function asmGlobal_SaveStoryLocal(data,slot_num)");
ToHTML("{");
ToHTML("var savedOk = false;");
ToHTML("if (asmGlobal_isLocalStorageAvailable()) {");
ToHTML("localStorage.setItem(slot_num+'_'+asmGlobal.filename,data);");
ToHTML("if (localStorage.getItem(slot_num+'_'+asmGlobal.filename)==data) {savedOk=true;}");
ToHTML("} else {");
ToHTML("asmGlobal_setCookie(slot_num+'_'+asmGlobal.filename,data);");
ToHTML("if (asmGlobal_getCookie(slot_num+'_'+asmGlobal.filename)==data) {savedOk=true;}");
ToHTML("}");
ToHTML("if (savedOk) {");
ToHTML("return 'ok';");
ToHTML("}");
ToHTML("else {");
ToHTML("return '';");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_LoadStory(slot_num)");
ToHTML("{");
ToHTML("if (slot_num===undefined) { slot_num = 1; };");
ToHTML("var data = '';");
ToHTML("if (asmGlobal_inLibNow()) {");
ToHTML("data = asmGlobal_LoadStoryLib(slot_num);"); // из библиотеки
ToHTML("}");
ToHTML("else {");
ToHTML("data = asmGlobal_LoadStoryLocal(slot_num);"); // локально
ToHTML("}");
ToHTML("if (data) {");
ToHTML("asmGlobal_LoadStoryData(data);");
ToHTML("}");
ToHTML("else {");
ToHTML("asmGlobal_AlertMessage('"+Lang.StoryNotLoaded+"');");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_LoadStoryLib(slot_num)");
ToHTML("{");
ToHTML("var url = 'https://'+window.location.hostname+'/command.php?login='+asmGlobal_urlencode(asmGlobal_getCookie('login'))+'&password='+asmGlobal_urlencode(asmGlobal_getCookie('password'))+'&com=loadstory&value='+asmGlobal.filename+'&slot='+slot_num;");
ToHTML("return asmGlobal_getServerData(url);");
ToHTML("}");
ToHTML("function asmGlobal_LoadStoryLocal(slot_num)");
ToHTML("{");
ToHTML("if (asmGlobal_isLocalStorageAvailable()) {");
ToHTML("return localStorage.getItem(slot_num+'_'+asmGlobal.filename);");
ToHTML("} else {");
ToHTML("return asmGlobal_getCookie(slot_num+'_'+asmGlobal.filename);");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_SaveLoadWind(save,savesList) {");
ToHTML("if (!savesList) {");
ToHTML("var inner = asmGlobal_SavedList(save);");
ToHTML("} else {");
ToHTML("var inner = asmGlobal_SavedList(save,savesList);");
ToHTML("}");
ToHTML("if (inner) {");
ToHTML("asmGlobal.prefsDiv.innerHTML = inner;");
ToHTML("asmGlobal.prefsDiv.style.display = 'block';");
ToHTML("asmGlobal_Animate(asmGlobal.prefsDiv,'effect_fade_fast');");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_SaveStoryData() {");
ToHTML("var Save = {};");
ToHTML("Save.buildInfo = asmGlobal.buildInfo;"); // метка сборки
ToHTML("Save.asm = asm;"); // глобальные настройки пользователя
ToHTML("Save.console = asmGlobal.console;"); // содержимое лога
ToHTML("Save.curPassage = asmGlobal.CurLocation.Title;"); // текущий параграф
ToHTML("Save.prvPassage = asmGlobal.PrevLocation.Title;"); // предыдущий параграф
ToHTML("Save.fontSize = asmGlobal.fontSize;"); // размер шрифта
ToHTML("Save.animationEnable = asmGlobal.animation_enable;"); // настройка анимации
ToHTML("Save.audioEnable = asmGlobal.audio_enable;"); // настройка аудио
ToHTML("Save.visitedList = asmGlobal.visitedList;"); // посещения параграфов
ToHTML("Save.music = asmGlobal.musicAudio.src;"); // музыка
ToHTML("Save.musicLoop = asmGlobal.musicAudio.loop;");
ToHTML("Save.video = asmGlobal.videoDiv.innerHTML;"); // видео
if (style_view=='vis' || style_view=='bt') {
ToHTML(""); // buttonsList
}
ToHTML("Save.text = asmGlobal.printDiv.innerHTML;"); // текст
ToHTML("Save.image = asmGlobal.printImage.src;"); // иллюстрация
ToHTML("Save.filters = asmGlobal.printImage.style.filter;"); // фильтры иллюстрации
ToHTML("Save.menu = asmGlobal.menuDiv.innerHTML;"); // содержимое меню
ToHTML("Save.title = asmGlobal.printTitle.innerHTML;"); // содержимое заголовка
ToHTML("Save.events = asmGlobal.Events;"); // таймеры
ToHTML("Save.timeToFade = asmGlobal.TimeToFade;"); // TimeToFade
ToHTML("Save.spriteEffect = asmGlobal.SpriteEffect;"); // SpriteEffect
ToHTML("Save.textEffect = asmGlobal.TextEffect;"); // TextEffect
ToHTML("Save.choice = $$choice;"); // номер последнего варианта
ToHTML("Save.select = $$select;"); // номер последнего выбора
ToHTML("Save.input = $$input;"); // последнее введённое значение в input()
ToHTML("Save.avatar = asmGlobal.avatarBlock.innerHTML;"); // текущая аватара
ToHTML("Save.vars = [];"); // значения переменных и функций пользователя
ToHTML("var names = asmGlobal_getUserVars();");
ToHTML("for (var i in names) {");
ToHTML("var name = names[i];");
ToHTML("var obj = window[name];");
ToHTML("var saveVar = {};");
ToHTML("saveVar.name  = name;");
ToHTML("if (obj && obj.parentNode && obj.parentNode==asmGlobal.spritesDiv) {"); // спрайт
ToHTML("saveVar.sprite = true;");
ToHTML("var props = ['left','right','top','bottom','width','height','opacity','filter'];");
ToHTML("for (var i in props) {");
ToHTML("saveVar[props[i]] = obj[props[i]];");
ToHTML("}");
ToHTML("}");
ToHTML("saveVar.value = JSON.stringify(obj, function(key,val) {");
ToHTML("if (asmGlobal_isFunction(val)) {");
ToHTML("return val.toString();");
ToHTML("}");
ToHTML("return val;");
ToHTML("});");
ToHTML("Save.vars.push(saveVar);");
ToHTML("}");
ToHTML("return asmGlobal_base64encode(JSON.stringify(Save));");
ToHTML("}");
ToHTML("function asmGlobal_LoadStoryData(data) {");
ToHTML("asmGlobal_closeWinds();");
ToHTML("var Save = JSON.parse(asmGlobal_base64decode(data));");
if (!TestMode) {
ToHTML("if (Save.buildInfo.label!=buildInfo.label) {"); // метка сборки
ToHTML("asmGlobal_AlertMessage('"+Lang.SaveNotComp+"'); return;");
ToHTML("}");
}
ToHTML("asm = Save.asm;"); // глобальные настройки пользователя
ToHTML("asmGlobal_stopAllEvents();");
ToHTML("asmGlobal.console = Save.console;"); // содержимое лога
ToHTML("asmGlobal.CurLocation = asmGlobal_GetLocation(Save.curPassage);"); // текущий параграф
ToHTML("if (Save.prvPassage) {"); // предыдущий параграф
ToHTML("asmGlobal.PrevLocation = asmGlobal_GetLocation(Save.prvPassage);");
ToHTML("} else {");
ToHTML("asmGlobal.PrevLocation = undefined;");
ToHTML("}");
ToHTML("asmGlobal.fontSize = Save.fontSize;"); // размер шрифта
ToHTML("asmGlobal.printDiv.style.fontSize = asmGlobal.fontSize+'em';");
ToHTML("asmGlobal.printAdd.style.fontSize = asmGlobal.fontSize+'em';");
ToHTML("asmGlobal.animation_enable = Save.animationEnable;"); // настройка анимации
ToHTML("asmGlobal.videoDiv.innerHTML = Save.video;"); // видео
ToHTML("asmGlobal.audio_enable = Save.audioEnable;"); // настройка аудио
ToHTML("asmGlobal_setAudioPath(Save.music,Save.musicLoop); asmGlobal_playMusic();"); // музыка
ToHTML("asmGlobal.visitedList = Save.visitedList;"); // посещения параграфов
ToHTML("asmGlobal.printDiv.innerHTML = Save.text;"); // текст
ToHTML("asmGlobal_FlipPage();");
if (style_view=='vis' || style_view=='bt') {
ToHTML("asmGlobal.typer.stop();");
}
ToHTML("asmGlobal.printImage.src = Save.image;"); // иллюстрация
ToHTML("asmGlobal.printImage.style.filter = Save.filters;"); // текущие фильтры
ToHTML("asmGlobal.menuDiv.innerHTML = Save.menu;"); // содержимое меню
ToHTML("asmGlobal.printTitle.innerHTML = Save.title;"); // содержимое заголовка
ToHTML("var eventsArr = Save.events;"); // таймеры
ToHTML("for (var i=0; i<eventsArr.length; i++) {");
ToHTML("var eventArr = eventsArr[i].split(':');");
ToHTML("asmGlobal_startEvent(asmGlobal.Location[eventArr[0]].Title,eventArr[1]);");
ToHTML("}");
ToHTML("asmGlobal.TimeToFade = Save.timeToFade;"); // TimeToFade
ToHTML("asmGlobal.SpriteEffect = Save.spriteEffect;"); // SpriteEffect
ToHTML("asmGlobal.TextEffect = Save.textEffect;"); // TextEffect
ToHTML("$$choice = Save.choice;"); // номер последнего варианта
ToHTML("$$select = Save.select;"); // номер последнего выбора
ToHTML("$$input = Save.input;"); // последнее введённое значение в input()
ToHTML("asmGlobal.avatarBlock.innerHTML = Save.avatar;"); // текущая аватара
ToHTML("asmGlobal_resetUserVars();"); // сброс переменных
ToHTML("asmGlobal.spritesDiv.innerHTML = '';"); // удаление спрайтов
ToHTML("for (var i in Save.vars) {"); // значения переменных
ToHTML("var name = Save.vars[i].name;");
ToHTML("var value = Save.vars[i].value;");
ToHTML("window[name] = JSON.parse(value, function(key,val) {");
ToHTML("if (val && val.toString().substr(0,8)=='function') {");
ToHTML("return eval('('+val+')');");
ToHTML("}");
ToHTML("return val;");
ToHTML("});");
ToHTML("if (Save.vars[i].sprite) {"); // спрайт
ToHTML("var spr = window[name];");
ToHTML("spr = sprite(window[name].mypath);");
ToHTML("spr.action = window[name].myaction;");
ToHTML("spr.drag   = window[name].mydrag;");
ToHTML("var props = ['left','right','top','bottom','width','height','opacity','filter'];");
ToHTML("for (var j in props) {");
ToHTML("spr[props[j]] = Save.vars[i][props[j]];");
ToHTML("}");
ToHTML("spr.show();");
ToHTML("}");
ToHTML("}");
if (TestMode) {
ToHTML("if (asmGlobal.consoleShow) {");
ToHTML("asmGlobal_showConsole(true);");
ToHTML("}");
}
ToHTML("asmGlobal.showCover = false;");
ToHTML("}");
ToHTML("function asmGlobal_getUserVars() {");
ToHTML("var names = [];");
ToHTML("for (var name in window) {");
ToHTML("if (asmGlobal.stopNames.indexOf(name)==-1) {");
ToHTML("names.push(name);");
ToHTML("}");
ToHTML("}");
ToHTML("return names;");
ToHTML("}");
ToHTML("function asmGlobal_resetUserVars() {");
ToHTML("var names = asmGlobal_getUserVars();");
ToHTML("for (var i in names) {");
ToHTML("window[names[i]] = undefined;");
ToHTML("}");
ToHTML("}");
ToHTML("function asmGlobal_NewGame() {");
ToHTML("asm = {");
for (var prop in asmProps) {
var value = asmProps[prop];
if (typeof value=='string') {
value = "'"+value+"'";
}
ToHTML(prop+':'+value+',');
}
ToHTML("};");
ToHTML("asmGlobal_stopAllEvents();");
ToHTML("document.title = $$storytitle;");
ToHTML("asmGlobal.console = '';");
ToHTML("asmGlobal.visitedList = [];");
ToHTML("asmGlobal.TimeToFade = "+TimeToFade+";");
ToHTML("$$choice = 0;");
ToHTML("$$input = '';");
ToHTML("asmGlobal_closeWinds();");
ToHTML("asmGlobal_ToText('',true);");
ToHTML("asmGlobal_setAudioPath(); asmGlobal_stopMusic();");
ToHTML("asmGlobal.printImage.style.filter = '';");
ToHTML("asmGlobal_ToText('',true,asmGlobal.menuDiv,true);");
ToHTML("asmGlobal.printAddText.innerHTML = '';");
ToHTML("asmGlobal_ToText('',true,asmGlobal.printTitle,true);");
ToHTML("asmGlobal.popupPassage = false;");
ToHTML("asmGlobal.printImage.src = asmGlobal.pictureDefault;");
ToHTML("sprites(true);");
ToHTML("asmGlobal_scrollDiv();");
ToHTML("asmGlobal.CurLocation = '';");
if (style_view=='vis' || style_view=='bt') {
ToHTML("asmGlobal_SetAvatar();");
}
ToHTML("asmGlobal_resetUserVars();");
if (OnlyPassageNum==-1) {
ToHTML("var StoryAuthor = asmGlobal_getAsmSys_story('storyauthor');");
ToHTML("var StoryTitle = asmGlobal_getAsmSys_story('storytitle');");
ToHTML("var StorySubtitle = asmGlobal_getAsmSys_story('storysubtitle');");
ToHTML("asmGlobal.pageDiv.style.display = 'none'; asmGlobal.toolbarDiv.style.display = 'none';");
ToHTML("asmGlobal.showCover = true;");
ToHTML("asmGlobal_showShadow(true);");
ToHTML("var layer = $('shadowlayer');");
ToHTML("layer.onclick = function() {");
ToHTML("if (asmGlobal.showCover) {");
ToHTML("asmGlobal_StartGame();");
ToHTML("};");
ToHTML("};");
ToHTML("layer.innerHTML = \"\
<table width='100%' height='100%' cellpadding='0' cellspacing='0'><tr><td valign='middle'>\
<div id='storyauthor'>\"+StoryAuthor+\"</div>\
<div id='storytitle'>\"+StoryTitle+\"</div>\
<div id='storysubtitle'>\"+StorySubtitle+\"</div>\
<div id='copyraxma' style='text-align:center;font-size:0.65em;position:absolute;bottom:1em;left:0;right:0;'><a class='plink' style='color:inherit;' href='https://axmajs.ru/' target='_blank' onclick='event.stopPropagation();'>\"+'"+Lang.CreatedBy+"'+\" AXMA&nbsp;Story&nbsp;Maker</a></div>\
</td></tr></table>\";\
");
ToHTML("var storyauthor = $('storyauthor');");
ToHTML("storyauthor.style.WebkitAnimationDuration = '5000ms';");
ToHTML("storyauthor.style.animationDuration = '5000ms';");
ToHTML("storyauthor.style.WebkitAnimationDelay = '1000ms';");
ToHTML("storyauthor.style.animationDelay = '1000ms';");
ToHTML("storyauthor.className = 'effect_fade';");
ToHTML("var storytitle = $('storytitle');");
ToHTML("storytitle.style.WebkitAnimationDuration = '5000ms';");
ToHTML("storytitle.style.animationDuration = '5000ms';");
ToHTML("storytitle.style.WebkitAnimationDelay = '3000ms';");
ToHTML("storytitle.style.animationDelay = '3000ms';");
ToHTML("storytitle.className = 'effect_fade';");
ToHTML("var storysubtitle = $('storysubtitle');");
ToHTML("storysubtitle.style.WebkitAnimationDuration = '5000ms';");
ToHTML("storysubtitle.style.animationDuration = '5000ms';");
ToHTML("storysubtitle.style.WebkitAnimationDelay = '5000ms';");
ToHTML("storysubtitle.style.animationDelay = '5000ms';");
ToHTML("storysubtitle.className = 'effect_fade';");
ToHTML("var copyraxma = $('copyraxma');");
ToHTML("if (copyraxma) {");
ToHTML("copyraxma.style.WebkitAnimationDuration = '5000ms';");
ToHTML("copyraxma.style.animationDuration = '5000ms';");
ToHTML("copyraxma.style.WebkitAnimationDelay = '7000ms';");
ToHTML("copyraxma.style.animationDelay = '7000ms';");
ToHTML("copyraxma.className = 'effect_fade';");
ToHTML("}");
ToHTML("layer.style.WebkitAnimationDelay = '12000ms';");
ToHTML("layer.style.animationDelay = '12000ms';");
ToHTML("layer.className = 'effect_flash';");
} else {
ToHTML("asmGlobal_StartGame();");
}
ToHTML("}"); // asmGlobal_NewGame()
ToHTML("function asmGlobal_StartGame()");
ToHTML("{");
if (OnlyPassageNum==-1) {
ToHTML("asmGlobal.musicAudio.play();"); // автостарт для тач-устройств
ToHTML("asmGlobal.showCover = false;");
ToHTML("asmGlobal.pageDiv.style.display = 'block';");
ToHTML("asmGlobal.toolbarDiv.style.display = 'block';");
ToHTML("asmGlobal_MenuInit();");
ToHTML("asmGlobal_PrintLocation('Start');");
} else {
ToHTML("asmGlobal_PrintLocation('"+LocationArr[OnlyPassageNum].Title+"');");
}
ToHTML("}");
ToHTML (ThemeBottom());
html = html.replace(/\[\[asmQuot\]\]/g,'"');
html = html.replace(/[\r\n]/g,'');
html = Lang.License + html;
MessageHide();
if (TestMode)
{
TargetFormat = TargetFormatBak;
VisualEventsStop();
mainDiv.style.display = 'none';
var iframe = document.createElement('iframe');
iframe.id = 'previewWin';
iframe.src = 'about:blank';
iframe.frameborder = 0;
iframe.scrolling = 'auto';
iframe.style.display = 'block';
document.body.appendChild(iframe);
previewWin = $('previewWin');
PreviewVisible = true;
Animate(previewWin,'effect_scale',function() {
closePreview.style.display = 'block';
Animate(closePreview,'effect_scale');
});
previewWin.contentWindow.focus();
html = html.replace(/<body(.*?)>/,"<body$1 onkeyup=\"if(event.keyCode==27){asmGlobal_MessageFromFrame('ClosePreview');}\">");
previewWin.contentWindow.document.open();
previewWin.contentWindow.document.write(html);
previewWin.contentWindow.document.close();
}
else
{
if (!PublishToInet)
{
Message(Lang.PleaseWait,true);
saveData(CommandServer('com='+TargetFormat),html,function(response) {
response = response.trim();
MessageHide();
if (response=='register')
{
SignInWindow();
}
else if (response=='needpaid')
{
AlertMessage(Lang.NeedPaidAccount+"<p></p><div class='plink' id='item0'>"+Lang.BuyPaidAccount+'</div>');
SetEvent('item0',function(){ShowWind(false);WindowOpen('https://axmajs.ru/buy/');});
}
else if (response=='')
{
Message(Lang.Error2);
}
else
{
var downloadWin = WindowOpen(CommandServer('com=download_html'),'asm_html');
}
});
}
else
{
if (!CheckRequired()) {
return false;
}
if (!TargetDesktop) {
var storytitle = GetLocByTitle('StoryTitle');
if (storytitle!=false) {
storytitle = storytitle.Text.replace(/<[^<>]+?>/g,' ').trim().toLowerCase();
}
var file_id = false;
Message(Lang.ListLoading,true);
setTimeout (function() {
saveData(Lang.Server()+'/include/user_files_asm.php','login='+urlencode(AuthLogin)+'&password='+urlencode(AuthPassword),function(files) {
if (files) {
files = files.split('\n');
for (var key in files) {
var item = files[key].split('[:73143:]');
var id = item[0].trim();
var title = item[1].trim().toLowerCase();
if (title==storytitle) {
file_id = id;
break;
}
}
}
if (file_id) {
SendPub(file_id);
}
else {
AreYouSure(SendPub,Lang.WantNewPub);
}
});
}, 1);
} else {
chrome_PublishToLib(html,LocationArr.length,GetLocByTitle('StoryTitle').Text.trim());
}
}
}
}
function CheckRequired()
{
var CheckLoc = ['Start','StoryTitle','StoryAuthor','StorySubtitle'];
for (var key in CheckLoc) {
var loc = GetLocByTitle(CheckLoc[key]);
if (!loc || loc.Text.trim()=='') {
AlertMessage(Lang.MissReqPass+' <b>'+CheckLoc[key]+'</b>');
return false;
}
}
return true;
}
function SendPub(file_id)
{
if (!file_id) {
file_id = '';
}
var data =
'login='+urlencode(AuthLogin)
+'&password='+urlencode(AuthPassword)
+'&files='+urlencode(html)
+'&filesType='+'html'
+'&source='+urlencode(CreateSaveData())
+'&file_id='+urlencode(file_id)
+'&title='+urlencode(GetLocByTitle('StoryTitle').Text)
+'&subtitle='+urlencode(GetLocByTitle('StorySubtitle').Text)
+'&author='+urlencode(GetLocByTitle('StoryAuthor').Text)
+'&lang='+LangCode
+'&passages='+LocationArr.length
+'&style='+style_view
+'&code=ASM_online';
if (html.length>(1024*1024*20)) {
AlertMessage(Lang.FileTooLarge);
return false;
}
Message(Lang.PleaseWait,true);
setTimeout (function() {
saveData(Lang.Server()+'/include/post.php',data,function(answer) {
html = '';
data = '';
if (answer=='') {
AlertMessage(Lang.ErrorPub+'<br>'+Lang.ErrorReadCode+': 1');
} else if (answer.substr(0,5)=='error') {
AlertMessage(Lang.ErrorPub+'<br>'+Lang.ErrorReadCode+': '+answer.substr(5));
} else {
AlertMessage(Lang.SuccessPub+"<p></p><a href='"+answer+"' target='_blank' id='item0'>"+answer+"</a>");
SetEvent('item0',function(){ShowWind(false);});
}
MessageHide();
});
}, 1);
}
function AddFileData(type,dataurl)
{
var tp = "";
if (type=='audio') {
tp = "audio/mpeg";
} else if (type=='image') {
tp = "image/png,image/jpeg,image/gif";
}
var handleDataFile = function(files,type) {
if (window.FileReader) {
var file = files[0];
$('fileSelector').value = '';
var reader = new FileReader();
reader.onload = function() {
var fileName = file.name.replace(/\..+?$/,'');
AddFileWind(type,reader.result,fileName);
}
reader.readAsDataURL(file);
}
};
var s = "<input type='file' id='fileSelector' accept='"+tp+"' style='display:none;'>";
if (dataurl) {
s += "<div id='file_preview'>"+FileDataPreview(type,dataurl)+"</div>";
s += "<p>"+Lang.FileName+"<br>";
s += "<input id='filename' type='text'>";
s += "<p><span class='button' id='item1' style='float:left;'>"+Lang.HTMLSave+"</span><span class='button' id='item2' style='float:right;'>"+Lang.FileAnother+"</span>";
} else {
s += "<div class='menu_item' id='item3'>"+Lang.FileSelect+"</div>";
}
mywindow_inner.innerHTML = s;
SetEvent('item1',function(){SaveFileData(dataurl,$('filename').value,type);});
SetEvent('item2',function(){ShowWind(false);AddFileData(type);});
SetEvent('item3',function(){SelectFile(type);});
$('fileSelector').onchange = function() {
handleDataFile(this.files,type);
};
if (!dataurl) {
SelectFile(type);
}
}
function FileDataPreview(type,dataurl)
{
var view = "";
if (type=='audio') {
view = "<audio controls><source src='"+dataurl+"' type='audio/mp3'></audio>";
} else if (type=='image') {
view = "<a download onclick='this.href=this.firstChild.src'><img src='"+dataurl+"' onload=\"\
var img = new Image();\
img.src = this.src;\
img.onload = function() {\
document.getElementById('show_image_size').innerHTML = img.width+'х'+img.height+'px, '+Math.ceil(img.src.length/1024)+'KB';\
};\
\"></a><p id='show_image_size'>"+Lang.ShowSize+"</p>";
}
return view;
}
function showImageSize(dataurl,elem)
{
var img = new Image();
img.src = dataurl;
img.onload = function() {
elem.innerHTML = img.width+'х'+img.height+'px, '+Math.ceil(img.src.length/1024)+'KB';
};
}
function FileDataList(type,onlynames)
{
var data = GetLocByTitle('StoryData');
if (data)
{
data = data.Text.replace(/\n+/,'\n').trim().split('\n');
}
var list = [];
for (var key in data)
{
var line = data[key];
if (line.indexOf('::')==-1)
{
continue;
}
line = line.split('::');
var id = line[0].trim().toLowerCase();
if (onlynames)
{
list.push(id);
}
else
{
var dataurl = line[1].trim();
var mytype = line[1].split(':')[1].split(';')[0].split('/')[0];
if (type!='all')
{
if (mytype==type)
{
list.push([id,dataurl,mytype]);
}
}
else
{
list.push([id,dataurl,mytype]);
}
}
}
return list.sort();
}
function FileDataWind(type,insert)
{
var s = '';
if (!insert)
{
s += "<div style='margin-bottom:8px;'>";
if (type=='all')
{
s += "<span class='accent'>"+Lang.FilesAll+"</span></div>";
s += "<span class='button leftBigButton' id='item1'>"+Lang.FilesImages+"</span>";
s += "<span class='button rightBigButton' id='item2'>"+Lang.FilesSounds+"</span>";
}
if (type=='image')
{
s += "<span class='accent'>"+Lang.FilesImages+"</span></div>";
s += "<span class='button leftBigButton' id='item3'>"+Lang.FilesSounds+"</span>";
s += "<span class='button rightBigButton' id='item4'>"+Lang.FilesAll+"</span>";
}
if (type=='audio')
{
s += "<span class='accent'>"+Lang.FilesSounds+"</span></div>";
s += "<span class='button leftBigButton' id='item5'>"+Lang.FilesImages+"</span>";
s += "<span class='button rightBigButton' id='item6'>"+Lang.FilesAll+"</span>";
}
s += "<div style='clear:both;margin-bottom:10px;'></div>";
}
var list = FileDataList(type);
if (list.length>0)
{
for (var key in list)
{
var id = list[key][0];
var dataurl = list[key][1];
if (type!='all')
{
var mytype = type;
}
else
{
var mytype = list[key][2];
}
var view = "<div class='data_title'>"+id+'</div>';
if (mytype=='image')
{
view += "<img src='"+dataurl+"'>";
}
if (mytype=='audio')
{
view += "<audio controls forevent onclick='event.stopPropagation();'><source src='"+dataurl+"' type='audio/mp3'></audio>";
}
if (insert)
{
s += "<div class='menu_item data_item' forevent2='"+id+"'>"+view+"</div>";
}
else
{
s += "<div class='menu_item data_item' forevent2='"+id+"|"+type+"|"+mytype+"|"+insert+"|"+dataurl+"'>"+view+"</div>";
}
}
mywindow_inner.innerHTML = s;
SetEvent('item1',function(){FileDataWind('image',false);});
SetEvent('item2',function(){FileDataWind('audio',false);});
SetEvent('item3',function(){FileDataWind('audio',false);});
SetEvent('item4',function(){FileDataWind('all',false);});
SetEvent('item5',function(){FileDataWind('image',false);});
SetEvent('item6',function(){FileDataWind('all',false);});
if (insert) {
SetEventsByAttr(15,'forevent2');
} else {
SetEventsByAttr(16,'forevent2');
}
ShowWind(true,true);
if (!insert) {
SelectedMenuItemNum = 2;
SelectMenuItem(SelectedMenuItemNum,true);
}
}
else
{
ShowWind(false);
Message(Lang.FilesNo);
}
}
function EditFileData(id,type,mytype,insert,dataurl)
{
var s = "<div class='menu_item' id='item1'>"+Lang.Back+"</div>";
s += "<p>"+FileDataPreview(mytype,dataurl)+"</p>";
s += "<input type='text' id='filename' style='margin-bottom:8px;' value='"+id+"'>";
s += "<span style='float:left;' class='button' id='item2'>"+Lang.FileRename+"</span>";
s += "<span style='float:right;' class='button' id='item3'>"+Lang.FileRemove+"</span>";
s += "<div style='clear:both;'></div>";
mywindow_inner.innerHTML = s;
SetEvent('item1',function(){FileDataWind(type,insert);});
SetEvent('item2',function(){ChangeFileData(id,type,insert,$('filename').value);});
SetEvent('item3',function(){ChangeFileData(id,type,insert,false);});
ShowWind(true);
}
function ChangeFileData(id,type,insert,name)
{
var ok = false;
var dataPassage = GetLocByTitle('StoryData');
if (dataPassage)
{
id = id.trim().toLowerCase()
data = dataPassage.Text.replace(/\n+/,'\n').trim().split('\n');
for (i=0; i<data.length; i++)
{
var line = data[i];
if (line.indexOf('::')==-1)
{
continue;
}
line = line.split('::');
var myid = line[0].trim().toLowerCase();
var mydataurl = line[1].trim();
if (myid==id)
{
if (name===false)
{
data.splice(i,1);
ok = true;
}
else
{
name = NameFileData(name);
if (name)
{
data[i] = name+'::'+mydataurl;
ok = true;
}
}
break;
}
}
if (ok)
{
dataPassage.Text = data.join('\n');
SelectNPaint();
FileDataWind(type,insert);
}
}
}
function AddFileWind(type,result,name)
{
var fileSize = result.length;
if (fileSize>maxFileSizeStoryData) {
AlertMessage(Lang.FileTooLarge+'<br>('+fileSize+'>'+maxFileSizeStoryData+')');
} else {
AddFileData(type,result);
ShowWind(true);
var fileNameInput = $('filename');
if (fileNameInput) {
fileNameInput.value = name;
fileNameInput.select();
}
}
}
function SelectFile(type)
{
if (TargetChromeApp) {
chrome_SelectDataFile(type);
} else {
$('fileSelector').click();
}
}
function CreateStoryData()
{
if (GetLocIndexByTitle('StoryData')==-1)
{
var x = LastLocation().Left+Cell*2;
var y = LastLocation().Top+Cell*2;
LocationArr.push(new Locations("StoryData",'',x,y,6,false));
SelectNPaint();
return true;
}
else
{
return false;
}
}
function SaveFileData(dataurl,name,type)
{
name = NameFileData(name);
if (name)
{
CreateStoryData();
GetLocByTitle('StoryData').Text += '\n' + name + '::' + dataurl;
SelectNPaint();
ShowWind(false);
}
}
function NameFileData(name)
{
name = name.replace(/::/g,':').replace(/[\r\n"']+/g,'').trim().toLowerCase();
if (name=='')
{
$('filename').focus();
Message(Lang.InputFileName);
return false;
}
var storydataLoc = GetLocByTitle('StoryData');
if (storydataLoc)
{
var list = FileDataList(false,true);
var namelc = name.toLowerCase();
for (var key in list)
{
if (list[key].split('::')[0].trim().toLowerCase()==namelc)
{
$('filename').focus();
Message(Lang.FileNameExists);
return false;
}
}
}
return name;
}
var chrome_OS = null; // текущая ОС
var chrome_Version; // версия программы
var chrome_CurrentEntry = ''; // путь последнего загруженного/сохранённого файла
var chrome_RecentFiles = [];
var fileDialog = $('fileDialog');
if (TargetChromeApp) {
chrome_Version = chrome.runtime.getManifest().version;
chrome.runtime.getPlatformInfo(function(info) {
chrome_OS = info.os;
if (navigator.onLine) {
chrome_CheckUpdates();
}
});
}
function chrome_InsertMedia(picture,video,audio) {
chrome_AddFile(picture,video,audio);
}
function chrome_AddFile(picture,video,audio) {
var type = 'all';
if (video) {
type = 'video';
} else if (picture) {
type = 'image';
} else if (audio) {
type = 'audio';
}
chrome_FileDialog(open,false,type,'',function(path) {
var fileName = chrome_GetTitleFromPath(path,true);
var filesDirName = 'files';
var slash = '/';
if (chrome_OS=='win') {
slash = '\\';
}
var filesDir = chrome_GetFilesDirectory()+filesDirName;
var newPath = filesDir+slash+fileName;
if (newPath!=path) {
var fs = require('fs');
if (!fs.existsSync(filesDir)) {
fs.mkdirSync(filesDir);
}
fs.createReadStream(path).pipe(fs.createWriteStream(newPath));
}
if (video || fileName.substr(-4).toLowerCase()=='.mp4') {
InsertLink("video('"+filesDirName+"/"+fileName+"');");
} else if (picture) {
InsertLink("picture('"+filesDirName+"/"+fileName+"');");
} else {
InsertLink("music('"+filesDirName+"/"+fileName+"');");
}
});
}
function chrome_SelectDataFile(type) {
var exts;
if (type=='image') {
var desc = Lang.Images;
exts = ['png','gif','jpg','jpeg'];
}
if (type=='audio') {
var desc = Lang.AudioMP3;
exts = ['mp3'];
}
chrome.fileSystem.chooseEntry({
type: 'openFile',
accepts: [{
description: desc,
extensions: exts
}],
acceptsAllTypes: false
},
function(entry) {
if (chrome.runtime.lastError) {
return;
}
entry.file(function(file) {
var reader = new FileReader();
reader.onload = function() {
var fileName = file.name.replace(/\..+?$/,'');
AddFileWind(type,reader.result,fileName);
}
reader.readAsDataURL(file);
});
});
}
function chrome_SelectImage() {
chrome.fileSystem.chooseEntry({
type: 'openFile',
accepts: [{
description: Lang.Images,
extensions: ['png','gif','jpg','jpeg']
}],
acceptsAllTypes: false
},
function(entry) {
if (chrome.runtime.lastError) {
return;
}
entry.file(function(file) {
var reader = new FileReader();
reader.onload = function() {
ThemeSetImage(reader.result);
}
reader.readAsDataURL(file);
});
});
}
function chrome_SelectFile(menu,merge) {
if (menu) {
var str = '';
str += "<div class='menu_item' id='item01'>"+Lang.FileSelect+"</div>";
str += "<div class='menu_item' id='item02'>"+Lang.MenuMergeStory+"</div>";
if (navigator.onLine) {
str += "<div class='menu_item' id='item03'>"+Lang.LoadFromCloud+"</div>";
}
str += "<div class='menu_item' id='item04'>"+Lang.MenuFromBackUp+"</div>";
if (navigator.onLine) {
str += "<div class='menu_item' id='item06'>"+Lang.MenuModules+"</div>";
}
if (chrome_RecentFiles.length>0) {
str += "<p></p>";
for (var i in chrome_RecentFiles) {
var item = chrome_RecentFiles[i];
if (item && typeof item=='string') {
var name = chrome_GetTitleFromPath(item);
str += "<div class='menu_item accent' forevent='"+item+"'>"+name+"</div>";
}
}
}
mywindow_inner.innerHTML = str;
SetEvent('item01',function(){ShowWind(false);chrome_SelectFile(false,false);});
SetEvent('item02',function(){ShowWind(false);chrome_SelectFile(false,true);});
SetEvent('item03',function(){ShowWind(false);SelectStory(false,true);});
SetEvent('item04',function(){ShowWind(false);FromBackup();});
SetEvent('item06',function(){ShowWind(false);Modules();});
SetEventsByAttr(17);
ShowWind(true);
} else {
chrome_FileDialog(true,false,'sm','',function(path) {
chrome_LoadFile(path,merge);
});
}
}
function chrome_LoadFile(path,merge) {
var fs = require('fs');
if (path && typeof path=='string' && path.substr(-3)=='.sm' && fs.existsSync(path)) {
Message(Lang.Loading);
fs.readFile(path,'utf8',function(err,data) {
if (!err) {
LoadStory(0,merge,data);
if (!merge) {
chrome_SetCurrentEntry(path);
}
return true;
} else {
chrome_ErrorLoadFile(path);
return false;
}
});
} else if (path!='') {
chrome_ErrorLoadFile(path);
return false;
}
}
function chrome_ErrorLoadFile(path) {
Message(Lang.ErrorLoadFile);
NewGame();
for (var i in chrome_RecentFiles) {
var item = chrome_RecentFiles[i];
if (item && typeof item=='string' && item==path) {
chrome_RecentFiles.splice(i,1);
chrome_SaveRecent();
break;
}
}
}
function chrome_Save(com,data) {
if (com=='SaveStory') {
if (chrome_CurrentEntry) {
chrome_WriteFile(chrome_CurrentEntry,data);
} else {
chrome_Save('SaveStoryDialog',data);
}
}
if (com=='SaveStoryDialog') {
var path = Lang.DefaultFileName+'.sm';
if (chrome_CurrentEntry) {
path = chrome_CurrentEntry;
}
chrome_FileDialog(false,false,'sm',path,function(selectedPath) {
chrome_WriteFile(selectedPath,data);
});
}
}
function chrome_WriteFile(path,data) {
Message(Lang.Saving);
if (path) {
var fs = require('fs');
fs.writeFile(path,data,'utf8',function(err) {
if (!err) {
chrome_SetCurrentEntry(path);
ToBackup();
Message(Lang.Saved);
} else {
Message(Lang.StoryNotSaved);
}
});
} else {
Message(Lang.StoryNotSaved);
}
}
function chrome_ToStorage(key,value,callback) {
var obj = {};
obj[key] = value;
chrome.storage.local.set(obj,callback);
}
function chrome_FromStorage(key,callback) {
chrome.storage.local.get(key,function(result) {
var value = result[key];
callback(value);
});
}
function chrome_SetCurrentEntry(path) {
if (!path || typeof path!='string') {
chrome_CurrentEntry = '';
document.title = Lang.DefaultFileName+' | '+Lang.AppName+' '+chrome_Version;
} else {
chrome_CurrentEntry = path;
var tmpArr = [];
for (var i in chrome_RecentFiles) {
var item = chrome_RecentFiles[i];
if (item && typeof item=='string') {
if (item!=path) {
tmpArr.push(item);
}
}
}
chrome_RecentFiles = tmpArr.slice();
chrome_RecentFiles.unshift(path);
var max = 16;
if (chrome_RecentFiles.length>max) {
chrome_RecentFiles = chrome_RecentFiles.slice(0,max);
}
chrome_SaveRecent();
document.title = chrome_GetTitleFromPath(path)+' | '+Lang.AppName+' '+chrome_Version;
}
}
function chrome_GetTitleFromPath(path,withExt) {
var slash = '/';
if (chrome_OS=='win') {
slash = '\\';
}
var file = path.split(slash);
file = file[file.length-1]; // имя файла
if (withExt) {
return file;
} else {
return file.replace(/\.[^\.]*?$/,'').trim(); // без расширения
}
}
function chrome_GetFilesDirectory(path) {
if (!path) {
path = chrome_CurrentEntry;
}
var slash = '/';
path = path.replace(/\\/g,slash).split(slash);
path.pop();
return path.join(slash)+slash;
}
function chrome_LoadRecent() {
var fromCL = false;
var gui = require('nw.gui');
fromCL = chrome_LoadFile(gui.App.argv.toString().trim(),false);
chrome_FromStorage('recent_files',function(data) {
if (data) {
chrome_RecentFiles = data;
if (!fromCL) {
if (chrome_RecentFiles.length>0) {
chrome_LoadFile(chrome_RecentFiles[0],false);
} else {
NewGame();
}
}
} else {
if (!fromCL) {
NewGame();
}
}
});
}
function chrome_SaveRecent() {
chrome_ToStorage('recent_files',chrome_RecentFiles);
}
function chrome_PublishToLib(html,locsCount,storyTitle) {
if (AuthLogin.trim()=='' || AuthPassword.trim()=='') {
SignInWindow(function() {
chrome_PublishToLib(html,locsCount,storyTitle);
});
} else {
Message(Lang.ListLoading,true);
var xmlhttp = getXmlHttp();
var params = 'login='+encodeURIComponent(AuthLogin)+'&password='+encodeURIComponent(AuthPassword);
xmlhttp.open('POST',Lang.Server()+'/include/user_files_asm.php',true);
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState==4) {
if(xmlhttp.status==200) {
var answer = xmlhttp.responseText.trim();
var str = '';
str += "<p>"+Lang.AboutPub+"</p>";
str += "<p><select id='item0' style='font-size:13px;margin-bottom:10px;'><option value=''>"+Lang.PubNew+"</option>";
if (answer) {
str += "<option disabled>──────────────────</option>";
answer = answer.split('\n');
for (var i in answer) {
var id = answer[i].split('[:73143:]');
selected = '';
if (id[1].toLowerCase()==storyTitle.toLowerCase()) {
selected = ' selected';
}
str += "<option value='"+id[0]+"'"+selected+">"+id[1]+"</option>";
}
}
str += "</select></p>";
str += "<div style='margin-top:10px;'><span class='button' id='item1' style='float:left;'>"+Lang.Send+"</span><span class='button' id='item2' style='float:right;'>"+Lang.SignIn+"</span></div><div style='clear:both;'></div>";
mywindow_inner.innerHTML = str;
SetEvent('item1',function(){chrome_PublishSend(html,locsCount,$('item0').value);});
SetEvent('item2',function(){SignInWindow(PublishToInet);});
ShowWind(true);
}
MessageHide();
}
};
xmlhttp.send(params);
}
}
function chrome_PublishSend(html,locsCount,id) {
if (chrome_GetFilesDirectory()=='/') {
Message(Lang.SaveFirst);
ShowWind(false);
return;
}
if (id) {
var newPub = false;
var mess = Lang.WantUpdPub;
} else {
var newPub = true;
var mess = Lang.WantNewPub;
}
AreYouSure(
function() {
var post = function() {
var formData = new FormData();
var postData = function() {
Message(Lang.PleaseWait);
formData.append('login',AuthLogin);
formData.append('password',AuthPassword);
formData.append('files',zipContent);
formData.append('filesType','zip');
formData.append('source',CreateSaveData(true));
formData.append('title',GetLocByTitle('StoryTitle').Text);
formData.append('subtitle',GetLocByTitle('StorySubtitle').Text);
formData.append('author',GetLocByTitle('StoryAuthor').Text);
formData.append('code','ASM_'+chrome_Version);
formData.append('lang',LangCode);
formData.append('passages',LocationArr.length);
formData.append('style',style_view);
if (id) {
formData.append('file_id',id);
}
var xmlhttp = getXmlHttp();
xmlhttp.open('POST',Lang.Server()+'/include/post.php',true);
xmlhttp.upload.onprogress = function(event) {
Message(Lang.Sending+'...'+Math.ceil(event.loaded/event.total*100)+'%',true,true);
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState==4) {
if(xmlhttp.status==200) {
var answer = xmlhttp.responseText.trim();
if (answer=='') {
AlertMessage(Lang.ErrorPub+'<br>'+Lang.ErrorReadCode+': 1');
} else if (answer.substr(0,5)=='error') {
AlertMessage(Lang.ErrorPub+'<br>'+Lang.ErrorReadCode+': '+answer.substr(5));
} else {
AlertMessage(Lang.SuccessPub+"<p></p><a href='"+answer+"' target='_blank'>"+answer+"</a>");
}
} else {
AlertMessage(Lang.ErrorPub+'<br>'+Lang.ErrorReadCode+': 2');
}
MessageHide();
}
};
xmlhttp.send(formData);
}
var JSZip = require('jszip');
var zip = new JSZip();
zip.file('index.html',html);
var filesDir = 'files';
var path = chrome_GetFilesDirectory()+filesDir;
var fs = require('fs');
var zipContent = '';
var createZip = function() {
zip.generateAsync({
type: 'base64',
compression: 'DEFLATE'
}).then(function(content) {
MessageHide();
zipContent = content;
postData();
});
};
if (fs.existsSync(path)) {
Message(Lang.PleaseWait,true);
var walk   = require('walk');
var files  = [];
var walker = walk.walk(path,{
followLinks: false
});
walker.on('file', function(root, stat, next) {
if (stat.name.substr(0,1)!='.') {
files.push([root+'/'+stat.name,filesDir+root.replace(path,'')+'/'+stat.name,stat.name]);
}
next();
});
walker.on('end', function() {
var totalSize = 0;
var maxTotalSize = 80*1024*1024;
var mb = ' MB';
if (LangCode=='ru') {
mb = ' Мб';
}
var maxSizeError = Lang.ErrorTotalSize+' '+Math.round(maxTotalSize/1024/1024)+mb;
var exts = ['png','jpg','jpeg','svg','gif','mp3','mp4','css','js'];
for (var i in files) {
var filePath  = files[i][0];
var fileNameF = files[i][1];
var fileName  = files[i][2];
var fileExt   = fileName.split('.').pop().toLowerCase();
if (exts.indexOf(fileExt)==-1) {
MessageHide();
AlertMessage(Lang.BadExt+'<br><span class=accent>'+fileName+'</span>');
return;
}
if (!/^[0-9a-zA-Z_\-\.\/]+?$/.test(fileNameF) || fileName.length>128) {
MessageHide();
AlertMessage(Lang.BadExt+'<br><span class=accent>'+fileName+'</span>');
return;
}
var data = fs.readFileSync(filePath);
totalSize += data.length;
if (totalSize<=maxTotalSize) {
zip.file(fileNameF,data);
} else {
MessageHide();
AlertMessage(maxSizeError);
return;
}
}
createZip();
});
} else {
createZip();
}
};
post();
},
mess
);
}
function chrome_SendMessage(s) {
previewWin.contentWindow.postMessage(s,'*');
}
function chrome_ChangeLanguage() {
if (LangCode=='en') {
var value = 'ru';
} else {
var value = 'en';
}
global.localStorage.setItem('lang_code',value);
chrome.runtime.reload();
}
function chrome_CheckUpdates() {
var path = Lang.Server()+'/include/checkversion.php?version='+chrome_Version+'&lang='+LangCode+'&os='+chrome_OS;
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET',path,true);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState==4) {
if(xmlhttp.status==200) {
var answer = xmlhttp.responseText.trim();
if (answer!=chrome_Version) {
AreYouSure(function() {
window.open(Lang.Server()+'/download/');
},"<p class='accent'>"+Lang.UpdateFound+' '+Lang.Version+' '+answer+'.</p>'+Lang.GotoDownload);
}
}
}
};
xmlhttp.send(null);
}
function chrome_FileDialog(open,dir,type,path,callback) {
var file = '';
if (!path) {
path = '';
} else {
var slash = '/';
if (chrome_OS=='win') {
slash = '\\';
}
path = path.split(slash);
file = path.pop(); // имя файла
path = path.join(slash); // путь к файлу
}
if (open) {
fileDialog.removeAttribute('nwsaveas');
} else {
fileDialog.setAttribute('nwsaveas',file);
}
if (dir) {
fileDialog.setAttribute('nwdirectory','');
fileDialog.removeAttribute('nwworkingdir');
} else {
fileDialog.removeAttribute('nwdirectory');
fileDialog.setAttribute('nwworkingdir',path);
}
if (type=='image') {
fileDialog.setAttribute('accept','.gif,.png,.jpg,.jpeg');
} else if (type=='audio') {
fileDialog.setAttribute('accept','.mp3');
} else if (type=='video') {
fileDialog.setAttribute('accept','.mp4');
} else if (type=='sm') {
fileDialog.setAttribute('accept','.sm');
} else if (type=='all') {
fileDialog.setAttribute('accept','.gif,.png,.jpg,.jpeg,.mp3,.mp4');
} else {
fileDialog.setAttribute('accept','');
}
fileDialog.onchange = function() {
callback(this.value);
};
fileDialog.onclick = function() {
this.value = '';
};
fileDialog.click();
}
var ThemeElements = [
['AudioButton',Lang.Audio,'button'],
['ConsoleButton',Lang.Console,'button'],
['PrefsButton',Lang.HTMLPrefs,'button'],
['ViewButton',Lang.ViewButton,'button'],
['body',Lang.GlobalSettings,'body'],
['printCont',Lang.PrintBlock,'block'],
['printImage',Lang.PrintImage,'image'],
['menu',Lang.PrintMenu,'menu'],
['toolbar',Lang.Toolbar,'toolbar']
];
var CurrentSelectedBlock;
var ThemeCheckImageSize;
var ThemeImageRuleBorder;
function RestoreStoryStyle()
{
ShowWind(false);
BackupStoryStyle();
ThemePreview();
}
function CreateStoryStyle()
{
if (GetLocIndexByTitle('StoryStyle')==-1) {
var x = LastLocation().Left+Cell*2;
var y = LastLocation().Top+Cell*2;
LocationArr.push(new Locations("StoryStyle",SetStyleText(),x,y,6,false));
SelectNPaint();
return true;
} else {
return false;
}
}
function handleFile(files)
{
if (window.FileReader) {
var file = files[0];
$('fileSelector').value = '';
var reader = new FileReader();
reader.onload = function() {
ThemeSetImage(reader.result);
}
reader.readAsDataURL(file);
}
}
function ThemeChangeImage(id)
{
CurrentSelectedBlock = id;
if (TargetChromeApp) {
chrome_SelectImage();
} else {
$('fileSelector').click();
}
}
function ThemeSetImage(data)
{
var img = new Image();
img.src = data;
img.onload = function()
{
if (!ThemeCheckImageSize || (img.width==24 && img.height==24)) {
var rule = 'background-image';
if (ThemeImageRuleBorder) {
rule = 'border-image';
}
SetThemeStyle('#'+CurrentSelectedBlock,rule,img.src,true);
ThemePreview();
} else {
AlertMessage(Lang.SelectImageSize+' 24x24px');
}
}
}
function ShowHideButton(id,show)
{
if (show) {
show = 'inline-block';
} else {
show = 'none';
}
SetThemeStyle('#'+id,'display',show,false);
}
var styleBegin; // начало правила стиля
function GetThemeStyle(id,rule,bgimage)
{
var StoryStyleIndex = GetLocIndexByTitle('StoryStyle');
var style = '';
if (GetLocIndexByTitle('StoryStyle')!=-1) {
style = LocationArr[StoryStyleIndex].Text;
} else {
style = SetStyleText();
}
style = style.replace(/background-color/g,'background-polor');
if (rule=='background-color') {
rule = 'background-polor';
}
if (bgimage) {
re = new RegExp(('('+id+'[^}]*?\\{[^}]*?'+rule+'\\s*?:\\s*?url\\s*?\\(\\s*?)([^)]+?)\\s*?\\)'),'mi');
} else {
re = new RegExp(('('+id+'[^}]*?\\{[^}]*?'+rule+'\\s*?:\\s*?)([^;}]+?)\\s*?;'),'mi');
}
var match = style.match(re);
if (match && match[2]) {
styleBegin = matchIndex(match,2);
return match[2].replace(/"/g,"'");
} else {
return false;
}
}
function matchIndex(match,n)
{
var ix = match.index;
for (var i=1; i<n; i++) {
ix+= match[i].length;
}
return ix;
}
function SetThemeStyle(id,rule,value,bgimage)
{
value = value.replace(/"/g,"'").trim();
CreateStoryStyle();
var StoryStyleIndex = GetLocIndexByTitle('StoryStyle');
var style = LocationArr[StoryStyleIndex].Text;
var myvalue = GetThemeStyle(id,rule,bgimage);
if (myvalue!=false) {
style = style.substr(0,styleBegin)+value+style.substr(styleBegin+myvalue.length);
} else {
var re = new RegExp(('('+id+'[^}]+?\s*?\\{)()'),'mi');
var match = style.match(re);
var newrule = rule+':'+value+';';
if (bgimage) {
newrule = rule+':url('+value+');';
}
if (match) {
styleBegin = matchIndex(match,2);
style = style.substr(0,styleBegin)+newrule+' '+style.substr(styleBegin);
} else {
style = style.trim()+'\n\n'+id+' {'+newrule+'}';
}
}
LocationArr[StoryStyleIndex].Text = style;
SelectNPaint();
}
function ChangeTheme()
{
var str = '';
for (var i=0; i<style_themes.length; i++) {
str += "<div class='menu_item' forevent='"+i+"'>"+style_themes[i]+"</div>";
}
mywindow_inner.innerHTML = str;
SetEventsByAttr(7);
ShowWind(true);
SelectMenuItem(style_current_theme,true);
}
function SelectTheme(themeNum)
{
BackupStoryStyle();
SetTheme(themeNum);
SelectMenuItem(style_current_theme,true);
ThemePreview();
}
function BackupStoryStyle()
{
var i = GetLocIndexByTitle('StoryStyle');
if (i!=-1) {
var j = GetLocIndexByTitle('StoryStyle.bak');
if (j!=-1) {
LocationArr[j].Text = LocationArr[i].Text;
LocationArr.splice(i,1);
} else {
LocationArr[i].Title = 'StoryStyle.bak';
}
SelectNPaint();
}
}
function ThemeEditor(close)
{
if (!close) {
platetitle.innerHTML = Lang.ThemeEdit;
var s = '';
s+="<input type='file' id='fileSelector' accept='image/png,image/jpeg,image/gif' style='display:none;'>";
s+="<div style='width:100%;text-align:center;'>";
if (style_view!='vis') {
s+="<span class='button' id='item1' style='margin-bottom:8px;width:auto;'>"+Lang.ChangeTheme+"</span>&nbsp; ";
}
s+="<span class='button' id='item2' style='margin-bottom:8px;width:auto;'>"+Lang.GlobalSettings+"</span>&nbsp; ";
s+="<span class='button' id='item3' style='margin-bottom:8px;width:auto;'>"+Lang.RestoreStoryStyle+"</span>";
s+="</div>";
platecontent.innerHTML = s;
SetEvent('fileSelector',function(){handleFile(this.files);},'change');
SetEvent('item1',function(){ChangeTheme();});
SetEvent('item2',function(){PropertyEditor('body');});
SetEvent('item3',function(){AreYouSure(RestoreStoryStyle);});
ShowPlate(true);
ThemePreview();
} else {
ShowPlate(false);
}
}
function ResizePreviewIframe() {
if (previewTheme) {
previewTheme.style.height = (myplate.offsetHeight-previewTheme.offsetTop-15)+'px';
}
}
function ThemePreview()
{
var s = ThemeTop(true,false,-1)+ThemePreviewBody()+ThemeBottom(true);
if (!$('previewTheme')) {
previewTheme = document.createElement('iframe');
platecontent.appendChild(previewTheme);
previewTheme.id = 'previewTheme';
previewTheme.style.width = '100%';
previewTheme.frameBorder = '0';
previewTheme.scrolling = 'auto';
previewTheme.style.border = '1px solid #AAAAAA';
ResizePreviewIframe();
window.onresize = function() { ResizePreviewIframe(); };
window.addEventListener('orientationchange',function() { ResizePreviewIframe(); },false);
previewTheme.src = 'about:blank';
}
previewTheme.contentWindow.document.open();
previewTheme.contentWindow.document.write(s);
previewTheme.contentWindow.document.close();
}
var ThemeHTML = '';
function ThemeTop(preview,TestMode,OnlyPassageNum)
{
if (TargetFormatBak=='html') {
SetTheme(style_current_theme);
} else {
SetTheme(1);
}
ThemeHTML = '';
if (preview) {
ToTheme("<!DOCTYPE html>");
}
ToTheme("<html lang='"+LangCode+"'>");
ToTheme("<head>");
ToTheme("<title>"+Lang.AppName+"</title>");
ToTheme("<link rel='apple-touch-icon' href='https://sm.axmasoft.com/rsc/apple-touch-icon.png' />");
ToTheme("<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>");
ToTheme("<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no'>");
ToTheme("<meta name='mobile-web-app-capable' content='yes'>");
ToTheme("<meta name='apple-mobile-web-app-capable' content='yes'>");
ToTheme("<meta name='apple-mobile-web-app-status-bar-style' content='black'>");
ToTheme("<meta name='format-detection' content='telephone=no'>");
ToTheme("<meta http-equiv='X-UA-Compatible' content='IE=edge'>");
ToTheme("<style type='text/css'>");
var StoryStyleIndex = GetLocIndexByTitle('StoryStyle');
if (StoryStyleIndex!=-1) {
ToTheme(LocationArr[StoryStyleIndex].Text);
} else {
ToTheme(SetStyleText());
}
ToTheme("</style>");
ToTheme("</head>");
if (preview) {
ToThemW("<body id='body' oncontextmenu='return false;' onkeyup=\"if(event.keyCode==27){");
ToThemW("asmGlobal_MessageFromFrame('CloseThemeEditor');");
ToTheme("}\">");
} else {
ToThemW("<body id='body' onclick='asmGlobal_showPrefs(true);' oncontextmenu='");
if (OnlyPassageNum==-1) {
ToThemW("asmGlobal_showPrefs();");
}
ToThemW("return false;'>");
}
if (OnlyPassageNum==-1) {
ToTheme("<div id='toolbar'>");
} else {
ToTheme("<table style='width:100%;height:36px;background-color:#FFFFFF;color:#000000;opacity:0.7;text-align:center;position:absolute;top:0;left:0;right:0;z-index:200;overflow:hidden;text-shadow:none;' cellpadding='0' cellspacing='0'><tr><td valign='middle' width='1%'>&nbsp;</td><td valign='middle' width='98%'>"+LocationArr[OnlyPassageNum].Title+"</td><td valign='middle' width='1%'><span class='updateButton' onclick=\"asmGlobal_MessageFromFrame('CompilePassage');\" style='margin-right:0.5em;line-height:1;'>⟳</span></td></tr></table>");
ToTheme("<div id='toolbar' style='display:none;pointer-events:none;'>");
}
ToThemW("<table width='100%' cellpadding='0' cellspacing='0' border='0' style='table-layout:fixed;'><tr>");
ToThemW("<td width='20%' align='left'><nobr>");
if (preview || TestMode) {
ToThemW("<div class='imgbutton' style='margin-left:8px;' onclick='asmGlobal_tbAnimate(this,event);asmGlobal_showConsole();' id='ConsoleButton'></div>");
}
if (!preview && style_view=='vis' || style_view=='bt') {
ToThemW("<div class='imgbutton' style='margin-left:8px;' onclick='asmGlobal_tbAnimate(this,event);asmGlobal_togglePrint(false,true);event.stopPropagation();' id='ViewButton'></div>");
}
ToThemW("</nobr></td>");
ToThemW("<td width='60%' align='center' valign='middle'><div id='printTitle'>");
if (preview) {
ToThemW("Title text");
}
ToThemW("</div></td>");
ToThemW("<td width='20%' align='right'><nobr>");
ToThemW("<div class='imgbutton' style='margin-right:8px;");
if (preview) {
ToThemW("display:inline-block;opacity:1;");
}
ToThemW("' onclick='asmGlobal_tbAnimate(this,event);asmGlobal_PlayPauseButton();' id='AudioButton' ></div>");
ToThemW("<div class='imgbutton' style='margin-right:8px;' onclick='asmGlobal_tbAnimate(this,event);asmGlobal_showPrefs();event.stopPropagation();' id='PrefsButton'></div>");
ToThemW("</nobr></td>");
ToThemW("</tr></table>");
ToTheme("</div>"); // toolbar
if (TestMode) {
ToTheme("<div id='console'></div>");
}
ToThemW("<audio id='musicAudio' preload loop style='display:none;'></audio>");
ToThemW("<div id='page'>");
if (style_view=='sw') {
ToThemW("<div id='printHelper'>");
}
ToThemW("<div id='printCont'><div id='avatarBlock'></div>");
ToThemW("<div id='print'></div></div>");
if (style_view=='sw') {
ToThemW("</div>");
}
if (style_view!='vis' && style_view!='bt') {
ToThemW("<div id='printImage'");
if (style_view=='sw') {
ToThemW(" onclick='asmGlobal_showImage();");
} else {
ToThemW(" onclick='if(asmGlobal_isMobile()){asmGlobal_showImage();};");
}
ToThemW("event.stopPropagation();'>");
} else {
ToThemW("<div id='printImage' onclick='asmGlobal_togglePrint(true,false);event.stopPropagation();'>");
}
ToThemW("<div style='height:100%;width:100%;text-align:center;'><span style='display:inline-block;height:100%;vertical-align:middle;'></span><img id='clickImage' src='"+style_emptyImage+"' style='vertical-align:middle;margin:0;border:none;' alt='' border='0'><div id='videoDiv'></div><div id='spritesDiv'></div></div>");
ToThemW("</div>");
ToThemW("<div id='spacer'></div><div id='menu'><div id='menuTable' style='display:table;border-spacing:0;width:100%;min-width:100%;border:none;'><div style='display:table-row;'><div id='menuInner' style='display:table-cell;padding:0;width:100%;text-align:center;vertical-align:middle;'></div></div></div>");
if (!preview && (style_view!='vis' && style_view!='bt')) {
ToThemW("<div id='showImageButton' onclick='asmGlobal_showImageToggle();'></div>");
}
ToThemW("</div>");
if (preview && (style_view=='vis' || style_view=='bt')) {
ToThemW("<div id='buttonsList'><span class='button'>Button 1</span><span class='button'>Button 2</span><span class='button'>Button 3</span></div>");
}
ToThemW("</div>"); // pageDiv
if (!preview) {
ToTheme("<div id='printAddCont' onclick='asmGlobal_showPrefs(true);'><div id='printAdd' onclick=\"asmGlobal.prefsDiv.style.display='none';event.stopPropagation();\"><div id='printAddText'></div></div></div>");
}
ToTheme("<div id='prefs' class='wind' onclick='event.stopPropagation();'></div>");
ToTheme("<div id='dialog' class='wind' onclick='event.stopPropagation();'></div>");
ToTheme("<noscript style='position:absolute;top:40%;left:0;right:0;padding:5px;text-align:center;color:#FFFFFF;background-color:#222222;'>"+Lang.JSrequires+"</noscript>");
ToTheme("<script>");
ToTheme("var asmGlobal = {};");
asm_macros(false,true);
ToTheme("function onLoadStory() {");
ToTheme("asmGlobal.pageDiv.style.display = 'block';");
if (!preview) {
ToTheme("asmGlobal_NewGame(true);");
}
ToTheme("}");
ToTheme("asmGlobal.printTitle = $('printTitle');");
ToTheme("asmGlobal.printDiv = $('print');");
ToTheme("asmGlobal.printContDiv = $('printCont');");
ToTheme("asmGlobal.printAdd = $('printAdd');");
ToTheme("asmGlobal.printAddCont = $('printAddCont');");
ToTheme("asmGlobal.printAddText = $('printAddText');");
ToTheme("asmGlobal.pageDiv = $('page');");
ToTheme("asmGlobal.menuDiv = $('menuInner');");
ToTheme("asmGlobal.avatarBlock = $('avatarBlock');");
ToTheme("asmGlobal.toolbarDiv = $('toolbar');");
ToTheme("asmGlobal.prefsDiv = $('prefs');");
ToTheme("asmGlobal.printImage = $('clickImage');");
ToTheme("asmGlobal.videoDiv = $('videoDiv');");
ToTheme("asmGlobal.spritesDiv = $('spritesDiv');");
ToTheme("if (!('objectFit' in document.body.style)) {asmGlobal.printImage.style.width='auto';asmGlobal.printImage.style.height='auto';asmGlobal.printImage.style.maxWidth='100%';};"); // если нет свойства object-fit
ToTheme("asmGlobal.printImageBlock = $('printImage');");
ToTheme("asmGlobal.showImageButton = $('showImageButton');");
ToTheme("asmGlobal.consoleDiv = $('console');");
ToTheme("asmGlobal.dialogWind = $('dialog');");
ToTheme("asmGlobal.AudioButton = $('AudioButton');");
ToTheme("asmGlobal.badImage = '"+style_badImage+"';");
ToTheme("asmGlobal.pictureDefault = '"+style_pictureDefault+"';");
if (preview) {
if (style_view=='sw') {
ToTheme("asmGlobal.printImageBlock.style.display = 'none';");
} else {
ToTheme("asmGlobal.printImage.src = asmGlobal.pictureDefault;");
}
}
ToTheme("document.addEventListener('DOMContentLoaded',onLoadStory);");
if (TestMode || preview) {
ToTheme("function asmGlobal_MessageFromFrame(s) {");
ToTheme("	window.parent.parent.postMessage(s,'*');");
ToTheme("}");
ToTheme("window.addEventListener('message', function(e) {");
ToTheme("	eval(e.data);");
ToTheme("});");
}
return ThemeHTML;
}
function ThemePreviewBody()
{
ThemeHTML = 'function $(id) {return document.getElementById(id);}';
ToTheme("asmGlobal.printDiv.innerHTML = \"<h1>Header</h1><p></p><span class='plink'>Lorem ipsum dolor sit amet</span>, consectetur adipiscing elit. Duis eu dolor at nisl lobortis tincidunt. Proin ac dolor convallis, molestie erat nec, vestibulum dui. Nulla quis arcu ut justo varius mattis. Proin velit massa, sollicitudin et posuere fringilla, sollicitudin vitae lacus. Mauris laoreet erat eros, sit amet feugiat eros venenatis sit amet.<p></p>Sed consectetur, elit eu malesuada semper, <span class='plink'>ligula velit</span> consequat risus, in tincidunt metus ligula vel sapien. Phasellus pharetra ipsum ut urna accumsan, ac interdum mi volutpat. Curabitur semper leo ut sapien euismod lacinia. Mauris non tortor sodales, auctor risus id, rutrum massa. Praesent leo lacus, sollicitudin ac elit id, pulvinar pharetra nisl. Phasellus eu odio in neque tristique ornare. Quisque ac arcu imperdiet, accumsan purus vitae, lacinia leo. Fusce tellus nisl, elementum vel justo eu, eleifend consectetur erat. Mauris porta in sapien ut hendrerit. Vestibulum egestas tempus scelerisque.<p></p>Nullam vel neque ut lorem hendrerit euismod. Aenean lectus ligula, dignissim vel ultricies ut, dictum non nisl. Duis blandit porta purus, ac pellentesque purus condimentum a. Nunc pulvinar pretium orci nec eleifend. Proin non elit porttitor, iaculis ligula id, auctor tellus. Proin nec felis ut turpis ultrices congue in vel sapien. <span class='plink'>Pellentesque</span> commodo dolor vel cursus interdum. Nunc sem nisl, molestie vel lobortis vel, tincidunt eu lectus. Donec quis nulla varius mauris volutpat ornare. Phasellus venenatis nibh libero, nec maximus neque imperdiet eget.<p></p><div class='button'>Button 1</div><p></p><div class='button'>Button 2</div>\";");
ToTheme("asmGlobal.menuDiv.innerHTML = \"<span class='plink'>Menu Link 1</span><span>Menu Text</span><span class='plink'>Menu Link 2</span>\";");
ToTheme("var ThemeElements="+JSON.stringify(ThemeElements));
ToTheme("for (var i in ThemeElements) {");
ToTheme("	var id = ThemeElements[i][0];");
ToTheme("	if ($(id)) {");
ToTheme("		$(id).onclick = (function(id) {return function(e){asmGlobal_MessageFromFrame('PropertyEditor='+id);e.stopPropagation();};})(id);");
ToTheme("	}");
ToTheme("}");
return ThemeHTML;
}
function ThemeBottom(preview)
{
ThemeHTML = '';
ToTheme("<\/script>");
ToTheme("</body>");
ToTheme("</html>");
return ThemeHTML;
}
function ToTheme(str)
{
ThemeHTML += str+'\n';
}
function ToThemW(str)
{
ThemeHTML += str;
}
function ThemeChangeColor(id,bg,color,link,text)
{
var rule = 'color';
if (bg) {
rule = 'background-color';
}
SetThemeStyle(id,rule,color,false);
if (link) {
}
if (text && id=='#printCont') {
SetThemeStyle('.button','border-color',color,false);
SetThemeStyle('.myinput','border-color',color,false);
SetThemeStyle('.rcol','border-left-color',color,false);
SetThemeStyle('.hr','background-color',color,false);
SetThemeStyle('.hr','color',color,false);
SetThemeStyle('.choice .plink:before','color',color,false);
}
ThemePreview();
}
function ThemeSetShadow(checked)
{
var shadow = 'none';
if (checked) {
shadow = style_shadows;
}
SetThemeStyle('#printCont','box-shadow',shadow,false);
ThemePreview();
}
function ThemeSetValue(value,max)
{
value = parseInt(value,10);
if (isNaN(+value) || value<0) {
value = 0;
} else if (value>max) {
value = max;
}
return value;
}
function ThemeSetBorder(elem)
{
if (elem) {
var rule = 'border-width';
var id = '#printCont';
var value = ThemeSetValue(elem.value,24);
elem.value = value;
SetThemeStyle(id,rule,value+'px',false);
var StoryStyleIndex = GetLocIndexByTitle('StoryStyle');
var style = LocationArr[StoryStyleIndex].Text;
style = style.replace(/(border-image\s*?:\s*?url\s*?\(.*?\)\s*?)(\d+?)(\s+?.+?[;}])/gmi,'$1'+value+'$3');
LocationArr[StoryStyleIndex].Text = style;
SelectNPaint();
ThemePreview();
}
}
function ThemeSetRadius(elem)
{
if (elem) {
var rule = 'border-radius';
var id = '.button';
var value = ThemeSetValue(elem.value,24);
elem.value = value;
SetThemeStyle(id,rule,value+'px',false);
ThemePreview();
}
}
function PropertyEditor(id)
{
var name = '';
var found = false;
for (var key in ThemeElements) {
if (ThemeElements[key][0]==id) {
found = true;
name = ThemeElements[key][1];
type = ThemeElements[key][2];
break;
}
}
if (!found) {
return;
}
var menu_button = " class='menu_item'";
var str = "<div class='accent'>"+name+"</div><p></p>";
var myipnput = "<input style='text-align:center;' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false'";
if (type=='button') {
var checked = '';
var disabled = '';
disabled = ' disabled';
checked = ' checked';
if (GetThemeStyle(id,'display')=='none') {
checked = '';
}
str += "<div"+menu_button+" id='item20'>"+Lang.ChangeButton+" (24х24px)</div>";
} else if (type=='body') {
str += "<div>"+Lang.Font+"</div>";
var font_cur = GetThemeStyle('#body','font-family',false);
str += "<select id='item3'>";
for (var i=0; i<themes_fonts.length; i++) {
var font = themes_fonts[i];
var fname = font.split(',')[0].replace(/['"]/g,'').trim();
var selected = '';
if (font==font_cur)
{
selected = ' selected';
}
str += "<option value=\""+font+"\""+selected+">"+fname+'</option>';
}
str += "</select>";
str += "<p></p><div>"+Lang.MainColor+"</div>";
str += myipnput+" type='color' id='item4' value=\""+GetThemeStyle('#body','background-color',false)+"\"><p></p>";
var checked = '';
if (GetThemeStyle('#printCont','box-shadow',false)!='none') {
checked = ' checked';
}
var disabled = '';
if (GetThemeStyle('#printAdd','box-shadow',false)=='none') {
disabled = ' disabled';
}
str += "<div><label>"+Lang.ShadowsStatBlocks+"&nbsp;<input id='item5' type='checkbox'"+checked+disabled+"></label></div><p></p>";
str += "<div"+menu_button+" id='item6'>"+Lang.SetTexture+"</div><p></p>";
str += "<div"+menu_button+" id='item7'>"+Lang.RemoveTexture+"</div>";
} else if (type=='block') {
str += "<div>"+Lang.ColorBack+"</div>";
str += myipnput+" id='item8' type='color' value=\""+GetThemeStyle('#printCont','background-color',false)+"\"><p></p>";
str += "<div>"+Lang.ColorText+"</div>";
str += myipnput+" id='item9' type='color' value=\""+GetThemeStyle('#printCont','color',false)+"\"><p></p>";
str += "<div>"+Lang.ColorLink+"</div>";
str += myipnput+" id='item10' type='color' value=\""+GetThemeStyle('.plink','color',false)+"\"><p></p>";
str += "<div>"+Lang.ColorHeader+"</div>";
str += myipnput+" id='item11' type='color' value=\""+GetThemeStyle('h1','color',false)+"\"><p></p>";
if (style_view!='vis') {
str += "<div>"+Lang.ButtonRadius+"</div>";
str += myipnput+" id='item12' type='number' min='0' max='24' value=\""+parseInt(GetThemeStyle('.button','border-radius',false),10)+"\"><p></p>";
str += "<div>"+Lang.FrameWidth+"</div>";
str += myipnput+" id='item13' type='number' min='0' value=\""+parseInt(GetThemeStyle('#printCont','border-width',false),10)+"\"><p></p>";
str += "<div"+menu_button+" id='item14'>"+Lang.FrameSet+"</div><p></p>";
str += "<div"+menu_button+" id='item15'>"+Lang.FrameRemove+"</div>";
}
} else if (type=='toolbar') {
str += "<div>"+Lang.ColorBack+"</div>";
str += myipnput+" id='item16' type='color' value=\""+GetThemeStyle('#printTitle','background-color',false)+"\"><p></p>";
str += "<div>"+Lang.ColorText+"</div>";
str += myipnput+" id='item17' type='color' value=\""+GetThemeStyle('#printTitle','color',false)+"\"><p></p>";
} else if (type=='menu') {
if (style_view!='vis') {
str += "<div>"+Lang.ColorBack+"</div>";
str += myipnput+" id='item18' type='color' value=\""+GetThemeStyle('#menu','background-color',false)+"\"><p></p>";
}
str += "<div>"+Lang.ColorText+"</div>";
str += myipnput+" id='item19' type='color' value=\""+GetThemeStyle('#menu','color',false)+"\"><p></p>";
} else if (type=='image') {
str += Lang.NoProperties+'<p></p>';
}
mywindow_inner.innerHTML = str;
SetEvent('item20',function(){ThemeImageRuleBorder=false;ThemeCheckImageSize=true;ThemeChangeImage(id);});
SetEvent('item2',function(){ShowHideButton(id,this.checked);},'change');
SetEvent('item3',function(){SetThemeStyle('#body','font-family',this.value,false);ThemePreview();},'input');
SetEvent('item4',function(){ThemeChangeColor('#body',true,this.value);},'input');
SetEvent('item5',function(){ThemeSetShadow(this.checked);},'change');
SetEvent('item6',function(){ThemeImageRuleBorder=false;ThemeCheckImageSize=false;ThemeChangeImage('body');});
SetEvent('item7',function(){SetThemeStyle('#body','background-image',style_emptyImage,true);ThemePreview();});
SetEvent('item8',function(){ThemeChangeColor('#printCont',true,this.value);},'input');
SetEvent('item9',function(){ThemeChangeColor('#printCont',false,this.value,false,true);},'input');
SetEvent('item10',function(){ThemeChangeColor('.plink',false,this.value,true);},'input');
SetEvent('item11',function(){ThemeChangeColor('h1',false,this.value);},'input');
SetEvent('item12',function(){ThemeSetRadius(this);},'input');
SetEvent('item13',function(){ThemeSetBorder(this);},'input');
SetEvent('item14',function(){ThemeImageRuleBorder=true;ThemeCheckImageSize=false;ThemeChangeImage('printCont');});
SetEvent('item15',function(){SetThemeStyle('#printCont','border-image',style_emptyImage,true);ThemePreview();});
SetEvent('item16',function(){ThemeChangeColor('#printTitle',true,this.value);},'input');
SetEvent('item17',function(){ThemeChangeColor('#printTitle',false,this.value,false,true);},'input');
SetEvent('item18',function(){ThemeChangeColor('#menu',true,this.value);},'input');
SetEvent('item19',function(){ThemeChangeColor('#menu',false,this.value,false,true);},'input');
ShowWind(true);
}
document.addEventListener('DOMContentLoaded',startApp);
}()); // конец безымянной функции
