Add a new skin (iMobile)

This commit is contained in:
iTanken
2018-02-10 21:33:57 +08:00
parent 2fbf71c1e6
commit e3d16fc1ca
85 changed files with 6707 additions and 0 deletions

BIN
iMobile/js/.DS_Store vendored Normal file

Binary file not shown.

379
iMobile/js/common.js Normal file
View File

@@ -0,0 +1,379 @@
/*
* Copyright (c) 2010-2018, b3log.org & hacpai.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview util and every page should be used.
*
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.3.1.1, Jan 29, 2018
*/
/**
* @description Util
* @static
*/
var Util = {
/**
* 按需加载 MathJax 及 flow
* @returns {undefined}
*/
parseMarkdown: function (className) {
var hasMathJax = false;
var hasFlow = false;
var className = className || 'article-body';
$('.' + className).each(function () {
$(this).find('p').each(function () {
if ($(this).text().indexOf('$\\') > -1 || $(this).text().indexOf('$$') > -1) {
hasMathJax = true;
}
});
if ($(this).find('code.lang-flow, code.language-flow').length > 0) {
hasFlow = true
}
});
if (hasMathJax) {
var initMathJax = function () {
MathJax.Hub.Config({
tex2jax: {
inlineMath: [['$', '$'], ["\\(", "\\)"]],
displayMath: [['$$', '$$']],
processEscapes: true,
processEnvironments: true,
skipTags: ['pre', 'code', 'script']
}
});
MathJax.Hub.Typeset();
};
if (typeof MathJax !== 'undefined') {
initMathJax();
} else {
$.ajax({
method: "GET",
url: "https://cdn.staticfile.org/MathJax/MathJax-2.6-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&_=1473258780393",
dataType: "script",
cache: true
}).done(function () {
initMathJax();
});
}
}
if (hasFlow) {
var initFlow = function () {
$('.' + className + ' code.lang-flow, .' + className + ' code.language-flow').each(function (index) {
var $it = $(this);
var id = 'symFlow' + (new Date()).getTime() + index;
$it.hide();
var diagram = flowchart.parse($.trim($it.text()));
$it.parent().after('<div style="text-align: center" id="' + id + '"></div>')
diagram.drawSVG(id);
$it.parent().remove();
$('#' + id).find('svg').height('auto').width('auto');
});
};
if (typeof (flowchart) !== 'undefined') {
initFlow();
} else {
$.ajax({
method: "GET",
url: latkeConfig.staticServePath + '/js/lib/flowchart/flowchart.min.js',
dataType: "script",
cache: true
}).done(function () {
initFlow()
});
}
}
},
/**
* @description 是否登录
* @returns {Boolean} 是否登录
*/
isLoggedIn: function () {
if (($("#admin").length === 1 && $("#admin").data("login")) || latkeConfig.isLoggedIn === "true") {
return true;
} else {
return false;
}
},
/**
* @description 获取用户名称
* @returns {String} 用户名称
*/
getUserName: function () {
if ($("#adminName").length === 1) {
return $("#adminName").text();
} else {
return latkeConfig.userName;
}
},
/**
* @description 检测页面错误
*/
error: function () {
$("#tipMsg").text("Error: " + arguments[0] +
" File: " + arguments[1] + "\nLine: " + arguments[2] +
" please report this issue on https://github.com/b3log/solo/issues/new");
$("#loadMsg").text("");
},
/**
* @description IE6/7跳转到 kill-browser 页面
*/
killIE: function () {
var addKillPanel = function () {
if (Cookie.readCookie("showKill") === "") {
var left = ($(window).width() - 701) / 2,
top1 = ($(window).height() - 420) / 2;
$("body").append("<div style='display: block; height: 100%; width: 100%; position: fixed; background-color: rgb(0, 0, 0); opacity: 0.6; top: 0px;z-index:11'></div>"
+ "<iframe style='left:" + left + "px;z-index:20;top: " + top1 + "px; position: fixed; border: 0px none; width: 701px; height: 420px;' src='" + latkeConfig.servePath + "/kill-browser'></iframe>");
}
};
if ($.browser.msie) {
// kill IE6 and IE7
if ($.browser.version === "6.0" || $.browser.version === "7.0") {
addKillPanel();
return;
}
// 后台页面 kill 360
if (window.external && window.external.twGetRunPath) {
var path = external.twGetRunPath();
if (path && path.toLowerCase().indexOf("360se") > -1 &&
window.location.href.indexOf("admin-index") > -1) {
addKillPanel();
return;
}
}
}
},
/**
* @description 替换[emXX] 为图片
* @param {String} str 替换字符串
* @returns {String} 替换后的字符
*/
replaceEmString: function (str) {
var commentSplited = str.split("[em");
if (commentSplited.length === 1) {
return str;
}
str = commentSplited[0];
for (var j = 1; j < commentSplited.length; j++) {
var key = commentSplited[j].substr(0, 2);
str += "<img width='20' src='" + latkeConfig.staticServePath + "/images/emotions/em" + key + ".png' alt='" +
Label["em" + key + "Label"] + "' title='" +
Label["em" + key + "Label"] + "'/> " + commentSplited[j].substr(3);
}
return str;
},
/**
* @description URL 没有协议头,则自动加上 http://
* @param {String} url URL 地址
* @returns {String} 添加后的URL
*/
proessURL: function (url) {
if (!/^\w+:\/\//.test(url)) {
url = "http://" + url;
}
return url;
},
/**
* @description 切换到手机版
* @param {String} skin 切换前的皮肤名称
*/
switchMobile: function (skin) {
Cookie.createCookie("btouch_switch_toggle", skin, 365);
setTimeout(function () {
location.reload();
}, 1250);
},
/**
* @description topbar 相关事件
*/
setTopBar: function () {
var $top = $("#top");
if ($top.length === 1) {
var $showTop = $("#showTop");
$showTop.click(function () {
$top.slideDown();
$showTop.hide();
});
$("#hideTop").click(function () {
$top.slideUp();
$showTop.show();
});
}
},
/**
* @description 回到顶部
*/
goTop: function () {
$('html, body').animate({scrollTop: 0}, 500);
},
/**
* @description 回到底部
*/
goBottom: function (bottom) {
if (!bottom) {
bottom = 0;
}
var wHeight = $("body").height() > $(document).height() ? $("body").height() : $(document).height();
// window.scrollTo(0, wHeight - $(window).height() - bottom);
$('html, body').animate({scrollTop: (wHeight - $(window).height() - bottom)}, 500);
},
/**
* @description 页面初始化执行的函数
*/
init: function () {
//window.onerror = Util.error;
Util.killIE();
Util.setTopBar();
Util.parseMarkdown();
},
/**
* @description 替换侧边栏表情为图片
* @param {Dom} comments 评论内容元素
*/
replaceSideEm: function (comments) {
for (var i = 0; i < comments.length; i++) {
var $comment = $(comments[i]);
$comment.html(Util.replaceEmString($comment.html()));
}
},
/**
* @description 根据 tags穿件云效果
* @param {String} [id] tags 根元素 id默认为 tags
*/
buildTags: function (id) {
id = id || "tags";
// 根据引用次数添加样式,产生云效果
var classes = ["tags1", "tags2", "tags3", "tags4", "tags5"],
bList = $("#" + id + " b").get();
var max = parseInt($("#" + id + " b").last().text());
var distance = Math.ceil(max / classes.length);
for (var i = 0; i < bList.length; i++) {
var num = parseInt(bList[i].innerHTML);
// 算出当前 tag 数目所在的区间,加上 class
for (var j = 0; j < classes.length; j++) {
if (num > j * distance && num <= (j + 1) * distance) {
bList[i].parentNode.className = classes[j];
break;
}
}
}
// 按字母或者中文拼音进行排序
$("#" + id).html($("#" + id + " li").get().sort(function (a, b) {
var valA = $(a).find("span").text().toLowerCase();
var valB = $(b).find("span").text().toLowerCase();
// 对中英文排序的处理
return valA.localeCompare(valB);
}));
},
/**
* @description 时间戳转化为时间格式
* @param {String} time 时间
* @param {String} format 格式化后日期格式
* @returns {String} 格式化后的时间
*/
toDate: function (time, format) {
var dateTime = new Date(time);
var o = {
"M+": dateTime.getMonth() + 1, //month
"d+": dateTime.getDate(), //day
"H+": dateTime.getHours(), //hour
"m+": dateTime.getMinutes(), //minute
"s+": dateTime.getSeconds(), //second
"q+": Math.floor((dateTime.getMonth() + 3) / 3), //quarter
"S": dateTime.getMilliseconds() //millisecond
}
if (/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (dateTime.getFullYear() + "").substr(4 - RegExp.$1.length));
}
for (var k in o) {
if (new RegExp("(" + k + ")").test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
}
}
return format;
},
/**
* @description 获取窗口高度
* @returns {Inter} 窗口高度
*/
getWinHeight: function () {
if (window.innerHeight) {
return window.innerHeight;
}
if (document.compatMode === "CSS1Compat") {
return window.document.documentElement.clientHeight;
}
return window.document.body.clientHeight;
}
};
if (!Cookie) {
/**
* @description Cookie 相关操作
* @static
*/
var Cookie = {
/**
* @description 读取 cookie
* @param {String} name cookie key
* @returns {String} 对应 key 的值,如 key 不存在则返回 ""
*/
readCookie: function (name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ')
c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0)
return decodeURIComponent(c.substring(nameEQ.length, c.length));
}
return "";
},
/**
* @description 清除 Cookie
* @param {String} name 清除 key 为 name 的该条 Cookie
*/
eraseCookie: function (name) {
this.createCookie(name, "", -1);
},
/**
* @description 创建 Cookie
* @param {String} name 每条 Cookie 唯一的 key
* @param {String} value 每条 Cookie 对应的值,将被 UTF-8 编码
* @param {Int} days Cookie 保存时间
*/
createCookie: function (name, value, days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toGMTString();
}
document.cookie = name + "=" + encodeURIComponent(value) + expires + "; path=/";
}
};
}

