Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
14
Issues
14
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
La Quadrature du Net
rpteam
rp
Commits
cb0c3f94
Verified
Commit
cb0c3f94
authored
Dec 06, 2017
by
Thibaut Broggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move inline javascript to compiled webpack resources
parent
c86c970f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
79 deletions
+81
-79
apps/rp/templates/rp/article_list.html
apps/rp/templates/rp/article_list.html
+0
-79
static/src/admin.js
static/src/admin.js
+3
-0
static/src/rp.js
static/src/rp.js
+78
-0
No files found.
apps/rp/templates/rp/article_list.html
View file @
cb0c3f94
...
@@ -150,83 +150,4 @@
...
@@ -150,83 +150,4 @@
</div>
</div>
</div>
</div>
</div>
</div>
<script>
function
getCookie
(
name
)
{
var
cookieValue
=
null
;
if
(
document
.
cookie
&&
document
.
cookie
!==
''
)
{
var
cookies
=
document
.
cookie
.
split
(
'
;
'
);
for
(
var
i
=
0
;
i
<
cookies
.
length
;
i
++
)
{
var
cookie
=
jQuery
.
trim
(
cookies
[
i
]);
// Does this cookie string begin with the name we want?
if
(
cookie
.
substring
(
0
,
name
.
length
+
1
)
===
(
name
+
'
=
'
))
{
cookieValue
=
decodeURIComponent
(
cookie
.
substring
(
name
.
length
+
1
));
break
;
}
}
}
return
cookieValue
;
}
var
csrftoken
=
getCookie
(
'
csrftoken
'
);
function
csrfSafeMethod
(
method
)
{
// these HTTP methods do not require CSRF protection
return
(
/^
(
GET|HEAD|OPTIONS|TRACE
)
$/
.
test
(
method
));
}
$
.
ajaxSetup
({
beforeSend
:
function
(
xhr
,
settings
)
{
if
(
!
csrfSafeMethod
(
settings
.
type
)
&&
!
this
.
crossDomain
)
{
xhr
.
setRequestHeader
(
"
X-CSRFToken
"
,
csrftoken
);
}
}
});
function
call_upvote
(
id
)
{
$
.
post
(
"
/api/articles/
"
+
id
+
"
/upvote/
"
,
function
response
(
data
)
{
$
(
"
#count_up_
"
+
id
).
text
(
data
.
und_score_up
);
});
}
function
call_downvote
(
id
)
{
$
.
post
(
"
/api/articles/
"
+
id
+
"
/downvote/
"
,
function
response
(
data
)
{
$
(
"
#count_down_
"
+
id
).
text
(
data
.
und_score_down
);
});
}
function
clean_row
(
id
)
{
$
(
"
#row_
"
+
id
).
hide
();
$
(
"
#row_empty_
"
+
id
).
hide
();
$
(
"
#row_tags_
"
+
id
).
hide
();
}
function
call_recover
(
id
)
{
$
.
post
(
"
/api/articles/
"
+
id
+
"
/recover/
"
,
function
response
(
data
)
{
clean_row
(
id
);
});
}
function
call_reject
(
id
)
{
$
.
post
(
"
/api/articles/
"
+
id
+
"
/reject/
"
,
function
response
(
data
)
{
clean_row
(
id
);
});
}
function
call_publish
(
id
)
{
$
.
post
(
"
/api/articles/
"
+
id
+
"
/publish/
"
,
function
response
(
data
)
{
clean_row
(
id
);
});
}
function
call_priority
(
id
,
flag
)
{
if
(
flag
)
{
var
url
=
"
/api/articles/
"
+
id
+
"
/set_priority/
"
;
}
else
{
var
url
=
"
/api/articles/
"
+
id
+
"
/unset_priority/
"
;
}
$
.
post
(
url
,
function
response
(
data
)
{
$
(
"
#priority_
"
+
id
).
toggleClass
(
"
fa-star
"
).
toggleClass
(
"
fa-star-o
"
);
});
}
</script>
{% endblock %}
{% endblock %}
static/src/admin.js
View file @
cb0c3f94
...
@@ -16,3 +16,6 @@ require('simplemde/dist/simplemde.min.css')
...
@@ -16,3 +16,6 @@ require('simplemde/dist/simplemde.min.css')
// Local styles
// Local styles
import
styles
from
'
./admin.css
'
;
import
styles
from
'
./admin.css
'
;
// RP js
require
(
'
./rp.js
'
)
static/src/rp.js
0 → 100644
View file @
cb0c3f94
$
(
function
()
{
function
getCookie
(
name
)
{
var
cookieValue
=
null
;
if
(
document
.
cookie
&&
document
.
cookie
!==
''
)
{
var
cookies
=
document
.
cookie
.
split
(
'
;
'
);
for
(
var
i
=
0
;
i
<
cookies
.
length
;
i
++
)
{
var
cookie
=
jQuery
.
trim
(
cookies
[
i
]);
// Does this cookie string begin with the name we want?
if
(
cookie
.
substring
(
0
,
name
.
length
+
1
)
===
(
name
+
'
=
'
))
{
cookieValue
=
decodeURIComponent
(
cookie
.
substring
(
name
.
length
+
1
));
break
;
}
}
}
return
cookieValue
;
}
var
csrftoken
=
getCookie
(
'
csrftoken
'
);
function
csrfSafeMethod
(
method
)
{
// these HTTP methods do not require CSRF protection
return
(
/^
(
GET|HEAD|OPTIONS|TRACE
)
$/
.
test
(
method
));
}
$
.
ajaxSetup
({
beforeSend
:
function
(
xhr
,
settings
)
{
if
(
!
csrfSafeMethod
(
settings
.
type
)
&&
!
this
.
crossDomain
)
{
xhr
.
setRequestHeader
(
"
X-CSRFToken
"
,
csrftoken
);
}
}
});
window
.
call_upvote
=
function
(
id
)
{
$
.
post
(
"
/api/articles/
"
+
id
+
"
/upvote/
"
,
function
response
(
data
)
{
$
(
"
#count_up_
"
+
id
).
text
(
data
.
und_score_up
);
});
}
window
.
call_downvote
=
function
(
id
)
{
$
.
post
(
"
/api/articles/
"
+
id
+
"
/downvote/
"
,
function
response
(
data
)
{
$
(
"
#count_down_
"
+
id
).
text
(
data
.
und_score_down
);
});
}
window
.
clean_row
=
function
(
id
)
{
$
(
"
#row_
"
+
id
).
hide
();
$
(
"
#row_empty_
"
+
id
).
hide
();
$
(
"
#row_tags_
"
+
id
).
hide
();
}
window
.
call_recover
=
function
(
id
)
{
$
.
post
(
"
/api/articles/
"
+
id
+
"
/recover/
"
,
function
response
(
data
)
{
clean_row
(
id
);
});
}
window
.
call_reject
=
function
(
id
)
{
$
.
post
(
"
/api/articles/
"
+
id
+
"
/reject/
"
,
function
response
(
data
)
{
clean_row
(
id
);
});
}
window
.
call_publish
=
function
(
id
)
{
$
.
post
(
"
/api/articles/
"
+
id
+
"
/publish/
"
,
function
response
(
data
)
{
clean_row
(
id
);
});
}
window
.
call_priority
=
function
(
id
,
flag
)
{
if
(
flag
)
{
var
url
=
"
/api/articles/
"
+
id
+
"
/set_priority/
"
;
}
else
{
var
url
=
"
/api/articles/
"
+
id
+
"
/unset_priority/
"
;
}
$
.
post
(
url
,
function
response
(
data
)
{
$
(
"
#priority_
"
+
id
).
toggleClass
(
"
fa-star
"
).
toggleClass
(
"
fa-star-o
"
);
});
}
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment