embedding_redirection_js

   Usages of this macro
... in app.naml
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
<macro name="embedding_redirection_js">
    <n.node_parameter_or_root
Macro
Parameters: do
.>
        <n.if
Binary
Namespace: BasicNamespace
Parameters: condition, else, then
.has_embedding_redirection_url
Binary
Namespace: NodeNamespace
>
            <then>
                <script type="text/javascript">
                    var embeddedUrl = '<n.embedding_redirection_url
Binary
Namespace: NodeNamespace
/>';
                    if (!Nabble.isEmbedded) {
                        var url = top.location.href;
                        var cidPos = url.indexOf(';cid=');
                        if (cidPos > 0)
                            url = url.substring(0, cidPos);
 
                        var posHtml = url.lastIndexOf('.html');
                        var hash;
                        var c = '-';
                        if (url.indexOf('?') == -1 && posHtml > 0) {
                            var posStart = url.lastIndexOf('-');
                            hash = (posStart > 0)? url.substring(posStart+1, posHtml):'';
                        } else {
                            hash = url.replace('http://', '');
                            hash = hash.substring(hash.indexOf('/')+1);
                            hash = hash;
                            c = '+';
                        }
                        if (Nabble.analytics) Nabble.analytics();
                        var _hash = hash.length==1?'':'#nabble' + c + encodeURIComponent(hash);
                        if (top.location.hash) {
                            var realHash = top.location.hash.substring(1);
                            _hash += '|' + encodeURIComponent(realHash);
                        }
                        _hash = _hash.length == 8? '' : _hash;
                        top.location.replace(embeddedUrl + _hash);
                    }
                </script>
            </then>
        </n.if.has_embedding_redirection_url>
    </n.node_parameter_or_root.>
</macro>