16
iMobile/js/common.min.js vendored Normal file

File diff suppressed because one or more lines are too long

16
iMobile/js/l10n.js Normal file
View File

@@ -0,0 +1,16 @@
/*
* Copyright (c) 2010-2017, b3log.org & hacpai.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function convertEntities(b){var d,a;d=function(c){if(/&[^;]+;/.test(c)){var f=document.createElement("div");f.innerHTML=c;return !f.firstChild?c:f.firstChild.nodeValue}return c};if(typeof b==="string"){return d(b)}else{if(typeof b==="object"){for(a in b){if(typeof b[a]==="string"){b[a]=d(b[a])}}}}return b};

16
iMobile/js/l10n.min.js vendored Normal file
View File

@@ -0,0 +1,16 @@
/*
* Copyright (c) 2010-2017, b3log.org & hacpai.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function convertEntities(t){var e,n;if(e=function(t){if(/&[^;]+;/.test(t)){var e=document.createElement("div");return e.innerHTML=t,e.firstChild?e.firstChild.nodeValue:t}return t},"string"==typeof t)return e(t);if("object"==typeof t)for(n in t)"string"==typeof t[n]&&(t[n]=e(t[n]));return t}

BIN
iMobile/js/lib/.DS_Store vendored Normal file

Binary file not shown.

BIN
iMobile/js/lib/OwO/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,134 @@
(()=>{
class OwO {
constructor(option) {
const defaultOption = {
logo: 'OωO表情',
container: document.getElementsByClassName('OwO')[0],
target: document.getElementsByTagName('textarea')[0],
position: 'down',
width: '100%',
maxHeight: '250px',
api: 'https://itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/OwO.json',
useMarkdown: false,
appendContent: '',
addClass: '',
usedSize: 'h_200'
};
for (let defaultKey in defaultOption) {
if (defaultOption.hasOwnProperty(defaultKey) && !option.hasOwnProperty(defaultKey)) {
option[defaultKey] = defaultOption[defaultKey];
}
}
this.container = option.container;
this.target = option.target;
if (option.position === 'up') {
this.container.classList.add('OwO-up');
}
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
if (xhr.readyState === 4) {
if (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) {
this.odata = JSON.parse(xhr.responseText);
this.init(option);
} else {
console.log('OwO data request was unsuccessful: ' + xhr.status);
}
}
};
xhr.open('get', option.api, true);
xhr.send(null);
}
init(option) {
this.area = option.target;
this.packages = Object.keys(this.odata);
// fill in HTML
let html = `
<div class="OwO-logo"><span>${option.logo}</span></div>
<div class="OwO-body" style="width: ${option.width}">`;
for (let i = 0; i < this.packages.length; i++) {
html += `
<ul class="OwO-items OwO-items-${this.odata[this.packages[i]].type}" style="max-height: ${parseInt(option.maxHeight) - 30 + 'px'};">`;
let opackage = this.odata[this.packages[i]].container;
for (let i = 0; i < opackage.length; i++) {
html += (`
<li class="OwO-item ` + option.addClass + `" alt="${opackage[i].text}" title="${opackage[i].text}">${opackage[i].icon}</li>`);
}
html += `
</ul>`;
}
html += `
<div class="OwO-bar">
<ul class="OwO-packages">`;
for (let i = 0; i < this.packages.length; i++) {
html += `
<li><span>${this.packages[i]}</span></li>`
}
html += `
</ul>
</div>
</div>
`;
if(option.appendContent != '') {
html += option.appendContent;
}
this.container.innerHTML = html;
// bind event
this.logo = this.container.getElementsByClassName('OwO-logo')[0];
this.logo.addEventListener('click', () => {
this.toggle();
});
this.container.getElementsByClassName('OwO-body')[0].addEventListener('click', (e)=> {
let target = null;
if (e.target.classList.contains('OwO-item')) {
target = e.target;
} else if (e.target.parentNode.classList.contains('OwO-item')) {
target = e.target.parentNode;
}
if (target) {
var insertContent = target.innerHTML;
if(target.firstChild.tagName == "IMG" && option.useMarkdown) {
insertContent = "![" + target.title + "](" + (target.firstChild.src.substr(0,target.firstChild.src.indexOf(",")+1)) + option.usedSize + ")";
}
const cursorPos = this.area.selectionEnd;
let areaValue = this.area.value;
this.area.value = areaValue.slice(0, cursorPos) + insertContent + areaValue.slice(cursorPos);
this.area.focus();
//this.toggle();
}
});
this.packagesEle = this.container.getElementsByClassName('OwO-packages')[0];
for (let i = 0; i < this.packagesEle.children.length; i++) {
((index) =>{
this.packagesEle.children[i].addEventListener('click', () => {
this.tab(index);
});
})(i);
}
this.tab(0);
}
toggle() {
if (this.container.classList.contains('OwO-open')) {
this.container.classList.remove('OwO-open');
} else {
this.container.classList.add('OwO-open');
}
}
tab(index) {
const itemsShow = this.container.getElementsByClassName('OwO-items-show')[0];
if (itemsShow) {
itemsShow.classList.remove('OwO-items-show');
}
this.container.getElementsByClassName('OwO-items')[index].classList.add('OwO-items-show');
const packageActive = this.container.getElementsByClassName('OwO-package-active')[0];
if (packageActive) {
packageActive.classList.remove('OwO-package-active');
}
this.packagesEle.getElementsByTagName('li')[index].classList.add('OwO-package-active');
}
}
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = OwO;
} else {
window.OwO = OwO;
}
})();

290
iMobile/js/lib/OwO/OwO.js Normal file
View File

@@ -0,0 +1,290 @@
{
"颜文字": {
"type": "emoticon",
"container": [{
"icon": "OωO",
"text": "萌"
},
{
"icon": "|´・ω・)",
"text": "Hi"
},
{
"icon": "ヾ(≧∇≦*)ゝ",
"text": "开心"
},
{
"icon": "(●゚ω゚●)",
"text": "脸红"
},
{
"icon": " ̄﹃ ̄",
"text": "流口水"
},
{
"icon": "(/ω\)",
"text": "捂脸"
},
{
"icon": "→_→",
"text": "斜眼"
},
{
"icon": "(╯‵□′)╯︵┴─┴",
"text": "掀桌"
},
{
"icon": "∠( ᐛ 」∠)_",
"text": "给跪"
},
{
"icon": "(@。ε。@))",
"text": "么么哒"
},
{
"icon": "୧(๑•̀⌄•́๑)૭",
"text": "加油"
},
{
"icon": "⌇●﹏●⌇",
"text": "吓死宝宝惹"
},
{
"icon": "٩(ˊᗜˋ*)و",
"text": "有木有WiFi"
},
{
"icon": "(ノ°ο°)",
"text": "前方高能预警"
},
{
"icon": "(´இ皿இ`)",
"text": "我从未见过如此厚颜无耻之人"
},
{
"icon": "(ฅ´ω`ฅ)",
"text": "已阅留爪"
},
{
"icon": "(╯°A°)╯︵○○○",
"text": "去吧大师球"
},
{
"icon": "φ( ̄∇ ̄o)",
"text": "太萌惹"
},
{
"icon": "ヾ(´・ ・`。)\"",
"text": "咦咦咦"
},
{
"icon": "( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃",
"text": "气呼呼"
},
{
"icon": "(๑•̀ㅂ•́)و✧",
"text": "加油"
},
{
"icon": "Σ(っ °Д °;)っ",
"text": "什么鬼"
},
{
"icon": "─=≡Σ(((つ•̀ω•́)つ",
"text": "飞扑"
},
{
"icon": "╮(╯▽╰)╭ ",
"text": "无奈"
},
{
"icon": "( ,,´・ω・)ノ\"(´っω・`。)",
"text": "摸摸头"
},
{
"icon": "♥(✿ฺ´∀`✿ฺ)ノ",
"text": "花痴"
},
{
"icon": "٩(๑>◡<๑)۶",
"text": "真棒"
},
{
"icon": "(ó﹏ò。)",
"text": "我受到了惊吓"
}
]
},
"Emoji": {
"type": "emoji",
"container": [{
"icon": "😂",
"text": "笑哭"
},
{
"icon": "😀",
"text": "哈哈"
},
{
"icon": "😅",
"text": "流汗"
},
{
"icon": "😊",
"text": "可爱"
},
{
"icon": "🙂",
"text": "微笑"
},
{
"icon": "🙃",
"text": "我倒"
},
{
"icon": "😌",
"text": "嘻嘻"
},
{
"icon": "😍",
"text": "爱你"
},
{
"icon": "😘 ",
"text": "飞吻"
},
{
"icon": "😜",
"text": "鬼脸"
},
{
"icon": "😝",
"text": "啦啦啦"
},
{
"icon": "😏",
"text": "坏笑"
},
{
"icon": "😒",
"text": "撇嘴"
},
{
"icon": "🙄",
"text": "白眼"
},
{
"icon": "😳 ",
"text": "脸红"
},
{
"icon": "😡",
"text": "愤怒"
},
{
"icon": "😔",
"text": "哎"
},
{
"icon": "😫",
"text": "好累"
},
{
"icon": "😱",
"text": "惊恐"
},
{
"icon": "😭",
"text": "大哭"
},
{
"icon": "😶",
"text": "无语"
},
{
"icon": "😣",
"text": "难过"
},
{
"icon": "😤",
"text": "气死"
},
{
"icon": "😪",
"text": "困了"
},
{
"icon": "😮",
"text": "惊呆"
},
{
"icon": "😲",
"text": "天哪"
},
{
"icon": "🤥",
"text": "说谎"
},
{
"icon": "🤢",
"text": "恶心"
},
{
"icon": "👻",
"text": "吓死你"
},
{
"icon": "👍",
"text": "棒棒哒"
},
{
"icon": "👎",
"text": "鄙视"
},
{
"icon": "👏",
"text": "鼓掌"
},
{
"icon": "👋",
"text": "拜拜"
},
{
"icon": "👭",
"text": "朋友"
},
{
"icon": "🌝",
"text": "满月"
},
{
"icon": "🌞",
"text": "太阳"
},
{
"icon": "🙈",
"text": "看不见"
},
{
"icon": "💊",
"text": "该吃药了"
},
{
"icon": "🙏",
"text": "拜托"
}
]
},
"Markdown": {
"type": "emoticon",
"container": [
{ "icon": "[TEXT](https://zixizixi.cn 'TITLE')", "text": "链接" },
{ "icon": "![ALT](https://zixizixi.cn/icon.png 'TITLE')", "text": "图片" },
{ "icon": "#", "text": "标题" },
{ "icon": "> ", "text": "引用" },
{ "icon": "*", "text": "粗/斜/项" },
{ "icon": "```", "text": "代码" }
]
}
}

View File

@@ -0,0 +1,444 @@
{
"颜文字": {
"type": "emoticon",
"container": [
{"icon": "OωO","text": "萌"},
{"icon": "|´・ω・)","text": "Hi"},
{"icon": "ヾ(≧∇≦*)ゝ","text": "开心"},
{"icon": "(●゚ω゚●)","text": "脸红"},
{"icon": " ̄﹃ ̄","text": "流口水"},
{"icon": "(/ω\)","text": "捂脸"},
{"icon": "→_→","text": "斜眼"},
{"icon": "(╯‵□′)╯︵┴─┴","text": "掀桌"},
{"icon": "∠( ᐛ 」∠)_","text": "给跪"},
{"icon": "(@。ε。@))","text": "么么哒"},
{"icon": "୧(๑•̀⌄•́๑)૭","text": "加油"},
{"icon": "⌇●﹏●⌇","text": "吓死宝宝惹"},
{"icon": "٩(ˊᗜˋ*)و","text": "有木有WiFi"},
{"icon": "(ノ°ο°)","text": "前方高能预警"},
{"icon": "(´இ皿இ`)","text": "我从未见过如此厚颜无耻之人"},
{"icon": "(ฅ´ω`ฅ)","text": "已阅留爪"},
{"icon": "(╯°A°)╯︵○○○","text": "去吧大师球"},
{"icon": "φ( ̄∇ ̄o)","text": "太萌惹"},
{"icon": "ヾ(´・ ・`。)\"","text": "咦咦咦"},
{"icon": "( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃","text": "气呼呼"},
{"icon": "(๑•̀ㅂ•́)و✧","text": "加油"},
{"icon": "Σ(っ °Д °;)っ","text": "什么鬼"},
{"icon": "─=≡Σ(((つ•̀ω•́)つ","text": "飞扑"},
{"icon": "╮(╯▽╰)╭ ","text": "无奈"},
{"icon": "( ,,´・ω・)ノ\"(´っω・`。)","text": "摸摸头"},
{"icon": " ♥(✿ฺ´∀`✿ฺ)ノ","text": "花痴"},
{"icon": "٩(๑>◡<๑)۶","text": "真棒"},
{"icon": "(ó﹏ò。)","text": "我受到了惊吓"}
]
},
"图片表情": {
"type": "image",
"container": [
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/weixiao.jpeg?x-oss-process=image/resize,h_100\">",
"text": "微笑"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/feiwen.jpeg?x-oss-process=image/resize,h_100\">",
"text": "飞吻"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/hahaha.jpeg?x-oss-process=image/resize,h_100\">",
"text": "哈哈哈"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/haixiu.jpeg?x-oss-process=image/resize,h_100\">",
"text": "人家害羞啦"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/huachi.jpeg?x-oss-process=image/resize,h_100\">",
"text": "犯花痴"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/huaixiao.jpeg?x-oss-process=image/resize,h_100\">",
"text": "坏笑"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/jingya.jpeg?x-oss-process=image/resize,h_100\">",
"text": "好惊讶啊"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/kongbu.jpeg?x-oss-process=image/resize,h_100\">",
"text": "好恐怖啊"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/meimeida.jpeg?x-oss-process=image/resize,h_100\">",
"text": "美美哒"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/mengmengda.jpeg?x-oss-process=image/resize,h_100\">",
"text": "萌萌哒"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/pibei.jpeg?x-oss-process=image/resize,h_100\">",
"text": "疲惫不堪"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/shangxin.jpeg?x-oss-process=image/resize,h_100\">",
"text": "好伤心"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/shuangfeile.jpeg?x-oss-process=image/resize,h_100\">",
"text": "爽︿( ̄︶ ̄)︽( ̄︶ ̄)︿飞.飞.飞."
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/woyun.jpeg?x-oss-process=image/resize,h_100\">",
"text": "我晕@"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/wuyu.jpeg?x-oss-process=image/resize,h_100\">",
"text": "无语了"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/ganga.jpeg?x-oss-process=image/resize,h_100\">",
"text": "这就尴尬了..."
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/bishi.jpeg?x-oss-process=image/resize,h_100\">",
"text": "凸^-^凸"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/fennu.jpeg?x-oss-process=image/resize,h_100\">",
"text": "愤怒!"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/xianggu.jpeg?x-oss-process=image/resize,h_100\">",
"text": "蓝瘦香菇"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/xiaoku.jpeg?x-oss-process=image/resize,h_100\">",
"text": "笑哭了"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/xingfen.jpeg?x-oss-process=image/resize,h_100\">",
"text": "好兴奋呀~"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/xixi.jpeg?x-oss-process=image/resize,h_100\">",
"text": "(*^__^*) 嘻嘻"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/yindang.jpeg?x-oss-process=image/resize,h_100\">",
"text": "淫荡的笑了"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/simple/zhayan.jpeg?x-oss-process=image/resize,h_100\">",
"text": "向你眨了眨眼"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/bbxlk.jpg?x-oss-process=image/resize,h_100\">",
"text": "宝宝心里苦"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/douwo.jpg?x-oss-process=image/resize,h_100\">",
"text": "你在逗我?"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/huanhu.jpg?x-oss-process=image/resize,h_100\">",
"text": "来呀~"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/jizhi.jpg?x-oss-process=image/resize,h_100\">",
"text": "机智如我"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/maijiu.jpg?x-oss-process=image/resize,h_100\">",
"text": "买酒去"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/guizhidao.jpg?x-oss-process=image/resize,h_100\">",
"text": "鬼知道"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/laji.gif?x-oss-process=image/resize,h_100\">",
"text": "辣鸡"
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/zhuangb.jpg?x-oss-process=image/resize,h_100\">",
"text": "走一趟"
}
]
},
"Ac娘": {
"type": "image",
"container": [
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/01.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/02.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/03.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/04.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/05.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/06.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/07.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/08.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/09.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/10.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/11.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/12.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/13.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/14.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/15.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/16.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/17.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/18.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/19.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/20.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/21.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/22.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/23.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/24.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/25.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/26.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/27.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/28.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/29.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/30.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/31.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/32.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/33.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/34.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/35.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/36.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/37.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/38.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/39.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/40.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/41.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/42.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/43.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/44.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/45.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/46.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/47.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/48.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/49.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/50.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/51.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/52.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/53.png?x-oss-process=image/resize,h_100\">",
"text": ""
},
{
"icon": "<img src=\"//itanken.oss-cn-hangzhou.aliyuncs.com/images/emimg/acfun/54.png?x-oss-process=image/resize,h_100\">",
"text": ""
}
]
},
"Emoji": {
"type": "emoji",
"container": [
{"icon": "😂","text": "笑哭"},
{"icon": "😀","text": "哈哈"},
{"icon": "😅","text": "流汗"},
{"icon": "😊","text": "可爱"},
{"icon": "🙂","text": "微笑"},
{"icon": "🙃","text": "我倒"},
{"icon": "😌","text": "嘻嘻"},
{"icon": "😍","text": "爱你"},
{"icon": "😘","text": "飞吻"},
{"icon": "😜","text": "鬼脸"},
{"icon": "😝","text": "啦啦啦"},
{"icon": "😏","text": "坏笑"},
{"icon": "😒","text": "撇嘴"},
{"icon": "🙄","text": "白眼"},
{"icon": "😳","text": "脸红"},
{"icon": "😡","text": "愤怒"},
{"icon": "😔","text": "哎"},
{"icon": "😫","text": "好累"},
{"icon": "😱","text": "惊恐"},
{"icon": "😭","text": "大哭"},
{"icon": "😶","text": "无语"},
{"icon": "😣","text": "难过"},
{"icon": "😤","text": "气死"},
{"icon": "😪","text": "困了"},
{"icon": "😮","text": "惊呆"},
{"icon": "😲","text": "天哪"},
{"icon": "🤥","text": "说谎"},
{"icon": "🤢","text": "恶心"},
{"icon": "👻","text": "吓死你"},
{"icon": "👍","text": "棒棒哒"},
{"icon": "👎","text": "鄙视"},
{"icon": "👏","text": "鼓掌"},
{"icon": "👋","text": "拜拜"},
{"icon": "👭","text": "朋友"},
{"icon": "🌝","text": "满月"},
{"icon": "🌞","text": "太阳"},
{"icon": "🙈","text": "看不见"},
{"icon": "💊","text": "该吃药了"},
{"icon": "🙏","text": "拜托"}
]
},
"MD": {
"type": "emoticon",
"container": [
{"icon":"[TEXT](https://zixizixi.cn 'TITLE')","text":"链接"},
{"icon":"![ALT](https://zixizixi.cn/icon.png 'TITLE')","text":"图片"},
{"icon":"#","text":"标题"},
{"icon":"> ","text":"引用"},
{"icon":"*","text":"粗/斜/项"},
{"icon":"```","text":"代码"}
]
}
}

1
iMobile/js/lib/OwO/OwO.min.css vendored Normal file

File diff suppressed because one or more lines are too long

153
iMobile/js/lib/OwO/OwO.min.js vendored Normal file
View File

@@ -0,0 +1,153 @@
'use strict';
var _createClass = function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function(Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; };
}();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
(function() {
var OwO = function() {
function OwO(option) {
var _this = this;
_classCallCheck(this, OwO);
var defaultOption = {
logo: 'OωO表情',
container: document.getElementsByClassName('OwO')[0],
target: document.getElementsByTagName('textarea')[0],
position: 'down',
width: '100%',
maxHeight: '250px',
api: '/skins/mobile/js/lib/OwO/OwO.json',
useMarkdown: false,
appendContent: '',
addClass: '',
usedSize: 'h_200'
};
for (var defaultKey in defaultOption) {
if (defaultOption.hasOwnProperty(defaultKey) && !option.hasOwnProperty(defaultKey)) {
option[defaultKey] = defaultOption[defaultKey];
}
}
this.container = option.container;
this.target = option.target;
if (option.position === 'up') {
this.container.classList.add('OwO-up');
}
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) {
_this.odata = JSON.parse(xhr.responseText);
_this.init(option);
} else {
console.log('OwO data request was unsuccessful: ' + xhr.status);
}
}
};
xhr.open('get', option.api, true);
xhr.send(null);
}
_createClass(OwO, [{
key: 'init',
value: function init(option) {
var _this2 = this;
this.area = option.target;
this.packages = Object.keys(this.odata);
// fill in HTML
var html = '<div class="OwO-logo"><span>' + option.logo + '</span></div>\n<div class="OwO-body" style="width: ' + option.width + '">';
for (var i = 0; i < this.packages.length; i++) {
html += '<ul class="OwO-items OwO-items-' + this.odata[this.packages[i]].type + '" style="max-height: ' + (parseInt(option.maxHeight) - 30 + 'px') + ';">';
var opackage = this.odata[this.packages[i]].container;
for (var _i = 0; _i < opackage.length; _i++) {
html += '<li class="OwO-item ' + option.addClass + ('" alt="' + opackage[_i].text + '" title="' + opackage[_i].text + '">' + opackage[_i].icon + '</li>');
}
html += '</ul>';
}
html += '<div class="OwO-bar"><ul class="OwO-packages">';
for (var _i2 = 0; _i2 < this.packages.length; _i2++) {
html += '<li><span>' + this.packages[_i2] + '</span></li>';
}
html += '</ul></div></div>';
if (option.appendContent != '') {
html += option.appendContent;
}
this.container.innerHTML = html;
// bind event
this.logo = this.container.getElementsByClassName('OwO-logo')[0];
this.logo.addEventListener('click', function() {
_this2.toggle();
});
this.container.getElementsByClassName('OwO-body')[0].addEventListener('click', function(e) {
var target = null;
if (e.target.classList.contains('OwO-item')) {
target = e.target;
} else if (e.target.parentNode.classList.contains('OwO-item')) {
target = e.target.parentNode;
}
if (target) {
var insertContent = target.innerHTML;
if (target.firstChild.tagName == "IMG" && option.useMarkdown) {
insertContent = "![" + target.title + "](" + target.firstChild.src.substr(0, target.firstChild.src.indexOf(",") + 1) + option.usedSize + ")";
}
var cursorPos = _this2.area.selectionEnd;
var areaValue = _this2.area.value;
_this2.area.value = areaValue.slice(0, cursorPos) + insertContent + areaValue.slice(cursorPos);
_this2.area.focus();
//_this2.toggle();
}
});
this.packagesEle = this.container.getElementsByClassName('OwO-packages')[0];
var _loop = function _loop(_i3) {
(function(index) {
_this2.packagesEle.children[_i3].addEventListener('click', function() {
_this2.tab(index);
});
})(_i3);
};
for (var _i3 = 0; _i3 < this.packagesEle.children.length; _i3++) {
_loop(_i3);
}
this.tab(0);
}
}, {
key: 'toggle',
value: function toggle() {
if (this.container.classList.contains('OwO-open')) {
this.container.classList.remove('OwO-open');
} else {
this.container.classList.add('OwO-open');
}
}
}, {
key: 'tab',
value: function tab(index) {
var itemsShow = this.container.getElementsByClassName('OwO-items-show')[0];
if (itemsShow) {
itemsShow.classList.remove('OwO-items-show');
}
this.container.getElementsByClassName('OwO-items')[index].classList.add('OwO-items-show');
var packageActive = this.container.getElementsByClassName('OwO-package-active')[0];
if (packageActive) {
packageActive.classList.remove('OwO-package-active');
}
this.packagesEle.getElementsByTagName('li')[index].classList.add('OwO-package-active');
}
}]);
return OwO;
}();
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = OwO;
} else {
window.OwO = OwO;
}
})();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
/*! layer mobile-v2.0.0 Web弹层组件 MIT License http://layer.layui.com/mobile By 贤心 */
;!function(e){"use strict";var t=document,n="querySelectorAll",i="getElementsByClassName",a=function(e){return t[n](e)},s={type:0,shade:!0,shadeClose:!0,fixed:!0,anim:"scale"},l={extend:function(e){var t=JSON.parse(JSON.stringify(s));for(var n in e)t[n]=e[n];return t},timer:{},end:{}};l.touch=function(e,t){e.addEventListener("click",function(e){t.call(this,e)},!1)};var r=0,o=["layui-m-layer"],c=function(e){var t=this;t.config=l.extend(e),t.view()};c.prototype.view=function(){var e=this,n=e.config,s=t.createElement("div");e.id=s.id=o[0]+r,s.setAttribute("class",o[0]+" "+o[0]+(n.type||0)),s.setAttribute("index",r);var l=function(){var e="object"==typeof n.title;return n.title?'<h3 style="'+(e?n.title[1]:"")+'">'+(e?n.title[0]:n.title)+"</h3>":""}(),c=function(){"string"==typeof n.btn&&(n.btn=[n.btn]);var e,t=(n.btn||[]).length;return 0!==t&&n.btn?(e='<span yes type="1">'+n.btn[0]+"</span>",2===t&&(e='<span no type="0">'+n.btn[1]+"</span>"+e),'<div class="layui-m-layerbtn">'+e+"</div>"):""}();if(n.fixed||(n.top=n.hasOwnProperty("top")?n.top:100,n.style=n.style||"",n.style+=" top:"+(t.body.scrollTop+n.top)+"px"),2===n.type&&(n.content='<i></i><i class="layui-m-layerload"></i><i></i><p>'+(n.content||"")+"</p>"),n.skin&&(n.anim="up"),"msg"===n.skin&&(n.shade=!1),s.innerHTML=(n.shade?"<div "+("string"==typeof n.shade?'style="'+n.shade+'"':"")+' class="layui-m-layershade"></div>':"")+'<div class="layui-m-layermain" '+(n.fixed?"":'style="position:static;"')+'><div class="layui-m-layersection"><div class="layui-m-layerchild '+(n.skin?"layui-m-layer-"+n.skin+" ":"")+(n.className?n.className:"")+" "+(n.anim?"layui-m-anim-"+n.anim:"")+'" '+(n.style?'style="'+n.style+'"':"")+">"+l+'<div class="layui-m-layercont">'+n.content+"</div>"+c+"</div></div></div>",!n.type||2===n.type){var d=t[i](o[0]+n.type),y=d.length;y>=1&&layer.close(d[0].getAttribute("index"))}document.body.appendChild(s);var u=e.elem=a("#"+e.id)[0];n.success&&n.success(u),e.index=r++,e.action(n,u)},c.prototype.action=function(e,t){var n=this;e.time&&(l.timer[n.index]=setTimeout(function(){layer.close(n.index)},1e3*e.time));var a=function(){var t=this.getAttribute("type");0==t?(e.no&&e.no(),layer.close(n.index)):e.yes?e.yes(n.index):layer.close(n.index)};if(e.btn)for(var s=t[i]("layui-m-layerbtn")[0].children,r=s.length,o=0;o<r;o++)l.touch(s[o],a);if(e.shade&&e.shadeClose){var c=t[i]("layui-m-layershade")[0];l.touch(c,function(){layer.close(n.index,e.end)})}e.end&&(l.end[n.index]=e.end)},e.layer={v:"2.0",index:r,open:function(e){var t=new c(e||{});return t.index},close:function(e){var n=a("#"+o[0]+e)[0];n&&(n.innerHTML="",t.body.removeChild(n),clearTimeout(l.timer[e]),delete l.timer[e],"function"==typeof l.end[e]&&l.end[e](),delete l.end[e])},closeAll:function(){for(var e=t[i](o[0]),n=0,a=e.length;n<a;n++)layer.close(0|e[0].getAttribute("index"))}},"function"==typeof define?define(function(){return layer}):function(){var e=document.scripts,n=e[e.length-1],i=n.src,a=i.substring(0,i.lastIndexOf("/")+1);n.getAttribute("merge")||document.head.appendChild(function(){var e=t.createElement("link");return e.href=a+"need/layer.css?2.0",e.type="text/css",e.rel="styleSheet",e.id="layermcss",e}())}()}(window);

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

