-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstory.php
More file actions
125 lines (114 loc) · 5.34 KB
/
story.php
File metadata and controls
125 lines (114 loc) · 5.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
/*
* Property of Writale
* All rights reserved
* Writale © 2013
*/
require_once realpath(dirname(__FILE__) . "/class/init.php");
require realpath(dirname(__FILE__) . "/control/session/saved.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
</head>
<body>
</body>
</html>
function init (node,count) {
if(count == Number(iNumFragment.value)+1 && Number(iRequired.value) === 0) {
sType = 'sty=1';
}
else {
sType = 'frg=1';
}
oTarget = _gAny('objectid-'+count).value;
iUser = _gAny('userid-'+count).value;
likeLink = util.firstChild(node);
(function (sType,oTar,iUsr,lLink) {
if(lLink.innerHTML.trim() === 'Like')
addEvent.call(lLink,'click',function (e) {
perform(e,sType,oTar,iUsr);
},false);
else
addEvent.call(lLink,'click',function (e){
retreat(e,sType,oTar,iUsr);
},false);
addEvent.call(util.lastChild(node),'click',function (e) {
showLikes(e,sType,oTar);
},false);
})(sType,oTarget,iUser,likeLink);
}
function showLikes (e,sType,oTarget) {
util.stopDefault(e);
if((e.target.innerHTML.trim()).length === 0)
return;
var sExtraArg = '&'+sType+'&otg='+oTarget;
wxhr.dialog.load(5,true,function () {
wxhr.dialog.addShutter(_gAny("d-ok-show-people"));
},sExtraArg);
wxhr.dialog.addShortcutShutter();
}
function perform (e,sType,oTarget,iUser) {
util.stopDefault(e);
var sArg = 'like?'+sType+'&otg='+oTarget+'&lkee='+iUser,
nLike = e.target;
e.target.innerHTML = 'Unlike';
incrementLikes(util.nextSibling(e.target));
wxhr.writlike(sArg,nError, function (res) {
afterLike(res,nLike);
});
removeEvent.call(e.target,'click',perform,false);
}
function retreat (e,sType,oTarget,iUser) {
util.stopDefault(e);
var sArg = 'like?'+sType+'&otg='+oTarget+'&lkee='+iUser+'&un=1',
nUnlike = e.target;
e.target.innerHTML = 'Like';
decrementLikes(util.nextSibling(e.target));
wxhr.writlike(sArg,nError,function (res) {
afterUnlike(res,nUnlike);
});
removeEvent.call(e.target,'click',retreat,false);
}
function afterLike (res,el) {
if(res) {
addEvent.call(el,'click',retreat,false);
}
else {
el.innerHTML ='Like';
decrementLikes(util.nextSibling(el));
addEvent.call(el,'click',perform,false);
}
}
function afterUnlike (res,el) {
if(res) {
addEvent.call(el,'click',perform,false);
}
else {
el.innerHTML = 'Unlike';
incrementLikes(util.nextSibling(el));
addEvent.call(el,'click', retreat, false);
}
}
function incrementLikes (el) {
var iCount;
if((el.innerHTML.trim()).length === 0)
el.innerHTML = '(1)';
else {
iCount = util.getNumber(el,1,')');
if(iCount < 999)
el.innerHTML = '('+(++iCount)+')';
}
}
function decrementLikes (el) {
var iCount;
if((el.innerHTML.trim()).length === 0)
return;
else {
if((iCount = util.getNumber(el,1,')')) === 1)
el.innerHTML = '';
else if(iCount && iCount < 1000)
el.innerHTML = '('+(--iCount)+')';
}
}