Grammalecte  Check-in [9db066f572]

Overview
Comment:[fx] Manualy apply change from webext (je me metrise pas les merge de fossil)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fx | webext_sharedworker
Files: files | file ages | folders
SHA3-256: 9db066f572f5332e7699f6d14026c2f2b229a931eece46b2ed2c574792387dc0
User & Date: IllusionPerdu on 2017-08-10 15:08:51
Other Links: branch diff | manifest | tags
Context
2017-08-10
16:48
[fx] Add image loader for content_script check-in: ef8e7d82d5 user: IllusionPerdu tags: fx, webext_sharedworker
15:08
[fx] Manualy apply change from webext (je me metrise pas les merge de fossil) check-in: 9db066f572 user: IllusionPerdu tags: fx, webext_sharedworker
14:23
[fx] SharedWorker communicate with intermediate iframe to/from webpage check-in: 4dc627f1b1 user: IllusionPerdu tags: fx, webext_sharedworker
Changes

Modified gc_lang/fr/webext/content_scripts/modify_page.js from [649173c95f] to [b9e5fe8eb0].

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
        console.error(e);
    }
}
document.body.appendChild(iframe);


console.log('[Web] La suite des initialisations');







function wrapTextareas() {;
    let lNode = document.getElementsByTagName("textarea");
    for (let xNode of lNode) {
        createGCButton(xNode);
    }
}

function createGCButton (xActiveTextZone) {

    let xParentElement = xActiveTextZone.parentElement;














































    let xGCButton = document.createElement("div");
    xGCButton.textContent = "@";
    xGCButton.title = "Grammalecte"
    xGCButton.style = "padding: 5px; color: #FFF; background-color: hsla(210, 50%, 50%, 80%); border-radius: 3px; cursor: pointer";

    xGCButton.onclick = function() {
        console.log(xActiveTextZone.value);

    };
    xParentElement.insertBefore(xGCButton, xActiveTextZone);


}



function removeEverything () {















    while (document.body.firstChild) {
        document.body.firstChild.remove();
    }
}



function change (param) {
    document.getElementById("title").setAttribute("background-color", "#809060");




    console.log("param: " + param);
    document.getElementById("title").setAttribute("background-color", "#FF0000");















}


/*
    Assign do_something() as a listener for messages from the extension.
*/








>
>
>
>
>
>
>
|


|



|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
<
<
>
|
<
>
|
<
>
>
|
>
>
|
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
<



>
>
|
<
>
>
>
>
|
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
126
127
128

129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144

145
146
147
148
149
150

151
152
153
154
155

156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
        console.error(e);
    }
}
document.body.appendChild(iframe);


console.log('[Web] La suite des initialisations');

let nWrapper = 0;
let xConjPanel = null;
let xTFPanel = null;
let xLxgPanel = null;
let xGCPanel = null;

function wrapTextareas () {
    let lNode = document.getElementsByTagName("textarea");
    for (let xNode of lNode) {
        createWrapper(xNode);
    }
}

function createWrapper (xTextArea) {
    try {
        let xParentElement = xTextArea.parentElement;
        let xWrapper = document.createElement("div");
        xWrapper.style = "padding: 5px; color: hsl(210, 10%, 90%); background-color: hsl(210, 50%, 50%); border-radius: 3px;";
        xWrapper.id = nWrapper + 1;
        nWrapper += 1;
        xParentElement.insertBefore(xWrapper, xTextArea);
        xWrapper.appendChild(xTextArea); // move textarea in wrapper
        let xToolbar = createWrapperToolbar(xTextArea);
        xWrapper.appendChild(xToolbar);
    }
    catch (e) {
        showError(e);
    }
}


let sButtonStyle = "display: inline-block; padding: 0 5px; margin-left: 5px; background-color: hsl(210, 50%, 60%); border-radius: 2px; cursor: pointer;";

function createWrapperToolbar (xTextArea) {
    try {
        let xToolbar = document.createElement("div");
        xToolbar.style = "display: flex; justify-content: flex-end; margin-top: 5px; padding: 5px 10px;";
        /*let xLogo = document.createElement("img");
        xLogo.src = browser.extension.getURL("img/logo-16.png");
        xTitle.appendChild(xLogo);*/
        xToolbar.appendChild(document.createTextNode("Grammalecte"));
        let xConjButton = document.createElement("div");
        xConjButton.textContent = "Conjuguer";
        xConjButton.style = sButtonStyle;
        xConjButton.onclick = function() {
            createConjPanel();
        };
        xToolbar.appendChild(xConjButton);
        let xTFButton = document.createElement("div");
        xTFButton.textContent = "Formater";
        xTFButton.style = sButtonStyle;
        xTFButton.onclick = function() {
            createTFPanel();
        };
        xToolbar.appendChild(xTFButton);
        let xLxgButton = document.createElement("div");
        xLxgButton.textContent = "Analyser";
        xLxgButton.style = sButtonStyle;
        xLxgButton.onclick = function() {
            createLxgPanel();
        };
        xToolbar.appendChild(xLxgButton);
        let xGCButton = document.createElement("div");
        xGCButton.textContent = "Corriger";


        xGCButton.style = sButtonStyle;
        xGCButton.onclick = function() {

            createGCPanel();
        };

        xToolbar.appendChild(xGCButton);
        return xToolbar;
    }
    catch (e) {
        showError(e);
    }

}


function createConjPanel () {
    console.log("Conjugueur");
    if (xConjPanel !== null) {
        xConjPanel.style.display = "block";
    } else {
        // create the panel
        xConjPanel = document.createElement("div");
        xConjPanel.style = "position: fixed; left: 50%; top: 50%; z-index: 100; height: 400px; margin-top: -200px; width: 600px; margin-left: -300px; border-radius: 10px;"
                         + " color: hsl(210, 10%, 4%); background-color: hsl(210, 20%, 90%); border: 10px solid hsla(210, 20%, 70%, .5);";
        xConjPanel.textContent = "Conjugueur";
        xConjPanel.setAttribute("draggable", true);
        xConjPanel.appendChild(createCloseButton(xConjPanel));
        document.body.appendChild(xConjPanel);

    }
}



function createTFPanel () {

    console.log("Formateur de texte");
}

function createLxgPanel () {
    console.log("Analyse");

}

function createGCPanel () {
    console.log("Correction grammaticale");
}

function createCloseButton (xParentNode) {
    let xButton = document.createElement("div");
    xButton.style = "float: right; width: 20px; padding: 5px 10px; color: hsl(210, 0%, 100%); text-align: center;"
                  + "font-size: 20px; font-weight: bold; background-color: hsl(0, 80%, 50%); border-radius: 0 0 0 3px; cursor: pointer;";
    xButton.textContent = "×";
    xButton.onclick = function () {
        xParentNode.style.display = "none";
    }
    return xButton;
}


/*
    Assign do_something() as a listener for messages from the extension.
*/