748
iMobile/js/page.js Normal file
View File

@@ -0,0 +1,748 @@
/*
* Copyright (c) 2010-2018, b3log.org & hacpai.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Page util, load heighlight and process comment.
*
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.4.0.0, Nov 10, 2017
*/
var Page = function (tips) {
this.currentCommentId = "";
this.tips = tips;
};
$.extend(Page.prototype, {
/*
* @description 评论时点击表情,在评论内容中插入相关代码
* @param {String} name 用于区别回复评论还是对文章的评论
*/
insertEmotions: function (name) {
var _it = this;
if (name === undefined) {
name = "";
}
$("#emotions" + name + " span").click(function () {
var $comment = $("#comment" + name);
var endPosition = _it._getCursorEndPosition($comment[0]);
var key = this.title + ' ',
textValue = $comment[0].value;
textValue = textValue.substring(0, endPosition) + key + textValue.substring(endPosition, textValue.length);
$("#comment" + name).val(textValue);
if ($.browser.msie) {
endPosition -= textValue.split('\n').length - 1;
var oR = $comment[0].createTextRange();
oR.collapse(true);
oR.moveStart('character', endPosition + key.length);
oR.select();
} else {
$comment[0].setSelectionRange(endPosition + key.length, endPosition + key.length);
}
});
},
/**
* @description 获取当前光标最后位置
* @param {Dom} textarea 评论框对象
* @returns {Num} 光标位置
*/
_getCursorEndPosition: function (textarea) {
textarea.focus();
if (textarea.setSelectionRange) { // W3C
return textarea.selectionEnd;
} else if (document.selection) { // IE
var i = 0,
oS = document.selection.createRange(),
oR = document.body.createTextRange();
oR.moveToElementText(textarea);
oS.getBookmark();
for (i = 0; oR.compareEndPoints('StartToStart', oS) < 0 && oS.moveStart("character", -1) !== 0; i++) {
if (textarea.value.charAt(i) === '\n') {
i++;
}
}
return i;
}
},
/*
* @description 评论校验
* @param {String} state 用于区别回复评论还是对文章的评论
*/
validateComment: function (state) {
if (Util.isLoggedIn()) {
var commenterContent = $("#comment" + state).val().replace(/(^\s*)|(\s*$)/g, "");
if (2 > commenterContent.length || commenterContent.length > 500) {
$("#commentErrorTip" + state).html(this.tips.commentContentCannotEmptyLabel);
$("#comment" + state).focus();
} else {
return true;
}
$("#commentErrorTip" + state).show();
return false;
}
var commentName = $("#commentName" + state).val().replace(/(^\s*)|(\s*$)/g, ""),
commenterContent = $("#comment" + state).val().replace(/(^\s*)|(\s*$)/g, "");
if (2 > commentName.length || commentName.length > 20) {
$("#commentErrorTip" + state).html(this.tips.nameTooLongLabel);
$("#commentName" + state).focus();
} else if ($("#commentEmail" + state).val().replace(/\s/g, "") === "") {
$("#commentErrorTip" + state).html(this.tips.mailCannotEmptyLabel);
$("#commentEmail" + state).focus();
} else if (!/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test($("#commentEmail" + state).val())) {
$("#commentErrorTip" + state).html(this.tips.mailInvalidLabel);
$("#commentEmail" + state).focus();
} else if (2 > commenterContent.length || commenterContent.length > 500) {
$("#commentErrorTip" + state).html(this.tips.commentContentCannotEmptyLabel);
$("#comment" + state).focus();
} else if ($("#commentValidate" + state).val().replace(/\s/g, "") === "") {
$("#commentErrorTip" + state).html(this.tips.captchaCannotEmptyLabel);
$("#commentValidate" + state).focus();
} else {
return true;
}
$("#commentErrorTip" + state).show();
return false;
},
/*
* @description 把评论中的标识替换为图片
* @param {Dom} selector
*/
replaceCommentsEm: function (selector) {
var $commentContents = $(selector);
for (var i = 0; i < $commentContents.length; i++) {
var str = $commentContents[i].innerHTML;
$commentContents[i].innerHTML = Util.replaceEmString(str);
}
},
/*
* @description 初始化 SyantaxHighlighter
* @param {Array} languages 需要加载的语言
*/
_initSyntaxHighlighter: function (languages) {
// load brush js
for (var i = 0; i < languages.length; i++) {
switch (languages[i]) {
case "groovy":
languages[i] = 'groovy ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushGroovy.js';
break;
case "java":
languages[i] = 'java ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushJava.js';
break;
case "php":
languages[i] = 'php ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushPhp.js';
break;
case "scala":
languages[i] = 'scala ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushScala.js';
break;
case "sql":
languages[i] = 'sql ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushSql.js';
break;
case "applescript":
languages[i] = 'applescript ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushAppleScript.js';
break;
case "as3":
case "actionscript3":
languages[i] = 'actionscript3 as3 ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushAS3.js';
break;
case "bash":
case "shell":
languages[i] = 'bash shell ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushBash.js';
break;
case "coldfusion":
case "cf":
languages[i] = 'coldfusion cf ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushColdFusion.js';
break;
case "c#":
case "c-sharp":
case "csharp":
languages[i] = 'c# c-sharp csharp ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushCSharp.js';
break;
case "cpp":
case "c":
languages[i] = 'cpp c ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushCpp.js';
break;
case "css":
languages[i] = 'css ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushCss.js';
break;
case "delphi":
case "pascal":
languages[i] = 'delphi pascal ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushDelphi.js';
break;
case "diff":
case "patch":
case "pas":
languages[i] = 'diff patch pas ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushDiff.js';
break;
case "erl":
case "erlang":
languages[i] = 'erl erlang ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushErlang.js';
break;
case "js":
case "jscript":
case "javascript":
languages[i] = 'js jscript javascript ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushJScript.js';
break;
case "jfx":
case "javafx":
languages[i] = 'jfx javafx ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushJavaFX.js';
break;
case "perl":
case "pl":
languages[i] = 'perl pl ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushPerl.js';
break;
case "plain":
case "text":
languages[i] = 'text plain ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushPlain.js';
break;
case "ps":
case "powershell":
languages[i] = 'ps powershell ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushPowerShell.js';
break;
case "py":
case "python":
languages[i] = 'py python ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushPython.js';
break;
case "rails":
case "ror":
case "ruby":
case "rb":
languages[i] = 'ruby rails ror rb ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushRuby.js';
break;
case "sass":
case "scss":
languages[i] = 'sass scss ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushSass.js';
break;
case "vb":
case "vbnet":
languages[i] = 'vb vbnet ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushVb.js';
break;
case "xml":
case "xhtml":
case "xslt":
case "html":
languages[i] = 'xml xhtml xslt html ' +
latkeConfig.staticServePath + '/js/lib/SyntaxHighlighter/scripts/shBrushXml.js';
break;
default:
break;
}
}
// code high lighter
SyntaxHighlighter.autoloader.apply(null, languages);
SyntaxHighlighter.config.stripBrs = true;
SyntaxHighlighter.all();
},
/*
* @description 加载 SyntaxHighlighter
* @param {String} SHTheme SyntaxHighLighter 样式
*/
_loadSyntaxHighlighter: function (SHTheme) {
var cssName = SHTheme ? SHTheme : "shCoreEclipse",
that = this;
// load css
if (document.createStyleSheet) {
document.createStyleSheet(latkeConfig.staticServePath + "/js/lib/SyntaxHighlighter/styles/" + cssName + ".css");
} else {
$("head").append($("<link rel='stylesheet' href='" + latkeConfig.staticServePath + "/js/lib/SyntaxHighlighter/styles/"
+ cssName + ".css' type='text/css' charset='utf-8' />"));
}
// load js
$.ajax({
url: latkeConfig.staticServePath + "/js/lib/SyntaxHighlighter/scripts/shCore.js",
dataType: "script",
cache: true,
success: function () {
// get brush settings
var languages = [],
isScrip = false;
$(".article-body pre, .code-highlight pre").each(function () {
var name = this.className.split(";")[0];
var language = name.substr(7, name.length - 1);
if (this.className.indexOf("html-script: true") > -1 &&
(language !== "xml" && language !== "xhtml" &&
language !== "xslt" && language != "html")) {
isScrip = true;
}
languages.push(language);
});
// when html-script is true, need shBrushXml.js
if (isScrip) {
$.ajax({
url: latkeConfig.staticServePath + "/js/lib/SyntaxHighlighter/scripts/shBrushXml.js",
dataType: "script",
cache: true,
success: function () {
that._initSyntaxHighlighter(languages);
}
});
} else {
that._initSyntaxHighlighter(languages);
}
}
});
},
/*
* @description 解析语法高亮
* @param {Obj} obj 语法高亮配置参数
* @param {Obj} obj.SHTheme 语法高亮 SyntaxHighLighter 样式
*/
parseLanguage: function (obj) {
var isPrettify = false,
isSH = false;
$(".article-body pre, .code-highlight pre").each(function () {
if (this.className.indexOf("brush") > -1) {
isSH = true;
}
if (this.className.indexOf("prettyprint") > -1) {
isPrettify = true;
}
});
if (isSH) {
this._loadSyntaxHighlighter(obj ? (obj.SHTheme ? obj.SHTheme : undefined) : undefined);
return false;
}
if (isPrettify) {
// load css
if (document.createStyleSheet) {
document.createStyleSheet(latkeConfig.staticServePath + "/js/lib/google-code-prettify/prettify.css");
} else {
$("head").append($("<link rel='stylesheet' href='" + latkeConfig.staticServePath + "/js/lib/google-code-prettify/prettify.css'>"));
}
// load js
$.ajax({
url: latkeConfig.staticServePath + "/js/lib/google-code-prettify/prettify.js",
dataType: "script",
cache: true,
success: function () {
prettyPrint();
}
});
return false;
}
// otherelse use highlight
// load css
if (document.createStyleSheet) {
document.createStyleSheet(latkeConfig.staticServePath + "/js/lib/highlight.js-9.6.0/styles/default.css");
} else {
$("head").append($("<link rel='stylesheet' href='" + latkeConfig.staticServePath + "/js/lib/highlight.js-9.6.0/styles/github.css'>"));
}
$.ajax({
url: latkeConfig.staticServePath + "/js/lib/highlight.js-9.6.0/highlight.pack.js",
dataType: "script",
cache: true,
success: function () {
hljs.initHighlighting.called = false;
hljs.initHighlighting();
}
});
},
/*
* @description 文章/自定义页面加载
* @param {Obj} obj 配置设定
* @param {Obj} obj.language 代码高亮配置
*/
load: function (obj) {
var that = this;
// emotions
that.insertEmotions();
// language
that.parseLanguage(obj ? (obj.language ? obj.language : undefined) : undefined);
// submit comment
$("#commentValidate").keypress(function (event) {
if (event.keyCode === 13) {
that.submitComment();
}
});
$("#comment").keypress(function (event) {
if (event.keyCode === 13 && event.ctrlKey) {
that.submitComment();
}
});
// captcha
$("#captcha").click(function () {
$(this).attr("src", latkeConfig.servePath + "/captcha.do?code=" + Math.random());
});
// cookie
if (!Util.isLoggedIn()) {
$("#commentEmail").val(Cookie.readCookie("commentEmail"));
$("#commentURL").val(Cookie.readCookie("commentURL"));
$("#commentName").val(Cookie.readCookie("commentName"));
}
// if no JSON, add it.
try {
JSON
} catch (e) {
document.write("<script src=\"" + latkeConfig.staticServePath + "/js/lib/json2.js\"><\/script>");
}
},
/*
* @description 加载随机文章
* @param {String} headTitle 随机文章标题
*/
loadRandomArticles: function (headTitle) {
var randomArticles1Label = this.tips.randomArticles1Label;
// getRandomArticles
$.ajax({
url: latkeConfig.servePath + "/get-random-articles.do",
type: "POST",
success: function (result, textStatus) {
var randomArticles = result.randomArticles;
if (!randomArticles || 0 === randomArticles.length) {
$("#randomArticles").remove();
return;
}
var listHtml = "";
for (var i = 0; i < randomArticles.length; i++) {
var article = randomArticles[i];
var title = article.articleTitle;
var randomArticleLiHtml = "<li>" + "<a rel='nofollow' title='" + title + "' href='" + latkeConfig.servePath +
article.articlePermalink + "'>" + title + "</a></li>";
listHtml += randomArticleLiHtml;
}
var titleHTML = headTitle ? headTitle : "<h4>" + randomArticles1Label + "</h4>";
var randomArticleListHtml = titleHTML + "<ul class='marginLeft12'>" + listHtml + "</ul>";
$("#randomArticles").append(randomArticleListHtml);
}
});
},
/*
* @description 加载相关文章
* @param {String} id 文章 id
* @param {String} headTitle 相关文章标题
*/
loadRelevantArticles: function (id, headTitle) {
$.ajax({
url: latkeConfig.servePath + "/article/id/" + id + "/relevant/articles",
type: "GET",
success: function (data, textStatus) {
var articles = data.relevantArticles;
if (!articles || 0 === articles.length) {
$("#relevantArticles").remove();
return;
}
var listHtml = "";
for (var i = 0; i < articles.length; i++) {
var article = articles[i];
var title = article.articleTitle;
var articleLiHtml = "<li>"
+ "<a rel='nofollow' title='" + title + "' href='" + latkeConfig.servePath + article.articlePermalink + "'>"
+ title + "</a></li>"
listHtml += articleLiHtml
}
var relevantArticleListHtml = headTitle
+ "<ul class='marginLeft12'>"
+ listHtml + "</ul>";
$("#relevantArticles").append(relevantArticleListHtml);
},
error: function () {
$("#relevantArticles").remove();
}
});
},
/*
* @description 加载站外相关文章
* @param {String} tags 文章 tags
* @param {String} headTitle 站外相关文章标题
*/
loadExternalRelevantArticles: function (tags, headTitle) {
var tips = this.tips;
try {
$.ajax({
url: "https://rhythm.b3log.org/get-articles-by-tags.do?tags=" + tags
+ "&blogHost=" + tips.blogHost + "&paginationPageSize=" + tips.externalRelevantArticlesDisplayCount,
type: "GET",
cache: true,
dataType: "jsonp",
error: function () {
$("#externalRelevantArticles").remove();
},
success: function (data, textStatus) {
var articles = data.articles;
if (!articles || 0 === articles.length) {
$("#externalRelevantArticles").remove();
return;
}
var listHtml = "";
for (var i = 0; i < articles.length; i++) {
var article = articles[i];
var title = article.articleTitle;
var articleLiHtml = "<li>"
+ "<a rel='nofollow' title='" + title + "' target='_blank' href='" + article.articlePermalink + "'>"
+ title + "</a></li>"
listHtml += articleLiHtml
}
var titleHTML = headTitle ? headTitle : "<h4>" + tips.externalRelevantArticles1Label + "</h4>";
var randomArticleListHtml = titleHTML
+ "<ul class='marginLeft12'>"
+ listHtml + "</ul>";
$("#externalRelevantArticles").append(randomArticleListHtml);
}
});
} catch (e) {
// 忽略相关文章加载异常load script error
}
},
/*
* @description 提交评论
* @param {String} commentId 回复评论时的评论 id
* @param {String} state 区分回复文章还是回复评论的标识
*/
submitComment: function (commentId, state, reply) {
this.currentCommentId = commentId; // iadd
if (!state) {
state = '';
}
var that = this,
tips = this.tips,
type = "article";
if (tips.externalRelevantArticlesDisplayCount === undefined) {
type = "page";
}
if (this.validateComment(state)) {
$("#submitCommentButton" + state).attr("disabled", "disabled");
$("#commentErrorTip" + state).show().html(this.tips.loadingLabel);
var requestJSONObject = {
"oId": tips.oId,
"commentContent": $("#comment" + state).val().replace(/(^\s*)|(\s*$)/g, "")
};
if (!Util.isLoggedIn()) {
requestJSONObject = {
"oId": tips.oId,
"commentContent": $("#comment" + state).val().replace(/(^\s*)|(\s*$)/g, ""),
"commentEmail": $("#commentEmail" + state).val(),
"commentURL": Util.proessURL($("#commentURL" + state).val().replace(/(^\s*)|(\s*$)/g, "")),
"commentName": $("#commentName" + state).val().replace(/(^\s*)|(\s*$)/g, ""),
"captcha": $("#commentValidate" + state).val()
};
Cookie.createCookie("commentName", requestJSONObject.commentName, 365);
Cookie.createCookie("commentEmail", requestJSONObject.commentEmail, 365);
Cookie.createCookie("commentURL", $("#commentURL" + state).val().replace(/(^\s*)|(\s*$)/g, ""), 365);
}
if (state === "Reply" || reply) { // iadd
requestJSONObject.commentOriginalCommentId = commentId;
}
$.ajax({
type: "POST",
url: latkeConfig.servePath + "/add-" + type + "-comment.do",
cache: false,
contentType: "application/json",
data: JSON.stringify(requestJSONObject),
success: function (result) {
$("#submitCommentButton" + state).removeAttr("disabled");
if (!result.sc) {
$("#commentErrorTip" + state).html(result.msg);
$("#commentValidate" + state).val('');
$("#captcha" + state).click();
if (!Util.isLoggedIn()) {
$("#captcha" + state).attr("src", latkeConfig.servePath + "/captcha.do?code=" + Math.random());
}
return;
}
$("#comment" + state).val(result.commentContent); // Server processed XSS
$("#commentName" + state).val(result.commentName); // Server processed XSS
result.replyNameHTML = "";
if (!Util.isLoggedIn()) {
$("#captcha" + state).attr("src", latkeConfig.servePath + "/captcha.do?code=" + Math.random());
if ($("#commentURL" + state).val().replace(/\s/g, "") === "") {
result.replyNameHTML = '<a>' + $("#commentName" + state).val() + '</a>';
} else {
result.replyNameHTML = '<a href="' + Util.proessURL($("#commentURL" + state).val()) +
'" target="_blank">' + $("#commentName" + state).val() + '</a>';
}
result.userName = result.commentName;
} else {
result.replyNameHTML = '<a href="' + window.location.host +
'" target="_blank">' + Util.getUserName() + '</a>';
result.userName = Util.getUserName();
}
if (typeof(addComment) === "undefined") { // https://github.com/b3log/solo/issues/12246
that.addCommentAjax(Util.replaceEmString(result.cmtTpl), state);
} else { // 1.9.0 向后兼容 iadd
that.addCommentAjax(addComment(result, state, reply), state);
}
}
});
}
},
/*
* @description 添加回复评论表单
* @param {String} id 被回复的评论 id
* @param {String} commentFormHTML 评论表单HTML
* @param {String} endHTML 判断该表单使用 table 还是 div 标签,然后进行构造
*/
addReplyForm: function (id, commentFormHTML, endHTML) {
var that = this;
if (id === this.currentCommentId) {
if ($("#commentNameReply").val() === "") {
$("#commentNameReply").focus();
} else if ($("#commentEmailReply").val() === "") {
$("#commentEmailReply").focus();
} else {
$("#commentReply").focus();
}
return;
}
$("#replyForm").remove();
endHTML = endHTML ? endHTML : "";
if (endHTML === "</div>") {
$("#" + id).append(commentFormHTML + $("#commentForm").html() + endHTML);
} else {
$("#" + id).append(commentFormHTML + $("#commentForm").html() + "</table>" + endHTML);
}
// change id, bind event and set value
$("#replyForm input, #replyForm textarea").each(function () {
this.id = this.id + "Reply";
});
$("#commentNameReply").val(Cookie.readCookie("commentName"));
$("#commentEmailReply").val(Cookie.readCookie("commentEmail"));
var $label = $("#replyForm #commentURLLabel");
if ($label.length === 1) {
$label.attr("id", "commentURLLabelReply");
}
$("#commentURLReply").val(Cookie.readCookie("commentURL"));
$("#replyForm #emotions").attr("id", "emotionsReply");
this.insertEmotions("Reply");
$("#commentReply").unbind().keypress(function (event) {
if (event.keyCode === 13 && event.ctrlKey) {
that.submitComment(id, 'Reply');
event.preventDefault();
}
});
$("#commentValidateReply").unbind().keypress(function (event) {
if (event.keyCode === 13) {
that.submitComment(id, 'Reply');
event.preventDefault();
}
});
$("#replyForm #captcha").attr("id", "captchaReply").attr("src", latkeConfig.servePath + "/captcha.do?" + new Date().getTime()).click(function () {
$(this).attr("src", latkeConfig.servePath + "/captcha.do?code=" + Math.random());
});
$("#replyForm #commentErrorTip").attr("id", "commentErrorTipReply").html("").hide();
$("#replyForm #submitCommentButton").attr("id", "submitCommentButtonReply");
$("#replyForm #submitCommentButtonReply").unbind("click").removeAttr("onclick").click(function () {
that.submitComment(id, 'Reply');
});
if ($("#commentNameReply").val() === "") {
$("#commentNameReply").focus();
} else if ($("#commentEmailReply").val() === "") {
$("#commentEmailReply").focus();
} else {
$("#commentReply").focus();
}
this.currentCommentId = id;
},
/*
* @description 隐藏回复评论的浮出层
* @parma {String} id 被回复的评论 id
*/
hideComment: function (id) {
$("#commentRef" + id).hide();
},
/*
* @description 显示回复评论的浮出层
* @parma {Dom} it 触发事件的 dom
* @param {String} id 被回复的评论 id
* @param {Int} top 位置相对浮出层的高度
* @param {String} [parentTag] it 如果嵌入在 position 为 relative 的元素 A 中时,需取到 A 元素
*/
showComment: function (it, id, top, parentTag) {
var positionTop = parseInt($(it).position().top);
if (parentTag) {
positionTop = parseInt($(it).parents(parentTag).position().top);
}
if ($("#commentRef" + id).length > 0) {
// 此处重复设置 top 是由于评论为异步,原有回复评论的显示位置应往下移动
$("#commentRef" + id).show().css("top", (positionTop + top) + "px");
} else {
var $refComment = $("#" + id).clone();
$refComment.addClass("comment-body-ref").attr("id", "commentRef" + id);
$refComment.find("#replyForm").remove();
$("#comments").append($refComment);
$("#commentRef" + id).css("top", (positionTop + top) + "px");
}
},
/*
* @description 回复不刷新,将回复内容异步添加到评论列表中
* @parma {String} commentHTML 回复内容 HTML
* @param {String} state 用于区分评论文章还是回复评论
*/
addCommentAjax: function (commentHTML, state) {
if ($("#comments").children().length > 0) {
$($("#comments").children()[0]).before(commentHTML);
} else {
$("#comments").html(commentHTML);
}
if (state === "") {
$("#commentErrorTip").html("").hide();
$("#comment").val("");
$("#commentValidate").val("");
$("#captcha").attr("src", latkeConfig.servePath + "/captcha.do?code=" + Math.random());
} else {
$("#replyForm").remove();
}
window.location.hash = "#comments";
}
});

30
iMobile/js/welcome.js Normal file
View File

@@ -0,0 +1,30 @@
(function() {
var wemsg = function(smsg) {
layer.msg(smsg, { time: 2000 });
},
xcookie = function(name) {
return Cookie.readCookie(name);
},
ccookie = function(name, value, days) {
Cookie.createCookie(name, value, days);
};
if ($("body").width() > 750 && xcookie("showTips") == "" && xcookie("isShowTips") == "" && top.location.pathname == "/" && navigator.cookieEnabled) {
layer.confirm(`客官您好,<b>${ $("#logofont").text() }</b>欢迎您的访问,已默认为您开启图标悬浮提示,是否需要显示悬浮提示?`, {
btn: ['留着吧', '消失一周', '再想想'],
closeBtn: false,
time: 9999,
title: false,
success: function(layero) {
layero.find('.layui-layer-btn .layui-layer-btn0').css({ "border-color": "#333", "background-color": "#666" });
}
}, function() {
ccookie("isShowTips", "1", 90);
wemsg('<b>好嘞~</b>');
}, function() {
ccookie("showTips", "0", 7);
wemsg('<b><i>7</i> 天内访问将不再提示!<b>');
}, function() {
layer.closeAll();
});
}
})();

82
iMobile/js/yilia7.js Normal file
View File

