cdn
8 years ago
buttons.html
11 years ago
download.html
10 years ago
exclude.php
8 years ago
htaccess.html
9 years ago
lazy_load.php
9 years ago
newpost.php
9 years ago
nginx_gzip.php
9 years ago
permission_error.html
10 years ago
preload.php
8 years ago
timeout.php
8 years ago
update_error.html
10 years ago
update_now.php
9 years ago
update_success.html
10 years ago
update_success.php
10 years ago
updatepost.php
9 years ago
timeout.php
597 lines
| 1 | <style type="text/css"> |
| 2 | .wpfc-timeout-item:hover{ |
| 3 | background-color: #E5E5E5; |
| 4 | } |
| 5 | .wpfc-timeout-item{ |
| 6 | float: left; |
| 7 | width: 330.5px; |
| 8 | margin-right: 7px; |
| 9 | margin-left: 20px; |
| 10 | -moz-border-radius:5px 5px 5px 5px; |
| 11 | -webkit-border-radius:5px 5px 5px 5px; |
| 12 | border-radius:5px 5px 5px 5px; |
| 13 | border:1px solid transparent; |
| 14 | cursor:pointer; |
| 15 | padding:9px; |
| 16 | outline:none !important; |
| 17 | list-style: outside none none; |
| 18 | } |
| 19 | .star{ |
| 20 | float:left; |
| 21 | height:28px; |
| 22 | width:32px; |
| 23 | display: none; |
| 24 | } |
| 25 | .star img{ |
| 26 | margin:9px 4px 4px; |
| 27 | } |
| 28 | |
| 29 | .wpfc-timeout-item-form-title{ |
| 30 | max-width:380px; |
| 31 | font-weight:bold; |
| 32 | white-space:nowrap; |
| 33 | max-width:615px; |
| 34 | margin-bottom:3px; |
| 35 | text-overflow:ellipsis; |
| 36 | -o-text-overflow:ellipsis; |
| 37 | -moz-text-overflow:ellipsis; |
| 38 | -webkit-text-overflow:ellipsis; |
| 39 | line-height:1em; |
| 40 | font-family: Verdana,Geneva,Arial,Helvetica,sans-serif; |
| 41 | } |
| 42 | .wpfc-timeout-item-details{ |
| 43 | font-size:11px; |
| 44 | color:#888; |
| 45 | display:block; |
| 46 | white-space:nowrap; |
| 47 | font-family: Verdana,Geneva,Arial,Helvetica,sans-serif; |
| 48 | line-height:1.5em; |
| 49 | } |
| 50 | .wpfc-timeout-item-details b { |
| 51 | display:inline; |
| 52 | margin-left: 1px; |
| 53 | |
| 54 | } |
| 55 | .wpfc-timeout-item-right{ |
| 56 | margin-right: 0; |
| 57 | margin-left: 0; |
| 58 | } |
| 59 | </style> |
| 60 | <div id="wpfc-modal-timeout" style="display:none;top: 10.5px; left: 226px; position: absolute; padding: 6px; height: auto; width: 560px; z-index: 10001;"> |
| 61 | <div style="height: 100%; width: 100%; background: none repeat scroll 0% 0% rgb(0, 0, 0); position: absolute; top: 0px; left: 0px; z-index: -1; opacity: 0.5; border-radius: 8px;"> |
| 62 | </div> |
| 63 | <div style="z-index: 600; border-radius: 3px;"> |
| 64 | <div style="font-family:Verdana,Geneva,Arial,Helvetica,sans-serif;font-size:12px;background: none repeat scroll 0px 0px rgb(255, 161, 0); z-index: 1000; position: relative; padding: 2px; border-bottom: 1px solid rgb(194, 122, 0); height: 35px; border-radius: 3px 3px 0px 0px;"> |
| 65 | <table width="100%" height="100%"> |
| 66 | <tbody> |
| 67 | <tr> |
| 68 | <td valign="middle" style="vertical-align: middle; font-weight: bold; color: rgb(255, 255, 255); text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.5); padding-left: 10px; font-size: 13px; cursor: move;">Cache Timeout Wizard</td> |
| 69 | <td width="20" align="center" style="vertical-align: middle;"></td> |
| 70 | <td width="20" align="center" style="vertical-align: middle; font-family: Arial,Helvetica,sans-serif; color: rgb(170, 170, 170); cursor: default;"> |
| 71 | <div title="Close Window" class="close-wiz"></div> |
| 72 | </td> |
| 73 | </tr> |
| 74 | </tbody> |
| 75 | </table> |
| 76 | </div> |
| 77 | <div class="window-content-wrapper" style="padding: 8px;"> |
| 78 | <div style="z-index: 1000; height: auto; position: relative; display: inline-block; width: 100%;" class="window-content"> |
| 79 | |
| 80 | |
| 81 | <div id="wpfc-wizard-timeout" class="wpfc-cdn-pages-container"> |
| 82 | <div wpfc-cdn-page="1" class="wiz-cont" style="padding:0 0;min-height:37px;"> |
| 83 | |
| 84 | <table width="100%" cellspacing="0" cellpadding="0" border="0" height="100%" style="background-color:#FFFFFF;border:1px solid #ccc !important;border-radius:10px;"> |
| 85 | <tbody> |
| 86 | <tr> |
| 87 | <td valign="top" id="cond-list"> |
| 88 | <table width="100%" cellspacing="0" cellpadding="5" border="0" class="cond-line active-line"> |
| 89 | <tbody> |
| 90 | <tr> |
| 91 | <td width="100" height="30" class="" style="padding-left:10px;font-family: Verdana,Geneva,Arial,Helvetica,sans-serif;font-size: 12px;">If REQUEST_URI</td> |
| 92 | <td class="" width="95"> |
| 93 | <select name="wpfc-timeout-rule-prefix"> |
| 94 | <option selected="" value=""></option> |
| 95 | <option value="all">All</option> |
| 96 | <option value="homepage">Home Page</option> |
| 97 | <option value="startwith">Starts With</option> |
| 98 | <option value="exact">Is Equal To</option> |
| 99 | <!-- <option value="contain">Contains</option> --> |
| 100 | </select> |
| 101 | </td> |
| 102 | <td width="300"> |
| 103 | <div class="wpfc-timeout-rule-line-middle"> |
| 104 | <input type="text" name="wpfc-timeout-rule-content" style="width:300px;"> |
| 105 | </div> |
| 106 | </td> |
| 107 | </tr> |
| 108 | </tbody> |
| 109 | </table> |
| 110 | </td> |
| 111 | </tr> |
| 112 | </tbody> |
| 113 | </table> |
| 114 | |
| 115 | <div id="cond-single" style="border-top:1px solid #ccc; margin:10px 0px 5px 0px;"></div> |
| 116 | |
| 117 | <table width="100%" cellspacing="0" cellpadding="0" border="0" height="100%" style="background-color:#FFFFFF;border:1px solid #ccc !important;border-radius:10px;"> |
| 118 | <tbody> |
| 119 | <tr> |
| 120 | <td valign="top"> |
| 121 | <table width="100%" cellspacing="0" cellpadding="5" border="0" class="cond-line active-line"> |
| 122 | <tbody> |
| 123 | <tr> |
| 124 | <td width="10">Then</td> |
| 125 | <td class="" width="95"> |
| 126 | <select name="wpfc-timeout-rule-schedule"> |
| 127 | <?php |
| 128 | $schedules = wp_get_schedules(); |
| 129 | $first = true; |
| 130 | foreach ($schedules as $key => $value) { |
| 131 | if($first){ |
| 132 | echo "<option value=''>Choose One</option>"; |
| 133 | $first = false; |
| 134 | } |
| 135 | echo "<option value='{$key}'>{$value["display"]}</option>"; |
| 136 | } |
| 137 | ?> |
| 138 | </select> |
| 139 | </td> |
| 140 | <td width="300" height="30" class="" style="font-family: Verdana,Geneva,Arial,Helvetica,sans-serif;font-size: 12px;"> |
| 141 | <span class="wpfc-timeout-at-text" style="padding-right:5px;display:none;">at</span> |
| 142 | <select name="wpfc-timeout-rule-hour" style="display:none;"> |
| 143 | <?php |
| 144 | for ($i=0; $i < 24; $i++) { |
| 145 | ?> |
| 146 | <option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, '0', STR_PAD_LEFT); ?></option> |
| 147 | <?php |
| 148 | } |
| 149 | ?> |
| 150 | </select> |
| 151 | <select name="wpfc-timeout-rule-minute" style="display:none;"> |
| 152 | <?php |
| 153 | for ($i=0; $i < 60; $i++) { |
| 154 | ?> |
| 155 | <option value="<?php echo $i; ?>"><?php echo str_pad($i, 2, '0', STR_PAD_LEFT); ?></option> |
| 156 | <?php |
| 157 | } |
| 158 | ?> |
| 159 | </select> |
| 160 | <span>delete the files</span> |
| 161 | </td> |
| 162 | <td width="100"></td> |
| 163 | </tr> |
| 164 | </tbody> |
| 165 | </table> |
| 166 | </td> |
| 167 | </tr> |
| 168 | </tbody> |
| 169 | </table> |
| 170 | |
| 171 | |
| 172 | <table class="wpfc-server-time-cont" width="100%" cellspacing="0" cellpadding="0" border="0" height="100%" style="background: lightYellow; border: 1px solid #DCDCBC !important;border-radius:10px;margin-top:5px;"> |
| 173 | <tbody> |
| 174 | <tr> |
| 175 | <td valign="top" id="cond-list"> |
| 176 | <table width="100%" cellspacing="0" cellpadding="5" border="0" class="cond-line active-line"> |
| 177 | <tbody> |
| 178 | <tr> |
| 179 | <td class="" width="300" style="text-align: center;"> |
| 180 | <label>Server Time: </label><label class="wpfc-server-time"><?php echo date("H:i:s"); ?></label> |
| 181 | </td> |
| 182 | </tr> |
| 183 | </tbody> |
| 184 | </table> |
| 185 | </td> |
| 186 | </tr> |
| 187 | </tbody> |
| 188 | </table> |
| 189 | |
| 190 | |
| 191 | </div> |
| 192 | </div> |
| 193 | </div> |
| 194 | </div> |
| 195 | <div class="window-buttons-wrapper" style="padding: 0px; display: inline-block; width: 100%; border-top: 1px solid rgb(255, 255, 255); background: none repeat scroll 0px 0px rgb(222, 222, 222); z-index: 999; position: relative; text-align: right; border-radius: 0px 0px 3px 3px;"> |
| 196 | <div style="padding: 12px; height: 23px;"> |
| 197 | <button class="wpfc-dialog-buttons buttons-blood" type="button" action="remove"> |
| 198 | <span>Remove Rule</span> |
| 199 | </button> |
| 200 | <button class="wpfc-dialog-buttons" type="button" action="back"> |
| 201 | <span>Back</span> |
| 202 | </button> |
| 203 | <button class="wpfc-dialog-buttons" type="button" action="next"> |
| 204 | <span>Next</span> |
| 205 | </button> |
| 206 | <button class="wpfc-dialog-buttons" type="button" action="close"> |
| 207 | <span>Close</span> |
| 208 | </button> |
| 209 | <button class="wpfc-dialog-buttons buttons-green" type="button" action="finish"> |
| 210 | <span>Save</span> |
| 211 | </button> |
| 212 | </div> |
| 213 | </div> |
| 214 | </div> |
| 215 | </div> |
| 216 | <script type="text/javascript"> |
| 217 | var WpFcTimeout = { |
| 218 | rules: [], |
| 219 | schedules: {}, |
| 220 | init: function(rules){ |
| 221 | this.rules = rules; |
| 222 | this.insert_existing_rules(); |
| 223 | this.click_event_for_add_button(); |
| 224 | |
| 225 | setInterval(function(){ WpFcTimeout.server_clock(); }, 1000); |
| 226 | }, |
| 227 | server_clock: function(){ |
| 228 | jQuery(".wpfc-server-time").each(function(i, e){ |
| 229 | var time = jQuery(e).text().split(":"); |
| 230 | |
| 231 | time[2]++; |
| 232 | |
| 233 | if(time[2] > 59){ |
| 234 | time[2] = "0"; |
| 235 | time[1]++; |
| 236 | } |
| 237 | |
| 238 | if(time[1] > 59){ |
| 239 | time[1] = "0"; |
| 240 | time[0]++; |
| 241 | } |
| 242 | |
| 243 | if(time[0] > 23){ |
| 244 | time[0] = "0"; |
| 245 | } |
| 246 | |
| 247 | jQuery(time).each(function(i, e){ |
| 248 | if((time[i] < 10) && ((time[i] + "").length < 2)){ |
| 249 | time[i] = "0" + time[i]; |
| 250 | } |
| 251 | }); |
| 252 | |
| 253 | jQuery(e).text(time.join(":")); |
| 254 | }); |
| 255 | }, |
| 256 | remove_rule: function(clone_modal_id, number){ |
| 257 | jQuery("div.wpfc-timeout-rule-line[wpfc-timeout-rule-number='" + number + "']").remove(); |
| 258 | |
| 259 | Wpfc_Dialog.remove(clone_modal_id); |
| 260 | |
| 261 | this.save(function(){ |
| 262 | jQuery("div.wpfc-timeout-item[wpfc-timeout-item-number='" + number + "']").remove(); |
| 263 | }); |
| 264 | }, |
| 265 | add_item: function(number, e){ |
| 266 | var self = this; |
| 267 | var item = jQuery(".wpfc-timeout-item").first().clone(); |
| 268 | |
| 269 | item.attr("wpfc-timeout-item-number", number); |
| 270 | item.attr("prefix", e.prefix); |
| 271 | item.attr("content", e.content); |
| 272 | item.attr("schedule", e.schedule); |
| 273 | |
| 274 | if(typeof e.hour != "undefined" && typeof e.minute != "undefined"){ |
| 275 | item.attr("hour", e.hour); |
| 276 | item.attr("minute", e.minute); |
| 277 | } |
| 278 | |
| 279 | item.find(".wpfc-timeout-item-url").html(self.create_url_description(e.prefix, e.content)); |
| 280 | |
| 281 | if(typeof e.hour != "undefined" && typeof e.minute != "undefined"){ |
| 282 | item.find(".wpfc-timeout-item-form-title").html(self.create_title(e.prefix, e.content, e.schedule, e.hour, e.minute)); |
| 283 | }else{ |
| 284 | item.find(".wpfc-timeout-item-form-title").html(self.create_title(e.prefix, e.content, e.schedule)); |
| 285 | } |
| 286 | |
| 287 | item.click(function(){ |
| 288 | var clone_modal = jQuery("#wpfc-modal-timeout").clone(); |
| 289 | var clone_modal_id = "wpfc-modal-timeout-" + new Date().getTime(); |
| 290 | |
| 291 | self.hide_input_content(clone_modal); |
| 292 | self.show_hour_and_minute(clone_modal); |
| 293 | |
| 294 | if(jQuery(this).attr("schedule").match(/^(onceaday|daily)/i)){ |
| 295 | clone_modal.find(".wpfc-timeout-at-text").show(); |
| 296 | clone_modal.find("select[name='wpfc-timeout-rule-hour']").show(); |
| 297 | clone_modal.find("select[name='wpfc-timeout-rule-minute']").show(); |
| 298 | |
| 299 | clone_modal.find("select[name='wpfc-timeout-rule-hour']").val(jQuery(this).attr("hour")); |
| 300 | clone_modal.find("select[name='wpfc-timeout-rule-minute']").val(jQuery(this).attr("minute")); |
| 301 | } |
| 302 | |
| 303 | if(e.prefix == "homepage" || e.prefix == "all"){ |
| 304 | clone_modal.find("input").attr("name", "wpfc-timeout-rule-content").hide(); |
| 305 | } |
| 306 | |
| 307 | clone_modal.attr("id", clone_modal_id); |
| 308 | clone_modal.find("select[name='wpfc-timeout-rule-schedule']").val(jQuery(this).attr("schedule")); |
| 309 | clone_modal.find("select[name='wpfc-timeout-rule-prefix']").val(jQuery(this).attr("prefix")); |
| 310 | clone_modal.find("input[name='wpfc-timeout-rule-content']").val(jQuery(this).attr("content")); |
| 311 | |
| 312 | |
| 313 | jQuery("#wpfc-modal-timeout").after(clone_modal); |
| 314 | |
| 315 | if(typeof e.editable == "undefined"){ |
| 316 | Wpfc_Dialog.dialog(clone_modal_id, {"close" : |
| 317 | function(){ |
| 318 | }, |
| 319 | "remove" : |
| 320 | function(){ |
| 321 | self.remove_rule(clone_modal_id, number); |
| 322 | }, |
| 323 | "finish" : |
| 324 | function(){ |
| 325 | var prefix = clone_modal.find("select[name='wpfc-timeout-rule-prefix']").val(); |
| 326 | var content = clone_modal.find("input[name='wpfc-timeout-rule-content']").val(); |
| 327 | var schedule = clone_modal.find("select[name='wpfc-timeout-rule-schedule']").val(); |
| 328 | var hour = clone_modal.find("select[name='wpfc-timeout-rule-hour']").val(); |
| 329 | var minute = clone_modal.find("select[name='wpfc-timeout-rule-minute']").val(); |
| 330 | |
| 331 | content = self.remove_host_name(content); |
| 332 | content = content.replace(/^\/|\/$/g, ''); |
| 333 | |
| 334 | jQuery("div.wpfc-timeout-rule-line[wpfc-timeout-rule-number='" + number + "']").find("select[name='wpfc-timeout-rule-prefix-" + number + "']").val(prefix); |
| 335 | jQuery("div.wpfc-timeout-rule-line[wpfc-timeout-rule-number='" + number + "']").find("input[name='wpfc-timeout-rule-content-" + number + "']").val(content); |
| 336 | jQuery("div.wpfc-timeout-rule-line[wpfc-timeout-rule-number='" + number + "']").find("input[name='wpfc-timeout-rule-schedule-" + number + "']").val(schedule); |
| 337 | jQuery("div.wpfc-timeout-rule-line[wpfc-timeout-rule-number='" + number + "']").find("input[name='wpfc-timeout-rule-hour-" + number + "']").val(hour); |
| 338 | jQuery("div.wpfc-timeout-rule-line[wpfc-timeout-rule-number='" + number + "']").find("input[name='wpfc-timeout-rule-minute-" + number + "']").val(minute); |
| 339 | |
| 340 | if(self.is_empty_values(prefix, content, schedule)){ |
| 341 | Wpfc_Dialog.remove(clone_modal_id); |
| 342 | |
| 343 | self.save(function(){ |
| 344 | jQuery("div.wpfc-timeout-item[wpfc-timeout-item-number='" + number + "']").attr("prefix", prefix); |
| 345 | jQuery("div.wpfc-timeout-item[wpfc-timeout-item-number='" + number + "']").attr("content", content); |
| 346 | jQuery("div.wpfc-timeout-item[wpfc-timeout-item-number='" + number + "']").attr("schedule", schedule); |
| 347 | jQuery("div.wpfc-timeout-item[wpfc-timeout-item-number='" + number + "']").attr("hour", hour); |
| 348 | jQuery("div.wpfc-timeout-item[wpfc-timeout-item-number='" + number + "']").attr("minute", minute); |
| 349 | |
| 350 | jQuery("div.wpfc-timeout-item[wpfc-timeout-item-number='" + number + "']").find(".wpfc-timeout-item-url").html(self.create_url_description(prefix, content)); |
| 351 | |
| 352 | jQuery("div.wpfc-timeout-item[wpfc-timeout-item-number='" + number + "']").find(".wpfc-timeout-item-form-title").html(self.create_title(prefix, content, schedule, hour, minute)); |
| 353 | }); |
| 354 | } |
| 355 | } |
| 356 | }); |
| 357 | }else if(e.editable == false){ |
| 358 | Wpfc_Dialog.dialog(clone_modal_id, {"close" : function(){}}); |
| 359 | } |
| 360 | }); |
| 361 | |
| 362 | item.show(); |
| 363 | |
| 364 | jQuery(".wpfc-timeout-list").append(item); |
| 365 | }, |
| 366 | create_title: function(prefix, content, schedule, hour, minute){ |
| 367 | var title = ""; |
| 368 | |
| 369 | if(prefix == "exact"){ |
| 370 | title = "Is Equal To: " + content; |
| 371 | }else if(prefix == "startwith"){ |
| 372 | title = "Start With: " + content; |
| 373 | }else if(prefix == "contain"){ |
| 374 | title = "Contains: " + content; |
| 375 | }else if(prefix == "homepage"){ |
| 376 | title = "Home Page"; |
| 377 | }else if(prefix == "all"){ |
| 378 | title = "The All Cache"; |
| 379 | } |
| 380 | |
| 381 | if(typeof this.schedules[schedule] != "undefined"){ |
| 382 | title = title + ' - <span style="color: green;">' + this.schedules[schedule].display + '</span>'; |
| 383 | }else{ |
| 384 | title = title + ' - <span style="color: green;">' + schedule + '</span>'; |
| 385 | } |
| 386 | |
| 387 | if(schedule.match(/^(onceaday|daily)/i)){ |
| 388 | if(typeof hour != "undefined" && typeof minute != "undefined"){ |
| 389 | minute = ((minute + "").length > 1) ? minute : "0" + (minute + ""); |
| 390 | hour = ((hour + "").length > 1) ? hour : "0" + (hour + ""); |
| 391 | |
| 392 | title = title + '/<span style="color:red;font-size:10px;">' + hour + ":" + minute + '</span>'; |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | return title; |
| 397 | }, |
| 398 | create_url_description: function(prefix, content){ |
| 399 | var request_uri = content; |
| 400 | var b_start = "<b style='font-size:11px;color:#FFA100;'>"; |
| 401 | var b_end = "</b>" |
| 402 | |
| 403 | if(prefix == "exact"){ |
| 404 | request_uri = b_start + content + b_end; |
| 405 | }else if(prefix == "startwith"){ |
| 406 | request_uri = b_start + content + b_end + '(.*)'; |
| 407 | }else if(prefix == "contain"){ |
| 408 | request_uri = '(.*)' + b_start + content + b_end + '(.*)'; |
| 409 | }else if(prefix == "homepage" || prefix == "all"){ |
| 410 | request_uri = ""; |
| 411 | } |
| 412 | |
| 413 | return "<?php echo home_url();?>" + "/" + request_uri; |
| 414 | }, |
| 415 | add_line: function(number, e){ |
| 416 | var line = jQuery(".wpfc-timeout-rule-line").first().closest(".wpfc-timeout-rule-line").clone(); |
| 417 | |
| 418 | line.attr("wpfc-timeout-rule-number", number); |
| 419 | |
| 420 | line.find(".wpfc-timeout-rule-line-add").remove(); |
| 421 | line.find(".wpfc-timeout-rule-line-delete").show(); |
| 422 | line.find("select").attr("name", "wpfc-timeout-rule-prefix-" + number).val(e.prefix); |
| 423 | line.find("input[name='wpfc-timeout-rule-content']").attr("name", "wpfc-timeout-rule-content-" + number).val(e.content); |
| 424 | line.find("input[name='wpfc-timeout-rule-schedule']").attr("name", "wpfc-timeout-rule-schedule-" + number).val(e.schedule); |
| 425 | line.find("input[name='wpfc-timeout-rule-hour']").attr("name", "wpfc-timeout-rule-hour-" + number).val(e.hour); |
| 426 | line.find("input[name='wpfc-timeout-rule-minute']").attr("name", "wpfc-timeout-rule-minute-" + number).val(e.minute); |
| 427 | |
| 428 | console.log(e); |
| 429 | |
| 430 | jQuery(".wpfc-timeout-rule-container").append(line); |
| 431 | }, |
| 432 | click_event_for_add_button: function(){ |
| 433 | var self = this; |
| 434 | |
| 435 | jQuery(".wpfc-add-new-timeout-button").click(function(e){ |
| 436 | var clone_modal = jQuery("#wpfc-modal-timeout").clone(); |
| 437 | //var number = jQuery("div.wpfc-timeout-rule-line[wpfc-timeout-rule-number]").length; |
| 438 | var number = new Date().getTime(); |
| 439 | var clone_modal_id = "wpfc-modal-timeout-" + new Date().getTime(); |
| 440 | |
| 441 | clone_modal.attr("id", clone_modal_id); |
| 442 | |
| 443 | self.hide_input_content(clone_modal); |
| 444 | self.show_hour_and_minute(clone_modal); |
| 445 | |
| 446 | jQuery("#wpfc-modal-timeout").after(clone_modal); |
| 447 | |
| 448 | Wpfc_Dialog.dialog(clone_modal_id, {"finish" : |
| 449 | function(){ |
| 450 | var prefix = clone_modal.find("select[name='wpfc-timeout-rule-prefix']").val(); |
| 451 | var content = clone_modal.find("input[name='wpfc-timeout-rule-content']").val(); |
| 452 | var schedule = clone_modal.find("select[name='wpfc-timeout-rule-schedule']").val(); |
| 453 | var hour = clone_modal.find("select[name='wpfc-timeout-rule-hour']").val(); |
| 454 | var minute = clone_modal.find("select[name='wpfc-timeout-rule-minute']").val(); |
| 455 | |
| 456 | content = self.remove_host_name(content); |
| 457 | content = content.replace(/^\/|\/$/g, ''); |
| 458 | |
| 459 | if(self.is_empty_values(prefix, content, schedule)){ |
| 460 | self.add_line(number + 1, {"prefix" : prefix, "content" : content, "schedule" : schedule, "hour" : hour, "minute" : minute}); |
| 461 | |
| 462 | Wpfc_Dialog.remove(clone_modal_id); |
| 463 | |
| 464 | self.save(function(){ |
| 465 | self.add_item(number + 1, {"prefix" : prefix, "content" : content, "schedule" : schedule, "hour" : hour, "minute" : minute}); |
| 466 | }); |
| 467 | } |
| 468 | }, |
| 469 | "close" : |
| 470 | function(){ |
| 471 | } |
| 472 | }); |
| 473 | }); |
| 474 | }, |
| 475 | save: function(callback){ |
| 476 | var rule_number, prefix, schedule, content, hour, minute, rule, rules = [], self = this; |
| 477 | |
| 478 | jQuery("form div.wpfc-timeout-rule-line").each(function(i, e){ |
| 479 | rule_number = jQuery(e).attr("wpfc-timeout-rule-number"); |
| 480 | prefix = jQuery(e).find("select[name^='wpfc-timeout-rule-prefix']").val(); |
| 481 | content = jQuery(e).find("input[name^='wpfc-timeout-rule-content']").val(); |
| 482 | schedule = jQuery(e).find("input[name^='wpfc-timeout-rule-schedule']").val(); |
| 483 | hour = jQuery(e).find("input[name^='wpfc-timeout-rule-hour']").val(); |
| 484 | minute = jQuery(e).find("input[name^='wpfc-timeout-rule-minute']").val(); |
| 485 | |
| 486 | content = self.remove_host_name(content); |
| 487 | content = content.replace(/^\/|\/$/g, ''); |
| 488 | |
| 489 | |
| 490 | rules.push({"prefix" : prefix, "content" : content, "schedule" : schedule, "hour" : hour, "minute" : minute}); |
| 491 | }); |
| 492 | |
| 493 | jQuery("#revert-loader-toolbar").show(); |
| 494 | |
| 495 | jQuery.ajax({ |
| 496 | type: 'POST', |
| 497 | dataType: "json", |
| 498 | url: ajaxurl, |
| 499 | data : {"action": "wpfc_save_timeout_pages", "rules" : rules, security: '<?php echo wp_create_nonce( "wpfc-save-timeout-ajax-nonce" ); ?>'}, |
| 500 | success: function(res){ |
| 501 | if(res.success){ |
| 502 | jQuery("#revert-loader-toolbar").hide(); |
| 503 | callback(); |
| 504 | self.set_right_class_for_item(); |
| 505 | }else{ |
| 506 | alert("The rule cannot be added..."); |
| 507 | } |
| 508 | }, |
| 509 | error: function(e) { |
| 510 | alert("unknown error"); |
| 511 | } |
| 512 | }); |
| 513 | }, |
| 514 | insert_existing_rules: function(){ |
| 515 | var self = this; |
| 516 | |
| 517 | if(typeof this.rules != "undefined" && this.rules && this.rules.length > 0){ |
| 518 | jQuery.each(self.rules, function(i, e){ |
| 519 | if(i > 0){ |
| 520 | } |
| 521 | |
| 522 | self.add_line(i + 1, e); |
| 523 | self.add_item(i + 1, e); |
| 524 | }); |
| 525 | |
| 526 | self.set_right_class_for_item(); |
| 527 | } |
| 528 | }, |
| 529 | set_right_class_for_item: function(){ |
| 530 | jQuery(".wpfc-timeout-item").each(function(i, e){ |
| 531 | if(i%2 == 0){ |
| 532 | jQuery(e).addClass("wpfc-timeout-item-right"); |
| 533 | }else{ |
| 534 | jQuery(e).removeClass("wpfc-timeout-item-right"); |
| 535 | } |
| 536 | }); |
| 537 | }, |
| 538 | is_empty_values: function(prefix, content, schedule){ |
| 539 | if(prefix){ |
| 540 | jQuery("#wpfc-wizard-timeout select[name='wpfc-timeout-rule-prefix']").css({'border-color': '#ddd'}); |
| 541 | }else{ |
| 542 | jQuery("#wpfc-wizard-timeout select[name='wpfc-timeout-rule-prefix']").css({'border-color': 'red'}); |
| 543 | } |
| 544 | |
| 545 | if(content){ |
| 546 | jQuery("#wpfc-wizard-timeout input[name='wpfc-timeout-rule-content']").css({'border-color': '#ddd'}); |
| 547 | }else{ |
| 548 | jQuery("#wpfc-wizard-timeout input[name='wpfc-timeout-rule-content']").css({'border-color': 'red'}); |
| 549 | } |
| 550 | |
| 551 | if(schedule){ |
| 552 | jQuery("#wpfc-wizard-timeout select[name='wpfc-timeout-rule-schedule']").css({'border-color': '#ddd'}); |
| 553 | }else{ |
| 554 | jQuery("#wpfc-wizard-timeout select[name='wpfc-timeout-rule-schedule']").css({'border-color': 'red'}); |
| 555 | } |
| 556 | |
| 557 | if(prefix && content && schedule){ |
| 558 | return true; |
| 559 | } |
| 560 | |
| 561 | return false; |
| 562 | }, |
| 563 | remove_host_name: function(content){ |
| 564 | //to replace the urls which start with http:// or www. or with Host_Name |
| 565 | content = content.replace(new RegExp('.*' + location.hostname.replace(/www\./, "") + "\/", "gi"), ""); |
| 566 | content = content.replace(/\/$/, ""); |
| 567 | |
| 568 | return content; |
| 569 | }, |
| 570 | hide_input_content: function(clone_modal){ |
| 571 | clone_modal.find("select[name='wpfc-timeout-rule-prefix']").change(function(){ |
| 572 | if(jQuery(this).val() == "homepage" || jQuery(this).val() == "all"){ |
| 573 | clone_modal.find("input").hide(); |
| 574 | clone_modal.find("input").attr("name", "wpfc-timeout-rule-content").val(jQuery(this).val()); |
| 575 | }else{ |
| 576 | clone_modal.find("input").show(); |
| 577 | clone_modal.find("input").attr("name", "wpfc-timeout-rule-content").val(""); |
| 578 | } |
| 579 | }); |
| 580 | }, |
| 581 | show_hour_and_minute: function(clone_modal){ |
| 582 | clone_modal.find("select[name='wpfc-timeout-rule-schedule']").change(function(e){ |
| 583 | if(jQuery(this).val().match(/^(onceaday|daily)/i)){ |
| 584 | clone_modal.find(".wpfc-timeout-at-text").show(); |
| 585 | clone_modal.find("select[name='wpfc-timeout-rule-hour']").show(); |
| 586 | clone_modal.find("select[name='wpfc-timeout-rule-minute']").show(); |
| 587 | clone_modal.find(".wpfc-server-time-cont").show(); |
| 588 | }else{ |
| 589 | clone_modal.find(".wpfc-timeout-at-text").hide(); |
| 590 | clone_modal.find("select[name='wpfc-timeout-rule-hour']").hide(); |
| 591 | clone_modal.find("select[name='wpfc-timeout-rule-minute']").hide(); |
| 592 | clone_modal.find(".wpfc-server-time-cont").hide(); |
| 593 | } |
| 594 | }); |
| 595 | } |
| 596 | }; |
| 597 | </script> |