From 67619cdba8f6b9fdac130c7728f29feb6b400555 Mon Sep 17 00:00:00 2001 From: WizLxn Date: Tue, 17 Mar 2015 09:54:47 +0800 Subject: [PATCH] Merge branch 'v2.1.16' --- CHANGELOG.md | 42 +- CMakeLists.txt | 13 + build/osx/Info.plist | 4 +- i18n/wiznote_zh_CN.ts | 732 +++--- i18n/wiznote_zh_TW.ts | 740 +++--- .../core/CLucene/queryParser/QueryParser.cpp | 2 +- .../queryParser/QueryParserTokenManager.cpp | 4 +- lib/cryptopp/wake.cpp | 16 +- mac-package.sh | 4 +- share/files/code/insert_code-webengine.htm | 339 +++ share/files/code/insert_code.htm | 308 +++ share/files/code/wiz_code_highlight.css | 291 +++ share/files/editor/index.html | 4 +- share/files/editor/qwebchannel.js | 473 ++++ share/files/editor/todo-webengine.js | 1865 +++++++++++++++ share/files/editor/todo.js | 36 +- share/files/editor/webchannel_inject.js | 64 + .../files/editor/wiznote_extend-webengine.js | 395 ++++ share/files/editor/wiznote_extend.js | 31 + .../editor/wiztodo_read_checked-webengine.js | 1554 ++++++++++++ share/files/editor/wiztodo_read_checked.js | 154 +- share/files/errorpage/load_error.png | Bin 0 -> 2976 bytes share/files/errorpage/load_fail.html | 24 + share/files/errorpage/load_fail_comments.html | 50 + share/files/mainmenu.ini | 7 + .../files/markdown}/WizNote-Markdown.js | 2 +- .../google-code-prettify/lang-apollo.js | 0 .../google-code-prettify/lang-basic.js | 0 .../google-code-prettify/lang-clj.js | 0 .../google-code-prettify/lang-css.js | 0 .../google-code-prettify/lang-dart.js | 0 .../google-code-prettify/lang-erlang.js | 0 .../markdown}/google-code-prettify/lang-go.js | 0 .../markdown}/google-code-prettify/lang-hs.js | 0 .../google-code-prettify/lang-lisp.js | 0 .../google-code-prettify/lang-llvm.js | 0 .../google-code-prettify/lang-lua.js | 0 .../google-code-prettify/lang-matlab.js | 0 .../markdown}/google-code-prettify/lang-ml.js | 0 .../google-code-prettify/lang-mumps.js | 0 .../markdown}/google-code-prettify/lang-n.js | 0 .../google-code-prettify/lang-pascal.js | 0 .../google-code-prettify/lang-proto.js | 0 .../markdown}/google-code-prettify/lang-r.js | 0 .../markdown}/google-code-prettify/lang-rd.js | 0 .../google-code-prettify/lang-scala.js | 0 .../google-code-prettify/lang-sql.js | 0 .../google-code-prettify/lang-tcl.js | 0 .../google-code-prettify/lang-tex.js | 0 .../markdown}/google-code-prettify/lang-vb.js | 0 .../google-code-prettify/lang-vhdl.js | 0 .../google-code-prettify/lang-wiki.js | 0 .../markdown}/google-code-prettify/lang-xq.js | 0 .../google-code-prettify/lang-yaml.js | 0 .../google-code-prettify/prettify.css | 0 .../google-code-prettify/prettify.js | 0 .../google-code-prettify/run_prettify.js | 0 .../files/markdown}/inlinecss/csstoinline.js | 0 .../inlinecss/jquery.inlineStyler.min.js | 0 .../files/markdown}/markdown/github2.css | 1 - .../files/markdown}/markdown/jquery.min.js | Bin .../files/markdown}/markdown/marked.min.js | 0 .../markdown}/wiznote-markdown-inject.js | 0 share/skins/default/groupLimit.png | Bin 0 -> 1131 bytes share/skins/default/groupLimit@2x.png | Bin 0 -> 1307 bytes src/CMakeLists.txt | 8 + src/html/wizhtmlcollector.cpp | 1 + src/mac/wizUserInfoWidgetBaseMac.mm | 5 +- src/mac/wizmachelper.h | 1 - src/mac/wizmachelper.mm | 3 +- src/mac/wizmactoolbar.h | 14 +- src/mac/wizmactoolbar.mm | 14 + src/main.cpp | 1 + src/notifybar.cpp | 5 +- src/plugins/coreplugin/inoteview.h | 5 + src/plugins/markdown/CMakeLists.txt | 5 - src/plugins/markdown/markdown.cpp | 193 +- src/plugins/markdown/markdown.h | 8 +- src/plugins/markdown/markdown.qrc | 42 - src/share/websocketclientwrapper.cpp | 74 + src/share/websocketclientwrapper.h | 65 + src/share/websockettransport.cpp | 104 + src/share/websockettransport.h | 62 + src/share/wizDatabase.cpp | 138 +- src/share/wizDatabase.h | 11 +- src/share/wizIndex.cpp | 9 +- src/share/wizIndex.h | 5 +- src/share/wizSyncableDatabase.h | 7 +- src/share/wizmisc.cpp | 35 +- src/share/wizmisc.h | 1 + src/share/wizobject.h | 2 +- src/share/wizsettings.cpp | 2 +- src/share/wizui.cpp | 6 + src/share/wizui.h | 1 + src/sync/sync.cpp | 129 +- src/sync/wizXmlRpcServer.cpp | 4 +- src/sync/wizXmlRpcServer.h | 4 +- src/sync/wizkmsync.cpp | 12 + src/sync/wizkmsync.h | 1 + src/sync/wizkmxmlrpc.h | 2 +- src/titlebar.cpp | 160 +- src/titlebar.h | 17 + src/titleedit.cpp | 18 +- src/titleedit.h | 1 - src/ui/wizLoginDialog.ui | 8 +- src/utils/pinyin.cpp | 2 +- src/widgets/WizCodeEditorDialog.cpp | 189 +- src/widgets/WizCodeEditorDialog.h | 35 +- src/widgets/wizUserInfoWidget.h | 10 +- src/wizCategoryView.cpp | 181 +- src/wizCategoryView.h | 15 +- src/wizCategoryViewItem.cpp | 71 +- src/wizDocumentListView.cpp | 33 +- src/wizDocumentListView.h | 8 +- src/wizDocumentListViewItem.cpp | 18 +- src/wizDocumentView.cpp | 76 +- src/wizDocumentView.h | 25 + src/wizDocumentWebEngine.cpp | 2089 +++++++++++++++++ src/wizDocumentWebEngine.h | 367 +++ src/wizDocumentWebView.cpp | 305 ++- src/wizDocumentWebView.h | 41 +- src/wizEditorToolBar.cpp | 536 ++++- src/wizEditorToolBar.h | 28 +- src/wizFileReader.cpp | 45 +- src/wizFileReader.h | 11 +- src/wizSearchWidget.cpp | 8 +- src/wizSearchWidget.h | 9 +- src/wizUpgrade.cpp | 2 +- src/wizWebEngineInjectObject.cpp | 47 + src/wizWebEngineInjectObject.h | 32 + src/wizWebSettingsDialog.cpp | 47 +- src/wizWebSettingsDialog.h | 5 +- src/wizactions.cpp | 145 +- src/wizactions.h | 1 - src/wizattachmentlistwidget.cpp | 38 +- src/wizattachmentlistwidget.h | 2 +- src/wizdef.h | 2 +- src/wizmainwindow.cpp | 812 ++++--- src/wizmainwindow.h | 47 +- src/wiznoteinfoform.cpp | 88 +- src/wiznoteinfoform.h | 8 + 141 files changed, 11917 insertions(+), 1799 deletions(-) create mode 100644 share/files/code/insert_code-webengine.htm create mode 100644 share/files/code/insert_code.htm create mode 100644 share/files/code/wiz_code_highlight.css create mode 100644 share/files/editor/qwebchannel.js create mode 100644 share/files/editor/todo-webengine.js create mode 100644 share/files/editor/webchannel_inject.js create mode 100644 share/files/editor/wiznote_extend-webengine.js create mode 100644 share/files/editor/wiztodo_read_checked-webengine.js create mode 100644 share/files/errorpage/load_error.png create mode 100644 share/files/errorpage/load_fail.html create mode 100644 share/files/errorpage/load_fail_comments.html rename {src/plugins/markdown/res => share/files/markdown}/WizNote-Markdown.js (98%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-apollo.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-basic.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-clj.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-css.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-dart.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-erlang.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-go.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-hs.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-lisp.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-llvm.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-lua.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-matlab.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-ml.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-mumps.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-n.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-pascal.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-proto.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-r.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-rd.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-scala.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-sql.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-tcl.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-tex.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-vb.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-vhdl.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-wiki.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-xq.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/lang-yaml.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/prettify.css (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/prettify.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/google-code-prettify/run_prettify.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/inlinecss/csstoinline.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/inlinecss/jquery.inlineStyler.min.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/markdown/github2.css (95%) rename {src/plugins/markdown/res => share/files/markdown}/markdown/jquery.min.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/markdown/marked.min.js (100%) rename {src/plugins/markdown/res => share/files/markdown}/wiznote-markdown-inject.js (100%) create mode 100644 share/skins/default/groupLimit.png create mode 100644 share/skins/default/groupLimit@2x.png delete mode 100644 src/plugins/markdown/markdown.qrc create mode 100644 src/share/websocketclientwrapper.cpp create mode 100644 src/share/websocketclientwrapper.h create mode 100644 src/share/websockettransport.cpp create mode 100644 src/share/websockettransport.h create mode 100644 src/wizDocumentWebEngine.cpp create mode 100644 src/wizDocumentWebEngine.h create mode 100644 src/wizWebEngineInjectObject.cpp create mode 100644 src/wizWebEngineInjectObject.h diff --git a/CHANGELOG.md b/CHANGELOG.md index a5a198ed4..2acaa837a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,44 @@ -## 2.1.14(2014-11-19) +##2.1.16(2015-3-12) + +Bugfixes: + +- [Mac]Fix the delay problem of text input. +- [Linux]Fix the crash problem when drag document to folder. +- Fixed the initialization delay problem of insert code panel. + +Features: + +- Add the funtion of importing files(not supported documents with images for now). +- Added support table cell alignment. +- Modify the usage of editor color selection buttons. +- Add function to retrieve the deleted notes. +- Modify the limitation prompt of group. +- Optimized loading speed of notes list. +- Modify the Markdown references css file storage location, you can manually modify the style. +- You can edit note information now. + + +##2.1.15(2015-1-16) + +Bugfixes: + +- Fix the problem that modify the sync interval had no effect. +- Fix the width problem when pasting as plain text. + +Features: + +- Modify the way of checking the status of the group notes, no longer allowed to edit notes that editing by other users! +- Add the function of manually sorting folders. You can choose to manually sort the folder or sorted in a systematic manner in the preferences. +- Quit program if system tray icon is unvisible when users close the mainwindow. +- Change the icon for system tray icon. +- Add the function of sending notes by email. +- Added support for searching encrypted notes, need to enter the password in the preferences. +- Add the function of setting the editor background color in preferences. +- Add the function of editing the html source code of notes. +- All unread messages can be marked as read. +- Update note version when upload data to server. + +##2.1.14(2014-11-9) Bugfixes: diff --git a/CMakeLists.txt b/CMakeLists.txt index a07f5eb37..3c0331df5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,17 @@ if(NOT CMAKE_BUILD_TYPE) FORCE) endif() +include(CheckCXXCompilerFlag) +CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) +CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) +if(COMPILER_SUPPORTS_CXX11) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +elseif(COMPILER_SUPPORTS_CXX0X) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") +else() + message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") +endif() + if(NOT WIZNOTE_USE_QT5) set(WIZNOTE_USE_QT5 OFF CACHE BOOL "Build WizNote use Qt5, default is off.") @@ -39,6 +50,8 @@ if(APPLE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -gdwarf-2") add_definitions(-DBUILD4APPSTORE=TRUE) endif(APPSTORE_BUILD) +# add_definitions(-DUSECOCOATOOLBAR=TRUE) +# add_definitions(-DUSEWEBENGINE=FALSE) endif(APPLE) if(APPLE) diff --git a/build/osx/Info.plist b/build/osx/Info.plist index d6e03eafd..8efda03c7 100644 --- a/build/osx/Info.plist +++ b/build/osx/Info.plist @@ -15,7 +15,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleShortVersionString - 2.1.15 + 2.1.16.2 LSApplicationCategoryType public.app-category.productivity CFBundleName @@ -27,7 +27,7 @@ CFBundleSignature ???? CFBundleVersion - 9.1 + 9.2.2 CSResourcesFileMapped LSRequiresCarbon diff --git a/i18n/wiznote_zh_CN.ts b/i18n/wiznote_zh_CN.ts index 5612af0e8..da42270f7 100644 --- a/i18n/wiznote_zh_CN.ts +++ b/i18n/wiznote_zh_CN.ts @@ -14,39 +14,26 @@ 所有文件(*.*) - - + + Can not save attachment to %1 不能保存附件到 %1 - + Save attachments to 保存附件到 - - CWizAttachmentListViewItem - - - Uploading (%1 %) ... - 正在上传 (%1 %) ... - - - - Unknow State - 未知状态 - - CWizAttachmentListWidget - + Add attachments 添加附件 - + Attachments 附件 @@ -54,176 +41,196 @@ CWizCategoryBaseView - + %1 files to load. - 导入 %1 个文件. + 导入 %1 个文件. - + loading... - 正在导入... + 正在导入... CWizCategoryView - - - + + + Please input folder name: 请输入文件夹名称: - + New tag 新建标签 - - + + Please input tag name: 请输入标签名称: - + New group folder 新建群组文件夹 - - + + Move Note: %1 to %2 移动笔记 %1 到 %2 - + Rename tag 重命名标签 - + Rename group folder 重命名群组文件夹 - + Do you really want to delete all notes inside folder: %1 ? (All notes will move to trash folder and remove from cloud server) 确定要删除文件夹 %1 内的所有笔记吗?(所有笔记将会被移动到已删除,并从云端服务器移除) - + Delete tag 删除标签 - + Do you really want to delete tag: %1 ? (include child tags if any) 确定要删除标签 %1 吗?(如果存在子标签也将被删除) - + Delete group folder 删除群组文件夹 - + Do you really want to delete folder: %1? (All notes will move to unclassified folder, It's safe.) 是否要删除文件夹: %1?(所有笔记将会被移动到未分类) - + + Recovery notes + 恢复笔记 + + + Info 提示 - + Your enterprise services has expired, could not manage members. Please purchase services or apply for an extension. 您的企业服务已到期,将无法进行成员管理。请购买服务或申请延期。 - + Create new group 创建群组 - - + + View group info 群组信息 - - + + Manage group 管理群组信息 - + Storage Limit Info 容量限制信息 - + + Traffic Limit Info + 流量限制信息 + + + + Note Count Limit Info + 笔记数目限制信息 + + + + Group notes count limit exceeded! + 群组笔记数目超出限制! + + + View team info 团队信息 - + Manage team 管理团队信息 - + New note 新建笔记 - + Create new group... 创建群组... - + Recent meesages 最近消息 - + Select one or more files to open 选择文件 - + Recent notes 近期笔记 - + No tag notes 无标签笔记 - + New folder 新建文件夹 - + Move folder 移动文件夹 - + Please input new folder name: 请输入新的文件夹名: - + Rename folder 重命名文件夹 - + Delete Folder 删除文件夹 @@ -233,7 +240,7 @@ Console - 消息控制台 + 消息控制台 @@ -269,84 +276,90 @@ CWizDatabase - + Please input document password to encrypt 请输入笔记密码 - + + User password check failed! + 密码错误! + + + My Notes 我的笔记 - - + + My Journals 我的日记 - + My Events 我的事件 - + My Sticky Notes 我的桌面便笺 - + My Emails 我的邮件 - + My Drafts 我的草稿 - + My Tasks 我的任务 - + Inbox 收集箱 - + Completed 已完成 - + Doucment %1 Password 笔记 %1 密码 - + Password : 密码: - - + + + Info 提示 - + No password cert founded. Please create password cert from windows client first. 未发现加密证书,请从Windows客户端创建加密证书。 - + Password 密码 - + password error! 密码错误! @@ -407,27 +420,27 @@ 在新窗口中打开 - + Move notes 移动笔记 - + Move Note: %1 to %2 移动笔记: %1到%2 - + Copy documents 复制笔记 - + Password 密码 - + Please input document password to cancel encrypt. 请输入笔记密码 @@ -450,25 +463,48 @@ 正在从云服务器下载笔记,稍等片刻( %1 %)... + + CWizDocumentWebEngine + + + Image File + 图片文件 + + + + Images (*.png *.bmp *.gif *.jpg) + 图片 (*.png *.bmp *.gif *.jpg) + + + + PDF Files (*.pdf) + PDF 文件 (*.pdf) + + CWizDocumentWebView - + Image File 图片文件 - + Images (*.png *.bmp *.gif *.jpg) 图片 (*.png *.bmp *.gif *.jpg) - + + PDF Files (*.pdf) + PDF 文件 (*.pdf) + + + Inof 提示 - + No available printer founded! Please add printer to system printer list. 未发现可用打印机!请在系统打印机列表中添加打印机。 @@ -567,7 +603,7 @@ Send me a copy - 抄送给我自己 + 抄送给我自己 @@ -577,7 +613,7 @@ Notes: - 备注: + 备注: @@ -664,6 +700,11 @@ Password 密码 + + + Please input email as your account + 请输入邮箱作为用户名 + Create Account @@ -684,11 +725,6 @@ Can not open database while update user profile 更新用户档案时无法打开数据库 - - - Please input eamil as your account - 请输入邮箱作为用户名 - Please enter your password @@ -784,7 +820,7 @@ - + Open 查看 @@ -814,10 +850,20 @@ 加密 - + Locate 定位 + + + Password + 密码 + + + + Please input document password to cancel encrypt. + 请输入笔记密码。 + CWizOptionsWidget @@ -1201,7 +1247,7 @@ Tips mouse dragging screenshots; area right in the screenshots saved; screenshots area right outside cancellation; ESC to exit. - 提示 + 提示 拖拽鼠标选取截图区域;双击选区保存; 选区外右键取消选取;ECS键退出截图。 @@ -1210,7 +1256,7 @@ Coordinate information x: %1 y: %2 w: %3 h: %4 - 坐标信息 + 坐标信息 x: %1 y: %2 w: %3 h: %4 @@ -1557,45 +1603,41 @@ w: %3 h: %4 CWizWebSettingsDialog - - wow, seems unable to load what you want... - 无法打开网页,请重试... + + + Load Error + 无法加载该页面 + + + + Network anomalies, check the network, then retry! + 网络异常,请检查后重试! Core::CWizDocumentView - - Checking whether note is eiditable... - 正在检查笔记是否可编辑... - - - - Checking whether checklist is clickable... - 正在检查清单项是否可点击... - - - + You have occupied this note by clicking checklist ! Switch to other notes to free this note. 您点击了阅读状态的清单项,当前笔记正被您占用!如需解除,请切换到其他笔记。 - + %1 is currently editing this note. Note has been locked. 当前笔记正在被 %1 编辑,笔记已处于锁定状态。 - + %1 is currently editing this note. 当前笔记正在被 %1 编辑。 - + The current network in poor condition, you are <b> offline editing mode </b>. 当前网络状况不佳,您正处于 <b> 离线编辑模式 </b>。 - + New version on server avalible. <a href='%1'>Click to down load new version.<a> 检测到当前笔记有更新,<a href='%1'>下载更新<a> @@ -1603,114 +1645,131 @@ w: %3 h: %4 Core::Internal::EditorToolBar - + FormatMatch 格式刷 - + ForeColor 字体颜色 - + BackColor 背景色 - + Bold 粗体 - + Italic 斜体 - + UnderLine 下划线 - + StrikeThrough 删除线 - + JustifyLeft 左对齐 - + JustifyCenter 居中对齐 - + JustifyRight 右对齐 - + UnorderedList 无序列表 - + OrderedList 有序列表 - + InsertTable 插入表格 - + InsertHorizontal 插入水平标尺 - + InsertCheckList 插入清单 - + InsertImage 插入图片 - + Receive mobile image 手机传图 - + Find & Replace 查找 & 替换 - + Screen shot 屏幕截图 - + View source 查看源码 - - + + Insert code + 插入代码 + + + + + transparent + 清除颜色 + + + + + show more colors... + 显示更多颜色... + + + + Save as... 另存为... - - + + Image Files (*.%1) 图片文件 (*.%1) @@ -1718,93 +1777,93 @@ w: %3 h: %4 Core::Internal::MainWindow - + WizNote 为知笔记 - + 1 note 1 条笔记 - - + + %1 notes %1 条笔记 - + sorry, sync failed. please input your password and try again. 抱歉,同步失败了。请输入您的密码再试一次。 - + Info 提示 - + Connection is not available, please check your network connection. 网络连接不可用,请检查网络连接. - + + Search + 搜索 + + + Unread Messages 未读消息 - + Mark all messages read 全部标记为已读 - - PDF Files (*.pdf) - PDF 文件 (*.pdf) - - - + Open Directory 选择文件夹 - + Can't find note %1 , may be it has been deleted. 找不到笔记 %1 , 该篇笔记可能已被删除。 - + Show/Hide MainWindow 显示/隐藏主窗口 - + New Note 新建笔记 - + Hide TrayIcon 隐藏托盘图标 - + Logout 注销 - + Exit 退出 - + Rebuild full text search index 重建搜索索引 - + Rebuild full text search is quit slow if you have quite a few notes or attachments, you do not have to use this function while search should work as expected. 重建全文搜索索引会非常慢。只有在您的搜索出现异常的时候才需要用这个功能。 @@ -1850,64 +1909,70 @@ w: %3 h: %4 Core::Internal::TitleBar - + Switch to Editing View (Alt + 1) 切换到编辑视图 (Alt + 1) - + Switch to Reading View (Alt + 1) 切换到阅读视图 (Alt + 1) - + Save and switch to Reading View (Alt + 1) 保存并切换到阅读视图 (Alt + 1) - + View and add tags (Alt + 2) 浏览并添加标签 (Alt + 2) - + Add attachments (Alt + 3) 添加附件 (Alt + 3) - + View and add attachments (Alt + 3) 浏览并添加附件 (Alt + 3) - + View and recover note's history (Alt + 4) 浏览并恢复历史版本 (Alt + 4) - + View and modify note's info (Alt + 5) 浏览并修改笔记属性 (Alt + 5) - + Share document by email (Alt + 6) 通过邮件发送笔记 (Alt + 6) - + Add comments (Alt + 7) 添加评论 (Alt + 7) - + View and add comments (Alt + 7) 查看并添加评论 (Alt + 7) - - Network service not available! - 网络连接不可用! + + + Load Error + 无法加载该页面 + + + + Network anomalies, check the network, then retry! + 网络异常,请检查后重试! @@ -2034,13 +2099,13 @@ w: %3 h: %4 列表 - + Table 表格 - + Link 链接 @@ -2142,84 +2207,114 @@ w: %3 h: %4 + Move to page start + 移动到文章开始 + + + + Move to page end + 移动到文章结尾 + + + + Move to line start + 移动到行首 + + + + Move to line end + 移动到行尾 + + + Hide category view 隐藏侧边栏 - + Show category view 显示侧边栏 - + Enter fullscreen 进入全屏幕 - + Leave fullscreen 离开全屏幕 - + + Minimize + 最小化 + + + Insert check list 插入清单 - + Convert to plain text 转为纯文本 - + View html source... 查看网页源代码... - + Screen shot... 屏幕截图... - - + + Developer mode + 开发者模式 + + + + Justify left 左对齐 - - + + Justify right 右对齐 - - + + Justify center 居中 - + Justify both side 两端对齐 - + Indent 增加缩进级别 - + Outdent 减少缩进级别 - + Convert to unoredered list 转为(无序)符号列表 - + Convert to ordered list 转为(有序)编号列表 @@ -2299,67 +2394,67 @@ w: %3 h: %4 全选 - - + + Insert table 插入表格 - + Insert link 插入链接 - - + + Bold 粗体 - - + + Italic 斜体 - - + + Underline 下划线 - - + + Strike through 删除线 - + Insert horizontal 插入水平标尺 - + Insert date 插入日期 - + Insert time 插入时间 - + Insert code 插入代码 - + Insert image 插入图片 - + Remove format 清除样式 @@ -2374,19 +2469,19 @@ w: %3 h: %4 前进 - - + + WizNote 为知笔记 - + cn.wiz.wiznoteformac - + Can not open database 无法打开数据库 @@ -2411,7 +2506,7 @@ w: %3 h: %4 大小: - + Un-downloaded 未下载 @@ -2431,10 +2526,20 @@ w: %3 h: %4 打开... - + Downloading (%1 %) ... 正在下载 (%1 %) ... + + + Uploading (%1 %) ... + 正在上传 (%1 %) ... + + + + Unknow State + 未知状态 + @@ -2522,8 +2627,8 @@ w: %3 h: %4 - Import file - 导入文件 + Import file... + 导入文件... @@ -2586,6 +2691,11 @@ w: %3 h: %4 Remove from shortcuts 从快捷方式中移除 + + + Recovery deleted notes... + 恢复已删除笔记... + @@ -2648,181 +2758,231 @@ w: %3 h: %4 转到笔记 - + Cut 剪切 - + Copy 拷贝 - + Paste 粘贴 - + Use "Google" search 使用 “Google" 搜索 - + Use "Baidu" search 使用 "百度" 搜索 - + Save Image as... 图片另存为... - + Copy Image 复制图片 - + Copy Image Link 复制图片链接 - + Insert Link 插入链接 - + Edit Link 编辑链接 - + Remove Link 删除链接 - + font color 字体颜色 - + background color 背景颜色 - + Delete table 删除表格 - + Delete row 删除行 - + Delete colum 删除列 - + Insert row 插入上行 - + Insert row next 插入下行 - + Insert colum 插入左列 - + Insert colum next 插入右列 - + Insert caption 插入表格名称 - + Delete caption 删除表格名称 - + Insert title 插入标题行 - + Delete title 删除标题行 - + Merge cells 合并单元格 - + Merge right 向右合并 - + Merge down 向下合并 - + Split cells 拆分单元格 - + Split rows 拆分成行 - + Split colums 拆分成列 - + Averaged distribute rows 平均分布各行 - + Averaged distribute colums 平均分布各列 - + Font 字体 - + Justify 段落方向 - - + + Cell Alignment + 单元格对齐 + + + + Align leftTop + 靠上两端对齐 + + + + Align top + 靠上居中 + + + + Align rightTop + 靠上右对齐 + + + + Align left + 中部两端对齐 + + + + Align center + 居中 + + + + Align right + 中部右对齐 + + + + Align leftBottom + 靠下两端对齐 + + + + Align bottom + 靠下居中 + + + + Align rightBottom + 靠下右对齐 + + + + Unknown 未知 @@ -3030,7 +3190,7 @@ w: %3 h: %4 %1 字节 - + Note History 笔记版本历史 @@ -3045,50 +3205,50 @@ w: %3 h: %4 $分享给朋友的笔记 - + Download Note %1 下载笔记 %1 - + Downloading,please wait... 正在下载,请稍等... - + Download Attachment %1 下载附件 %1 - + Downloading, please wait... 正在下载,请稍等... - + Print Document 打印文档 + + + Group notes count limit exceeded! + 群组笔记数目超出限制! + WizCodeEditorDialog - - Code Type : - 代码类型: - - - - Priview : - 预览: + + Language + 语言 - + OK 确定 - + Cancel 取消 @@ -3104,57 +3264,57 @@ w: %3 h: %4 wizLoginWidget - + Form - + - + Remember password 记住密码 - + Auto sign in 自动登录 - + Login 登录 - + Create Account 创建帐号 - + !! password error 密码错误 - + No account yet, 还没有帐号, - + click to sign up 点此注册 - + click to login 点此登录 - + Proxy settings 代理设置 - + Reset password 重置密码 diff --git a/i18n/wiznote_zh_TW.ts b/i18n/wiznote_zh_TW.ts index ebf5de516..1acb9c8f0 100644 --- a/i18n/wiznote_zh_TW.ts +++ b/i18n/wiznote_zh_TW.ts @@ -14,39 +14,26 @@ 所有檔案(*.*) - - + + Can not save attachment to %1 無法保存附件到 %1 - + Save attachments to 保存附件到 - - CWizAttachmentListViewItem - - - Uploading (%1 %) ... - 正在上傳 (%1 %) ... - - - - Unknow State - 位置狀態 - - CWizAttachmentListWidget - + Add attachments 新增附件 - + Attachments 附件 @@ -54,176 +41,196 @@ CWizCategoryBaseView - + %1 files to load. - 導入 %1 個檔案. + 導入 %1 個檔案. - + loading... - 正在導入... + 正在導入... CWizCategoryView - - - + + + Please input folder name: 請輸入資料夾名稱: - + New tag 新建標籤 - - + + Please input tag name: 請輸入標簽名稱: - + New group folder 新建群組資料夾 - - + + Move Note: %1 to %2 移動筆記 %1 到 %2 - + Rename tag 重新命名標籤 - + Rename group folder 重新命名群組資料夾 - + Do you really want to delete all notes inside folder: %1 ? (All notes will move to trash folder and remove from cloud server) 確定要刪除資料夾%1 內的所有文件嗎?(所有文件將會被移動到已刪除,並從雲端伺服器移除) - + Delete tag 刪除標籤 - + Do you really want to delete tag: %1 ? (include child tags if any) 確定要刪除標籤 %1 嗎?(如果存在子標籤也將被刪除) - + Delete group folder 刪除群組資料夾 - + Do you really want to delete folder: %1? (All notes will move to unclassified folder, It's safe.) 是否要刪除文件夾: %1? (所有筆記將會被移動到未分類) - + + Recovery notes + 恢復筆記 + + + Info 提示 - + Your enterprise services has expired, could not manage members. Please purchase services or apply for an extension. 您的企業服務已到期,將無法進行成員管理。請購買服務或申請延期。 - + Create new group 創建羣組 - - + + View group info 羣組信息 - - + + Manage group 管理羣組信息 - + Storage Limit Info 容量限制信息 - + + Traffic Limit Info + 流量限制信息 + + + + Note Count Limit Info + 筆記數目限制信息 + + + + Group notes count limit exceeded! + 羣組筆記數目超出限制! + + + View team info 團隊信息 - + Manage team 管理團隊信息 - + New note 新建筆記 - + Create new group... 創建羣組... - + Recent meesages 最近訊息 - + Select one or more files to open 選擇文件 - + Recent notes 最近筆記 - + No tag notes 無標籤筆記 - + New folder 新建資料夾 - + Move folder 移動資料夾 - + Please input new folder name: 請輸入新的資料夾名: - + Rename folder 重新命名資料夾 - + Delete Folder 刪除資料夾 @@ -233,7 +240,7 @@ Console - 訊息控制台 + 訊息控制台 @@ -263,90 +270,96 @@ you should select a file name which does not exists - 您應當使用一個不重復的名稱進行保存 + 您應當使用一個不重復的名稱進行保存 CWizDatabase - + Please input document password to encrypt 請輸入筆記密碼 - + + User password check failed! + 密碼錯誤! + + + My Notes 我的筆記 - - + + My Journals 我的日記 - + My Events 我的事件 - + My Sticky Notes 我的桌面便箋 - + My Emails 我的郵件 - + My Drafts 我的草稿 - + My Tasks 我的任務 - + Inbox 收集箱 - + Completed 已完成 - + Doucment %1 Password 筆記 %1 密碼 - + Password : 密碼: - - + + + Info 提示 - + No password cert founded. Please create password cert from windows client first. 未發現加密證書,請從Windows客戶端創建加密證書。 - + Password 密碼 - + password error! 密碼錯誤! @@ -407,27 +420,27 @@ 在新窗口中打開 - + Move notes 移動筆記 - + Move Note: %1 to %2 移動筆記: %1 到 %2 - + Copy documents 複製筆記 - + Password 密碼 - + Please input document password to cancel encrypt. 請輸入筆記密碼. @@ -450,25 +463,48 @@ 正在從雲伺服器下載筆記,稍等片刻( %1 %)... + + CWizDocumentWebEngine + + + Image File + 圖片文件 + + + + Images (*.png *.bmp *.gif *.jpg) + 圖片 (*.png *.bmp *.gif *.jpg) + + + + PDF Files (*.pdf) + PDF 檔案 (*.pdf) + + CWizDocumentWebView - + Image File 圖片文件 - + Images (*.png *.bmp *.gif *.jpg) 圖片 (*.png *.bmp *.gif *.jpg) - + + PDF Files (*.pdf) + PDF 檔案 (*.pdf) + + + Inof 提示 - + No available printer founded! Please add printer to system printer list. 未發現可用打印機!請在系統打印機列表中添加打印機。 @@ -567,7 +603,7 @@ Send me a copy - 抄送給我自己 + 抄送給我自己 @@ -597,7 +633,7 @@ Sending... - 正在發送中... + 正在發送中... @@ -605,12 +641,12 @@ Info - 提示 + 提示 Unkown error. - 未知錯誤。 + 未知錯誤。 @@ -664,6 +700,11 @@ Password 密碼 + + + Please input email as your account + 請輸入電郵作為用戶名 + Create Account @@ -684,11 +725,6 @@ Can not open database while update user profile 更新使用者檔案時無法開啟資料庫 - - - Please input eamil as your account - 請輸入電子郵件地址作為用戶名 - Please enter your password @@ -784,7 +820,7 @@ - + Open 檢視 @@ -814,10 +850,20 @@ 加密 - + Locate 定位 + + + Password + 密碼 + + + + Please input document password to cancel encrypt. + 請輸入筆記密碼. + CWizOptionsWidget @@ -933,7 +979,7 @@ Manually sorting folders - 手動排序資料夾 + 手動排序資料夾 @@ -1201,7 +1247,7 @@ Tips mouse dragging screenshots; area right in the screenshots saved; screenshots area right outside cancellation; ESC to exit. - 提示 + 提示 拖拽鼠標選取截圖區域;雙擊選區保存; 選區外右鍵取消選取;ECS鍵退出截圖。 @@ -1210,7 +1256,7 @@ Coordinate information x: %1 y: %2 w: %3 h: %4 - 坐標信息 + 坐標信息 x: %1 y: %2 w: %3 h: %4 @@ -1557,45 +1603,41 @@ w: %3 h: %4 CWizWebSettingsDialog - - wow, seems unable to load what you want... - 哇,好像暫時沒辦法加載... + + + Load Error + 無法加載該頁面 + + + + Network anomalies, check the network, then retry! + 網絡異常,請檢查後重試! Core::CWizDocumentView - - Checking whether note is eiditable... - 正在檢查筆記是否可編輯... - - - - Checking whether checklist is clickable... - 正在檢查清單項是否可點擊... - - - + You have occupied this note by clicking checklist ! Switch to other notes to free this note. 您點擊了閱讀狀態的清單項,當前筆記正被您佔用!如需解除,請切換到其他筆記。 - + %1 is currently editing this note. Note has been locked. 當前筆記正在被 %1 編輯,筆記已處於鎖定狀態。 - + %1 is currently editing this note. 當前筆記正在被 %1 編輯。 - + The current network in poor condition, you are <b> offline editing mode </b>. 當前網絡狀況不佳,您正處於 <b> 離線編輯模式 </b>。 - + New version on server avalible. <a href='%1'>Click to down load new version.<a> 檢測到當前筆記有更新,<a href='%1'>下載更新<a> @@ -1603,114 +1645,131 @@ w: %3 h: %4 Core::Internal::EditorToolBar - + FormatMatch 格式刷 - + ForeColor 字體顏色 - + BackColor 背景顏色 - + Bold 粗體 - + Italic 斜體 - + UnderLine 底線 - + StrikeThrough 刪除線 - + JustifyLeft 左對齊 - + JustifyCenter 居中 - + JustifyRight 右對齊 - + UnorderedList 無序列表 - + OrderedList 有序列表 - + InsertTable 插入表格 - + InsertHorizontal 插入水平標尺 - + InsertCheckList 插入清單 - + InsertImage 插入圖片 - + Receive mobile image 手機傳圖 - + Find & Replace 查找 & 替換 - + Screen shot 屏幕截圖 - + View source 查看源碼 - - + + Insert code + 插入代碼 + + + + + transparent + 清除顏色 + + + + + show more colors... + 顯示更多顏色... + + + + Save as... 另存爲... - - + + Image Files (*.%1) 圖片檔案 (*.%1) @@ -1718,93 +1777,93 @@ w: %3 h: %4 Core::Internal::MainWindow - + WizNote 爲知筆記 - + 1 note 1 條筆記 - - + + %1 notes %1 條筆記 - + sorry, sync failed. please input your password and try again. 抱歉,同步失敗了。請輸入您的密碼再試一次。 - + Info 提示 - + Connection is not available, please check your network connection. 網絡連接不可用,請檢查網絡連接. - + + Search + 搜索 + + + Unread Messages 未讀消息 - + Mark all messages read 全部標記為為已讀 - - PDF Files (*.pdf) - PDF 檔案 (*.pdf) - - - + Open Directory 選擇文件夾 - + Can't find note %1 , may be it has been deleted. 找不到筆記 %1 , 該篇筆記可能已被刪除。 - + Show/Hide MainWindow 顯示/隱藏主窗口 - + New Note 新建筆記 - + Hide TrayIcon 隱藏托盤圖標 - + Logout 註銷 - + Exit 退出 - + Rebuild full text search index 重建搜尋索引 - + Rebuild full text search is quit slow if you have quite a few notes or attachments, you do not have to use this function while search should work as expected. 重建全文搜索索引會非常慢。只有在您的搜索出現異常的時候才需要使用這個功能。 @@ -1850,64 +1909,70 @@ w: %3 h: %4 Core::Internal::TitleBar - + Switch to Editing View (Alt + 1) 切換到編輯檢視方式 (Alt + 1) - + Switch to Reading View (Alt + 1) 切換到閱讀檢視方式 (Alt + 1) - + Save and switch to Reading View (Alt + 1) 保存並切換到閱讀檢視方式 (Alt + 1) - + View and add tags (Alt + 2) 瀏覽並添加標籤 (Alt + 2) - + Add attachments (Alt + 3) 添加附件 (Alt + 3) - + View and add attachments (Alt + 3) 瀏覽並添加附件 (Alt + 3) - + View and recover note's history (Alt + 4) 瀏覽並恢復歷史版本 (Alt + 4) - + View and modify note's info (Alt + 5) 瀏覽並修改筆記屬性 (Alt + 5) - + Share document by email (Alt + 6) 通過郵件發送筆記 (Alt + 6) - + Add comments (Alt + 7) 添加評論 (Alt + 7) - + View and add comments (Alt + 7) 查看並添加評論 (Alt + 7) - - Network service not available! - 網絡連接不可用用! + + + Load Error + 無法加載該頁面 + + + + Network anomalies, check the network, then retry! + 網絡異常,請檢查後重試! @@ -2034,13 +2099,13 @@ w: %3 h: %4 列表 - + Table 表格 - + Link 連結 @@ -2142,84 +2207,114 @@ w: %3 h: %4 + Move to page start + 移動到文章開始 + + + + Move to page end + 移動到文章結尾 + + + + Move to line start + 移動到行首 + + + + Move to line end + 移動到行尾 + + + Hide category view 隱藏側邊欄 - + Show category view 顯示側邊欄 - + Enter fullscreen 進入全屏幕 - + Leave fullscreen 離開全屏幕 - + + Minimize + 最小化 + + + Insert check list 插入清單 - + Convert to plain text 轉為純文字 - + View html source... 查看網頁源代碼... - + Screen shot... 屏幕截圖... - - + + Developer mode + 開發者模式 + + + + Justify left 左對齊 - - + + Justify right 右對齊 - - + + Justify center 居中 - + Justify both side 兩端對齊 - + Indent 增加縮進級別 - + Outdent 減少縮進級別 - + Convert to unoredered list 轉爲(無序)符號列表 - + Convert to ordered list 轉爲(有序)編號列表 @@ -2299,67 +2394,67 @@ w: %3 h: %4 全選 - - + + Insert table 插入表格 - + Insert link 插入連結 - - + + Bold 粗體 - - + + Italic 斜體 - - + + Underline 底線 - - + + Strike through 刪除線 - + Insert horizontal 插入水平標尺 - + Insert date 插入日期 - + Insert time 插入時間 - + Insert code 插入代碼 - + Insert image 插入圖片 - + Remove format 清除樣式 @@ -2374,19 +2469,19 @@ w: %3 h: %4 前進 - - + + WizNote 爲知筆記 - + cn.wiz.wiznoteformac - + Can not open database 無法開啟資料庫 @@ -2411,7 +2506,7 @@ w: %3 h: %4 大小: - + Un-downloaded 未下載 @@ -2431,10 +2526,20 @@ w: %3 h: %4 開啟... - + Downloading (%1 %) ... 正在下載 (%1 %) ... + + + Uploading (%1 %) ... + 正在上傳 (%1 %) ... + + + + Unknow State + 位置狀態 + @@ -2528,8 +2633,8 @@ w: %3 h: %4 - Import file - 導入文件 + Import file... + 導入文件... @@ -2592,6 +2697,11 @@ w: %3 h: %4 Remove from shortcuts 從快捷方式中移除 + + + Recovery deleted notes... + 恢復已刪除筆記... + Tags... @@ -2648,181 +2758,231 @@ w: %3 h: %4 轉到筆記 - + Cut 剪下 - + Copy 複製 - + Paste 貼上 - + Use "Google" search 使用“Google"搜尋 - + Use "Baidu" search 使用 "百度" 搜索 - + Save Image as... 圖片另存為... - + Copy Image 復制圖片 - + Copy Image Link 復制圖片鏈接 - + Insert Link 插入連結 - + Edit Link 編輯連結 - + Remove Link 刪除連結 - + font color 字體顏色 - + background color 背景顏色 - + Delete table 刪除表格 - + Delete row 刪除行 - + Delete colum 刪除列 - + Insert row 插入上行 - + Insert row next 插入下行 - + Insert colum 插入左列 - + Insert colum next 插入右列 - + Insert caption 插入表格名稱 - + Delete caption 刪除表格名稱 - + Insert title 插入標題行 - + Delete title 刪除標題行 - + Merge cells 合併單元格 - + Merge right 向右合併 - + Merge down 向下合併 - + Split cells 拆分單元格 - + Split rows 拆分成行 - + Split colums 拆分成列 - + Averaged distribute rows 平均分佈各行 - + Averaged distribute colums 平均分佈各列 - + Font 字體 - + Justify 段落方向 - - + + Cell Alignment + 單元格對齊 + + + + Align leftTop + 靠上兩端對齊 + + + + Align top + 靠上居中 + + + + Align rightTop + 靠上右對齊 + + + + Align left + 中部兩端對齊 + + + + Align center + 居中 + + + + Align right + 中部右對齊 + + + + Align leftBottom + 靠下兩端對齊 + + + + Align bottom + 靠下居中 + + + + Align rightBottom + 靠下右對齊 + + + + Unknown 未知 @@ -3030,7 +3190,7 @@ w: %3 h: %4 - + Note History 筆記版本歷史 @@ -3045,50 +3205,50 @@ w: %3 h: %4 $分享給朋友的筆記 - + Download Note %1 下載筆記 %1 - + Downloading,please wait... 正在下載,請稍等... - + Download Attachment %1 下載附件 %1 - + Downloading, please wait... 正在下載,請稍等... - + Print Document 打印文檔 + + + Group notes count limit exceeded! + 羣組筆記數目超出限制! + WizCodeEditorDialog - - Code Type : - 代碼類型: - - - - Priview : - 預覽: + + Language + 語言 - + OK 確定 - + Cancel 取消 @@ -3104,57 +3264,57 @@ w: %3 h: %4 wizLoginWidget - + Form - + - + Remember password 記住密碼 - + Auto sign in 自動登錄 - + Login 登入 - + Create Account 建立帳號 - + !! password error 密碼錯誤 - + No account yet, 還沒有帳號, - + click to sign up 點此注冊 - + click to login 點此登錄 - + Proxy settings 代理設定 - + Reset password 重置密碼 diff --git a/lib/clucene/src/core/CLucene/queryParser/QueryParser.cpp b/lib/clucene/src/core/CLucene/queryParser/QueryParser.cpp index 2f9df9ae2..bfe6649c2 100644 --- a/lib/clucene/src/core/CLucene/queryParser/QueryParser.cpp +++ b/lib/clucene/src/core/CLucene/queryParser/QueryParser.cpp @@ -79,7 +79,7 @@ const TCHAR* QueryParserConstants::tokenImage[] = { _T("") }; -const int32_t QueryParser::jj_la1_0[] = {0x180,0x180,0xe00,0xe00,0x1f69f80,0x48000,0x10000,0x1f69000,0x1348000,0x80000,0x80000,0x10000,0x18000000,0x2000000,0x18000000,0x10000,0x80000000,0x20000000,0x80000000,0x10000,0x80000,0x10000,0x1f68000}; +const int32_t QueryParser::jj_la1_0[] = {0x180,0x180,0xe00,0xe00,0x1f69f80,0x48000,0x10000,0x1f69000,0x1348000,0x80000,0x80000,0x10000,static_cast(0x18000000),static_cast(0x2000000),static_cast(0x18000000),static_cast(0x10000),static_cast(0x80000000),static_cast(0x20000000),static_cast(0x80000000),static_cast(0x10000),static_cast(0x80000),static_cast(0x10000),static_cast(0x1f68000)}; const int32_t QueryParser::jj_la1_1[] = {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x1,0x0,0x0,0x0,0x0}; struct QueryParser::JJCalls { diff --git a/lib/clucene/src/core/CLucene/queryParser/QueryParserTokenManager.cpp b/lib/clucene/src/core/CLucene/queryParser/QueryParserTokenManager.cpp index 14de0cf18..0356fc6a2 100644 --- a/lib/clucene/src/core/CLucene/queryParser/QueryParserTokenManager.cpp +++ b/lib/clucene/src/core/CLucene/queryParser/QueryParserTokenManager.cpp @@ -15,9 +15,9 @@ CL_NS_DEF(queryParser) -const int64_t QueryParserTokenManager::jjbitVec2[]={0x0L, 0x0L, _ILONGLONG(0xffffffffffffffff), _ILONGLONG(0xffffffffffffffff)}; +const int64_t QueryParserTokenManager::jjbitVec2[]={0x0L, 0x0L, static_cast(_ILONGLONG(0xffffffffffffffff)), static_cast(_ILONGLONG(0xffffffffffffffff))}; const int64_t QueryParserTokenManager::jjbitVec0[] = { - _ILONGLONG(0xfffffffffffffffe), _ILONGLONG(0xffffffffffffffff), _ILONGLONG(0xffffffffffffffff), _ILONGLONG(0xffffffffffffffff) + static_cast(_ILONGLONG(0xfffffffffffffffe)), static_cast(_ILONGLONG(0xffffffffffffffff)), static_cast(_ILONGLONG(0xffffffffffffffff)),static_cast( _ILONGLONG(0xffffffffffffffff)) }; const int32_t QueryParserTokenManager::jjnextStates[]={ 15, 17, 18, 29, 32, 23, 33, 30, 20, 21, 32, 23, 33, 31, 34, 27, diff --git a/lib/cryptopp/wake.cpp b/lib/cryptopp/wake.cpp index c34165b8c..9f59b5f72 100644 --- a/lib/cryptopp/wake.cpp +++ b/lib/cryptopp/wake.cpp @@ -24,14 +24,14 @@ void WAKE_Base::GenKey(word32 k0, word32 k1, word32 k2, word32 k3) // x and z were declared as "long" in Wheeler's paper, which is a signed type. I don't know if that was intentional, but it's too late to change it now. -- Wei 7/4/2010 CRYPTOPP_COMPILE_ASSERT(sizeof(x) == 4); static int tt[10]= { - 0x726a8f3b, // table - 0xe69a3b5c, - 0xd3c71fe5, - 0xab3c73d2, - 0x4d3a8eb3, - 0x0396d6e8, - 0x3d4c2f7a, - 0x9ee27cf3, } ; + static_cast(0x726a8f3b), // table + static_cast(0xe69a3b5c), + static_cast(0xd3c71fe5), + static_cast(0xab3c73d2), + static_cast(0x4d3a8eb3), + static_cast(0x0396d6e8), + static_cast(0x3d4c2f7a), + static_cast(0x9ee27cf3), } ; t[0] = k0; t[1] = k1; t[2] = k2; diff --git a/mac-package.sh b/mac-package.sh index 61e0095ca..51ba602b6 100755 --- a/mac-package.sh +++ b/mac-package.sh @@ -23,14 +23,14 @@ setFile -a V ${package_home}/wiznote-disk-cover.jpg current_date=`date "+%Y-%m-%d"` rm -f "${package_output_path}/tmp.dmg" -rm -f "${package_output_path}/wiznote-${current_date}.dmg" +rm -f "${package_output_path}/wiznote-macos-${current_date}.dmg" if [ -e "$package_home" ]; then # 最好固定打包格式,可以只拷贝需要的文件,避免因为需要sudo权限才能访问的文件无法复制而导致失败 #cp -R $volumn_path/wiznote.app $volumn_path/.wiznote-disk-cover.jpg $volumn_path/.DS_store $volumn_path/Applications $package_data_path rm -rf ./${package_home}/WizNote.app && \ cp -R ../WizQTClient-Release-QT5/WizNote.app ${package_home} && \ hdiutil makehybrid -hfs -hfs-volume-name $volumn_name -hfs-openfolder $package_home $package_home -o "${package_output_path}/tmp.dmg" && \ - hdiutil convert -format UDZO "${package_output_path}/tmp.dmg" -o "${package_output_path}/wiznote-${current_date}.dmg" && \ + hdiutil convert -format UDZO "${package_output_path}/tmp.dmg" -o "${package_output_path}/wiznote-macos-${current_date}.dmg" && \ rm -f "${package_output_path}/tmp.dmg" rm -rf ./${package_home}/WizNote.app else diff --git a/share/files/code/insert_code-webengine.htm b/share/files/code/insert_code-webengine.htm new file mode 100644 index 000000000..df85cdc06 --- /dev/null +++ b/share/files/code/insert_code-webengine.htm @@ -0,0 +1,339 @@ + + + + + + + + + + + + + + + + + + + +
+
+ Language:  + +
+
+ +
+
+ + +
+
+
+ + + + diff --git a/share/files/code/insert_code.htm b/share/files/code/insert_code.htm new file mode 100644 index 000000000..eaedd1c02 --- /dev/null +++ b/share/files/code/insert_code.htm @@ -0,0 +1,308 @@ + + + + + + + + + + + + + + + + + + +
+
+ Wiz_Language_Replace:  + +
+
+ +
+
+ + +
+
+
+ + + + diff --git a/share/files/code/wiz_code_highlight.css b/share/files/code/wiz_code_highlight.css new file mode 100644 index 000000000..c874d1db3 --- /dev/null +++ b/share/files/code/wiz_code_highlight.css @@ -0,0 +1,291 @@ +code, tt { + + margin: 0 2px; + padding: 0 5px; + border: 1px solid #eaeaea; + background-color: #f8f8f8; + border-radius: 3px; + white-space: normal; + +} + +pre code { + margin: 0; + padding: 0; + white-space: pre; + word-wrap:break-word; + max-width:100%; + border: none; + background: transparent; } + +.highlight pre { + background-color: #f8f8f8; + border: 1px solid #cccccc; + font-size: 13px; + line-height: 19px; + overflow: auto; + padding: 6px 10px; + border-radius: 3px; } + +pre { + background-color: #f8f8f8; + border: 1px solid #cccccc; + font-size: 13px; + line-height: 19px; + overflow: auto; + padding: 6px 10px; + border-radius: 3px; +} +pre code, pre tt { + background-color: transparent; + border: none; +} + +@media screen { + pre { + word-wrap: break-word; + } +} +@media print { + table, pre { + page-break-inside: avoid; + } + pre { + word-wrap: break-word; + } +} + +/* + +Original style from softwaremaniacs.org (c) Ivan Sagalaev + +*/ + +.hljs { + display: block; padding: 0.5em; + background: #F0F0F0; +} + +.hljs, +.hljs-subst, +.hljs-tag .hljs-title, +.lisp .hljs-title, +.clojure .hljs-built_in, +.nginx .hljs-title { + color: black; +} + +.hljs-string, +.hljs-title, +.hljs-constant, +.hljs-parent, +.hljs-tag .hljs-value, +.hljs-rules .hljs-value, +.hljs-rules .hljs-value .hljs-number, +.hljs-preprocessor, +.hljs-pragma, +.haml .hljs-symbol, +.ruby .hljs-symbol, +.ruby .hljs-symbol .hljs-string, +.hljs-aggregate, +.hljs-template_tag, +.django .hljs-variable, +.smalltalk .hljs-class, +.hljs-addition, +.hljs-flow, +.hljs-stream, +.bash .hljs-variable, +.apache .hljs-tag, +.apache .hljs-cbracket, +.tex .hljs-command, +.tex .hljs-special, +.erlang_repl .hljs-function_or_atom, +.asciidoc .hljs-header, +.markdown .hljs-header, +.coffeescript .hljs-attribute { + color: #800; +} + +.smartquote, +.hljs-comment, +.hljs-annotation, +.hljs-template_comment, +.diff .hljs-header, +.hljs-chunk, +.asciidoc .hljs-blockquote, +.markdown .hljs-blockquote { + color: #888; +} + +.hljs-number, +.hljs-date, +.hljs-regexp, +.hljs-literal, +.hljs-hexcolor, +.smalltalk .hljs-symbol, +.smalltalk .hljs-char, +.go .hljs-constant, +.hljs-change, +.lasso .hljs-variable, +.makefile .hljs-variable, +.asciidoc .hljs-bullet, +.markdown .hljs-bullet, +.asciidoc .hljs-link_url, +.markdown .hljs-link_url { + color: #080; +} + +.hljs-label, +.hljs-javadoc, +.ruby .hljs-string, +.hljs-decorator, +.hljs-filter .hljs-argument, +.hljs-localvars, +.hljs-array, +.hljs-attr_selector, +.hljs-important, +.hljs-pseudo, +.hljs-pi, +.haml .hljs-bullet, +.hljs-doctype, +.hljs-deletion, +.hljs-envvar, +.hljs-shebang, +.apache .hljs-sqbracket, +.nginx .hljs-built_in, +.tex .hljs-formula, +.erlang_repl .hljs-reserved, +.hljs-prompt, +.asciidoc .hljs-link_label, +.markdown .hljs-link_label, +.vhdl .hljs-attribute, +.clojure .hljs-attribute, +.asciidoc .hljs-attribute, +.lasso .hljs-attribute, +.coffeescript .hljs-property, +.hljs-phony { + color: #88F +} + +.hljs-keyword, +.hljs-id, +.hljs-title, +.hljs-built_in, +.hljs-aggregate, +.css .hljs-tag, +.hljs-javadoctag, +.hljs-phpdoc, +.hljs-yardoctag, +.smalltalk .hljs-class, +.hljs-winutils, +.bash .hljs-variable, +.apache .hljs-tag, +.go .hljs-typename, +.tex .hljs-command, +.asciidoc .hljs-strong, +.markdown .hljs-strong, +.hljs-request, +.hljs-status { + font-weight: bold; +} + +.asciidoc .hljs-emphasis, +.markdown .hljs-emphasis { + font-style: italic; +} + +.nginx .hljs-built_in { + font-weight: normal; +} + +.coffeescript .javascript, +.javascript .xml, +.lasso .markup, +.tex .hljs-formula, +.xml .javascript, +.xml .vbscript, +.xml .css, +.xml .hljs-cdata { + opacity: 0.5; +} + +pre, code { + font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; +} +pre ol.linenums { + margin-left: 0; +} + +.pln { + color: #48484C; } + +.str { + color: #DD1144; } + +.kwd { + color: #1E347B; } + +.com { + color: #93A1A1; } + +.typ { + color: teal; } + +.lit { + color: #195F91; } + +.pun { + color: #93A1A1; } + +.opn { + color: #93A1A1; } + +.clo { + color: #93A1A1; } + +.tag { + color: #008; } + +.atn { + color: teal; } + +.atv { + color: #DD1144; } + +.dec { + color: teal; } + +.var { + color: teal; } + +.fun { + color: #DC322F; } + +/* Put a border around prettyprinted code snippets. */ +pre.prettyprint { + background-color: #F7F7F9; + padding: 10px; + border: 1px solid #E1E1E8; } + +pre.prettyprint.linenums { + box-shadow: 40px 0 0 #FBFBFC inset, 41px 0 0 #ECECF0 inset; } + +/* Specify class=linenums on a pre to get line numbering */ +ol.linenums { + color: #1E347B; + margin: 0 0 0 40px; } + +ol.linenums li { + color: #BEBEC5; + line-height: 18px; + padding-left: 12px; } + +li.L0, +li.L1, +li.L2, +li.L3, +li.L5, +li.L6, +li.L7, +li.L8 { + list-style-type: normal; } \ No newline at end of file diff --git a/share/files/editor/index.html b/share/files/editor/index.html index d15c74e05..40ca40dea 100644 --- a/share/files/editor/index.html +++ b/share/files/editor/index.html @@ -1,4 +1,4 @@ - + @@ -6,7 +6,7 @@ - + diff --git a/share/files/editor/qwebchannel.js b/share/files/editor/qwebchannel.js new file mode 100644 index 000000000..24ee8fcb9 --- /dev/null +++ b/share/files/editor/qwebchannel.js @@ -0,0 +1,473 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Milian Wolff +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWebChannel module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +"use strict"; + +var QWebChannelMessageTypes = { + signal: 1, + propertyUpdate: 2, + init: 3, + idle: 4, + debug: 5, + invokeMethod: 6, + connectToSignal: 7, + disconnectFromSignal: 8, + setProperty: 9, + response: 10, +}; + +var QWebChannel = function(transport, initCallback) +{ + if (typeof transport !== "object" || typeof transport.send !== "function") { + console.error("The QWebChannel expects a transport object with a send function and onmessage callback property." + + " Given is: transport: " + typeof(transport) + ", transport.send: " + typeof(transport.send)); + return; + } + + var channel = this; + this.transport = transport; + this.initCallback = {}; + + this.send = function(data) + { + if (typeof(data) !== "string") { + data = JSON.stringify(data); + } + channel.transport.send(data); + } + + this.transport.onmessage = function(message) + { + var data = message.data; + if (typeof data === "string") { + data = JSON.parse(data); + } + switch (data.type) { + case QWebChannelMessageTypes.signal: + channel.handleSignal(data); + break; + case QWebChannelMessageTypes.response: + channel.handleResponse(data); + break; + case QWebChannelMessageTypes.propertyUpdate: + channel.handlePropertyUpdate(data); + break; + case QWebChannelMessageTypes.init: + channel.initialize(data); + break; + default: + console.error("invalid message received:", message.data); + break; + } + } + + this.execCallbacks = {}; + this.execId = 0; + this.exec = function(data, callback) + { + if (!callback) { + // if no callback is given, send directly + channel.send(data); + return; + } + if (channel.execId === Number.MAX_VALUE) { + // wrap + channel.execId = Number.MIN_VALUE; + } + if (data.hasOwnProperty("id")) { + console.error("Cannot exec message with property id: " + JSON.stringify(data)); + return; + } + data.id = channel.execId++; + channel.execCallbacks[data.id] = callback; + channel.send(data); + }; + + this.objects = {}; + + this.handleSignal = function(message) + { + var object = channel.objects[message.object]; + if (object) { + object.signalEmitted(message.signal, message.args); + } else { + console.warn("Unhandled signal: " + message.object + "::" + message.signal); + } + } + + this.handleResponse = function(message) + { + if (!message.hasOwnProperty("id")) { + console.error("Invalid response message received: ", JSON.stringify(message)); + return; + } + channel.execCallbacks[message.id](message.data); + delete channel.execCallbacks[message.id]; + } + + this.handlePropertyUpdate = function(message) + { + for (var i in message.data) { + var data = message.data[i]; + var object = channel.objects[data.object]; + if (object) { + object.propertyUpdate(data.signals, data.properties); + } else { + console.warn("Unhandled property update: " + data.object + "::" + data.signal); + } + } + channel.exec({type: QWebChannelMessageTypes.idle}); + } + + this.debug = function(message) + { + channel.send({type: QWebChannelMessageTypes.debug, data: message}); + }; + + channel.exec({type: QWebChannelMessageTypes.init}, function(data) { + for (var objectName in data) { + var object = new QObject(objectName, data[objectName], channel); + } + // if (initCallback) { + // initCallback(channel); + // } + channel.exec({type: QWebChannelMessageTypes.idle}); + }); + + this.initialize = function(data) { + for (var objectName in data) { + var childObject = data[objectName]; + if (typeof childObject == "object") { + for (var childName in childObject) { + if (typeof childObject[childName] == "object") { + var object = new QObject(childName, childObject[childName], channel); + } + } + } + } + if (initCallback) { + initCallback(channel); + } + channel.exec({type: QWebChannelMessageTypes.idle}); + } +}; + +function QObject(name, data, webChannel) +{ + this.__id__ = name; + webChannel.objects[name] = this; + + // List of callbacks that get invoked upon signal emission + this.__objectSignals__ = {}; + + // Cache of all properties, updated when a notify signal is emitted + this.__propertyCache__ = {}; + + var object = this; + + // ---------------------------------------------------------------------- + + function unwrapQObject( response ) + { + if (!response + || !response["__QObject*__"] + || response["id"] === undefined + || response["data"] === undefined) { + return response; + } + var objectId = response.id; + if (webChannel.objects[objectId]) + return webChannel.objects[objectId]; + + var qObject = new QObject( objectId, response.data, webChannel ); + qObject.destroyed.connect(function() { + if (webChannel.objects[objectId] === qObject) { + delete webChannel.objects[objectId]; + // reset the now deleted QObject to an empty {} object + // just assigning {} though would not have the desired effect, but the + // below also ensures all external references will see the empty map + // NOTE: this detour is necessary to workaround QTBUG-40021 + var propertyNames = []; + for (var propertyName in qObject) { + propertyNames.push(propertyName); + } + for (var idx in propertyNames) { + delete qObject[propertyNames[idx]]; + } + } + }); + return qObject; + } + + function addSignal(signalData, isPropertyNotifySignal) + { + var signalName = signalData[0]; + var signalIndex = signalData[1]; + object[signalName] = { + connect: function(callback) { + if (typeof(callback) !== "function") { + console.error("Bad callback given to connect to signal " + signalName); + return; + } + + object.__objectSignals__[signalIndex] = object.__objectSignals__[signalIndex] || []; + object.__objectSignals__[signalIndex].push(callback); + + if (!isPropertyNotifySignal && signalName !== "destroyed") { + // only required for "pure" signals, handled separately for properties in propertyUpdate + // also note that we always get notified about the destroyed signal + webChannel.exec({ + type: QWebChannelMessageTypes.connectToSignal, + object: object.__id__, + signal: signalIndex + }); + } + }, + disconnect: function(callback) { + if (typeof(callback) !== "function") { + console.error("Bad callback given to disconnect from signal " + signalName); + return; + } + object.__objectSignals__[signalIndex] = object.__objectSignals__[signalIndex] || []; + var idx = object.__objectSignals__[signalIndex].indexOf(callback); + if (idx === -1) { + console.error("Cannot find connection of signal " + signalName + " to " + callback.name); + return; + } + object.__objectSignals__[signalIndex].splice(idx, 1); + if (!isPropertyNotifySignal && object.__objectSignals__[signalIndex].length === 0) { + // only required for "pure" signals, handled separately for properties in propertyUpdate + webChannel.exec({ + type: QWebChannelMessageTypes.disconnectFromSignal, + object: object.__id__, + signal: signalIndex + }); + } + } + }; + } + + /** + * Invokes all callbacks for the given signalname. Also works for property notify callbacks. + */ + function invokeSignalCallbacks(signalName, signalArgs) + { + var connections = object.__objectSignals__[signalName]; + if (connections) { + connections.forEach(function(callback) { + callback.apply(callback, signalArgs); + }); + } + } + + this.propertyUpdate = function(signals, propertyMap) + { + // update property cache + for (var propertyIndex in propertyMap) { + var propertyValue = propertyMap[propertyIndex]; + object.__propertyCache__[propertyIndex] = propertyValue; + } + + for (var signalName in signals) { + // Invoke all callbacks, as signalEmitted() does not. This ensures the + // property cache is updated before the callbacks are invoked. + invokeSignalCallbacks(signalName, signals[signalName]); + } + } + + this.signalEmitted = function(signalName, signalArgs) + { + invokeSignalCallbacks(signalName, signalArgs); + } + + function addMethod(methodData) + { + var methodName = methodData[0]; + var methodIdx = methodData[1]; + object[methodName] = function() { + var args = []; + var callback; + for (var i = 0; i < arguments.length; ++i) { + if (typeof arguments[i] === "function") + callback = arguments[i]; + else + args.push(arguments[i]); + } + + webChannel.exec({ + "type": QWebChannelMessageTypes.invokeMethod, + "object": object.__id__, + "method": methodIdx, + "args": args + }, function(response) { + if (response !== undefined) { + var result = unwrapQObject(response); + if (callback) { + (callback)(result); + } + } + }); + }; + } + + function bindGetterSetter(propertyInfo) + { + var propertyIndex = propertyInfo[0]; + var propertyName = propertyInfo[1]; + var notifySignalData = propertyInfo[2]; + // initialize property cache with current value + object.__propertyCache__[propertyIndex] = propertyInfo[3]; + + if (notifySignalData) { + if (notifySignalData[0] === 1) { + // signal name is optimized away, reconstruct the actual name + notifySignalData[0] = propertyName + "Changed"; + } + addSignal(notifySignalData, true); + } + + Object.defineProperty(object, propertyName, { + get: function () { + var propertyValue = object.__propertyCache__[propertyIndex]; + if (propertyValue === undefined) { + // This shouldn't happen + console.warn("Undefined value in property cache for property \"" + propertyName + "\" in object " + object.__id__); + } + + return propertyValue; + }, + set: function(value) { + if (value === undefined) { + console.warn("Property setter for " + propertyName + " called with undefined value!"); + return; + } + object.__propertyCache__[propertyIndex] = value; + webChannel.exec({ + "type": QWebChannelMessageTypes.setProperty, + "object": object.__id__, + "property": propertyIndex, + "value": value + }); + } + }); + + } + + // ---------------------------------------------------------------------- + + data.methods.forEach(addMethod); + + data.properties.forEach(bindGetterSetter); + + data.signals.forEach(function(signal) { addSignal(signal, false); }); + + for (var name in data.enums) { + object[name] = data.enums[name]; + } +} + +//required for use with nodejs +if (typeof module === 'object') { + module.exports = { + QWebChannel: QWebChannel + }; +} + + +///////-------------------------------------- + + +function initWebChannel(serverUrl) { + console.log("init function called , serverUrl : " + serverUrl); + // var channelScript = document.createElement('script'); + // channelScript.src = scriptText; + // channelScript.onload = function() { + // alert(1); + // console.log("channelScript loaded"); + // initializeJSObject(serverUrl); + // }; + // document.head.appendChild(channelScript); + // + initializeJSObject(serverUrl); + + $(document.body).delegate('a', 'click', function(e) { + var a = $(e.currentTarget), + href = a.attr('href') || ''; + alert("body link clicked : " + href); + console.log("eidtor link clicked : " + href); + if (href && href.indexOf('wiz:') === 0) { + //笔记内链 + + } else if (href && (href.indexOf('mailto:') === 0 || href.indexOf('ftp:') === 0 || href.indexOf('http:') === 0 || href.indexOf('https:') === 0)) { + //弹出浏览器窗口显示.... + + } + + e.stopPropagation(); + e.preventDefault(); + }); +} + +function output(message) +{ + console.log(message); +} + +function initializeJSObject(strUrl) +{ + output("Connecting to WebSocket server at " + strUrl + "."); + var socket = new WebSocket(strUrl); + socket.onclose = function() + { + console.error("web channel closed"); + }; + socket.onerror = function(error) + { + console.error("web channel error: " + error); + }; + socket.onopen = function() + { + output("WebSocket connected, setting up QWebChannel."); + new QWebChannel(socket, function(channel) { + // make dialog object accessible globally + // window.jsObject = channel.objects.jsObject; + // jsObject.speakHello(); + window.WizEditor = channel.objects.WizEditor; + initialUEditor(WizEditor); + output("Connected to WebChannel, ready to send/receive messages!"); + }); + } +} + +//${INIT_COMMAND} diff --git a/share/files/editor/todo-webengine.js b/share/files/editor/todo-webengine.js new file mode 100644 index 000000000..272782457 --- /dev/null +++ b/share/files/editor/todo-webengine.js @@ -0,0 +1,1865 @@ + +function initDefaultCss(document, destNode) { + var WIZ_TODO_STYLE_ID = 'wiz_todo_style_id'; + var WIZ_STYLE = 'wiz_style'; + var WIZ_LINK_VERSION = 'wiz_link_version'; + var WIZ_TODO_STYLE_VERSION = "01.00.09"; + + var style = document.getElementById(WIZ_TODO_STYLE_ID); + if (style && !!style.getAttribute && style.getAttribute(WIZ_LINK_VERSION) >= WIZ_TODO_STYLE_VERSION) + return; + // + if (style && style.parentElement) { + style.parentElement.removeChild(style); + } + // + var strStyle = '.wiz-todo, .wiz-todo-img {width: 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertical-align: -10%;-webkit-user-select: none;} .wiz-todo-label { display: inline-block; padding-top: 7px; padding-bottom: 6px; line-height: 1.5;} .wiz-todo-label-checked { /*text-decoration: line-through;*/ color: #666;} .wiz-todo-label-unchecked {text-decoration: initial;} .wiz-todo-completed-info {padding-left: 44px; display: inline-block; } .wiz-todo-avatar { width:20px; height: 20px; vertical-align: -20%; margin-right:10px; border-radius: 2px;} .wiz-todo-account, .wiz-todo-dt { color: #666; }'; // + var objStyle = document.createElement('style'); + objStyle.type = 'text/css'; + objStyle.textContent = strStyle; + objStyle.id = WIZ_TODO_STYLE_ID; + // objStyle.setAttribute(WIZ_STYLE, 'unsave'); + objStyle.setAttribute(WIZ_LINK_VERSION, WIZ_TODO_STYLE_VERSION); + // + destNode.appendChild(objStyle); +} + +function WizTodoWindowsHelper(external) { + + if (external) { + this.wizEditor = external; + } + + this.getUserAlias = getUserAlias; + this.getUserAvatarFileName = getUserAvatarFileName; + this.isPersonalDocument = isPersonalDocument; + this.getLocalDateTime = getLocalDateTime; + this.setDocumentModified = setDocumentModified; + this.getCheckedImageFileName = getCheckedImageFileName; + this.getUnCheckedImageFileName = getUnCheckedImageFileName; + this.setDocumentType = setDocumentType; + this.initCss = initCss; + this.canEdit = canEdit; + + function getUserAlias() { + return this.wizEditor.UserAlias; + } + + function getUserAvatarFileName(size) { + return this.wizEditor.GetUserAvatarFileName(size); + } + + function isPersonalDocument() { + + try { + return this.wizEditor.WizDocument.IsPersonalDocument(); + } + catch (e) { + return false; + } + } + + function getLocalDateTime(dt) { + var nosec = true; + return this.wizEditor.GetLocalDateString(dt, true) + ' ' + this.wizEditor.GetLocalTimeString(dt, nosec); + } + + function setDocumentModified() { + this.wizEditor.SetContentModified(true); + } + + function getCheckedImageFileName() { + return this.wizEditor.AppPath + "WizTools\\htmleditor\\checked.png"; + } + + function getUnCheckedImageFileName() { + return this.wizEditor.AppPath + "WizTools\\htmleditor\\unchecked.png"; + } + + function canEdit() { + return true; + } + + function initCss(document) { + initDefaultCss(document, document.head); + } + + function setDocumentType(type) { + /* + var oldType = this.wizDoc.Type; + if (oldType) { + if (-1 == oldType.indexOf(type)) { + this.wizDoc.Type = oldType + ';' + type; + } + } + else { + this.wizDoc.Type = type; + }*/ + this.wizEditor.WizDocument.Type = type; + } +} + +function WizTodoQtHelper() { + + this.getUserAlias = getUserAlias; + this.getUserAvatarFileName = getUserAvatarFileName; + this.isPersonalDocument = isPersonalDocument; + this.getLocalDateTime = getLocalDateTime; + this.setDocumentModified = setDocumentModified; + this.getCheckedImageFileName = getCheckedImageFileName; + this.getUnCheckedImageFileName = getUnCheckedImageFileName; + this.initCss = initCss; + this.canEdit = canEdit; + this.setDocumentType = setDocumentType; + this.setUserAlias = setUserAlias; + this.setUserAvatarFileName = setUserAvatarFileName; + this.setCheckedImageFileName = setCheckedImageFileName; + this.setUnCheckedImageFileName = setUnCheckedImageFileName; + this.setIsPersonalDocument = setIsPersonalDocument; + + + this.userAlias = null; + this.avatarFileName = null; + this.checkedFileName = null; + this.unCheckedFileName = null; + this.personalDocument = false; + + function setUserAlias(alias) { + this.userAlias = alias; + } + + function setUserAvatarFileName(avatarFileName) { + this.avatarFileName = avatarFileName; + } + + function setCheckedImageFileName(fileName) { + this.checkedFileName = fileName; + } + + function setUnCheckedImageFileName(fileName) { + this.unCheckedFileName = fileName; + } + + function setIsPersonalDocument(isPersonalDocument) { + this.personalDocument = isPersonalDocument; + } + + function getUserAlias() { + return this.userAlias; + } + + function getUserAvatarFileName(size) { + return this.avatarFileName; + } + + function isPersonalDocument() { + return this.personalDocument; + } + + function getLocalDateTime(dt) { + return ""; + } + + function setDocumentModified() { + WizEditor.setContentsChanged(true); + } + + function getCheckedImageFileName() { + return this.checkedFileName; + } + + function getUnCheckedImageFileName() { + return this.unCheckedFileName; + } + + function canEdit() { + return editor.body.contentEditable == "true"; + } + + function initCss(document) { + + var WIZ_TODO_STYLE_ID = 'wiz_todo_style_id'; + var WIZ_STYLE = 'wiz_style'; + var WIZ_LINK_VERSION = 'wiz_link_version'; + var WIZ_TODO_STYLE_VERSION = "01.00.09"; + + var style = document.getElementById(WIZ_TODO_STYLE_ID); + console.log("todo init css called from editor document : " + document + " find style : " + style); + if (style && !!style.getAttribute && style.getAttribute(WIZ_LINK_VERSION) >= WIZ_TODO_STYLE_VERSION) + return; + // + if (style && style.parentElement) { + style.parentElement.removeChild(style); + } + // + var strStyle = '.wiz-todo, .wiz-todo-img {width: 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertical-align: -10%;-webkit-user-select: none;} .wiz-todo-label { display: inline-block; padding-top: 7px; padding-bottom: 6px; line-height: 1.5;} .wiz-todo-label-checked { /*text-decoration: line-through;*/ color: #666;} .wiz-todo-label-unchecked {text-decoration: initial;} .wiz-todo-completed-info {padding-left: 44px; display: inline-block; } .wiz-todo-avatar { width:20px; height: 20px; vertical-align: -20%; margin-right:10px; border-radius: 2px;} .wiz-todo-account, .wiz-todo-dt { color: #666; }'; + // + var objStyle = document.createElement('style'); + objStyle.type = 'text/css'; + objStyle.textContent = strStyle; + objStyle.id = WIZ_TODO_STYLE_ID; + // objStyle.setAttribute(WIZ_STYLE, 'unsave'); + objStyle.setAttribute(WIZ_LINK_VERSION, WIZ_TODO_STYLE_VERSION); + // + console.log("add css style to document head, objStyle : " + objStyle); + console.log("before appendChild ,innerHTML : " + document.head.innerHTML); + document.head.appendChild(objStyle); + console.log("after appendChild ,innerHTML : " + document.head.innerHTML); + } + + function setDocumentType(type) { + WizEditor.setCurrentDocumentType(type); + } +} + + +function WizTodoAndroidHelper() { + + this.getUserAlias = getUserAlias; + this.getUserAvatarFileName = getUserAvatarFileName; + this.isPersonalDocument = isPersonalDocument; + this.getLocalDateTime = getLocalDateTime; + this.setDocumentModified = setDocumentModified; + this.getCheckedImageFileName = getCheckedImageFileName; + this.getUnCheckedImageFileName = getUnCheckedImageFileName; + this.initCss = initCss; + this.canEdit = canEdit; + this.setDocumentType = setDocumentType; + this.canInsert = canInsert; + + function getUserAlias() { + return window.WizNote.getUserAlias(); + } + + function getUserAvatarFileName(size) { + return window.WizNote.getUserAvatarFileName(size); + } + + function isPersonalDocument() { + return window.WizNote.isPersonalDocument(); + } + + function getLocalDateTime(dt) { + return window.WizNote.getLocalDateTime(dt); + } + + function setDocumentModified() { + window.WizNote.setDocumentModified(); + } + + function getCheckedImageFileName() { + return window.WizNote.getCheckedImageFileName(); + } + + function getUnCheckedImageFileName() { + return window.WizNote.getUnCheckedImageFileName(); + } + + function canEdit() { + return true; + } + + function initCss(document) { + initDefaultCss(document, document.head); + } + + function setDocumentType(type) { + window.WizNote.setDocumentType(type); + } + + function canInsert(caninsert) { + window.WizNote.canInsert(caninsert); + } +} + +function WizTodoIphoneHelper() { + + this.getUserAlias = getUserAlias; + this.getUserAvatarFileName = getUserAvatarFileName; + this.isPersonalDocument = isPersonalDocument; + this.getLocalDateTime = getLocalDateTime; + this.setDocumentModified = setDocumentModified; + this.getCheckedImageFileName = getCheckedImageFileName; + this.getUnCheckedImageFileName = getUnCheckedImageFileName; + this.initCss = initCss; + this.canEdit = canEdit; + this.setDocumentType = setDocumentType; + this.setUserAlias = setUserAlias; + this.setUserAvatarFileName = setUserAvatarFileName; + this.setCheckedImageFileName = setCheckedImageFileName; + this.setUnCheckedImageFileName = setUnCheckedImageFileName; + this.onAddTodoCompletedInfo = onAddTodoCompletedInfo; + this.setIsPersonalDocument = setIsPersonalDocument; + this.canInsert = canInsert; + + this.userAlias = null; + this.avatarFileName = null; + this.checkedFileName = null; + this.unCheckedFileName = null; + this.personalDocument = undefined; + + function setUserAlias(alias) { + this.userAlias = alias; + } + + function setUserAvatarFileName(avatarFileName) { + this.avatarFileName = avatarFileName; + } + + function setCheckedImageFileName(fileName) { + this.checkedFileName = fileName; + } + + function setUnCheckedImageFileName(fileName) { + this.unCheckedFileName = fileName; + } + + function setIsPersonalDocument(isPersonalDocument) { + this.personalDocument = isPersonalDocument; + } + + function getUserAlias() { + return this.userAlias; + } + + function getUserAvatarFileName(size) { + return this.avatarFileName; + } + + function isPersonalDocument() { + return this.personalDocument === 'true'; + } + + function getLocalDateTime(dt) { + return ""; + } + + function setDocumentModified() { + window.location.href = "wiztodolist://setDocumentModified/"; + } + + function getCheckedImageFileName() { + return this.checkedFileName; + } + + function getUnCheckedImageFileName() { + return this.unCheckedFileName; + } + + function canEdit() { + return true; + } + + function initCss(document) { + initDefaultCss(document, document.body); + } + + function setDocumentType(type) { + window.location.href = "wiztodolist://setDocumentType/" + "?type="+ type; + } + + function onAddTodoCompletedInfo(isChecked, id, dt, callBack) { + var href = "wiztodolist://onAddTodoCompletedInfo/" + "?checked="+ isChecked +"&id="+ id +"&dt="+ dt +"&callback="+ callBack; + window.location.href = href; + } + + function canInsert(caninsert) { + if (caninsert) + return; + window.location.href = "wiztodolist://canInsert/" + "?canInsert"+ caninsert; + } +} + + +var WizTodo = (function () { + + var WIZ_HTML_CLASS_WIZ_TODO = 'wiz-todo-img'; + var WIZ_HTML_CLASS_CANNOT_DRAG = 'wiz-img-cannot-drag'; + var WIZ_HTML_TODO_COMPLETED_INFO = 'wiz-todo-completed-info'; + var WIZ_HTML_TODO_AVATAR_SIZE = 40; + var WIZ_DOC_TODO_TYPE = "tasklist"; + var editorDocument = null; + var client = ""; + var todoHelper = null; + + var curTouchTarget = null; + var enterkeyDown = false; + var enterkeyInTodo = false; + + function getTodoHelper(wizClient) { + + switch(wizClient) { + case 'windows': + return new WizTodoWindowsHelper(external); + case 'qt': + console.log("get qt todo helper called"); + return new WizTodoQtHelper(); + case 'iphone': + return new WizTodoIphoneHelper(); + case 'web': + break; + case 'android': + return new WizTodoAndroidHelper(); + break; + } + } + + function isIphone() { + return 'iphone' === client; + } + + function isIpad() { + return 'ipad' === client; + } + + function isAndroid() { + return 'android' === client; + } + + function getElementDisply(ele) { + var displayStyle = ""; + if (ele) { + try { + if (window.getComputedStyle) { + displayStyle = window.getComputedStyle(ele, null).getPropertyValue('display'); + } else { + displayStyle = ele.currentStyle.display; + } + } + catch (e) { + displayStyle = ""; + } + } + // + return displayStyle; + } + + function getClassValue(ele) { + if (!ele) + return ""; + // + var classValue = !!ele.getAttribute && ele.getAttribute('class'); + if (!classValue) + return ""; + // + return classValue.toString(); + } + + function pasteHtmlAtCaret(html, selectPastedContent) { + var sel, range, retNode; + if (editorDocument.getSelection) { + // IE9 and non-IE + sel = editorDocument.getSelection(); + if (sel.getRangeAt && sel.rangeCount) { + range = sel.getRangeAt(0); + range.deleteContents(); + + // Range.createContextualFragment() would be useful here but is + // only relatively recently standardized and is not supported in + // some browsers (IE9, for one) + var el = editorDocument.createElement("div"); + el.innerHTML = html; + var frag = editorDocument.createDocumentFragment(), node, lastNode; + while ( (node = el.firstChild) ) { + lastNode = frag.appendChild(node); + } + var firstNode = frag.firstChild; + retNode = firstNode; + range.insertNode(frag); + + // Preserve the selection + if (lastNode) { + range = range.cloneRange(); + range.setStartAfter(lastNode); + if (selectPastedContent) { + range.setStartBefore(firstNode); + } else { + range.collapse(true); + } + sel.removeAllRanges(); + sel.addRange(range); + } + } + } else if ( (sel = editorDocument.selection) && sel.type != "Control") { + // IE < 9 + var originalRange = sel.createRange(); + originalRange.collapse(true); + sel.createRange().pasteHTML(html); + if (selectPastedContent) { + range = sel.createRange(); + range.setEndPoint("StartToStart", originalRange); + range.select(); + } + } + // + return retNode; + } + + function isLabel(ele) { + if (!ele) + return false; + // + if (-1 != getClassValue(ele).indexOf('wiz-todo-label')) + return true; + // + return false; + } + + function isTodoImage(ele) { + if (!ele) + return false; + if (!ele.getAttribute || -1 == getClassValue(ele).indexOf(WIZ_HTML_CLASS_WIZ_TODO)) + return false; + // + return true; + } + + function isCompletedInfo (ele) { + if (!ele) + return false; + if (!ele.getAttribute || -1 == getClassValue(ele).indexOf(WIZ_HTML_TODO_COMPLETED_INFO)) + return false; + // + return true; + } + + function isWizTodoBlockElement(ele) { + if (!ele) + return false; + // + var displayValue = getElementDisply(ele); + if (!displayValue) + return false; + // + var value = displayValue.toString().toLowerCase().trim(); + // + if (!value) + return false; + // + if (value == 'block' || value == 'list-item' || value == 'table-cell') + return true; + // + return false; + } + + function isBlockNode(node) { + if (!node) + return false; + // + if (node.nodeType == 9 || node.nodeType == 11) + return true; + // + var displayValue = getElementDisply(node); + if (!displayValue) + return false; + // + var value = displayValue.toString().toLowerCase().trim(); + // + if (!value) + return false; + // + if (value != 'inline' + && value != 'inline-block' + && value != 'inline-table' + && value != 'none') { + return true; + } + // + return false; + } + + function isInlineNode(node) { + return !isBlockNode(node); + } + + function isEmptyNode(node) { + if (!node) + return false; + // + if (node.normalize) { + node.normalize(); + } + // + if (!node.hasChildNodes()) + return true; + // + var childnodes = node.childNodes; + for (var i = 0; i < childnodes.length; i ++) { + var child = childnodes[i]; + //g + if (child.nodeType == 3) { + if (child.nodeValue != "") + return false; + } + // + if (!isEmptyNode(child)) + return false; + } + // + return true; + } + + function getBlockParentElement(ele) { + if (!ele) + return null; + // + var p = ele; + while (p) { + if (p.tagName && p.tagName.toLowerCase() == 'body') + return null; + // + if (isWizTodoBlockElement(p)) + return p; + // + p = p.parentElement; + } + // + return null; + } + + function removeInvalidText(ele) { + if (!ele) + return; + if (!ele.hasChildNodes()) + return; + // + for (var i = ele.childNodes.length - 1; i >= 0; i --) { + var child = ele.childNodes[i]; + // + if (child.nodeType == 3) { + if (child.nodeValue === "") { + ele.removeChild(child); + } + if (8203 == child.nodeValue.charCodeAt(0)) + ele.removeChild(child); + } + } + } + + function isTodoAtFirst(ele) { + if (!ele) + return false; + // + if (!ele.hasChildNodes()) + return false; + // + removeInvalidText(ele); + // + var label = null; + var todoimg = null; + var child = ele.childNodes[0]; + while (child) { + if (isLabel(child)) { + label = child; + break; + } + if (isTodoImage(child)) { + todoimg = child; + break; + } + // + if (!child.hasChildNodes()) + break; + // + child = child.childNodes[0]; + } + // + if (label) { + var todoLabel = label; + removeInvalidText(todoLabel); + // + var childnodes = todoLabel.childNodes; + // + if (!childnodes || childnodes.length < 1 || !childnodes[0].getAttribute) + return false; + if (childnodes.length < 1) + return false; + // + if (-1 != getClassValue(childnodes[0]).indexOf(WIZ_HTML_CLASS_WIZ_TODO)) + return true; + } + else if (todoimg) { + return true; + } + // + return false; + } + + var g_canInsertWizTodo = false; + function canInsertWizTodo() { + return !!g_canInsertWizTodo; + } + + function addCompletedInfo(label, isChecked, todoId, localDateTime) { + if (!label) + return; + // + if (isChecked) { + var html = "" + + "%4."; + // + var userName = todoHelper.getUserAlias(); + var avatar = todoHelper.getUserAvatarFileName(WIZ_HTML_TODO_AVATAR_SIZE); + // + html = html.replace('%1', avatar); + html = html.replace('%2', WIZ_HTML_CLASS_CANNOT_DRAG + ' ' + 'wiz-todo-avatar'); + html = html.replace('%3', userName); + html = html.replace('%4', localDateTime); + // + var info = editorDocument.createElement('span'); + info.className = WIZ_HTML_TODO_COMPLETED_INFO; + info.innerHTML = html; + info.setAttribute('wiz_todo_id', todoId); + // + for (var i = label.childNodes.length - 1; i >= 0; i --) { + var child = label.childNodes[i]; + // + if (child.tagName && child.tagName.toLowerCase() == 'br') { + label.removeChild(child); + } + } + // + var nextSib = label.nextElementSibling; + while (nextSib) { + if (isLabel(nextSib)) { + label.parentElement.insertBefore(info, nextSib); + break; + } + // + if (nextSib.tagName.toLowerCase() == 'br') { + label.parentElement.insertBefore(info, nextSib); + break; + } + // + nextSib = nextSib.nextElementSibling; + } + // + if (!nextSib) { + label.parentElement.appendChild(info); + } + // + setCaret(info); + } + else {// todo: find todo id + var info = label.parentElement.getElementsByClassName(WIZ_HTML_TODO_COMPLETED_INFO); + if (!info || info.length < 1) + return; + // + for (var i = 0; i < info.length; i ++) { + var child = info[0]; + var tmpLabel = child.getElementsByClassName('wiz-todo-label'); + var chileNextSib = child.nextElementSibling; + // + if (tmpLabel && tmpLabel.length > 0) { + var nextSib = tmpLabel[0]; + while (nextSib) { + var tmpNext = nextSib; + nextSib = nextSib.nextSibling; + child.parentElement.insertBefore(tmpNext, chileNextSib); + } + } + } + // + var nextSib = label.nextElementSibling; + while (nextSib) { + if (isLabel(nextSib)) + break; + // + if (isCompletedInfo(nextSib)) { + var tmpNode = nextSib; + nextSib = nextSib.nextElementSibling; + label.parentElement.removeChild(tmpNode); + continue; + } + // + nextSib = nextSib.nextElementSibling; + } + } + } + + function formatIntToDateString(n){ + + return n < 10 ? '0' + n : n; + } + + function ToDateString(dt){ + // + var ret = dt.getFullYear() + "-" + + formatIntToDateString(dt.getMonth() + 1) + "-" + + formatIntToDateString(dt.getDate()) + "T" + + formatIntToDateString(dt.getHours())+ ":" + + formatIntToDateString(dt.getMinutes()) + ":" + + formatIntToDateString(dt.getSeconds()); + return ret; + } + + function onTodoClick(todoEle) { + // + var label = getParentTodoLabelElement(todoEle); + // todo img add a label parent. + if (!label) { + label = editorDocument.createElement('label'); + label.className = 'wiz-todo-label wiz-todo-label-unchecked'; + todoEle.parentElement.insertBefore(label, todoEle); + var nextSib = todoEle; + while (nextSib) { + // + if (isBlockNode(nextSib)) + break; + // + label.appendChild(nextSib); + // + nextSib = nextSib.nextSibling; + } + } + // + var classValue = getClassValue(label); + // + var isChecked = todoEle.getAttribute('state') == 'checked'; + var imgSrc = isChecked ? todoHelper.getUnCheckedImageFileName() : todoHelper.getCheckedImageFileName(); + var state = isChecked ? 'unchecked' : 'checked'; + // + if (isChecked) { + if (-1 != classValue.indexOf('wiz-todo-label-checked')) { + classValue = classValue.replace('wiz-todo-label-checked', 'wiz-todo-label-unchecked'); + } + else { + classValue += ' wiz-todo-label-unchecked'; + } + } + else { + // + if (-1 != classValue.indexOf('wiz-todo-label-unchecked')) { + classValue = classValue.replace('wiz-todo-label-unchecked', 'wiz-todo-label-checked'); + } + else { + classValue += ' wiz-todo-label-checked'; + } + } + // + todoEle.src = imgSrc; + todoEle.setAttribute('state', state); + label.setAttribute('class', classValue); + // + if (!todoHelper.isPersonalDocument()) { + + if (isIpad() || isIphone()) { + todoHelper.onAddTodoCompletedInfo(!isChecked, todoEle.id, Date.now(), 'addTodoCompletedInfo'); + } + else { + var dt = todoHelper.getLocalDateTime(new Date()); + addCompletedInfo(label, !isChecked, todoEle.id, dt); + } + } + // + wrapSiblingIntoLabel(label); + // + var parent = getBlockParentElement(label); + if (!parent) { + var div = document.createElement('div'); + label.parentElement.insertBefore(div, label.nextSibling); + div.appendChild(label); + } + // + if (todoHelper.isPersonalDocument()) { + todoHelper.setDocumentModified(); + } + else { + if (!isIpad() && !isIphone()) { + todoHelper.setDocumentModified(); + } + } + } + + function isEmptyLabel(label) { + if (!label.hasChildNodes()) + return true; + // + var childnodes = label.childNodes; + // + for (var i in childnodes) { + var node = childnodes[i]; + // + if (node && isTodoImage(node)) + return false; + } + // + return true; + } + + function isSelectionInEmptyLabel(retLabel) { + retLabel.ret = null; + // + var rng = editorDocument.getSelection().getRangeAt(0); + // + var start = rng.startContainer; + var label = getParentTodoLabelElement(start); + if (!label) + return false; + retLabel.ret = label; + // + return isEmptyLabel(label); + } + + function isSelectionExactlyAfterTodoImage() { + var rng = editorDocument.getSelection().getRangeAt(0); + // + var start = rng.startContainer; + if (!start) + return false; + if (isWizTodoBlockElement(start)) { + if (!start.hasChildNodes()) + return false; + // + for (var i in start.childNodes) { + if (i + 1 > rng.startOffset) + return false; + var child = start.childNodes[i]; + // + if (child && child.tagName + && -1 != getClassValue(child).indexOf('wiz-todo-label') + && i + 1 == rng.startOffset) { + + removeInvalidText(child); + // + var lastChild = child.lastChild; + if (isTodoImage(lastChild)) + return true; + else + return false; + } + } + // + return false; + } + else { + var label = getParentTodoLabelElement(start); + if (!label) + return false; + // + if (!label.hasChildNodes()) + return false; + // + var child0 = label.childNodes[0]; + // + if (!isTodoImage(child0)) + return false; + // + var nextSib = child0.nextSibling; + while (nextSib) { + if (nextSib.nodeType == 3) { + var val = nextSib.nodeValue; + val = val.replace(/\s/ig, ''); + if (val !== "") + return false; + else { + nextSib = nextSib.nextSibling; + continue; + } + } + // + if (!nextSib.tagName) + return false; + // + removeInvalidText(nextSib); + // + if (!isEmptyNode(nextSib)) + return false; + // + if (nextSib.tagName.toLowerCase() != 'br' && !g_emptyCanRemove[nextSib.tagName]) + return false; + // + nextSib = nextSib.nextSibling; + } + if (1 != rng.startOffset || 1 != rng.endOffset) + return false; + // + return true; + } + + } + + function deleteEmptyLabel() { + + var label = {}; + if (isSelectionInEmptyLabel(label)) { + var label = label.ret; + var p = label.parentElement; + // + var sel = editorDocument.getSelection(); + // + if (label.hasChildNodes()) { + var childnodes = label.childNodes; + while (childnodes.length > 0) { + p.appendChild(childnodes[0]); + } + // + p.removeChild(label); + } + else { + p.removeChild(label); + } + // + // p.insertBefore(editorDocument.createElement('br'), p.firstChild); + // + var range = editorDocument.createRange(); + range.setStart(p, 0); + range.setEnd(p, 1); + // + sel.removeAllRanges(); + sel.addRange(range); + } + } + + function getSelectionBlockParent() { + var rng = editorDocument.getSelection().getRangeAt(0); + // + var p = rng.startContainer; + // + while (p && !isWizTodoBlockElement(p)) { + p = p.parentElement; + } + // + if (p && p.tagName.toString().toLowerCase() == 'body') + return p; + if (p && p.id && p.id == 'content-view-body') + return p; + if (p && p.tagName.toLowerCase() == 'td') + return p; + if (p && p.tagName.toLowerCase() == 'th') + return p; + // + return null; + } + + function isShouldWrapBlockElement(ele) { + if (!ele) + return false; + if (ele && ele.tagName.toString().toLowerCase() == 'body') + return true; + // editable div of android + if (ele && ele.id && ele.id == 'content-view-body') + return true; + if (ele && ele.tagName.toString().toLowerCase() == 'td') + return true; + if (ele && ele.tagName.toString().toLowerCase() == 'th') + return true; + // + return false; + } + + function wrapMainEditableInlineChildren(editableNode) { + if (!editableNode) + return; + // + if (!editableNode.hasChildNodes()) + return; + // + var childnodes = editableNode.childNodes; + // + var div = editorDocument.createElement('div'); + // + while (childnodes.length > 0) { + var node = childnodes[0]; + // + if (!isWizTodoBlockElement(node)) { + div.appendChild(node); + } + else break; + } + // + if (div.hasChildNodes()) { + var sel = editorDocument.getSelection(); + // + editableNode.insertBefore(div, editableNode.firstChild); + // + range = editorDocument.createRange(); + range.setStartAfter(div.lastChild); + range.setEndAfter(div.lastChild); + // + sel.removeAllRanges(); + sel.addRange(range); + } + } + + function setCaret(ele) { + if (!ele) + return; + if (!ele.hasChildNodes()) { + ele.appendChild(editorDocument.createElement('br')); + } + var sel = editorDocument.getSelection(); + // + var range = editorDocument.createRange(); + range.setStartAfter(ele.lastChild); + range.collapse(true); + // + sel.removeAllRanges(); + sel.addRange(range); + } + + function removeNestLabel(label) { + + if (!label) + return; + // + var p = label.parentElement; + if (!isLabel(p) || p.childElementCount < 1 || !isLabel(p.children[0])) + return; + // + if (!p.hasChildNodes()) + return; + var meetLabel = false; + while (p.childNodes.length > 0) { + var child = p.childNodes[0]; + // + if (child == label) { + meetLabel = true; + } + // + if (child != label && meetLabel) { + label.appendChild(child); + } + else if (child == label) { + p.parentElement.insertBefore(child, p.nextElementSibling); + } + else { + p.parentElement.insertBefore(child, p); + } + } + // + p.parentElement.removeChild(p); + // remove br after label + if (label.nextElementSibling && label.nextElementSibling.tagName.toLowerCase() == 'br') { + label.parentElement.removeChild(label.nextElementSibling); + } + if (label.lastElementChild && label.lastElementChild.tagName.toLowerCase() == 'br') { + label.removeChild(label.lastElementChild); + } + // + setCaret(label); + } + + function mergeNextSibilingTextChild(ele, mergePrev) { + if (!ele) + return; + // + while (ele.nextSibling && ele.nextSibling.nodeType == 3) { + ele.appendChild(ele.nextSibling); + } + // + if (mergePrev) { + var imgs = ele.getElementsByClassName(WIZ_HTML_CLASS_WIZ_TODO); + if (!imgs || imgs.length < 1) + return; + // + var img = imgs[0]; + var target = img.nextSibling; + // + while (ele.previousSibling && ele.previousSibling.nodeType == 3) { + if (target) { + ele.insertBefore(ele.previousSibling, target); + } + else { + ele.appendChild(ele.previousSibling); + } + } + } + // + setCaret(ele); + } + + function divideFromParentLabel(label) { + if (!label) + return; + // + var sel = editorDocument.getSelection(); + // + var p = label.parentElement; + if (!p || !isLabel(p)) + return; + // + p.parentElement.insertBefore(label, p.nextElementSibling); + // + setCaret(label); + } + + function wrapSiblingIntoLabel(label) { + if (!label) + return; + // + var nextSib = label.nextSibling; + while (nextSib) { + // + var tmpNext = nextSib; + nextSib = nextSib.nextSibling; + // + if (isLabel(tmpNext) || isCompletedInfo(tmpNext) || isBlockNode(tmpNext)) + break; + // + label.appendChild(tmpNext); + } + } + + function insertOneTodo() { + + // deleteEmptyLabel(); + if (!canInsert()) + return; + // + var strHTML = ""; + // + strHTML = strHTML.replace("%1", 'wiz_todo_' + Date.now() + '_' + Math.floor((Math.random()*1000000) + 1)); + strHTML = strHTML.replace("%2", todoHelper.getUnCheckedImageFileName()); + // + var label = pasteHtmlAtCaret(strHTML, false); + removeNestLabel(label); + // + var p = getSelectionBlockParent(); + if (isShouldWrapBlockElement(p)) { + wrapMainEditableInlineChildren(p); + } + // + // mergeNextSibilingTextChild(label, !!fromKeyUp); + // + divideFromParentLabel(label); + // + setCaret(label); + // + wrapSiblingIntoLabel(label); + // + todoHelper.setDocumentType(WIZ_DOC_TODO_TYPE); + todoHelper.setDocumentModified(); + // + return label; + } + + function getParentTodoLabelElement(start) { + if (!start) + return null; + // + var p = start; + while(p && !isWizTodoBlockElement(p)) { + + if (!!p.tagName && p.tagName.toLowerCase() == 'body') + break; + // + if (!!p.tagName && p.tagName.toLowerCase() == 'label' && -1 != getClassValue(p).indexOf('wiz-todo-label')) + return p; + // + p = p.parentElement; + } + // + return null; + } + + function getFirstLabelBeforeSelection() { + + } + + function getParentCompletedInfo(ele) { + if (!ele) + return null; + // + var p = ele; + while (p) { + if (isCompletedInfo(p)) + return p; + // + p = p.parentElement; + } + // + return null; + } + + function getLabelBeforeCaret() { + var sel = editorDocument.getSelection(); + // + if (!sel || sel.type.toLowerCase() == 'none') + return null; + if (sel.type.toLowerCase() != 'caret') + return null; + // + var rng = sel.getRangeAt(0); + // + var start = rng.startContainer; + var completed = getParentCompletedInfo(start); + // + if (isCompletedInfo(completed)) { + var prev = completed; + while (prev) { + if (isLabel(prev)) + return prev; + // + prev = prev.previousElementSibling; + } + } + // + if (isWizTodoBlockElement(start)) { + if (!start.hasChildNodes()) + return null; + // + for (var i = 0; i < start.childNodes.length; i ++) { + if (i + 1 > rng.startOffset) + return null; + var child = start.childNodes[i]; + // + if (child && child.tagName + && -1 != getClassValue(child).indexOf('wiz-todo-label') + && i + 1 == rng.startOffset) { + return child; + } + } + // + return null; + } + else { + return getParentTodoLabelElement(start.nodeType == 1 ? start : start.parentElement); + } + } + + function hasPrevSiblingTodo(ele) { + if (!ele) + return false; + // + var prevSibling = ele.previousSibling; + // + if (!prevSibling) + return false; + if (!prevSibling.tagName || !ele.tagName) + return false; + // + if (prevSibling.tagName.toString() != ele.tagName.toString()) + return false; + // + if (!isTodoAtFirst(prevSibling)) + return false; + // + return true; + } + + function removeSelfOnly(ele) { + if (!ele) + return null; + if (!ele.hasChildNodes()) { + ele.parentElement.removeChild(ele); + return null; + } + var firstChild = ele.firstChild; + // + while (ele.childNodes.length > 0) { + ele.parentElement.insertBefore(ele.childNodes[0], ele); + } + // + ele.parentElement.removeChild(ele); + // + return firstChild; + } + + function WIZTODOMAKEOBJECT(s) { + for (var k in s) { + s[k.toUpperCase()] = s[k]; + } + return s; + } + + g_emptyCanRemove = WIZTODOMAKEOBJECT({a:1,abbr:1,acronym:1,address:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,s:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,'var':1}); + + function isCompleteInfoNode(className) { + if (!className) + return false; + // + if (-1 != className.indexOf('wiz-todo-completed-info') + || -1 != className.indexOf('wiz-todo-account') + || -1 != className.indexOf('wiz-todo-dt')) { + return true; + } + // + return false; + } + + function emptyCanRemove(node) { + if (!node) + return false; + // + if (!node.tagName) + return false; + // + if (isEmptyNode(node) && g_emptyCanRemove[node.tagName] && isTodoTag(getClassValue(node))) + return true; + // + return false; + } + + function removeBlockElement(ele) { + if (!ele) + return null; + // + if (!ele.hasChildNodes()) + return ele; + // + var childnodes = ele.childNodes; + for (var i = childnodes.length - 1; i >= 0; i --) { + var child = childnodes[i]; + // + removeBlockElement(child); + // + if (isLabel(child)) { + + if (isEmptyNode(child)) { + child.parentElement && child.parentElement.removeChild(child); + } + else if (isEmptyLabel(child)) { + removeSelfOnly(child); + } + // + continue; + } + else if (child.tagName && child.tagName.toLowerCase() == 'br' + && isTodoTag(getClassValue(child.parentElement))) { + child.parentElement && child.parentElement.removeChild(child); + continue; + } + else if (emptyCanRemove(child)) { + child.parentElement && child.parentElement.removeChild(child); + continue; + } + else if (isInlineNode(child) && child.nodeType != 3 && child.tagName.toLowerCase() != 'br') { + child.parentElement && ele.parentElement.insertBefore(child, ele.nextSibling); + continue; + } + } + // + if (isBlockNode(ele)) { + return removeSelfOnly(ele); + } + // + if (emptyCanRemove(ele)) { + ele.parentElement && ele.parentElement.removeChild(ele); + return null; + } + // + return ele; + } + + function getFirstLabel(ele) { + if (!ele) + return null; + // + if (isLabel(ele)) + return ele; + if (!ele.hasChildNodes()) + return null; + // + var childnodes = ele.childNodes; + for (var i = 0; i < childnodes.length; i ++) { + var child = childnodes[i]; + // + if (isLabel(child)) + return child; + // + var l = getFirstLabel(child); + if (l) + return l; + } + // + return null; + } + + function getFirstLabelInLine() { + var sel = editorDocument.getSelection(); + if (sel.type.toLowerCase() == 'none' || sel.rangeCount < 1) + return; + // + var rng = sel.getRangeAt(0); + // + var start = rng.startContainer; + var p = getBlockParentElement(start); + if (!p) + return null; + // + if (!p.hasChildNodes()) + return null; + // + var label = getFirstLabel(p); + // + return label; + } + + function isTodoTag(className) { + if (!className) + return false; + if (-1 != className.indexOf('wiz-todo-label') + || -1 != className.indexOf('wiz-todo-tail') + || isCompleteInfoNode(className)) { + return true; + } + // + return false; + } + + function isEnterKeyInTodo(range) { + if (!range) + return false; + // + var start = range.startContainer; + if (isBlockNode(start)) { + return false; + } + // + var p = start; + while (p) { + if (isTodoTag(getClassValue(p))) + return true; + // + p = p.parentElement; + } + // + return false; + } + + function initEnterKeyState() { + enterkeyDown = true; + // + var sel = editorDocument.getSelection(); + var rng = sel.getRangeAt(0); + // + enterkeyInTodo = isEnterKeyInTodo(rng) ? true : false; + } + + function isInUeditor() { + var ueditor = document.getElementById('ueditor_0'); + return ueditor ? true : false; + } + + function onKeyDown(e) { + + if (!todoHelper.canEdit()) + return; + // + if (13 != e.keyCode) // Return key + return; + if (e.shiftKey) + return; + // + initEnterKeyState(); + // + var sel = editorDocument.getSelection(); + if (sel.type.toLowerCase() == 'none') + return; + // + var rng = sel.getRangeAt(0); + // + if (0 == rng.startOffset && 0 == rng.endOffset) { + g_canInsertWizTodo = false; + enterkeyInTodo = false; + return; + } + //should not get this label, is a bug.It should get the first label in the line. + var label = null; + /* + if (sel.type.toLowerCase() == 'caret') { + label = getLabelBeforeCaret(); + } + else { + var start = rng.startContainer; + start = start.nodeType == 1 ? start : start.parentElement; + // + label = getParentTodoLabelElement(start); + }*/ + label = getFirstLabelInLine(); + // + var parentEle = getBlockParentElement(label); + // + if (isWizTodoBlockElement(parentEle) && isTodoAtFirst(parentEle)) { + + var pp = parentEle; + if (isInUeditor() && parentEle.parentElement.tagName && parentEle.parentElement.tagName.toLowerCase() == 'li') { + pp = parentEle.parentElement; + } + + if (isSelectionExactlyAfterTodoImage() && hasPrevSiblingTodo(pp)) { + + var hasBr = false; + var nextSib = label.nextSibling; + while (nextSib) { + if (nextSib.tagName && nextSib.tagName.toLowerCase() == 'br') { + hasBr = true; + break; + } + + // + nextSib = nextSib.nextSibling; + } + // + if (isInUeditor() && pp === parentEle.parentElement) { + var ppp = pp.parentElement; + ppp.removeChild(pp); + // + var div = editorDocument.createElement('div'); + div.appendChild(editorDocument.createElement('br')); + // + ppp.parentElement.insertBefore(div, ppp.nextSibling); + // + setCaret(div); + } + else { + var p = label.parentElement; + p.removeChild(label); + if (!hasBr) { + p.appendChild(editorDocument.createElement('br')); + } + setCaret(p); + } + // + g_canInsertWizTodo = false; + return; + } + // + g_canInsertWizTodo = true; + } + else { + g_canInsertWizTodo = false; + } + // + if (g_canInsertWizTodo) { + if (parentEle) { + var eleName = parentEle.tagName.toLowerCase() == 'body' ? 'div' : parentEle.tagName; + var ele = editorDocument.createElement(eleName); + ele.innerHTML = "
"; + // + var pp = parentEle.parentElement; + var isInLiNodeInUE = false; + // + if (isInUeditor() && pp && pp.tagName && pp.tagName.toLowerCase() == 'li') { + var liNode = editorDocument.createElement('li'); + liNode.appendChild(ele); + // + pp.parentElement.insertBefore(liNode, pp.nextSibling); + // + isInLiNodeInUE = true; + } + else { + parentEle.parentElement.insertBefore(ele, parentEle.nextSibling); + } + // + var br = ele.lastChild; + // + rng.deleteContents(); + rng.setEndAfter(parentEle); + var frag = rng.extractContents(); + // + setCaret(ele); + var label = insertOneTodo(); + // + var firstChild = frag.firstChild; + label.appendChild(frag); + removeBlockElement(firstChild); + // + e.preventDefault(); + if (isInLiNodeInUE) { + e.stopPropagation(); + } + // + if (br) { + br.parentElement.removeChild(br); + } + // + if (label.getBoundingClientRect().top + label.clientHeight > document.documentElement.clientHeight + || label.getBoundingClientRect().top + label.clientHeight < 0) { + var labelX = label.getBoundingClientRect().left + document.body.scrollLeft; + var labelY = document.body.scrollTop + label.clientHeight; + // + window.scrollTo(labelX, labelY); + } + } + } + } + + function onKeyUp(e) { + + if (!todoHelper.canEdit()) + return; + // + if (13 != e.keyCode) // Return key + return; + if (!enterkeyDown || !enterkeyInTodo) + return; + // + enterkeyDown = false; + enterkeyInTodo = false; + // + if (!canInsertWizTodo()) { + var sel = editorDocument.getSelection(); + if (sel.type.toLowerCase() == 'none') + return; + // + var rng = sel.getRangeAt(0); + // + var start = rng.startContainer; + var p = getBlockParentElement(start); + // + var node = removeBlockElement(p.firstChild); + if (node && node.tagName && node.tagName.toLowerCase() != 'hr') { + if (node.tagName.toLowerCase() == 'br') { + node = node.parentElement; + } + // + setCaret(node); + } + else { + if (node) { + setCaret(node); + } + else { + setCaret(p); + } + } + } + } + + function onDocumentClick(e) { + if (!todoHelper.canEdit()) + return; + // + var node = e.target; + if (!node) + return; + if (!node.className) + return; + if (-1 != getClassValue(node).indexOf('wiz-todo-img')) { + onTodoClick(node); + } + } + + function onTouchStart(e) { + curTouchTarget = e.target; + } + + function onTouchEnd(e) { + if (e.target !== curTouchTarget) + return; + // + curTouchTarget = null; + // + if (isIphone() || isIpad()) { + onDocumentClick(e); + } + } + + function registerEvent() { + editorDocument.removeEventListener('keydown', onKeyDown); + editorDocument.removeEventListener('keyup', onKeyUp); + editorDocument.removeEventListener('click', onDocumentClick); + editorDocument.removeEventListener('touchstart', onTouchStart); + editorDocument.removeEventListener('touchEnd', onTouchEnd); + // + editorDocument.addEventListener('keydown', onKeyDown, isInUeditor() ? true : false); + editorDocument.addEventListener('keyup', onKeyUp); + editorDocument.addEventListener('click', onDocumentClick); + editorDocument.addEventListener('touchstart', onTouchStart); + editorDocument.addEventListener('touchend', onTouchEnd); + } + + function init(wizClient) { + console.log("init todo called , todoHelper : " + todoHelper); + // if (todoHelper != null) + // return; + + var ueditor = null; + if (wizClient == 'qt') { + ueditor = document.getElementById('ueditor_0'); + } + + // + editorDocument = ueditor ? ueditor.contentDocument : document; + // + client = wizClient; + // + todoHelper = getTodoHelper(wizClient); + // + registerEvent(); + + // + todoHelper.initCss(editorDocument); + console.log("init todo js finished , helper : " + todoHelper); + } + + function setUserAlias(alias) { + if (todoHelper.setUserAlias) { + todoHelper.setUserAlias(alias); + } + } + + function setUserAvatarFileName(avatarFileName) { + if (todoHelper.setUserAvatarFileName) { + todoHelper.setUserAvatarFileName(avatarFileName); + } + } + + function setCheckedImageFileName(fileName) { + if (todoHelper.setCheckedImageFileName) { + todoHelper.setCheckedImageFileName(fileName); + } + } + + function setUnCheckedImageFileName(fileName) { + if (todoHelper.setUnCheckedImageFileName) { + todoHelper.setUnCheckedImageFileName(fileName); + } + } + + function setIsPersonalDocument(isPersonalDocument) { + if (todoHelper.setIsPersonalDocument) { + todoHelper.setIsPersonalDocument(isPersonalDocument); + } + } + + function addTodoCompletedInfo(isChecked, id, localDateTime) { + var todoImg = editorDocument.getElementById(id); + var label = getParentTodoLabelElement(todoImg); + // + addCompletedInfo(label, isChecked === 'true', id, localDateTime); + } + + function _canInsert() { + + var sel = editorDocument.getSelection(); + if (!sel || sel.rangeCount < 1) + return false; + // + var rng = sel.getRangeAt(0); + if (!rng || !rng.collapsed) + return false; + // + return true; + } + + function canInsert() { + + var caninsert = _canInsert(); + // + if (todoHelper.canInsert) { + todoHelper.canInsert(caninsert); + } + // + return caninsert; + } + + return { + init: init, + insertOneTodo: insertOneTodo, + canInsert: canInsert, + setUserAlias: setUserAlias, + setUserAvatarFileName: setUserAvatarFileName, + setCheckedImageFileName: setCheckedImageFileName, + setUnCheckedImageFileName: setUnCheckedImageFileName, + setIsPersonalDocument: setIsPersonalDocument, + addTodoCompletedInfo: addTodoCompletedInfo, + } +})(); \ No newline at end of file diff --git a/share/files/editor/todo.js b/share/files/editor/todo.js index 058707909..a26f5a199 100644 --- a/share/files/editor/todo.js +++ b/share/files/editor/todo.js @@ -3,7 +3,7 @@ function initDefaultCss(document, destNode) { var WIZ_TODO_STYLE_ID = 'wiz_todo_style_id'; var WIZ_STYLE = 'wiz_style'; var WIZ_LINK_VERSION = 'wiz_link_version'; - var WIZ_TODO_STYLE_VERSION = "01.00.08"; + var WIZ_TODO_STYLE_VERSION = "01.00.09"; var style = document.getElementById(WIZ_TODO_STYLE_ID); if (style && !!style.getAttribute && style.getAttribute(WIZ_LINK_VERSION) >= WIZ_TODO_STYLE_VERSION) @@ -13,7 +13,7 @@ function initDefaultCss(document, destNode) { style.parentElement.removeChild(style); } // - var strStyle = '.wiz-todo, .wiz-todo-img {width: 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertical-align: -10%;-webkit-user-select: none;} .wiz-todo-label { display: inline-block; padding-top: 8px; padding-bottom: 8px; line-height: 1;} .wiz-todo-label-checked { /*text-decoration: line-through;*/ color: #666;} .wiz-todo-label-unchecked {text-decoration: initial;} .wiz-todo-completed-info {padding-left: 44px; display: inline-block; } .wiz-todo-avatar { width:20px; height: 20px; vertical-align: -20%; margin-right:10px; border-radius: 2px;} .wiz-todo-account, .wiz-todo-dt { color: #666; }'; // + var strStyle = '.wiz-todo, .wiz-todo-img {width: 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertical-align: -10%;-webkit-user-select: none;} .wiz-todo-label { display: inline-block; padding-top: 7px; padding-bottom: 6px; line-height: 1.5;} .wiz-todo-label-checked { /*text-decoration: line-through;*/ color: #666;} .wiz-todo-label-unchecked {text-decoration: initial;} .wiz-todo-completed-info {padding-left: 44px; display: inline-block; } .wiz-todo-avatar { width:20px; height: 20px; vertical-align: -20%; margin-right:10px; border-radius: 2px;} .wiz-todo-account, .wiz-todo-dt { color: #666; }'; // var objStyle = document.createElement('style'); objStyle.type = 'text/css'; objStyle.textContent = strStyle; @@ -113,19 +113,19 @@ function WizTodoQtHelper() { this.setDocumentType = setDocumentType; function getUserAlias() { - return objApp.getUserAlias(); + return WizEditor.getUserAlias(); } function getUserAvatarFileName(size) { - return objApp.getUserAvatarFilePath(size); + return WizEditor.getUserAvatarFilePath(size); } function isPersonalDocument() { - return objApp.isPersonalDocument(); + return WizEditor.isPersonalDocument(); } function getLocalDateTime(dt) { - return objApp.getFormatedDateTime(); + return WizEditor.getFormatedDateTime(); } function setDocumentModified() { @@ -133,11 +133,11 @@ function WizTodoQtHelper() { } function getCheckedImageFileName() { - return objApp.getSkinResourcePath() + "checked.png"; + return WizEditor.getSkinResourcePath() + "checked.png"; } function getUnCheckedImageFileName() { - return objApp.getSkinResourcePath() + "unchecked.png"; + return WizEditor.getSkinResourcePath() + "unchecked.png"; } function canEdit() { @@ -149,7 +149,7 @@ function WizTodoQtHelper() { var WIZ_TODO_STYLE_ID = 'wiz_todo_style_id'; var WIZ_STYLE = 'wiz_style'; var WIZ_LINK_VERSION = 'wiz_link_version'; - var WIZ_TODO_STYLE_VERSION = "01.00.08"; + var WIZ_TODO_STYLE_VERSION = "01.00.09"; var style = document.getElementById(WIZ_TODO_STYLE_ID); if (style && !!style.getAttribute && style.getAttribute(WIZ_LINK_VERSION) >= WIZ_TODO_STYLE_VERSION) @@ -159,7 +159,7 @@ function WizTodoQtHelper() { style.parentElement.removeChild(style); } // - var strStyle = '.wiz-todo, .wiz-todo-img {width: 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertical-align: -10%;-webkit-user-select: none;} .wiz-todo-label { display: inline-block; padding-top: 8px; padding-bottom: 8px; line-height: 1;} .wiz-todo-label-checked { /*text-decoration: line-through;*/ color: #666;} .wiz-todo-label-unchecked {text-decoration: initial;} .wiz-todo-completed-info {padding-left: 44px; display: inline-block; } .wiz-todo-avatar { width:20px; height: 20px; vertical-align: -20%; margin-right:10px; border-radius: 2px;} .wiz-todo-account, .wiz-todo-dt { color: #666; }'; + var strStyle = '.wiz-todo, .wiz-todo-img {width: 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertical-align: -10%;-webkit-user-select: none;} .wiz-todo-label { display: inline-block; padding-top: 7px; padding-bottom: 6px; line-height: 1.5;} .wiz-todo-label-checked { /*text-decoration: line-through;*/ color: #666;} .wiz-todo-label-unchecked {text-decoration: initial;} .wiz-todo-completed-info {padding-left: 44px; display: inline-block; } .wiz-todo-avatar { width:20px; height: 20px; vertical-align: -20%; margin-right:10px; border-radius: 2px;} .wiz-todo-account, .wiz-todo-dt { color: #666; }'; // var objStyle = document.createElement('style'); objStyle.type = 'text/css'; @@ -172,7 +172,7 @@ function WizTodoQtHelper() { } function setDocumentType(type) { - objApp.setCurrentDocumentType(type); + WizEditor.setCurrentDocumentType(type); } } @@ -299,7 +299,7 @@ function WizTodoIphoneHelper() { } function setDocumentModified() { - window.location.href = "wiztodolist://setDocumentModified"; + window.location.href = "wiztodolist://setDocumentModified/"; } function getCheckedImageFileName() { @@ -319,17 +319,18 @@ function WizTodoIphoneHelper() { } function setDocumentType(type) { - window.location.href = "wiztodolist://setDocumentType" + "&*/"+ type; + window.location.href = "wiztodolist://setDocumentType/" + "?type="+ type; } function onAddTodoCompletedInfo(isChecked, id, dt, callBack) { - window.location.href = "wiztodolist://onAddTodoCompletedInfo" + "&*/"+ isChecked +"&*/"+ id +"&*/"+ dt +"&*/"+ callBack; + var href = "wiztodolist://onAddTodoCompletedInfo/" + "?checked="+ isChecked +"&id="+ id +"&dt="+ dt +"&callback="+ callBack; + window.location.href = href; } function canInsert(caninsert) { if (caninsert) return; - window.location.href = "wiztodolist://canInsert" + "&*/"+ caninsert; + window.location.href = "wiztodolist://canInsert/" + "?canInsert"+ caninsert; } } @@ -746,11 +747,12 @@ var WizTodo = (function () { return n < 10 ? '0' + n : n; } + function ToDateString(dt){ // var ret = dt.getFullYear() + "-" + formatIntToDateString(dt.getMonth() + 1) + "-" + - formatIntToDateString(dt.getDate()) + " " + + formatIntToDateString(dt.getDate()) + "T" + formatIntToDateString(dt.getHours())+ ":" + formatIntToDateString(dt.getMinutes()) + ":" + formatIntToDateString(dt.getSeconds()); @@ -808,7 +810,7 @@ var WizTodo = (function () { if (!todoHelper.isPersonalDocument()) { if (isIpad() || isIphone()) { - todoHelper.onAddTodoCompletedInfo(!isChecked, todoEle.id, ToDateString(new Date()), 'addTodoCompletedInfo'); + todoHelper.onAddTodoCompletedInfo(!isChecked, todoEle.id, Date.now(), 'addTodoCompletedInfo'); } else { var dt = todoHelper.getLocalDateTime(new Date()); diff --git a/share/files/editor/webchannel_inject.js b/share/files/editor/webchannel_inject.js new file mode 100644 index 000000000..04ecc0502 --- /dev/null +++ b/share/files/editor/webchannel_inject.js @@ -0,0 +1,64 @@ +var serverUrl = '${SERVER_URL}'; +var webchannelFile = '${WEBCHANNEL_FILE}'; + +function init(scriptText) { + console.log("init function called , js file : " + webchannelFile); + var channelScript = document.createElement('script'); + channelScript.src = scriptText; + channelScript.onload = function() { + alert(1); + console.log("channelScript loaded"); + initializeJSObject(serverUrl); + }; + document.head.appendChild(channelScript); + // + $(document.body).delegate('a', 'click', function(e) { + var a = $(e.currentTarget), + href = a.attr('href') || ''; + alert("body link clicked : " + href); + console.log("eidtor link clicked : " + href); + if (href && href.indexOf('wiz:') === 0) { + //笔记内链 + + } else if (href && (href.indexOf('mailto:') === 0 || href.indexOf('ftp:') === 0 || href.indexOf('http:') === 0 || href.indexOf('https:') === 0)) { + //弹出浏览器窗口显示.... + + } + + e.stopPropagation(); + e.preventDefault(); + }); +} + +function output(message) +{ + console.log(message); +} + +function initializeJSObject(strUrl) +{ + output("Connecting to WebSocket server at " + strUrl + "."); + var socket = new WebSocket(strUrl); + socket.onclose = function() + { + console.error("web channel closed"); + }; + socket.onerror = function(error) + { + console.error("web channel error: " + error); + }; + socket.onopen = function() + { + output("WebSocket connected, setting up QWebChannel."); + new QWebChannel(socket, function(channel) { + // make dialog object accessible globally + // window.jsObject = channel.objects.jsObject; + // jsObject.speakHello(); + window.WizEditor = channel.objects.WizEditor; + initialUEditor(WizEditor); + output("Connected to WebChannel, ready to send/receive messages!"); + }); + } +} + +init('${SCRIPTTEXT}'); \ No newline at end of file diff --git a/share/files/editor/wiznote_extend-webengine.js b/share/files/editor/wiznote_extend-webengine.js new file mode 100644 index 000000000..35cc8d466 --- /dev/null +++ b/share/files/editor/wiznote_extend-webengine.js @@ -0,0 +1,395 @@ +var + editor = {}, + m_inited = false, + m_currentGUID = "", + m_defaultCss = ""; + m_defaultCssVersion = 1, + WizEditor = {}; + m_header = "", + wiz_html = "", + wiz_head = ""; + +// setup ueditor +function initialUEditor(wizEditor) { + WizEditor = wizEditor + wizEditor.viewNoteRequest.connect(function (strGUID, bEditing, strHtml, strHead) { + var result = viewNote(strGUID, bEditing, strHtml, strHead); + WizEditor.on_viewDocumentFinished(result); + }); + WizEditor.resetDefaultCss.connect(function (strCssPath) { + m_defaultCss = strCssPath; + }); + + console.log("try to init editor by js"); + try { + var editorOption = { + toolbars: [], + //iframeCssUrl: m_defaultCss, + //initialStyle: 'body{font-size:13px}', + //enterTag: 'div', + fullscreen: true, + autoHeightEnabled: false, + scaleEnabled: false, + contextMenu: [], + elementPathEnabled: false, + wordCount: false, + imagePopup: false, + maximumWords: 100000000, + }; + + + + editor = new baidu.editor.ui.Editor(editorOption); + //objApp.ResetInitialStyle(); + editor.render('editorArea'); + + editor.addListener("sourceModeChanged",function(type,mode){ + }); + + // hide builtin toolbar, from UE dev team. + editor.addListener('ready', function () { + editor.ui.getDom('toolbarbox').style.display = 'none'; + editor.ui.getDom('bottombar').style.display = 'none'; + editor.ui.getDom('scalelayer').style.display = 'none'; + editor.ui.getDom('elementpath').style.display = "none"; + editor.ui.getDom('wordcount').style.display = "none"; + editor.ui._updateFullScreen(); + + console.log("ueditor get ready"); + WizEditor.on_ueditorInitFinished(); + + var ueditor = document.getElementById('ueditor_0'); + $(ueditor.contentDocument.body).delegate('a', 'click', function(e) { + var a = $(e.currentTarget), + href = a.attr('href') || ''; + console.log("eidtor link clicked : " + href); + if (href && href.indexOf('wiz:') === 0) { + //笔记内链 + + } else if (href && (href.indexOf('mailto:') === 0 || href.indexOf('ftp:') === 0 || href.indexOf('http:') === 0 || href.indexOf('https:') === 0)) { + //弹出浏览器窗口显示.... + + } + + e.stopPropagation(); + e.preventDefault(); + }); + + }); + + editor.addListener('aftersetcontent', function() { + console.log("set content"); + updateCss(); + WizEditor.onNoteLoadFinished(); + }); + + editor.addListener('selectionchange', function () { + WizEditor.onEditorSelectionChanged(); + }); + + // 因为QWebEngineView无法响应foucsInEvent,focusOutEvent或keyPressEvent,所以使用编辑器来触发 + // editor.addListener('focus', function () { + // WizEditor.focusInEditor(); + // }); + // editor.addListener('blur', function () { + // WizEditor.focusOutEditor(); + // }); + // editor.addListener('keydown', function() { + // WizEditor.setContentsChanged(true); + // }); + + } catch (err) { + alert(err); + } +} + +function speakHelloWorld() +{ + console.log("speak Hello World"); +} + +function functionTest() +{ + editor.execCommand('paste'); + console.log("called from test"); + editor.execCommand('insertHtml', "inserted text", true); +} + +function setEditorHtml(html, bEditing) +{ + editor.reset(); + editor.document.head.innerHTML = wiz_head; + //if (bEditing) { + // editor.document.head.innerHTML = wiz_head + m_header; // restore original header + //} else { + // editor.document.head.innerHTML = wiz_head; + //} + + editor.document.body.innerHTML = html; + editor.fireEvent('aftersetcontent'); + editor.fireEvent('contentchange'); + + bEditing ? editor.setEnabled() : editor.setDisabled(); + + window.UE.utils.domReady(function() { + //special process to remove css style added by phone + editor.window.scrollTo(0, 0); + }); +} + +function setEditing(bEditing) { + + console.log("set document editing : " + bEditing + " head : " + wiz_head); + + editor.document.head.innerHTML = wiz_head; + //if (bEditing) { + // editor.document.head.innerHTML = wiz_head + m_header; // restore original header + //} else { + // editor.document.head.innerHTML = wiz_head; + //} + + editor.document.body.innerHTML = wiz_html; + + //special process to remove css style added by phone + + editor.fireEvent('aftersetcontent'); + editor.fireEvent('contentchange'); + + bEditing ? editor.setEnabled() : editor.setDisabled(); +} + +function viewNote(strGUID, bEditing, strHtml, strHead) +{ + console.log("view note : " + strGUID + "\n" + strHead) + try { + m_currentGUID = strGUID; + wiz_html = strHtml; + wiz_head = strHead; + + if (m_inited) { + setEditorHtml(wiz_html, bEditing); + } else { + editor.ready(function() { + m_header = editor.document.head.innerHTML; // save original header + setEditorHtml(wiz_html, bEditing); + m_inited = true; + }); + } + + return true; + } catch (err) { + alert(err); + return false; + } +} + +function viewCurrentNote() +{ + console.log("view currentnote called"); + return viewNote(WizEditor.currentNoteGUID(), WizEditor.currentIsEditing(), + WizEditor.currentNoteHtml(), WizEditor.currentNoteHead()); +} + +function updateCurrentNoteHtml(strGUID, strHtml, strHead) +{ + console.log("update current note html , m_currentGUID : " + m_currentGUID + " \n editor note guid : " + strGUID); + if (m_currentGUID == strGUID) + { + wiz_html = strHtml; + wiz_head = strHead; + } + console.log("update current note html finished, html body ; " + wiz_html); +} + +function updateCss() +{ + console.log("update csss file in wiz_extend : " + editor.document.head.innerHTML); + var css= editor.document.getElementsByTagName('link'); + console.log("update Css. get css file : " + css) + for (var i = 0; i < css.length; i++) { + if (css[i].rel != 'stylesheet') return; + if (css[i].type != 'text/css') return; + if (css[i].href.match(m_defaultCss)) { + css[i].href = m_defaultCss + "?v=" + m_defaultCssVersion; + console.log("after change file location : " + css[i].href); + m_defaultCssVersion++; + } + } +} + +// helper functions +function WizGetLinkUrl() { + console.log('WizGetLinkUrl called'); + try { + var range = editor.selection.getRange(), + link = range.collapsed ? editor.queryCommandValue( "link" ) : editor.selection.getStart(), + url; + + link = UE.dom.domUtils.findParentByTagName( link, "a", true ); + if(link){ + url = UE.utils.html(link.getAttribute( 'data_ue_src' ) || link.getAttribute( 'href', 2 )); + } + } catch (error) { + alert(error); + return "ERROR"; + } + + console.log("before WizGetLinkUrl return : " + url); + return url ? url: ''; +} + +function WizGetImgElementByPoint(posX, posY) { + var element = editor.document.elementFromPoint(posX, posY); + if (element && element.tagName == 'IMG') { + return element.src; + } + + return ''; +} + +//special process to remove css style added by phone. *** should remove before 2014-10-08 +function WizSpecialProcessForPhoneCss() { + + var cssElem = editor.document.getElementById("wiz_phone_default_css"); + if (cssElem) + { + if (editor.document.head.contains(cssElem)) + { + editor.document.head.removeChild(cssElem); + } + else if (editor.document.body.contains(cssElem)) + { + editor.document.body.removeChild(cssElem); + } + } +} + + +function WizReplaceText(findtxt, replacetxt, caseSensitive) { + if (!findtxt) { + return false; + } + if (findtxt == replacetxt || (!caseSensitive && findtxt.toLowerCase() == replacetxt.toLowerCase())) { + return false; + } + obj = { + searchStr:findtxt, + dir:1, + casesensitive:caseSensitive, + replaceStr:replacetxt + }; + return frCommond(obj); +} + +//全部替换 +function WizRepalceAll(findtxt, replacetxt, caseSensitive) { + if (!findtxt) { + return false; + } + if (findtxt == replacetxt || (!caseSensitive && findtxt.toLowerCase() == replacetxt.toLowerCase())) { + return false; + } + obj = { + searchStr:findtxt, + casesensitive:caseSensitive, + replaceStr:replacetxt, + all:true + }; + var num = frCommond(obj); + return num; +} + +//执行 +var frCommond = function (obj) { + return editor.execCommand("searchreplace", obj); +}; + +//插入code的代码时,li的属性会丢失。需要在head中增加li的属性 +function WizAddCssForCodeLi() { + var WIZ_INLINE_CODE_ID = 'wiz_inline_code_id'; + var WIZ_LINK_VERSION = 'wiz_link_version'; + var WIZ_TODO_STYLE_VERSION = "01.00.00"; + + var style = document.getElementById(WIZ_INLINE_CODE_ID); + if (style && !!style.getAttribute && style.getAttribute(WIZ_LINK_VERSION) >= WIZ_TODO_STYLE_VERSION) + return; + // + if (style && style.parentElement) { + style.parentElement.removeChild(style); + } + // + var strStyle = 'ol.linenums li {color: #BEBEC5;line-height: 18px;padding-left: 12px; }'; + // + var objStyle = document.createElement('style'); + objStyle.type = 'text/css'; + objStyle.textContent = strStyle; + objStyle.id = WIZ_INLINE_CODE_ID; + objStyle.setAttribute(WIZ_LINK_VERSION, WIZ_TODO_STYLE_VERSION); + // + editor.document.head.appendChild(objStyle); +} + +//在原有代码块的基础上插入新代码时,删除之前的标志 +function WizInsertCodeHtml(html) { + // var parentElem = editor.document.getSelection(); + // if (parentElem && parentElem.type == "pre") + // { + // document.removeChild(parentElem); + // } + + + editor.execCommand('insertHtml', html, true); +} + +function WizAddCssForCode(cssFile) { + console.log("WizAddCssForCode called , css file " + cssFile); + var doc = editor.document; + if (!doc) + return; + // + var oldLink = doc.getElementById('wiz_code_highlight_link'); + if (oldLink) { + console.log("old css link find, try to remove"); + oldLink.parentNode.removeChild(oldLink); + } + // + var link = doc.createElement('link'); + if (!link) + return; + try { + link.type = 'text/css'; + link.rel = 'stylesheet'; + link.id = 'wiz_code_highlight_link'; + link.href = cssFile; + // + if (!doc.head) + { + doc.insertBefore(doc.createElement('head'), doc.body); + } + doc.head.appendChild(link); + } + catch(e) { + + } +} + + +function WizClearEditorHeight() { + editor.document.body.style.height=''; +} + + +function WizMoveEnd(){ + obj = editor.document.body; + obj.focus(); + var len = obj.value.length; + if (document.selection) { + var sel = obj.createTextRange(); + sel.moveStart('character',len); + sel.collapse(); + sel.select(); + } else if (typeof obj.selectionStart == 'number' && typeof obj.selectionEnd == 'number') { + obj.selectionStart = obj.selectionEnd = len; + } + +} \ No newline at end of file diff --git a/share/files/editor/wiznote_extend.js b/share/files/editor/wiznote_extend.js index 2b87b97e0..a0f0583a9 100644 --- a/share/files/editor/wiznote_extend.js +++ b/share/files/editor/wiznote_extend.js @@ -271,6 +271,37 @@ function WizInsertCodeHtml(html) { editor.execCommand('insertHtml', html, true); } +function WizAddCssForCode(cssFile) { + console.log("WizAddCssForCode called , css file " + cssFile); + var doc = editor.document; + if (!doc) + return; + // + var oldLink = doc.getElementById('wiz_code_highlight_link'); + if (oldLink) { + console.log("old css link find, try to remove"); + oldLink.parentNode.removeChild(oldLink); + } + // + var link = doc.createElement('link'); + if (!link) + return; + try { + link.type = 'text/css'; + link.rel = 'stylesheet'; + link.id = 'wiz_code_highlight_link'; + link.href = cssFile; + // + if (!doc.head) + { + doc.insertBefore(doc.createElement('head'), doc.body); + } + doc.head.appendChild(link); + } + catch(e) { + + } +} function WizClearEditorHeight() { editor.document.body.style.height=''; diff --git a/share/files/editor/wiztodo_read_checked-webengine.js b/share/files/editor/wiztodo_read_checked-webengine.js new file mode 100644 index 000000000..26893c60d --- /dev/null +++ b/share/files/editor/wiztodo_read_checked-webengine.js @@ -0,0 +1,1554 @@ +// Copyright (c) 2014, Dan Kogai +// All rights reserved. + +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: + +// * Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. + +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. + +// * Neither the name of {{{project}}} nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. + +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +/* + * $Id: base64.js,v 2.15 2014/04/05 12:58:57 dankogai Exp dankogai $ + * + * Licensed under the MIT license. + * http://opensource.org/licenses/mit-license + * + * References: + * http://en.wikipedia.org/wiki/Base64 + */ + +(function(global) { + 'use strict'; + // existing version for noConflict() + var _Base64 = global.Base64; + var version = "2.1.5"; + // if node.js, we use Buffer + var buffer; + if (typeof module !== 'undefined' && module.exports) { + buffer = require('buffer').Buffer; + } + // constants + var b64chars + = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + var b64tab = function(bin) { + var t = {}; + for (var i = 0, l = bin.length; i < l; i++) t[bin.charAt(i)] = i; + return t; + }(b64chars); + var fromCharCode = String.fromCharCode; + // encoder stuff + var cb_utob = function(c) { + if (c.length < 2) { + var cc = c.charCodeAt(0); + return cc < 0x80 ? c + : cc < 0x800 ? (fromCharCode(0xc0 | (cc >>> 6)) + + fromCharCode(0x80 | (cc & 0x3f))) + : (fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) + + fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) + + fromCharCode(0x80 | ( cc & 0x3f))); + } else { + var cc = 0x10000 + + (c.charCodeAt(0) - 0xD800) * 0x400 + + (c.charCodeAt(1) - 0xDC00); + return (fromCharCode(0xf0 | ((cc >>> 18) & 0x07)) + + fromCharCode(0x80 | ((cc >>> 12) & 0x3f)) + + fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) + + fromCharCode(0x80 | ( cc & 0x3f))); + } + }; + var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g; + var utob = function(u) { + return u.replace(re_utob, cb_utob); + }; + var cb_encode = function(ccc) { + var padlen = [0, 2, 1][ccc.length % 3], + ord = ccc.charCodeAt(0) << 16 + | ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) + | ((ccc.length > 2 ? ccc.charCodeAt(2) : 0)), + chars = [ + b64chars.charAt( ord >>> 18), + b64chars.charAt((ord >>> 12) & 63), + padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63), + padlen >= 1 ? '=' : b64chars.charAt(ord & 63) + ]; + return chars.join(''); + }; + var btoa = global.btoa ? function(b) { + return global.btoa(b); + } : function(b) { + return b.replace(/[\s\S]{1,3}/g, cb_encode); + }; + var _encode = buffer + ? function (u) { return (new buffer(u)).toString('base64') } + : function (u) { return btoa(utob(u)) } + ; + var encode = function(u, urisafe) { + return !urisafe + ? _encode(u) + : _encode(u).replace(/[+\/]/g, function(m0) { + return m0 == '+' ? '-' : '_'; + }).replace(/=/g, ''); + }; + var encodeURI = function(u) { return encode(u, true) }; + // decoder stuff + var re_btou = new RegExp([ + '[\xC0-\xDF][\x80-\xBF]', + '[\xE0-\xEF][\x80-\xBF]{2}', + '[\xF0-\xF7][\x80-\xBF]{3}' + ].join('|'), 'g'); + var cb_btou = function(cccc) { + switch(cccc.length) { + case 4: + var cp = ((0x07 & cccc.charCodeAt(0)) << 18) + | ((0x3f & cccc.charCodeAt(1)) << 12) + | ((0x3f & cccc.charCodeAt(2)) << 6) + | (0x3f & cccc.charCodeAt(3)), + offset = cp - 0x10000; + return (fromCharCode((offset >>> 10) + 0xD800) + + fromCharCode((offset & 0x3FF) + 0xDC00)); + case 3: + return fromCharCode( + ((0x0f & cccc.charCodeAt(0)) << 12) + | ((0x3f & cccc.charCodeAt(1)) << 6) + | (0x3f & cccc.charCodeAt(2)) + ); + default: + return fromCharCode( + ((0x1f & cccc.charCodeAt(0)) << 6) + | (0x3f & cccc.charCodeAt(1)) + ); + } + }; + var btou = function(b) { + return b.replace(re_btou, cb_btou); + }; + var cb_decode = function(cccc) { + var len = cccc.length, + padlen = len % 4, + n = (len > 0 ? b64tab[cccc.charAt(0)] << 18 : 0) + | (len > 1 ? b64tab[cccc.charAt(1)] << 12 : 0) + | (len > 2 ? b64tab[cccc.charAt(2)] << 6 : 0) + | (len > 3 ? b64tab[cccc.charAt(3)] : 0), + chars = [ + fromCharCode( n >>> 16), + fromCharCode((n >>> 8) & 0xff), + fromCharCode( n & 0xff) + ]; + chars.length -= [0, 0, 2, 1][padlen]; + return chars.join(''); + }; + var atob = global.atob ? function(a) { + return global.atob(a); + } : function(a){ + return a.replace(/[\s\S]{1,4}/g, cb_decode); + }; + var _decode = buffer + ? function(a) { return (new buffer(a, 'base64')).toString() } + : function(a) { return btou(atob(a)) }; + var decode = function(a){ + return _decode( + a.replace(/[-_]/g, function(m0) { return m0 == '-' ? '+' : '/' }) + .replace(/[^A-Za-z0-9\+\/]/g, '') + ); + }; + var noConflict = function() { + var Base64 = global.Base64; + global.Base64 = _Base64; + return Base64; + }; + // export Base64 + global.Base64 = { + VERSION: version, + atob: atob, + btoa: btoa, + fromBase64: decode, + toBase64: encode, + utob: utob, + encode: encode, + encodeURI: encodeURI, + btou: btou, + decode: decode, + noConflict: noConflict + }; + // if ES5 is available, make Base64.extendString() available + if (typeof Object.defineProperty === 'function') { + var noEnum = function(v){ + return {value:v,enumerable:false,writable:true,configurable:true}; + }; + global.Base64.extendString = function () { + Object.defineProperty( + String.prototype, 'fromBase64', noEnum(function () { + return decode(this) + })); + Object.defineProperty( + String.prototype, 'toBase64', noEnum(function (urisafe) { + return encode(this, urisafe) + })); + Object.defineProperty( + String.prototype, 'toBase64URI', noEnum(function () { + return encode(this, true) + })); + }; + } + // that's it! +})(this); + +if (this['Meteor']) { + Base64 = global.Base64; // for normal export in Meteor.js +} +//////////////////////////////////////////////////////////////////////////////// + +function WizDoc(wizDoc) { + + this.doc = wizDoc; + + this.getHtml = getHtml; + this.setHtml = setHtml; + this.canEdit = canEdit; + this.getTitle = getTitle; + + function getHtml() { + if (!this.doc) + return null; + // + var html = this.doc.GetHtml(); + // + return html; + } + + function setHtml(html, resources) { + if (!this.doc) + return; + // + this.doc.SetHtml2(html, resources); + } + + function canEdit() { + return this.doc.CanEdit; + } + + function getTitle() { + return this.doc.Title; + } +} + +function WizInitReadCss(document, destNode) { + var WIZ_TODO_STYLE_ID = 'wiz_todo_style_id'; + var WIZ_STYLE = 'wiz_style'; + var WIZ_LINK_VERSION = 'wiz_link_version'; + var WIZ_TODO_STYLE_VERSION = "01.01.00";// must above todo edit css version + + var style = document.getElementById(WIZ_TODO_STYLE_ID); + if (style && !!style.getAttribute && style.getAttribute(WIZ_LINK_VERSION) >= WIZ_TODO_STYLE_VERSION) + return; + // + if (style && style.parentElement) { + style.parentElement.removeChild(style); + } + // + var strStyle = '.wiz-todo, .wiz-todo-img {width: 16px; height: 16px; cursor: default; padding: 0 10px 0 2px; vertical-align: -7%;-webkit-user-select: none;} .wiz-todo-label { line-height: 2.5;} .wiz-todo-label-checked { /*text-decoration: line-through;*/ color: #666;} .wiz-todo-label-unchecked {text-decoration: initial;} .wiz-todo-completed-info {padding-left: 44px; display: inline-block; } .wiz-todo-avatar { width:20px; height: 20px; vertical-align: -20%; margin-right:10px; border-radius: 2px;} .wiz-todo-account, .wiz-todo-dt { color: #666; }'; + // + var objStyle = document.createElement('style'); + objStyle.type = 'text/css'; + objStyle.textContent = strStyle; + objStyle.id = WIZ_TODO_STYLE_ID; + // objStyle.setAttribute(WIZ_STYLE, 'unsave'); + objStyle.setAttribute(WIZ_LINK_VERSION, WIZ_TODO_STYLE_VERSION); + // + destNode.appendChild(objStyle); +} + +function WizTodoReadCheckedWindows (wizApp) { + + if (wizApp) { + this.app = wizApp; + this.doc = new WizDoc(wizApp.Window.CurrentDocument); + this.personalDB = wizApp.PersonalDatabase; + this.database = wizApp.Database; + this.commonUI = wizApp.CreateWizObject('WizKMControls.WizCommonUI'); + } + + this.initCss = initCss; + this.getDocHtml = getDocHtml; + this.setDocHtml = setDocHtml; + this.canEdit = canEdit; + this.getCheckedImageFileName = getCheckedImageFileName; + this.getUnCheckedImageFileName = getUnCheckedImageFileName; + this.isPersonalDocument = isPersonalDocument; + this.getUserAlias = getUserAlias; + this.getUserAvatarFileName = getUserAvatarFileName; + this.getLocalDateTime = getLocalDateTime; + this.getWizDocument = getWizDocument; + this.getAvatarName = getAvatarName; + this.onClickingTodo = onClickingTodo; + this.onBeforeSave = onBeforeSave; + + function initCss() { + WizInitReadCss(document, document.head); + } + + function getDocHtml() { + return this.doc.getHtml(); + } + + function setDocHtml(html, resources) { + // + var progress = this.app.CreateWizObject("WizKMControls.WizProgressWindow"); + if (progress) { + progress.Text = this.doc.getTitle(); + progress.Show(); + progress.Max = 1; + } + // + this.doc.setHtml(html, resources); + // + if (progress) { + progress.Hide(); + progress.Destroy(); + } + } + + function canEdit() { + return this.doc.canEdit(); + } + + function getCheckedImageFileName() { + return this.app.AppPath + "WizTools\\htmleditor\\checked.png"; + } + + function getUnCheckedImageFileName() { + return this.app.AppPath + "WizTools\\htmleditor\\unchecked.png"; + } + + function isPersonalDocument() { + return this.database.KbGUID == ""; + } + + function getLocalDateTime(dt) { + return this.commonUI.ToLocalDateString(dt, true) + ' ' + this.commonUI.ToLocalTimeString2(dt, true); + } + + function getUserAlias() { + if (!this.personalDB || !this.database) + return ""; + // + var kbguid = this.database.KbGUID; + if (!kbguid) + return ""; + // + return this.personalDB.GetUserAlias(kbguid); + } + + function getUserAvatarFileName(size) { + if (!this.database) + return ""; + if (!this.database.GetAvatarFileName) + return ""; + // + var fileName = this.database.GetAvatarFileName(); + // + var pos = fileName.lastIndexOf('\\'); + var filePath = fileName.substr(0, pos); + var fileTitle = fileName.substr(pos + 1, fileName.lastIndexOf('.') - pos - 1); + var ext = fileName.substr(fileName.lastIndexOf('.') + 1); + // + var cacheFileName = filePath + "\\" + fileTitle + size.toString() + "." + ext; + if (this.commonUI.PathFileExists(cacheFileName)) + return cacheFileName; + // + if (!this.commonUI || !this.commonUI.ResizeImage) + return fileName; + var newFileName = this.commonUI.ResizeImage(fileName, size); + // + if (!this.commonUI.PathFileExists(newFileName)) + return fileName; + // + this.commonUI.CopyFile(newFileName, cacheFileName); + // + return cacheFileName; + } + + function getWizDocument() { + return this.doc.doc; + } + + function getAvatarName(avatarFileName) { + if (!avatarFileName) + return ""; + // + var pos = avatarFileName.lastIndexOf('\\'); + if (-1 == pos) { + pos = avatarFileName.lastIndexOf('/'); + } + // + if (-1 != pos) { + return avatarFileName.substr(pos + 1); + } + else return ""; + } + + function onClickingTodo(callback) { + this.app.ExecuteCommand("OnClickingChecklist", + "WizTodoReadChecked." + callback + "({cancel}, {needCallAgain});", "readingnote"); + } + + function onBeforeSave(isModified) { + // this.app.ExecuteCommand("onBeforeSaveChecklist", isModified, "readingnote"); + } +} + +function WizTodoReadCheckedQt () { + + this.initCss = initCss; + this.getDocHtml = getDocHtml; + this.setDocHtml = setDocHtml; + this.canEdit = canEdit; + this.getCheckedImageFileName = getCheckedImageFileName; + this.getUnCheckedImageFileName = getUnCheckedImageFileName; + this.isPersonalDocument = isPersonalDocument; + this.getUserAlias = getUserAlias; + this.getUserAvatarFileName = getUserAvatarFileName; + this.getLocalDateTime = getLocalDateTime; + this.getAvatarName = getAvatarName; + this.onClickingTodo = onClickingTodo; + this.setUserAlias = setUserAlias; + this.setUserAvatarFileName = setUserAvatarFileName; + this.setCheckedImageFileName = setCheckedImageFileName; + this.setUnCheckedImageFileName = setUnCheckedImageFileName; + this.setIsPersonalDocument = setIsPersonalDocument; + this.setCanEdit = setCanEdit; + this.setDocOriginalHtml = setDocOriginalHtml; + + + this.userAlias = null; + this.avatarFileName = null; + this.checkedFileName = null; + this.unCheckedFileName = null; + this.personalDocument = false; + this.canedit = false; + this.originalHtml = ""; + + // WizEditor.setDocOriginalHtml.connect(function (strHtml) { + // this.originalHtml = strHtml; + // console.log("after set original html , html : " + getDocHtml()); + // }); + + function initCss() { + } + + function setUserAlias(alias) { + this.userAlias = alias; + } + + function setUserAvatarFileName(avatarFileName) { + this.avatarFileName = avatarFileName; + } + + function setCheckedImageFileName(fileName) { + this.checkedFileName = fileName; + } + + function setUnCheckedImageFileName(fileName) { + this.unCheckedFileName = fileName; + } + + function setIsPersonalDocument(isPersonalDocument) { + this.personalDocument = isPersonalDocument; + } + + function setCanEdit(canEdit) { + this.canedit = canEdit; + } + + function setDocOriginalHtml (strHtml) { + console.log("set doc originalHtml called , html : " + strHtml); + this.originalHtml = strHtml; + } + + function getDocHtml() { + return this.originalHtml; + } + + function setDocHtml(html, resources) { + WizEditor.saveHtmlToCurrentNote(html, resources); + } + + function canEdit() { + return this.canedit; + } + + function getCheckedImageFileName() { + return this.checkedFileName; + } + + function getUnCheckedImageFileName() { + return this.unCheckedFileName; + } + + function isPersonalDocument() { + return this.personalDocument; + } + + function getLocalDateTime(dt) { + return ""; + } + + function getUserAlias() { + return this.userAlias; + } + + function getUserAvatarFileName(size) { + return this.avatarFileName; + } + + function getAvatarName(avatarFileName) { + if (!avatarFileName) + return ""; + // + var pos = avatarFileName.lastIndexOf('\\'); + if (-1 == pos) { + pos = avatarFileName.lastIndexOf('/'); + } + // + if (-1 != pos) { + return avatarFileName.substr(pos + 1); + } + else return ""; + } + + function onClickingTodo(callback) { + WizEditor.clickingTodoCallBack.connect(WizTodoReadChecked[callback]); + return WizEditor.checkListClickable(); + } +} + +function WizTodoReadCheckedAndroid () { + + this.initCss = initCss; + this.getDocHtml = getDocHtml; + this.setDocHtml = setDocHtml; + this.canEdit = canEdit; + this.getCheckedImageFileName = getCheckedImageFileName; + this.getUnCheckedImageFileName = getUnCheckedImageFileName; + this.isPersonalDocument = isPersonalDocument; + this.getUserAlias = getUserAlias; + this.getUserAvatarFileName = getUserAvatarFileName; + this.getLocalDateTime = getLocalDateTime; + this.onDocumentClose = onDocumentClose; + this.onTodoImageClicked = onTodoImageClicked; + this.getAvatarName = getAvatarName; + this.onClickingTodo = onClickingTodo; + this.onBeforeSave = onBeforeSave; + + function initCss() { + } + + function getDocHtml() { + return window.WizNote.getDocHtml(); + } + + function setDocHtml(html, resources) { + window.WizNote.setDocHtml(html, resources); + } + + function canEdit() { + return window.WizNote.canEdit(); + } + + function getCheckedImageFileName() { + return window.WizNote.getCheckedImageFileName(); + } + + function getUnCheckedImageFileName() { + return window.WizNote.getUnCheckedImageFileName(); + } + + function isPersonalDocument() { + return window.WizNote.isPersonalDocument(); + } + + function getLocalDateTime(dt) { + return window.WizNote.getLocalDateTime(dt); + } + + function getUserAlias() { + return window.WizNote.getUserAlias(); + } + + function getUserAvatarFileName(size) { + return window.WizNote.getUserAvatarFileName(size); + } + + function onDocumentClose(isModified) { + window.WizNote.onWizTodoReadCheckedClose(); + } + + function onTodoImageClicked() { + + } + + function getAvatarName(avatarFileName) { + if (!avatarFileName) + return ""; + // + var pos = avatarFileName.lastIndexOf('\\'); + if (-1 == pos) { + pos = avatarFileName.lastIndexOf('/'); + } + // + if (-1 != pos) { + return avatarFileName.substr(pos + 1); + } + else return ""; + } + + function onClickingTodo(callback) { + window.WizNote.onClickingTodo(callback); + } + + function onBeforeSave(modified) { + + } +} + +function WizTodoReadCheckedIphone() { + + this.initCss = initCss; + this.getUserAlias = getUserAlias; + this.getUserAvatarFileName = getUserAvatarFileName; + this.isPersonalDocument = isPersonalDocument; + this.getLocalDateTime = getLocalDateTime; + this.getCheckedImageFileName = getCheckedImageFileName; + this.getUnCheckedImageFileName = getUnCheckedImageFileName; + this.getDocHtml = getDocHtml; + this.setDocHtml = setDocHtml; + this.canEdit = canEdit; + this.setUserAlias = setUserAlias; + this.setUserAvatarFileName = setUserAvatarFileName; + this.setCheckedImageFileName = setCheckedImageFileName; + this.setUnCheckedImageFileName = setUnCheckedImageFileName; + this.setIsPersonalDocument = setIsPersonalDocument; + this.setCanEdit = setCanEdit; + this.setDocOriginalHtml = setDocOriginalHtml; + this.getAvatarName = getAvatarName; + this.onAddTodoCompletedInfo = onAddTodoCompletedInfo; + this.onClickingTodo = onClickingTodo; + this.onBeforeSave = onBeforeSave; + + this.userAlias = null; + this.avatarFileName = null; + this.checkedFileName = null; + this.unCheckedFileName = null; + this.personalDocument = undefined; + this.canedit = null; + this.originalHtml = ""; + + function initCss() { + } + + function setUserAlias(alias) { + this.userAlias = alias; + } + + function setUserAvatarFileName(avatarFileName) { + this.avatarFileName = avatarFileName; + } + + function setCheckedImageFileName(fileName) { + this.checkedFileName = fileName; + } + + function setUnCheckedImageFileName(fileName) { + this.unCheckedFileName = fileName; + } + + function setIsPersonalDocument(isPersonalDocument) { + this.personalDocument = isPersonalDocument; + } + + function setCanEdit(canEdit) { + this.canedit = canEdit; + } + + function setDocOriginalHtml(html) { + this.originalHtml = html; + } + + function getUserAlias() { + return this.userAlias; + } + + function getUserAvatarFileName(size) { + return this.avatarFileName; + } + + function isPersonalDocument() { + return this.personalDocument === 'true'; + } + + function getLocalDateTime(dt) { + return ""; + } + + function getCheckedImageFileName() { + return this.checkedFileName; + } + + function getUnCheckedImageFileName() { + return this.unCheckedFileName; + } + + function canEdit() { + return this.canedit === 'true'; + } + + function getDocHtml() { + return this.originalHtml; + } + + function setDocHtml(html, resources) { + window.location.href="wiztodolist://setDocHtml/"+"?html=" + html +"&resource="+ resources; + } + + function getAvatarName(avatarFileName) { + if (!avatarFileName) + return ""; + // + var pos = avatarFileName.lastIndexOf('\\'); + if (-1 == pos) { + pos = avatarFileName.lastIndexOf('/'); + } + // + if (-1 != pos) { + return avatarFileName.substr(pos + 1); + } + else return ""; + } + + function onAddTodoCompletedInfo(isChecked, id, dt, callBack) { + var href = "wiztodolist://onAddTodoCompletedInfo/" + "?checked="+ isChecked +"&id="+ id +"&dt="+ dt +"&callback="+ callBack; + window.location.href = href; + } + + function onClickingTodo(callback) { + window.location.href="wiztodolist://tryLockDocument/"+"?callback=" + callback; + } + + function onBeforeSave(isModified) { + + } +} +var WizTodoReadChecked = (function () { + + var WIZ_HTML_CLASS_WIZ_TODO = 'wiz-todo'; + var WIZ_HTML_CLASS_CANNOT_DRAG = 'wiz-img-cannot-drag'; + var WIZ_HTML_TODO_COMPLETED_INFO = 'wiz-todo-completed-info'; + var WIZ_HTML_TODO_AVATAR_SIZE = 40; + + var helper = null; + var wizClient = null; + var modifiedTodos = {}; + var editorDocument = null; + var needCallHelperClicking = true; + var beingClickedTodoEle = null; + var modified = false; + var bodyOriginalCursor = undefined; + + function getHelper(wizClient) { + switch(wizClient) { + case 'windows': + return new WizTodoReadCheckedWindows(external); + case 'qt': + return new WizTodoReadCheckedQt(); + case 'android': + return new WizTodoReadCheckedAndroid(); + case 'iphone': + return new WizTodoReadCheckedIphone(); + case 'web': + break; + } + } + + function isIphone() { + return 'iphone' === wizClient; + } + + function isIpad() { + return 'ipad' === wizClient; + } + + function isQt () { + return 'qt' == wizClient; + } + + function getClassValue(ele) { + if (!ele) + return ""; + // + var classValue = !!ele.getAttribute && ele.getAttribute('class'); + if (!classValue) + return ""; + // + return classValue.toString(); + } + + function getElementDisply(ele) { + var displayStyle = ""; + if (ele) { + try { + if (window.getComputedStyle) { + displayStyle = window.getComputedStyle(ele, null).getPropertyValue('display'); + } else { + displayStyle = ele.currentStyle.display; + } + } + catch (e) { + displayStyle = ""; + } + } + // + return displayStyle; + } + + function isWizTodoBlockElement(ele) { + if (!ele) + return false; + // + var displayValue = getElementDisply(ele); + if (!displayValue) + return false; + // + var value = displayValue.toString().toLowerCase().trim(); + // + if (!value) + return false; + // + if (value == 'block' || value == 'list-item' || value == 'table-cell') + return true; + // + return false; + } + + function getBlockParentElement(ele) { + if (!ele) + return null; + // + var p = ele; + while (p) { + if (p.tagName && p.tagName.toLowerCase() == 'body') + return null; + // + if (isWizTodoBlockElement(p)) + return p; + // + p = p.parentElement; + } + // + return null; + } + + function getParentTodoLabelElement(node) { + if (!node) + return null; + // + var p = node; + while(p && !isWizTodoBlockElement(p)) { + + if (!!p.tagName && p.tagName.toLowerCase() == 'body') + break; + // + if (!!p.tagName && p.tagName.toLowerCase() == 'label' && -1 != getClassValue(p).indexOf('wiz-todo-label')) + return p; + // + p = p.parentElement; + } + // + return null; + } + + function isLabel(ele) { + if (!ele) + return false; + // + if (-1 != getClassValue(ele).indexOf('wiz-todo-label')) + return true; + // + return false; + } + + function isBlockNode(node) { + if (!node) + return false; + // + if (node.nodeType == 9 || node.nodeType == 11) + return true; + // + var displayValue = getElementDisply(node); + if (!displayValue) + return false; + // + var value = displayValue.toString().toLowerCase().trim(); + // + if (!value) + return false; + // + if (value != 'inline' + && value != 'inline-block' + && value != 'inline-table' + && value != 'none') { + return true; + } + // + return false; + } + + function isCompletedInfo (ele) { + if (!ele) + return false; + if (!ele.getAttribute || -1 == getClassValue(ele).indexOf(WIZ_HTML_TODO_COMPLETED_INFO)) + return false; + // + return true; + } + + function addCompletedInfo(label, isChecked, todoId, localDateTime) { + if (!label) + return; + // + if (isChecked) { + var html = "" + + "%4."; + // + var userName = helper.getUserAlias(); + var avatar = helper.getUserAvatarFileName(WIZ_HTML_TODO_AVATAR_SIZE); + // + html = html.replace('%1', avatar); + html = html.replace('%2', WIZ_HTML_CLASS_CANNOT_DRAG + ' ' + 'wiz-todo-avatar'); + html = html.replace('%3', userName); + html = html.replace('%4', localDateTime); + // + var info = editorDocument.createElement('span'); + info.className = WIZ_HTML_TODO_COMPLETED_INFO; + info.innerHTML = html; + info.setAttribute('wiz_todo_id', todoId); + // + for (var i = label.childNodes.length - 1; i >= 0; i --) { + var child = label.childNodes[i]; + // + if (child.tagName && child.tagName.toLowerCase() == 'br') { + label.removeChild(child); + } + } + // + var nextSib = label.nextElementSibling; + while (nextSib) { + if (isLabel(nextSib)) { + label.parentElement.insertBefore(info, nextSib); + break; + } + // + if (nextSib.tagName.toLowerCase() == 'br') { + label.parentElement.insertBefore(info, nextSib); + break; + } + // + nextSib = nextSib.nextElementSibling; + } + // + if (!nextSib) { + label.parentElement.appendChild(info); + } + // + // setCaret(info); + // + if (modifiedTodos[todoId] === undefined) { + modifiedTodos[todoId] = {}; + } + // + modifiedTodos[todoId]['completedInfo'] = info.outerHTML; + } + else { + if (modifiedTodos[todoId] === undefined) { + modifiedTodos[todoId] = {}; + } + modifiedTodos[todoId]['completedInfo'] = ""; + // + var info = label.parentElement.getElementsByClassName(WIZ_HTML_TODO_COMPLETED_INFO); + if (!info || info.length < 1) + return; + // + for (var i = 0; i < info.length; i ++) { + var child = info[0]; + var tmpLabel = child.getElementsByClassName('wiz-todo-label'); + var chileNextSib = child.nextElementSibling; + // + if (tmpLabel && tmpLabel.length > 0) { + var nextSib = tmpLabel[0]; + while (nextSib) { + var tmpNext = nextSib; + nextSib = nextSib.nextSibling; + child.parentElement.insertBefore(tmpNext, chileNextSib); + } + } + } + // + var nextSib = label.nextElementSibling; + while (nextSib) { + if (isLabel(nextSib)) + break; + // + if (isCompletedInfo(nextSib)) { + var tmpNode = nextSib; + nextSib = nextSib.nextElementSibling; + label.parentElement.removeChild(tmpNode); + continue; + } + // + nextSib = nextSib.nextElementSibling; + } + } + } + + function formatIntToDateString(n){ + + return n < 10 ? '0' + n : n; + } + + function ToDateString(dt){ + // + var ret = dt.getFullYear() + "-" + + formatIntToDateString(dt.getMonth() + 1) + "-" + + formatIntToDateString(dt.getDate()) + "T" + + formatIntToDateString(dt.getHours())+ ":" + + formatIntToDateString(dt.getMinutes()) + ":" + + formatIntToDateString(dt.getSeconds()); + return ret; + } + + function clickTodo(todoEle) { + + if (helper.onTodoImageClicked) { + helper.onTodoImageClicked(); + } + + if (!helper.canEdit()) + return; + // + if (!todoEle) + return; + var label = getParentTodoLabelElement(todoEle); + // todo img add a label parent. + if (!label) { + label = editorDocument.createElement('label'); + label.className = 'wiz-todo-label wiz-todo-label-unchecked'; + todoEle.parentElement.insertBefore(label, todoEle); + var nextSib = todoEle; + while (!!nextSib && !isBlockNode(nextSib)) { + // + label.appendChild(nextSib); + // + nextSib = nextSib.nextSibling; + } + // only for read mode + label.setAttribute('no-exist', 'no-exist'); + } + // + var classValue = getClassValue(label); + // + var isChecked = !(todoEle.getAttribute('state') == 'checked'); + var imgSrc = isChecked ? helper.getCheckedImageFileName() : helper.getUnCheckedImageFileName(); + var state = isChecked ? 'checked' : 'unchecked'; + // + if (isChecked) { + // + if (-1 != classValue.indexOf('wiz-todo-label-unchecked')) { + classValue = classValue.replace('wiz-todo-label-unchecked', 'wiz-todo-label-checked'); + } + else { + classValue += ' wiz-todo-label-checked'; + } + } + else { + if (-1 != classValue.indexOf('wiz-todo-label-checked')) { + classValue = classValue.replace('wiz-todo-label-checked', 'wiz-todo-label-unchecked'); + } + else { + classValue += ' wiz-todo-label-unchecked'; + } + } + // + todoEle.src = imgSrc; + todoEle.setAttribute('state', state); + label.setAttribute('class', classValue); + // + if (!helper.isPersonalDocument()) { + if (isIpad() || isIphone()) { + helper.onAddTodoCompletedInfo(isChecked, todoEle.id, Date.now(), 'addTodoCompletedInfo'); + } + else { + var dt = helper.getLocalDateTime(new Date()); + addCompletedInfo(label, isChecked, todoEle.id, dt); + } + } + // + var nextSib = label.nextSibling; + while (nextSib) { + // + var tmpNext = nextSib; + nextSib = nextSib.nextSibling; + // + if (isLabel(tmpNext) || isCompletedInfo(tmpNext) || isBlockNode(tmpNext)) + break; + // + label.appendChild(tmpNext); + } + // + var parent = getBlockParentElement(label); + if (!parent) { + var div = editorDocument.createElement('div'); + label.parentElement.insertBefore(div, label.nextSibling); + div.appendChild(label); + } + // + var id = todoEle.id; + // + if (modifiedTodos[todoEle.id] === undefined) { + modifiedTodos[todoEle.id] = {}; + } + // + if (modifiedTodos[todoEle.id]['state'] === undefined) { + modifiedTodos[todoEle.id]['state'] = isChecked ? "checked" : "unchecked"; + } + else { + delete modifiedTodos[todoEle.id]; + } + // + } + + function onTodoClick(todoEle) { + + if (beingClickedTodoEle != null) + return; + // + if (!needCallHelperClicking) { + clickTodo(todoEle); + } + else { + if (helper.onClickingTodo) { + beingClickedTodoEle = todoEle; + helper.onClickingTodo("onClickingTodoCallback"); + } + } + } + + function onDocumentClick(e) { + var node = e.target; + if (!node) + return; + if (!node.className) + return; + if (-1 != getClassValue(node).indexOf('wiz-todo-img')) { + onTodoClick(node); + } + } + + function registerEvent() { + editorDocument.removeEventListener('click', onDocumentClick); + editorDocument.addEventListener('click', onDocumentClick); + } + + function unregisterEvent() { + if (editorDocument) { + editorDocument.removeEventListener('click', onDocumentClick); + } + } + + function init(client) { + + wizClient = client; + // + var ueditor = null; + if (wizClient == 'qt') { + ueditor = document.getElementById('ueditor_0'); + } + // + editorDocument = ueditor ? ueditor.contentDocument : document; + helper = getHelper(wizClient); + helper.initCss(); + // + registerEvent(); + } + + function clear() { + + unregisterEvent(); + // + helper = null; + wizClient = null; + modifiedTodos = {}; + editorDocument = null; + needCallHelperClicking = true; + beingClickedTodoEle = null; + modified = false; + bodyOriginalCursor = undefined; + } + + function extractTodoText(id, html) { + var todoImg = editorDocument.getElementById(id); + // + if (!todoImg) + return ""; + // + var todoText = ""; + // + var label = getParentTodoLabelElement(todoImg); + if (label && !label.getAttribute('no-exist')) { + var pos = html.indexOf(id); + if (-1 == pos) + return ""; + // + var html1 = html.substr(0, pos); + var pos1 = html1.lastIndexOf(""); + // + if (-1 == pos1 || -1 == pos2) + return ""; + // + todoText = html.substring(pos1, pos + pos2 + "".length); + } + else { + var regText = "]*?id[ ]*?=[ ]*?['\"]{id}['\"]*?.*?>.*?<\/{tagname}>"; + regText = regText.replace("{id}", id); + var parent = getBlockParentElement(todoImg); + var tagName = (!!parent && parent.tagName) ? parent.tagName.toLowerCase() : "div"; + regText = regText.replace("{tagname}", tagName); + var reg = new RegExp(regText, "igm"); + var matchs = html.match(reg); + + if (matchs && matchs.length > 0) + { + var reg = new RegExp("<\\/" + tagName + ">$", 'igm'); + todoText = matchs[0].replace(reg, ""); + } + else + { + var pos = html.indexOf(id); + if (-1 == pos) + return ""; + // + var html1 = html.substr(0, pos); + var pos1 = html1.lastIndexOf(""); + // + if (-1 == pos1 || -1 == pos2) + return ""; + // + todoText = html.substring(pos1, pos + pos2 + ">".length); + } + } + // + return todoText; + } + + function changeWizDocument(id, state, completedInfo, html) { + // var html = helper.getDocHtml(); + if (!html) + return null; + // + var todoText = extractTodoText(id, html); + // + if (todoText === "") + return null; + // + var pos = html.indexOf(todoText); + var firstHtml = html.substr(0, pos); + var lastHtml = html.substr(pos + todoText.length); + // + if (state == "checked" && todoText.match(/state[ ]*=[ ]*['\"]unchecked['\"]/ig)) { + + todoText = todoText.replace("wiz-todo-label-unchecked", "wiz-todo-label-checked"); + todoText = todoText.replace("unchecked.png", "checked.png"); + todoText = todoText.replace("state='unchecked'", "state='checked'"); + todoText = todoText.replace("state=\"unchecked\"", "state=\"checked\""); + } + else if (state == "unchecked" && todoText.match(/state[ ]*=[ ]*['\"]checked['\"]/ig)){ + + todoText = todoText.replace("wiz-todo-label-checked", "wiz-todo-label-unchecked"); + todoText = todoText.replace("checked.png", "unchecked.png"); + todoText = todoText.replace("state='checked'", "state='unchecked'"); + todoText = todoText.replace("state=\"checked\"", "state=\"unchecked\""); + } + else { + // on current user is not same as original one. + if (state == "checked" && completedInfo) { + var reg = new RegExp("]*?wiz_todo_id[ ]*=[ ]*['\"]" + id + "['\"][\\w\\W]*?wiz-todo-dt[\\w\\W]*?<\\/span><\\/span>", "igm"); + lastHtml = lastHtml.replace(reg, ""); + // + html = firstHtml + todoText + completedInfo + lastHtml; + return html; + } + // + return null; + } + // + if (-1 == todoText.indexOf('"; + } + else { + todoText = "