@@ -0,0 +1,82 @@
/* Copyright (c) 2010-2016, b3log.org & hacpai.com Licensed under the Apache License, Version 2.0 (the "License"); */
/**
* @fileoverview util and every page should be used.
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @version 1.2.0.0, Nov 3, 2015
*/
/**
* @description yilia 皮肤脚本
* @static
*/
var Yilia = {
/**
* @description 页面初始化
*/
init: function () {
Util.killIE();
this._initToc();
this.resetTags();
$(window).scroll(function () {
if ($("article").length > 0 && $("article.post").length === 0) {
$("article:not(.show)").each(function () {
if ($(this).offset().top <= $(window).scrollTop() + $(window).height() - $(this).height() / 7) {
$(this).addClass("show");
}
});
}
if ($(window).scrollTop() > $(window).height()) {
$(".icon-goup").show();
} else {
$(".icon-goup").hide();
}
if (($(document).height() - $("body").height() - 300) < $(window).scrollTop()) {
$("#backBtm").hide();
} else {
$("#backBtm").show();
}
if ($("article.post").length === 1) {
$("article.post").addClass('show');
}
});
$(window).scroll();
},
_initToc: function () {
if ($('.b3-solo-list li').length === 0) {
return false;
}
$('.side footer').after('<div class="toc"><a href="javascript:$(\'.side .toc\').hide()" class="close">X</a></div>');
$('.side .toc a').after($('.b3-solo-list'));
$('.side .toc-btn').show();
},
resetTags: function () {
$("a.tag").each(function (i) {
$(this).addClass("color" + Math.ceil(Math.random() * 4));
});
},
share: function () {
$(".share span").click(function () {
var key = $(this).data("type");
var title = encodeURIComponent($("title").text()),
url = $(".post-title a").attr('href') ? $(".post-title a").attr('href') : location,
pic = $(".post-content img:eq(0)").attr("src");
var urls = {};
urls.qq = "http://connect.qq.com/widget/shareqq/index.html?title=" + title + "&url=" + url;
urls.tencent = "http://share.v.t.qq.com/index.php?c=share&a=index&title=" + title +
"&url=" + url + "&pic=" + pic;
urls.weibo = "http://v.t.sina.com.cn/share/share.php?title=" +
title + "&url=" + url + "&pic=" + pic;
urls.google = "https://plus.google.com/share?url=" + url;
urls.twitter = "https://twitter.com/intent/tweet?status=" + title + " " + url;
window.open(urls[key], "_blank", "top=100,left=200,width=720,height=618");
});
}
};
Yilia.init();

