Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
piks3l
am2wiki
Commits
a967283b
Commit
a967283b
authored
Apr 18, 2017
by
piks3l
Browse files
Merge branch 'undefined' into 'master'
Replace am2wiki.html See merge request
!1
parents
e9fa7ac8
ff7c4331
Changes
1
Hide whitespace changes
Inline
Side-by-side
am2wiki.html
View file @
a967283b
...
...
@@ -7,7 +7,7 @@
<!--
Am2Wiki by Oncela
Last modification: 1
2
-04-2017
Last modification: 1
3
-04-2017
This program intends to convert amendments drafted by Members of European
Parliament into reusable formats.
...
...
@@ -28,6 +28,9 @@
var
rates
=
[
"
unrated
"
,
"
--
"
,
"
-
"
,
"
/
"
,
"
+
"
,
"
++
"
];
var
colors
=
[
"
white
"
,
"
#A60000
"
,
"
#F55E33
"
,
"
#BABABA
"
,
"
#AEF279
"
,
"
#44C92C
"
];
// Political groups of the EP
var
groups
=
[
""
,
"
EPP
"
,
"
S&D
"
,
"
ALDE
"
,
"
Verts/ALE
"
,
"
ECR
"
,
"
GUE/NGL
"
,
"
NI
"
,
"
EFD
"
];
// Template for conversion (how the amendments are displayed once processed: you can change it at will)
/*
%number = amendmend number
...
...
@@ -46,19 +49,27 @@
+
"
|-
\n
"
+
"
| colspan='2' style='background-color: %color; text-align:center;' |
\n
"
+
"
'''%number'''<br/>
\n
"
+
"
%member<br/>
\n
"
+
"
%group
"
// If a group has been set, the templateGroup (defined bellow) is inserted here
+
"
%article
\n
"
+
"
|-
\n
"
+
"
|width='50%' style='vertical-align:top;'|
\n
"
+
"
%left
\n
"
+
"
|width='50%' style='vertical-align:top;'|
\n
"
+
"
%right
\n
"
+
"
%comment
"
// If the amendment is commented, the templateComment (defined bellow) is inserted here
+
"
|}
\n\n\n
"
;
var
templateComment
=
+
"
%justif
"
// If the amendment is justified, the templateJustif (defined bellow) is inserted here
+
"
|}
\n\n
"
+
"
%comment
"
// If the amendment is commented, the templateComment (defined bellow) is inserted here
+
"
\n
"
;
var
templateGroup
=
"
'''%group'''<br/>
\n
"
;
var
templateJustif
=
"
|-
\n
"
+
"
| colspan='2' |
\n
"
+
"
'''Comment:''' %comment
\n
"
;
+
"
''Justification: %justif''
\n
"
;
var
templateComment
=
"
\n
%comment
\n\n
"
;
</script>
...
...
@@ -170,21 +181,20 @@
// Remove the begining of the file
cleanFile
=
cleanFile
.
replace
(
/^.*
?(
<NumAm>
)
/
,
"
$1
"
);
// Use the internal tags to retrieve the 4 relevant information for each amendment (number, article, left, right)
var
parser
=
[];
parser
[
0
]
=
cleanFile
.
match
(
/<NumAm>.*
?
<
\/
NumAm> *<RepeatBlock-By>/g
);
parser
[
1
]
=
cleanFile
.
match
(
/<
\/
DocAmend> *<Article>.*
?
<
\/
Article> *
\[\[
/g
);
parser
[
2
]
=
cleanFile
.
match
(
/
\[\[
.*
?\|\|
/g
);
parser
[
3
]
=
cleanFile
.
match
(
/
\|\|
.*
?\]\]
/g
);
// Put the information into the amendments array
for
(
var
i
=
0
;
i
<
parser
[
0
].
length
;
i
++
)
// Use the internal tags to isolate each amendment in an array
var
parser
=
cleanFile
.
match
(
/Am>.*
?
<
\/
NumAm>.*
?
<Members>.*
?\[\[
.*
?\]\]
.*
?((
<Num
)
|$
)
/g
);
// Use the internal tags to retrive each info and put them into the amendments array
for
(
var
i
=
0
;
i
<
parser
.
length
;
i
++
)
{
var
am
=
{};
am
.
number
=
parser
[
0
][
i
].
replace
(
/<NumAm> *
(
.*
?)
*<
\/
NumAm> *<RepeatBlock-By>/
,
"
Amendment $1
"
);
am
.
article
=
parser
[
1
][
i
].
replace
(
/<
\/
DocAmend> *<Article> *
(
.*
?)
*<
\/
Article> *
\[\[
/
,
"
$1
"
);
am
.
left
=
parser
[
2
][
i
].
replace
(
/
\[\[
*
(
.*
?)
*
\|\|
/
,
"
$1
"
);
am
.
right
=
parser
[
3
][
i
].
replace
(
/
\|\|
*
(
.*
?)
*
\]\]
/
,
"
$1
"
);
am
.
number
=
parser
[
i
].
replace
(
/Am> *
(
.*
?)
*<
\/
NumAm>.*/
,
"
Amendment $1
"
);
am
.
member
=
parser
[
i
].
replace
(
/.*<RepeatBlock-By> *<Members> *
(
.*
?)
*<
\/
Members>.*/
,
"
$1
"
);
am
.
article
=
parser
[
i
].
replace
(
/.*<Article> *
(
.*
?)
*<
\/
Article>.*/
,
"
$1
"
);
am
.
left
=
parser
[
i
].
replace
(
/.*
\[\[
*
(
.*
?)
*
\|\|
.*/
,
"
$1
"
);
am
.
right
=
parser
[
i
].
replace
(
/.*
\|\|
*
(
.*
?)
*
\]\]
.*/
,
"
$1
"
);
am
.
justif
=
(
parser
[
i
].
search
(
/TitreJust/
)
>
0
)
?
parser
[
i
].
replace
(
/.*<
\/
TitreJust> *
(
.*
?)
*<.*/
,
"
$1
"
)
:
""
;
am
.
group
=
0
;
am
.
comment
=
""
;
am
.
value
=
0
;
...
...
@@ -208,6 +218,16 @@
var
span
=
document
.
createElement
(
'
span
'
);
span
.
className
=
"
form_am
"
;
span
.
innerHTML
=
amendments
[
i
].
number
;
// Display or hide the content on click
span
.
onclick
=
function
()
{
var
cnt
=
this
.
parentNode
.
nextSibling
;
if
(
cnt
.
style
.
display
==
"
none
"
)
cnt
.
style
.
display
=
"
block
"
;
else
cnt
.
style
.
display
=
"
none
"
;
}
line
.
appendChild
(
span
);
// Create the checkboxes
...
...
@@ -241,6 +261,33 @@
line
.
appendChild
(
span
);
}
// Create the input for selecting the Group
var
group
=
document
.
createElement
(
'
select
'
);
var
opt
=
document
.
createElement
(
'
option
'
);
opt
.
value
=
0
;
opt
.
innerText
=
"
Group
"
;
opt
.
className
=
"
firstOpt
"
;
group
.
appendChild
(
opt
);
for
(
var
j
=
1
;
j
<
groups
.
length
;
j
++
)
{
var
opt
=
document
.
createElement
(
'
option
'
);
opt
.
value
=
j
;
opt
.
innerText
=
groups
[
j
];
group
.
appendChild
(
opt
);
}
group
.
onchange
=
function
()
{
this
.
parentNode
.
am
.
group
=
this
.
value
;
}
group
.
onclick
=
function
()
{
this
.
style
.
color
=
"
black
"
;
}
line
.
appendChild
(
group
);
// Create the input for adding a comment
var
comment
=
document
.
createElement
(
'
input
'
);
comment
.
type
=
"
text
"
;
...
...
@@ -252,11 +299,35 @@
line
.
appendChild
(
comment
);
form
.
appendChild
(
line
);
// Add the content of the amendment bellow
var
content
=
document
.
createElement
(
"
div
"
);
content
.
className
=
"
form_content
"
;
content
.
style
.
display
=
"
none
"
;
content
.
innerHTML
=
amendments
[
i
].
member
+
"
<br/><br/><b>
"
+
amendments
[
i
].
article
+
"
</b><br/><br/>
"
+
"
<table><tr><td>
"
+
amendments
[
i
].
left
+
"
</td><td>
"
+
amendments
[
i
].
right
+
"
</td></tr></table>
"
;
if
(
amendments
[
i
].
justif
!=
""
)
content
.
innerHTML
+=
"
<br/><i>Justification:
"
+
amendments
[
i
].
justif
+
"
</i>
"
;
content
.
innerHTML
=
content
.
innerHTML
.
replace
(
/'''''
(
.*
?)
'''''/g
,
"
<b>$1</b>
"
);
form
.
appendChild
(
content
);
}
// Change the display
document
.
getElementById
(
'
wikify
'
).
style
.
display
=
"
block
"
;
document
.
getElementById
(
'
intro
'
).
innerHTML
=
"
Rate each amendment (non-rated amendments won't be converted):<br/><br/>
"
;
document
.
getElementById
(
'
intro
'
).
innerHTML
=
"
Rate each amendment (non-rated amendments won't be converted).<br/>
"
+
"
Cick on the number of an amendment to show/hide its content.<br/><br/>
"
;
}
// Convert and display the rated amendments
...
...
@@ -271,13 +342,16 @@
var
am
=
amendments
[
i
];
if
(
am
.
value
>
0
)
{
var
amResult
=
template
.
replace
(
/
\%
number/g
,
am
.
number
);
amResult
=
amResult
.
replace
(
/
\%
rate/g
,
rates
[
am
.
value
]);
amResult
=
amResult
.
replace
(
"
%article
"
,
am
.
article
);
amResult
=
amResult
.
replace
(
"
%color
"
,
colors
[
am
.
value
]);
amResult
=
amResult
.
replace
(
"
%left
"
,
am
.
left
);
amResult
=
amResult
.
replace
(
"
%right
"
,
am
.
right
);
amResult
=
amResult
.
replace
(
"
%comment
"
,
am
.
comment
!=
""
?
templateComment
.
replace
(
"
%comment
"
,
am
.
comment
)
:
""
);
var
amResult
=
template
.
replace
(
/
\%
number/g
,
am
.
number
);
amResult
=
amResult
.
replace
(
/
\%
rate/g
,
rates
[
am
.
value
]);
amResult
=
amResult
.
replace
(
/
\%
member/g
,
am
.
member
);
amResult
=
amResult
.
replace
(
/
\%
group/g
,
am
.
group
!=
0
?
templateGroup
.
replace
(
/
\%
group/g
,
groups
[
am
.
group
])
:
""
);
amResult
=
amResult
.
replace
(
/
\%
article/g
,
am
.
article
);
amResult
=
amResult
.
replace
(
/
\%
color/g
,
colors
[
am
.
value
]);
amResult
=
amResult
.
replace
(
/
\%
left/g
,
am
.
left
);
amResult
=
amResult
.
replace
(
/
\%
right/g
,
am
.
right
);
amResult
=
amResult
.
replace
(
/
\%
justif/g
,
am
.
justif
!=
""
?
templateJustif
.
replace
(
/
\%
justif/g
,
am
.
justif
)
:
""
);
amResult
=
amResult
.
replace
(
/
\%
comment/g
,
am
.
comment
!=
""
?
templateComment
.
replace
(
/
\%
comment/g
,
am
.
comment
)
:
""
);
result
+=
amResult
;
}
...
...
@@ -315,6 +389,12 @@
height
:
2.5em
;
}
.form_line
span
:hover
{
cursor
:
pointer
;
text-decoration
:
underline
;
}
.form_am
,
.form_radio
{
padding
:
.5em
;
...
...
@@ -326,6 +406,29 @@
width
:
40em
;
}
select
{
margin-left
:
1em
;
color
:
gray
;
}
.firstOpt
{
color
:
gray
;
}
.form_content
{
margin
:
1em
4em
4em
;
}
.form_content
td
{
width
:
50%
;
padding-right
:
1em
;
vertical-align
:
top
;
}
#wikify
{
display
:
none
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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