2
iMobile/js/yilia7.min.js vendored Normal file
View File

@@ -0,0 +1,2 @@
/* Copyright (c) 2010-2016, b3log.org & hacpai.com Licensed under the Apache License, Version 2.0 (the "License");
*/var Yilia={init:function(){Util.killIE(),this._initToc(),this.resetTags(),$(window).scroll(function(){$("article").length>0&&0===$("article.post").length&&$("article:not(.show)").each(function(){$(this).offset().top<=$(window).scrollTop()+$(window).height()-$(this).height()/13&&$(this).addClass("show")}),$(window).scrollTop()>$(window).height()?$(".icon-goup").show():$(".icon-goup").hide(), (($(document).height() - $("body").height() - 300) < $(window).scrollTop()) ? $("#backBtm").hide() : $("#backBtm").show(), 1===$("article.post").length&&$("article.post").addClass("show")}),$(window).scroll()},_initToc:function(){return 0!==$(".b3-solo-list li").length&&($(".side footer").after('<div class="toc"><a href="javascript:hideToc();" class="close iconfont icon-close2"></a></div>'),$(".side .toc a").after($(".b3-solo-list")),void $(".side .toc-btn").show())},resetTags:function(){$("a.tag").each(function(t){$(this).addClass("color"+Math.ceil(3*Math.random()))})},share:function(){$(".share span").click(function(){var t=$(this).data("type"),i=encodeURIComponent($("title").text()+" "+$("meta[name=description]").attr("content")),o=$(".post-title a").attr("href")?$(".post-title a").attr("href"):location,img=($("article.post img:eq(1)").length==0?$("article.post img:eq(0)"):$("article.post img:eq(1)")),e=$(img).attr("src"),s={};s.qq = "http://connect.qq.com/widget/shareqq/index.html?title="+i+"&url="+o;s.tencent="http://share.v.t.qq.com/index.php?c=share&a=index&title="+i+"&url="+o+"&pic="+e,s.weibo="http://v.t.sina.com.cn/share/share.php?title="+i+"&url="+o+"&pic="+e,s.google="https://plus.google.com/share?url="+o,s.twitter="https://twitter.com/intent/tweet?status="+i+" "+o,window.open(s[t],"_blank","top=100,left=200,width=720,height=618")})}};Yilia.init();